• Main Page
  • Related Pages
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

gr_Caret.h

Go to the documentation of this file.
00001 /* Handle caret blinking.
00002  *
00003  * Author: Mike Nordell (tamlin@algonet.se)
00004  *         Pat Lam
00005  *         Dom Lachowicz
00006  *         Tomas Frydrych
00007  *         Marc Maurer <uwog@uwog.net>
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License
00010  * as published by the Free Software Foundation; either version 2
00011  * of the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00021  * 02111-1307, USA.
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     // Disable hides the caret if it's currently visible.
00044     // The caret can be disabled multiple times, and just as many enable
00045     // calls need to take place for the cursor to show up.
00046     // If the cursor is already enabled, the enable call just makes the
00047     // cursor get redrawn.
00048     // if bNoMulti is true, then only one enable call needed to reverse this disable.
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     // When you call setCoords, the cursor is explicitly shown
00056     // and the timer restarts from 0 for the next 500ms cycle.
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     // The caret needs to know about this to clip the save/restore rects.
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(); // no impl
00073     GR_Caret(const GR_Caret& rhs);          // no impl.
00074     void operator=(const GR_Caret& rhs);    // no impl.
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     // for bidi
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     // m_nDisableCount > 0 implies a disabled cursor.
00106     // m_nDisableCount should never be negative.
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     // no impls
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

Generated on Mon May 28 2012 for AbiWord by  doxygen 1.7.1