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
00071 private:
00072 GR_Caret();
00073 GR_Caret(const GR_Caret& rhs);
00074 void operator=(const GR_Caret& rhs);
00075
00076 static void s_work(UT_Worker * w);
00077 static void s_enable(UT_Worker * w);
00078 static void s_blink_timeout(UT_Worker * w);
00079
00080 UT_uint32 _getCursorBlinkTime() const;
00081 UT_uint32 _getCursorBlinkTimeout() const;
00082 bool _getCanCursorBlink() const;
00083
00084 void _erase();
00085 void _blink(bool bExplicit);
00086
00087 UT_sint32 m_xPoint;
00088 UT_sint32 m_yPoint;
00089 UT_uint32 m_iPointHeight;
00090
00091 UT_sint32 m_xPoint2;
00092 UT_sint32 m_yPoint2;
00093 UT_uint32 m_iPointHeight2;
00094 bool m_bPointDirection;
00095 const UT_RGBColor * m_pClr;
00096 GR_Graphics * m_pG;
00097
00098 UT_uint32 m_iWindowWidth;
00099 UT_uint32 m_iWindowHeight;
00100
00101 UT_Timer * m_worker;
00102 UT_Timer * m_enabler;
00103 UT_Timer * m_blinkTimeout;
00104
00105
00106
00107 UT_uint32 m_nDisableCount;
00108 bool m_bCursorBlink;
00109 bool m_bCursorIsOn;
00110 bool m_bPositionSet;
00111 bool m_bRecursiveDraw;
00112 bool m_bSplitCaret;
00113 bool m_bCaret1OnScreen;
00114 bool m_bCaret2OnScreen;
00115
00116 UT_RGBColor m_clrInsert;
00117 UT_RGBColor m_clrOverwrite;
00118
00119 bool m_insertMode;
00120 bool m_bRemote;
00121 UT_RGBColor m_clrRemote;
00122 std::string m_sID;
00123 UT_sint32 m_iCaretNumber;
00124 };
00125
00126 class ABI_EXPORT GR_CaretDisabler
00127 {
00128 public:
00129
00130 GR_CaretDisabler (GR_Caret * pCaret)
00131 : m_pCaret(pCaret)
00132 {
00133 if (m_pCaret)
00134 {
00135 m_pCaret->disable();
00136 }
00137 }
00138
00139 ~GR_CaretDisabler ()
00140 {
00141 if(m_pCaret)
00142 {
00143 m_pCaret->enable();
00144 }
00145 }
00146
00147 private:
00148
00149 GR_CaretDisabler ();
00150 GR_CaretDisabler (const GR_CaretDisabler & other);
00151 GR_CaretDisabler & operator=(const GR_CaretDisabler &other);
00152
00153 GR_Caret * m_pCaret;
00154 };
00155
00156
00157 #endif // GR_CARET_H