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

ap_TopRuler.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-2000 AbiSource, Inc.
00005  * Copyright (C) 2001 Tomas Frydrych
00006  * Copyright (C) 2004 Hubert Figuière
00007  *
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 
00024 #ifndef AP_TOPRULER_H
00025 #define AP_TOPRULER_H
00026 
00027 #include "xap_Features.h"
00028 // Class for dealing with the horizontal ruler at the top of
00029 // a document window.
00030 
00031 #include "ut_types.h"
00032 #include "ut_misc.h"
00033 #include "ut_units.h"
00034 #include "xav_Listener.h"
00035 #include "ap_Ruler.h"
00036 #include "ev_EditBits.h"
00037 #include "gr_Graphics.h"
00038 #include "fl_BlockLayout.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 UT_Timer;
00047 class fp_CellContainer;
00048 class  AP_TopRulerTableInfo;
00049 /*****************************************************************/
00050 
00051 
00052 
00053 /*****************************************************************/
00054 class ABI_EXPORT AP_TopRulerTableInfo
00055 {
00056 public:
00057     UT_sint32 m_iLeftCellPos;
00058     UT_sint32 m_iLeftSpacing;
00059     UT_sint32 m_iRightCellPos;
00060     UT_sint32 m_iRightSpacing;
00061     fp_CellContainer * m_pCell;
00062 };
00063 
00064 /*****************************************************************/
00065 
00066 /*****************************************************************/
00067 
00068 class ABI_EXPORT AP_TopRulerInfo
00069 {
00070 public:
00071     typedef enum _mode { TRI_MODE_COLUMNS, TRI_MODE_TABLE, TRI_MODE_FRAME } Mode;
00072 
00073     AP_TopRulerInfo(void) :
00074                             m_mode(TRI_MODE_COLUMNS),
00075                             m_xPaperSize(0),
00076                             m_xPageViewMargin(0),
00077                             m_xrPoint(0),
00078                             m_xrLeftIndent(0),
00079                             m_xrFirstLineIndent(0),
00080                             m_xrRightIndent(0),
00081                             m_xrTabStop(0),
00082                             m_pfnEnumTabStops(NULL),
00083                             m_pVoidEnumTabStopsData(NULL),
00084                             m_iTabStops(0),
00085                             m_iDefaultTabInterval(0),
00086                             m_pszTabStops(NULL),
00087                             m_iCurrentColumn(0),
00088                             m_iNumColumns(0),
00089                             m_vecTableColInfo (NULL),
00090                             m_vecFullTable(NULL),
00091                             m_iTablePadding(0),
00092                             m_iCells(0),
00093                             m_iCurCell(0)
00094         {
00095             xxx_UT_DEBUGMSG(("SEVIOR: Creating AP_TopRulerInfo %x \n",this));
00096 
00097             u.c.m_xaLeftMargin  = 0;
00098             u.c.m_xaRightMargin = 0;
00099             u.c.m_xColumnGap    = 0;
00100             u.c.m_xColumnWidth  = 0;
00101         }
00102     virtual ~AP_TopRulerInfo(void)
00103         {
00104             xxx_UT_DEBUGMSG(("SEVIOR: Deleting AP_TopRulerInfo %x \n",this));
00105             if(m_vecTableColInfo)
00106             {
00107                 UT_sint32 count = m_vecTableColInfo->getItemCount();
00108                 UT_sint32 i =0;
00109                 for(i=0; i< count; i++)
00110                 {
00111                     delete m_vecTableColInfo->getNthItem(i);
00112                 }
00113                 delete m_vecTableColInfo;
00114             }
00115             if(m_vecFullTable)
00116             {
00117                 UT_sint32 count = m_vecFullTable->getItemCount();
00118                 UT_sint32 i =0;
00119                 for(i=0; i< count; i++)
00120                 {
00121                     delete m_vecFullTable->getNthItem(i);
00122                 }
00123                 delete m_vecFullTable;
00124                 m_vecFullTable = NULL;
00125             }
00126         }
00127 
00128     Mode                    m_mode;
00129     UT_uint32               m_xPaperSize;
00130     UT_uint32               m_xPageViewMargin;
00131 
00132     // current caret position -- relative to the current column
00133 
00134     UT_sint32               m_xrPoint;
00135     UT_sint32               m_xrLeftIndent;
00136     UT_sint32               m_xrFirstLineIndent;
00137     UT_sint32               m_xrRightIndent;
00138     UT_sint32               m_xrTabStop;
00139 
00140     // tab stop information
00141 
00142     bool                    (*m_pfnEnumTabStops)(void * pData, UT_uint32 k, fl_TabStop *pTabInfo);
00143     void *                  m_pVoidEnumTabStopsData;
00144     UT_sint32               m_iTabStops;
00145     UT_sint32               m_iDefaultTabInterval;
00146     const char *            m_pszTabStops;
00147 
00148     // current column number and the number of columns
00149 
00150     UT_uint32               m_iCurrentColumn;
00151     UT_uint32               m_iNumColumns;
00152 
00153 // Column information for current table
00154 
00155     UT_GenericVector<AP_TopRulerTableInfo *> * m_vecTableColInfo;
00156     UT_GenericVector<AP_TopRulerTableInfo *> * m_vecFullTable;
00157     UT_sint32               m_iTablePadding;
00158     UT_sint32               m_iCells;
00159     UT_sint32               m_iCurCell;
00160     union _u {
00161 
00162         struct _c {
00163 
00164             // page absolute document margins
00165 
00166             UT_sint32       m_xaLeftMargin;
00167             UT_sint32       m_xaRightMargin;
00168 
00169             // column width and spacing -- currently we only support
00170             // uniform gaps and widths for columns
00171 
00172             UT_uint32       m_xColumnGap;
00173             UT_uint32       m_xColumnWidth;
00174 
00175         } c;                                    /* valid when column mode */
00176 
00177         struct _t {
00178 
00179             int foo;
00180 
00181         } t;                                    /* valid when table mode */
00182 
00183     } u;
00184 };
00185 
00186 class ABI_EXPORT AP_TopRuler : public AV_Listener, virtual public XAP_CustomWidgetLU
00187 {
00188 public:
00189     AP_TopRuler(XAP_Frame * pFrame);
00190     virtual ~AP_TopRuler(void);
00191 
00192     virtual void    setView(AV_View * pView);
00193     void            setViewHidden(AV_View * pView);
00194     void            setView(AV_View* pView, UT_uint32 iZoom);
00195     AV_View *       getView(void) const { return m_pView;}
00196     void            setOffsetLeftRuler(UT_uint32 iLeftRulerWidth);
00197     void            setZoom(UT_uint32 iZoom);
00198     void            setHeight(UT_uint32 iHeight);
00199     UT_uint32       getHeight(void) const;
00200     void            setWidth(UT_uint32 iWidth);
00201     UT_uint32       getWidth(void) const;
00202     GR_Graphics *   getGraphics(void) const { return m_pG;}
00203     bool            isHidden(void) const
00204         { return m_bIsHidden;}
00205     void            scrollRuler(UT_sint32 xoff, UT_sint32 xlimit);
00206 
00207     UT_sint32       setTableLineDrag(PT_DocPosition pos, UT_sint32 x, UT_sint32 & iFixed);
00208     void            mouseMotion(EV_EditModifierState ems, UT_sint32 x, UT_sint32 y);
00209     void            mousePress(EV_EditModifierState ems, EV_EditMouseButton emb, UT_uint32 x, UT_uint32 y);
00210     void            mouseRelease(EV_EditModifierState ems, EV_EditMouseButton emb, UT_sint32 x, UT_sint32 y);
00211 
00212     bool            isMouseOverTab(UT_uint32 x, UT_uint32 y);
00213     /* used with AV_Listener */
00214     virtual bool    notify(AV_View * pView, const AV_ChangeMask mask);
00215     virtual  AV_ListenerType getType(void) { return AV_LISTENER_TOPRULER;}
00216 
00217     /* used with AV_ScrollObj */
00218     static void     _scrollFuncX(void * pData, UT_sint32 xoff, UT_sint32 xlimit);
00219     static void     _scrollFuncY(void * pData, UT_sint32 yoff, UT_sint32 ylimit);
00220 
00221     /* for use with the prefs listener top_ruler_prefs_listener */
00222     UT_Dimension    getDimension() const { return m_dim; }
00223     void            setDimension( UT_Dimension newdim );
00224 
00225     UT_uint32       getTabToggleAreaWidth() const;
00226 
00227     static UT_uint32 getFixedWidth(){return s_iFixedWidth;}
00228 
00229 protected:
00230     /* implement XAP_CustomWidgetLU::drawLU */
00231     virtual void drawLU(const UT_Rect *clip);
00232 
00233     void    _draw(const UT_Rect * pClipRect, AP_TopRulerInfo * pUseInfo);
00234     void    _drawBar(const UT_Rect * pClipRect, AP_TopRulerInfo * pInfo,
00235                      GR_Graphics::GR_Color3D clr3d, UT_sint32 x, UT_sint32 w);
00236     void    _drawTickMark(const UT_Rect * pClipRect,
00237                           AP_TopRulerInfo * pInfo, ap_RulerTicks &tick,
00238                           GR_Graphics::GR_Color3D clr3d, GR_Font * pFont,
00239                           UT_sint32 k, UT_sint32 xTick);
00240     void    _drawTicks(const UT_Rect * pClipRect,
00241                        AP_TopRulerInfo * pInfo, ap_RulerTicks &tick,
00242                        GR_Graphics::GR_Color3D clr3d, GR_Font * pFont,
00243                        UT_sint32 xOrigin, UT_sint32 xFrom, UT_sint32 xTo);
00244 
00245     void    _getParagraphMarkerXCenters(AP_TopRulerInfo * pInfo,
00246                                         UT_sint32 * pLeft, UT_sint32 * pRight, UT_sint32 * pFirstLine);
00247     void    _getParagraphMarkerRects(AP_TopRulerInfo * pInfo,
00248                                      UT_sint32 leftCenter, UT_sint32 rightCenter, UT_sint32 firstLineCenter,
00249                                      UT_Rect * prLeftIndent, UT_Rect * prRightIndent, UT_Rect * prFirstLineIndent);
00250     void    _drawParagraphProperties(const UT_Rect * pClipRect,
00251                                      AP_TopRulerInfo * pInfo,
00252                                      bool bDrawAll = true);
00253 
00254     void    _getTabToggleRect(UT_Rect * prToggle);
00255     void    _drawTabToggle(const UT_Rect * pClipRect, bool bErase);
00256 
00257     void    _getTabStopXAnchor(AP_TopRulerInfo * pInfo, UT_sint32 k, UT_sint32 * pTab, eTabType & iType, eTabLeader & iLeader);
00258     void    _getTabStopRect(AP_TopRulerInfo * pInfo, UT_sint32 anchor, UT_Rect * pRect);
00259     void    _drawTabProperties(const UT_Rect * pClipRect,
00260                                    AP_TopRulerInfo * pInfo,
00261                                    bool bDrawAll = true);
00262 
00263     UT_sint32       _findTabStop(AP_TopRulerInfo * pInfo, UT_uint32 x, UT_uint32 y, UT_sint32 & anchor, eTabType & iType, eTabLeader & iLeader);
00264     const char *    _getTabStopString(AP_TopRulerInfo * pInfo, UT_sint32 k);
00265     void            _getTabZoneRect(AP_TopRulerInfo * pInfo, UT_Rect &rZone);
00266     void            _setTabStops(ap_RulerTicks tick, UT_sint32 iTab, eTabLeader iLeader, bool bDelete);
00267 
00268     UT_sint32   _getColumnMarkerXRightEnd(AP_TopRulerInfo * pInfo, UT_uint32 kCol);
00269     void        _getColumnMarkerRect(AP_TopRulerInfo * pInfo, UT_uint32 kCol, UT_sint32 xCenter,
00270                                      UT_Rect * prCol);
00271     void        _drawColumnProperties(const UT_Rect * pClipRect,
00272                                       AP_TopRulerInfo * pInfo,
00273                                       UT_uint32 kCol);
00274     void        _getCellMarkerRect(AP_TopRulerInfo * pInfo, UT_sint32 kCell,
00275                                    UT_Rect * prCell);
00276     void        _drawCellProperties(const UT_Rect * pClipRect,
00277                                       AP_TopRulerInfo * pInfo,
00278                                       UT_uint32 kCol, bool bDrawAll);
00279     void        _drawCellProperties(const UT_Rect * pClipRect,
00280                                     AP_TopRulerInfo * pInfo, bool bDrawAll);
00281     void        _drawCellGap( AP_TopRulerInfo * pInfo, UT_sint32 iCell);
00282 
00283     virtual void    _drawCellMark(UT_Rect * prDrag, bool bUp);
00284 
00285     void        _getMarginMarkerRects(AP_TopRulerInfo * pInfo, UT_Rect &rLeft, UT_Rect &rRight);
00286 
00287     virtual void    _drawMarginProperties(const UT_Rect * pClipRect,
00288                                       AP_TopRulerInfo * pInfo, GR_Graphics::GR_Color3D clr);
00289 
00290     void        _xorGuide(bool bClear=false);
00291 
00292     void        _ignoreEvent(bool bDone);
00293     double      _scalePixelDistanceToUnits(UT_sint32 xColRel, ap_RulerTicks & tick);
00294     double      _getUnitsFromRulerLeft(UT_sint32 xColRel, ap_RulerTicks & tick);
00295     UT_sint32   _getFirstPixelInColumn(AP_TopRulerInfo * pInfo, UT_uint32 kCol);
00296     UT_sint32   _snapPixelToGrid(UT_sint32 xDist, ap_RulerTicks & tick);
00297 
00298     virtual void    _drawLeftIndentMarker(UT_Rect & r, bool bFilled);
00299     virtual void    _drawRightIndentMarker(UT_Rect & r, bool bFilled);
00300     virtual void    _drawFirstLineIndentMarker(UT_Rect & r, bool bFilled);
00301 
00302     void        _drawTabStop(UT_Rect & r, eTabType iType, bool bFilled);
00303 
00304     virtual void    _drawColumnGapMarker(UT_Rect & r);
00305 
00306     bool        _isInBottomBoxOfLeftIndent(UT_uint32 y);
00307     void        _displayStatusMessage(XAP_String_Id messageID, const ap_RulerTicks &tick, double dValue);
00308     void        _displayStatusMessage(XAP_String_Id messageID, const ap_RulerTicks &tick, double dValue1, double dValue2);
00309     void        _displayStatusMessage(XAP_String_Id FormatMessageID, UT_sint32 iCol, const char * format);
00310     void        _displayStatusMessage(XAP_String_Id FormatMessageID);
00311 
00312 
00313     void        _refreshView(void);
00314 
00315     // must be static so that I can pass as a functional arg - shack
00316     static void _prefsListener( XAP_Prefs *pPrefs, UT_StringPtrMap *phChanges, void *data );
00317 
00318     // autoscroll stuff
00319     static void         _autoScroll(UT_Worker * pTimer);
00320 
00321     XAP_Frame *         m_pFrame;
00322     GR_Graphics *       m_pG;
00323     UT_uint32           m_iLeftRulerWidth; // device
00324     UT_sint32           m_xScrollOffset;
00325     UT_sint32           m_xScrollLimit;
00326 
00327     static UT_uint32    s_iFixedHeight /* =32 */;   /* size we draw stuff w/o regard to window size: device */
00328     static UT_uint32    s_iFixedWidth  /* =32 */;   /* minimum width of non-scrolling area on left: device */
00329 
00330 private:
00331     AV_ScrollObj *      m_pScrollObj;
00332 protected:
00333     AV_View *           m_pView;
00334 private:
00335     UT_Dimension        m_dim;
00336 
00337     UT_uint32           m_iHeight;      /* size of window: device */
00338     UT_uint32           m_iWidth;       /* size of window: device */
00339 
00340     UT_Timer *          m_pAutoScrollTimer;
00341     char                m_aScrollDirection; // 'L' == left   'R' == right
00342 
00343     UT_sint32           m_minColumnWidth; // logical
00344 
00345     UT_sint32           m_iMinCellPos;  /* cell marker left border while dragging: logical */
00346     UT_sint32           m_iMaxCellPos;  /* cell marker right border while dragging: logical */
00347 
00348     AP_TopRulerInfo     m_infoCache;
00349     bool                m_bValidMouseClick;
00350     bool                m_bEventIgnored;
00351 
00352     typedef enum _draggingWhat { DW_NOTHING,
00353                                  DW_LEFTMARGIN,
00354                                  DW_RIGHTMARGIN,
00355                                  DW_COLUMNGAP,
00356                                  DW_COLUMNGAPLEFTSIDE,
00357                                  DW_LEFTINDENT,
00358                                  DW_RIGHTINDENT,
00359                                  DW_FIRSTLINEINDENT,
00360                                  DW_LEFTINDENTWITHFIRST,
00361                                  DW_TABSTOP,
00362                                  DW_TABTOGGLE,
00363                                  DW_CELLMARK
00364     } DraggingWhat;
00365 
00366     DraggingWhat        m_draggingWhat;
00367     UT_sint32           m_draggingCenter; /* center of primary thing being dragged */
00368     UT_Rect             m_draggingRect; /* rectangle of primary thing being dragged */
00369     UT_sint32           m_dragging2Center; /* center of drag-along */
00370     UT_Rect             m_dragging2Rect; /* rect of drag-along */
00371     UT_sint32           m_draggingTab;  /* index of tab being dragged */
00372     eTabType            m_draggingTabType;
00373     eTabLeader          m_draggingTabLeader;
00374     UT_sint32           m_dragStart;
00375     bool                m_bBeforeFirstMotion;
00376     UT_sint32           m_oldX; /* Only for dragging; used to see if object has moved */
00377 
00378     eTabType            m_iDefaultTabType;
00379     UT_sint32           m_draggingCell; // index of cell being dragged
00380     bool                m_bGuide;   /* true ==> guide line XORed onscreen */
00381     UT_sint32           m_xGuide;   /* valid iff m_bGuide */
00382     UT_sint32           m_xOtherGuide;
00383 
00384     AV_ListenerId       m_lidTopRuler;      /* need to save the view/listenerID so we can removeListener in destructor */
00385     UT_sint32           m_iCellContainerLeftPos; // position of the left side of the container
00386                                                  // holding the cell
00387     bool                m_bIsHidden;
00388     UT_sint32           m_iOrigPosition;
00389 #if XAP_DONTUSE_XOR
00390     UT_Rect             m_guideCacheRect;
00391     UT_Rect             m_otherGuideCacheRect;
00392     GR_Image*           m_guideCache;
00393     GR_Image*           m_otherGuideCache;
00394 #endif
00395 };
00396 
00397 #endif /* AP_TOPRULER_H */

Generated on Sun Feb 14 2021 for AbiWord by  doxygen 1.7.1