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

ap_LeftRuler.h

Go to the documentation of this file.
00001 /* -*- mode: C++; tab-width: 4; c-basic-offset: 4; -*- */
00002 
00003 /* AbiWord
00004  * Copyright (C) 1998 AbiSource, Inc.
00005  * Copyright (C) 2004 Hubert Figuière
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301 USA.
00021  */
00022 
00023 #ifndef AP_LEFTRULER_H
00024 #define AP_LEFTRULER_H
00025 
00026 #include "xap_Features.h"
00027 // Class for dealing with the horizontal ruler at the top of
00028 // a document window.
00029 
00030 #include "ut_types.h"
00031 #include "ut_misc.h"
00032 #include "ut_units.h"
00033 #include "ut_hash.h"
00034 #include "xav_Listener.h"
00035 
00036 #include "gr_Graphics.h"
00037 #include "ev_EditBits.h"
00038 #include "pt_Types.h"
00039 #include "xap_Strings.h"
00040 #include "xap_CustomWidget.h"
00041 
00042 class XAP_App;
00043 class XAP_Frame;
00044 class XAP_Prefs;
00045 class AV_ScrollObj;
00046 class GR_Graphics;
00047 class ap_RulerTicks;
00048 class fp_CellContainer;
00049 class fp_TableContainer;
00050 /*****************************************************************/
00051 
00052 
00053 /*****************************************************************/
00054 class ABI_EXPORT AP_LeftRulerTableInfo
00055 {
00056 public:
00057     UT_sint32 m_iTopCellPos;
00058     UT_sint32 m_iTopSpacing;
00059     UT_sint32 m_iBotCellPos;
00060     UT_sint32 m_iBotSpacing;
00061     fp_CellContainer * m_pCell;
00062 };
00063 
00064 /*****************************************************************/
00065 
00066 /*****************************************************************/
00067 
00068 class ABI_EXPORT AP_LeftRulerInfo
00069 {
00070 public:
00071     typedef enum _mode { TRI_MODE_COLUMNS,
00072                          TRI_MODE_TABLE,
00073                          TRI_MODE_FRAME } Mode;
00074 
00075     AP_LeftRulerInfo(void) :    m_mode(TRI_MODE_COLUMNS),
00076                                 m_yPageStart(0),
00077                                 m_yPageSize(0),
00078                                 m_yPoint(0),
00079                                 m_yTopMargin(0),
00080                                 m_yBottomMargin(0),
00081                                 m_iNumRows(0),
00082                                 m_iCurrentRow(0),
00083                                 m_iTablePadding(0),
00084                                 m_vecTableRowInfo(NULL)
00085         {
00086         }
00087     virtual ~AP_LeftRulerInfo(void)
00088         {
00089             if(m_vecTableRowInfo)
00090             {
00091                 UT_sint32 count = m_vecTableRowInfo->getItemCount();
00092                 UT_sint32 i =0;
00093                 for(i=0; i< count; i++)
00094                 {
00095                     delete m_vecTableRowInfo->getNthItem(i);
00096                 }
00097                 DELETEP(m_vecTableRowInfo);
00098             }
00099         }
00100 
00101     Mode                    m_mode;
00102 
00103     /* all values are in layout units */
00104 
00105     UT_uint32               m_yPageStart;       /* absolute coord of start of page */
00106     UT_uint32               m_yPageSize;        /* absolute page size for the current page */
00107     UT_uint32               m_yPoint;           /* absolute coord of current insertion point */
00108     UT_sint32               m_yTopMargin;       /* content start relative to top of page */
00109     UT_sint32               m_yBottomMargin;    /* content end relative to top of page */
00110 
00111 // Things we need for Tables
00112 
00113     UT_sint32               m_iNumRows;
00114     UT_sint32               m_iCurrentRow;
00115     UT_sint32               m_iTablePadding;
00116     UT_GenericVector<AP_LeftRulerTableInfo *> * m_vecTableRowInfo;
00117 };
00118 
00119 /*****************************************************************/
00120 
00121 class ABI_EXPORT AP_LeftRuler : public AV_Listener, public XAP_CustomWidgetLU
00122 {
00123 public:
00124     AP_LeftRuler(XAP_Frame * pFrame);
00125     virtual ~AP_LeftRuler(void);
00126 
00127     virtual void        setView(AV_View * pView);
00128     void                setView(AV_View* pView, UT_uint32 iZoom);
00129     void                setViewHidden(AV_View* pView);
00130     void                setZoom(UT_uint32 iZoom);
00131     bool                isHidden(void) const
00132         { return m_bIsHidden;}
00133     AV_View *           getView(void) const
00134         {return m_pView;}
00135     void                setHeight(UT_uint32 iHeight);
00136     UT_uint32           getHeight(void) const;
00137     void                setWidth(UT_uint32 iWidth);
00138     UT_uint32           getWidth(void) const;
00139     void                scrollRuler(UT_sint32 yoff, UT_sint32 ylimit);
00140 
00141     void                mouseMotion(EV_EditModifierState ems, UT_sint32 x, UT_sint32 y);
00142     void                mousePress(EV_EditModifierState ems, EV_EditMouseButton emb, UT_uint32 x, UT_uint32 y);
00143 
00144     void                mouseRelease(EV_EditModifierState ems, EV_EditMouseButton emb, UT_sint32 x, UT_sint32 y);
00145     UT_sint32           setTableLineDrag(PT_DocPosition pos, UT_sint32 & iFixed, UT_sint32 y);
00146     /* used with AV_Listener */
00147     virtual bool        notify(AV_View * pView, const AV_ChangeMask mask);
00148     virtual  AV_ListenerType getType(void) { return AV_LISTENER_LEFTRULER;}
00149 
00150     /* used with AV_ScrollObj */
00151     static void         _scrollFuncX(void * pData, UT_sint32 xoff, UT_sint32 xlimit);
00152     static void         _scrollFuncY(void * pData, UT_sint32 yoff, UT_sint32 ylimit);
00153 
00154     /* for use with the prefs listener top_ruler_prefs_listener */
00155     UT_Dimension        getDimension() const { return m_dim; }
00156     void                setDimension( UT_Dimension newdim );
00157     GR_Graphics *       getGraphics(void) const { return m_pG;}
00158 protected:
00159     void                _refreshView(void);
00160 
00161     /* don't call this function directly, use XAP_CustomWidget::queueDraw() instead */
00162     virtual void        drawLU(const UT_Rect *clip);
00163 
00164 //  void                _draw3DFrame(const UT_Rect * pClipRect, AP_TopRulerInfo * pInfo,
00165 //                                   UT_sint32 x, UT_sint32 h);
00166 
00167     // must be static so that I can pass as a functional arg - shack
00168     static void _prefsListener( XAP_Prefs *pPrefs, UT_StringPtrMap *phChanges, void *data );
00169 
00170     XAP_Frame *         m_pFrame;
00171     GR_Graphics *       m_pG;
00172 
00173     // These are in device units.
00174     /* static const*/ UT_uint32 s_iFixedHeight /* =32 */;   /* size we draw stuff w/o regard to window size */
00175     /* static const*/ UT_uint32 s_iFixedWidth  /* =32 */;   /* minimum width of non-scrolling area on left */
00176 
00177 private:
00178     UT_sint32           _snapPixelToGrid(UT_sint32 xDist, ap_RulerTicks & tick);
00179     double              _scalePixelDistanceToUnits(UT_sint32 yDist, ap_RulerTicks & tick);
00180     void                _ignoreEvent(bool bDone);
00181 protected:
00182     void                _getMarginMarkerRects(const AP_LeftRulerInfo * pInfo, UT_Rect &rTop, UT_Rect &rBottom);
00183 
00184     virtual void        _drawMarginProperties(const UT_Rect * pClipRect,
00185                                               const AP_LeftRulerInfo * pInfo,
00186                                               GR_Graphics::GR_Color3D clr);
00187 private:
00188 
00189     void                _getCellMarkerRects(const AP_LeftRulerInfo * pInfo, UT_sint32 iCell, UT_Rect &rCell, fp_TableContainer * pBroke=NULL);
00190     void                _drawCellProperties(const AP_LeftRulerInfo * pInfo);
00191 protected:
00192     virtual void        _drawCellMark(UT_Rect *prDrag, bool bUp);
00193 private:
00194     void                _xorGuide(bool bClear=false);
00195     void                _displayStatusMessage(XAP_String_Id messageID, const ap_RulerTicks &tick, double dValue);
00196 
00197     AP_LeftRulerInfo *  m_lfi; /* the values we last drew with */
00198 
00199     // scrolling objects
00200     AV_ScrollObj *      m_pScrollObj;
00201     UT_sint32           m_yScrollOffset;
00202     UT_sint32           m_yScrollLimit;
00203 
00204     AV_ListenerId       m_lidLeftRuler;
00205 
00206     // misc info
00207 
00208     AV_View *           m_pView;
00209     UT_Dimension        m_dim;
00210     UT_uint32           m_iHeight;      /* size of window, in device units */
00211     UT_uint32           m_iWidth;       /* size of window, in device units */
00212 
00213     AP_LeftRulerInfo    m_infoCache;
00214     UT_sint32           m_oldY; /* Only for dragging; used to see if object has moved */
00215 
00216     typedef enum _draggingWhat { DW_NOTHING,
00217                                  DW_TOPMARGIN,
00218                                  DW_BOTTOMMARGIN,
00219                                  DW_CELLMARK
00220     } DraggingWhat;
00221 
00222     DraggingWhat        m_draggingWhat;
00223     UT_sint32           m_draggingCenter; /* center of primary thing being dragged */
00224     bool                m_bBeforeFirstMotion;
00225     UT_sint32           m_draggingCell;
00226     bool                m_bGuide;   /* true ==> guide line XORed onscreen */
00227     UT_sint32           m_yGuide;   /* valid iff m_bGuide */
00228 
00229     bool                m_bValidMouseClick;
00230     bool                m_bEventIgnored;
00231     UT_Rect             m_draggingRect;
00232     UT_sint32           m_minPageLength;
00233     PT_DocPosition       m_draggingDocPos;
00234     bool                m_bIsHidden;
00235 #if XAP_DONTUSE_XOR
00236     UT_Rect             m_guideCacheRect;
00237     GR_Image*           m_guideCache;
00238 #endif
00239 };
00240 
00241 #endif /* AP_LEFTRULER_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1