• 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., 51 Franklin Street, Fifth Floor, Boston, MA
00021  * 02110-1301 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     void                            setPendingBlink(void);
00071     bool                            doBlinkIfNeeded(void);
00072 private:
00073     GR_Caret(); // no impl
00074     GR_Caret(const GR_Caret& rhs);          // no impl.
00075     void operator=(const GR_Caret& rhs);    // no impl.
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     // for bidi
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     // m_nDisableCount > 0 implies a disabled cursor.
00107     // m_nDisableCount should never be negative.
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     // no impls
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

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1