Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef GR_CARET_H
00024 #define GR_CARET_H
00025
00026 #include "ut_color.h"
00027 #include "ut_timer.h"
00028 #include "ut_assert.h"
00029 #include "ut_string_class.h"
00030
00031 class GR_Graphics;
00032
00033 class ABI_EXPORT GR_Caret
00034 {
00035 friend class GR_Graphics;
00036
00037 public:
00038 explicit GR_Caret(GR_Graphics * pG);
00039 explicit GR_Caret(GR_Graphics * pG, const std::string& sID);
00040 ~GR_Caret();
00041
00042 void enable();
00043
00044
00045
00046
00047
00048
00049 void disable(bool bNoMulti = false);
00050 inline bool isEnabled() const { return m_nDisableCount == 0; }
00051
00052 void JustErase(UT_sint32 xPoint,UT_sint32 yPoint);
00053 void setBlink(bool bBlink);
00054 void forceDraw(void);
00055
00056
00057 void setCoords(UT_sint32 x, UT_sint32 y, UT_uint32 h,
00058 UT_sint32 x2 = 0, UT_sint32 y2 = 0, UT_uint32 h2 = 0,
00059 bool bPointDirection = false, const UT_RGBColor * pClr = NULL);
00060
00061
00062 void setWindowSize(UT_uint32 width, UT_uint32 height);
00063
00064 bool getInsertMode () { return m_insertMode; }
00065 void setInsertMode (bool mode) { m_insertMode = mode; }
00066 std::string getID(void) const { return m_sID; }
00067 void setRemoteColor(UT_RGBColor clrRemote);
00068
00069 void resetBlinkTimeout(void);
00070 void setPendingBlink(void);
00071 bool doBlinkIfNeeded(void);
00072 private:
00073 GR_Caret();
00074 GR_Caret(const GR_Caret& rhs);
00075 void operator=(const GR_Caret& rhs);
00076
00077 static void s_work(UT_Worker * w);
00078 static void s_enable(UT_Worker * w);
00079 static void s_blink_timeout(UT_Worker * w);
00080
00081 UT_uint32 _getCursorBlinkTime() const;
00082 UT_uint32 _getCursorBlinkTimeout() const;
00083 bool _getCanCursorBlink() const;
00084
00085 void _erase();
00086 void _blink(bool bExplicit);
00087
00088 UT_sint32 m_xPoint;
00089 UT_sint32 m_yPoint;
00090 UT_uint32 m_iPointHeight;
00091
00092 UT_sint32 m_xPoint2;
00093 UT_sint32 m_yPoint2;
00094 UT_uint32 m_iPointHeight2;
00095 bool m_bPointDirection;
00096 const UT_RGBColor * m_pClr;
00097 GR_Graphics * m_pG;
00098
00099 UT_uint32 m_iWindowWidth;
00100 UT_uint32 m_iWindowHeight;
00101
00102 UT_Timer * m_worker;
00103 UT_Timer * m_enabler;
00104 UT_Timer * m_blinkTimeout;
00105
00106
00107
00108 UT_uint32 m_nDisableCount;
00109 bool m_bCursorBlink;
00110 bool m_bCursorIsOn;
00111 bool m_bPositionSet;
00112 bool m_bRecursiveDraw;
00113 bool m_bSplitCaret;
00114 bool m_bCaret1OnScreen;
00115 bool m_bCaret2OnScreen;
00116
00117 UT_RGBColor m_clrInsert;
00118 UT_RGBColor m_clrOverwrite;
00119
00120 bool m_insertMode;
00121 bool m_bRemote;
00122 UT_RGBColor m_clrRemote;
00123 std::string m_sID;
00124 UT_sint32 m_iCaretNumber;
00125 long m_iLastDrawTime;
00126 UT_sint32 m_iRetry;
00127 bool m_bPendingBlink;
00128 };
00129
00130 class ABI_EXPORT GR_CaretDisabler
00131 {
00132 public:
00133
00134 GR_CaretDisabler (GR_Caret * pCaret)
00135 : m_pCaret(pCaret)
00136 {
00137 if (m_pCaret)
00138 {
00139 m_pCaret->disable();
00140 }
00141 }
00142
00143 ~GR_CaretDisabler ()
00144 {
00145 if(m_pCaret)
00146 {
00147 m_pCaret->enable();
00148 }
00149 }
00150
00151 private:
00152
00153 GR_CaretDisabler ();
00154 GR_CaretDisabler (const GR_CaretDisabler & other);
00155 GR_CaretDisabler & operator=(const GR_CaretDisabler &other);
00156
00157 GR_Caret * m_pCaret;
00158 };
00159
00160
00161 #endif // GR_CARET_H