• 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., 59 Temple Place - Suite 330, Boston, MA
00020  * 02111-1307, 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 "xav_Listener.h"
00034 
00035 #include "gr_Graphics.h"
00036 #include "ev_EditBits.h"
00037 #include "pt_Types.h"
00038 #include "xap_Strings.h"
00039 #include "xap_CustomWidget.h"
00040 
00041 class XAP_App;
00042 class XAP_Frame;
00043 class XAP_Prefs;
00044 class AV_ScrollObj;
00045 class GR_Graphics;
00046 class ap_RulerTicks;
00047 class fp_CellContainer;
00048 class fp_TableContainer;
00049 /*****************************************************************/
00050 
00051 
00052 /*****************************************************************/
00053 class ABI_EXPORT AP_LeftRulerTableInfo
00054 {
00055 public:
00056     UT_sint32 m_iTopCellPos;
00057     UT_sint32 m_iTopSpacing;
00058     UT_sint32 m_iBotCellPos;
00059     UT_sint32 m_iBotSpacing;
00060     fp_CellContainer * m_pCell;
00061 };
00062 
00063 /*****************************************************************/
00064 
00065 /*****************************************************************/
00066 
00067 class ABI_EXPORT AP_LeftRulerInfo
00068 {
00069 public:
00070     typedef enum _mode { TRI_MODE_COLUMNS,
00071                          TRI_MODE_TABLE,
00072                          TRI_MODE_FRAME } Mode;
00073 
00074     AP_LeftRulerInfo(void) :    m_mode(TRI_MODE_COLUMNS),
00075                                 m_yPageStart(0),
00076                                 m_yPageSize(0),
00077                                 m_yPoint(0),
00078                                 m_yTopMargin(0),
00079                                 m_yBottomMargin(0),
00080                                 m_iNumRows(0),
00081                                 m_iCurrentRow(0),
00082                                 m_iTablePadding(0),
00083                                 m_vecTableRowInfo(NULL)
00084         {
00085         }
00086     virtual ~AP_LeftRulerInfo(void)
00087         {
00088             if(m_vecTableRowInfo)
00089             {
00090                 UT_sint32 count = m_vecTableRowInfo->getItemCount();
00091                 UT_sint32 i =0;
00092                 for(i=0; i< count; i++)
00093                 {
00094                     delete m_vecTableRowInfo->getNthItem(i);
00095                 }
00096                 DELETEP(m_vecTableRowInfo);
00097             }
00098         }
00099 
00100     Mode                    m_mode;
00101 
00102     /* all values are in layout units */
00103 
00104     UT_uint32               m_yPageStart;       /* absolute coord of start of page */
00105     UT_uint32               m_yPageSize;        /* absolute page size for the current page */
00106     UT_uint32               m_yPoint;           /* absolute coord of current insertion point */
00107     UT_sint32               m_yTopMargin;       /* content start relative to top of page */
00108     UT_sint32               m_yBottomMargin;    /* content end relative to top of page */
00109 
00110 // Things we need for Tables
00111 
00112     UT_sint32               m_iNumRows;
00113     UT_sint32               m_iCurrentRow;
00114     UT_sint32               m_iTablePadding;
00115     UT_GenericVector<AP_LeftRulerTableInfo *> * m_vecTableRowInfo;
00116 };
00117 
00118 /*****************************************************************/
00119 
00120 class ABI_EXPORT AP_LeftRuler : public AV_Listener, public XAP_CustomWidgetLU
00121 {
00122 public:
00123     AP_LeftRuler(XAP_Frame * pFrame);
00124     virtual ~AP_LeftRuler(void);
00125 
00126     virtual void        setView(AV_View * pView);
00127     void                setView(AV_View* pView, UT_uint32 iZoom);
00128     void                setViewHidden(AV_View* pView);
00129     void                setZoom(UT_uint32 iZoom);
00130     bool                isHidden(void) const
00131         { return m_bIsHidden;}
00132     AV_View *           getView(void) const
00133         {return m_pView;}
00134     void                setHeight(UT_uint32 iHeight);
00135     UT_uint32           getHeight(void) const;
00136     void                setWidth(UT_uint32 iWidth);
00137     UT_uint32           getWidth(void) const;
00138     void                scrollRuler(UT_sint32 yoff, UT_sint32 ylimit);
00139 
00140     void                mouseMotion(EV_EditModifierState ems, UT_sint32 x, UT_sint32 y);
00141     void                mousePress(EV_EditModifierState ems, EV_EditMouseButton emb, UT_uint32 x, UT_uint32 y);
00142 
00143     void                mouseRelease(EV_EditModifierState ems, EV_EditMouseButton emb, UT_sint32 x, UT_sint32 y);
00144     UT_sint32           setTableLineDrag(PT_DocPosition pos, UT_sint32 & iFixed, UT_sint32 y);
00145     /* used with AV_Listener */
00146     virtual bool        notify(AV_View * pView, const AV_ChangeMask mask);
00147     virtual  AV_ListenerType getType(void) { return AV_LISTENER_LEFTRULER;}
00148 
00149     /* used with AV_ScrollObj */
00150     static void         _scrollFuncX(void * pData, UT_sint32 xoff, UT_sint32 xlimit);
00151     static void         _scrollFuncY(void * pData, UT_sint32 yoff, UT_sint32 ylimit);
00152 
00153     /* for use with the prefs listener top_ruler_prefs_listener */
00154     UT_Dimension        getDimension() const { return m_dim; }
00155     void                setDimension( UT_Dimension newdim );
00156     GR_Graphics *       getGraphics(void) const { return m_pG;}
00157 protected:
00158     void                _refreshView(void);
00159 
00160     /* don't call this function directly, use XAP_CustomWidget::queueDraw() instead */
00161     virtual void        drawLU(const UT_Rect *clip);
00162 
00163 //  void                _draw3DFrame(const UT_Rect * pClipRect, AP_TopRulerInfo * pInfo,
00164 //                                   UT_sint32 x, UT_sint32 h);
00165 
00166     // must be static so that I can pass as a functional arg - shack
00167     static void _prefsListener( XAP_Prefs *pPrefs, UT_StringPtrMap *phChanges, void *data );
00168 
00169     XAP_Frame *         m_pFrame;
00170     GR_Graphics *       m_pG;
00171 
00172     // These are in device units.
00173     /* static const*/ UT_uint32 s_iFixedHeight /* =32 */;   /* size we draw stuff w/o regard to window size */
00174     /* static const*/ UT_uint32 s_iFixedWidth  /* =32 */;   /* minimum width of non-scrolling area on left */
00175 
00176 private:
00177     UT_sint32           _snapPixelToGrid(UT_sint32 xDist, ap_RulerTicks & tick);
00178     double              _scalePixelDistanceToUnits(UT_sint32 yDist, ap_RulerTicks & tick);
00179     void                _ignoreEvent(bool bDone);
00180 protected:
00181     void                _getMarginMarkerRects(const AP_LeftRulerInfo * pInfo, UT_Rect &rTop, UT_Rect &rBottom);
00182 
00183     virtual void        _drawMarginProperties(const UT_Rect * pClipRect,
00184                                               const AP_LeftRulerInfo * pInfo,
00185                                               GR_Graphics::GR_Color3D clr);
00186 private:
00187 
00188     void                _getCellMarkerRects(const AP_LeftRulerInfo * pInfo, UT_sint32 iCell, UT_Rect &rCell, fp_TableContainer * pBroke=NULL);
00189     void                _drawCellProperties(const AP_LeftRulerInfo * pInfo);
00190 protected:
00191     virtual void        _drawCellMark(UT_Rect *prDrag, bool bUp);
00192 private:
00193     void                _xorGuide(bool bClear=false);
00194     void                _displayStatusMessage(XAP_String_Id messageID, const ap_RulerTicks &tick, double dValue);
00195 
00196     AP_LeftRulerInfo *  m_lfi; /* the values we last drew with */
00197 
00198     // scrolling objects
00199     AV_ScrollObj *      m_pScrollObj;
00200     UT_sint32           m_yScrollOffset;
00201     UT_sint32           m_yScrollLimit;
00202 
00203     AV_ListenerId       m_lidLeftRuler;
00204 
00205     // misc info
00206 
00207     AV_View *           m_pView;
00208     UT_Dimension        m_dim;
00209     UT_uint32           m_iHeight;      /* size of window, in device units */
00210     UT_uint32           m_iWidth;       /* size of window, in device units */
00211 
00212     AP_LeftRulerInfo    m_infoCache;
00213     UT_sint32           m_oldY; /* Only for dragging; used to see if object has moved */
00214 
00215     typedef enum _draggingWhat { DW_NOTHING,
00216                                  DW_TOPMARGIN,
00217                                  DW_BOTTOMMARGIN,
00218                                  DW_CELLMARK
00219     } DraggingWhat;
00220 
00221     DraggingWhat        m_draggingWhat;
00222     UT_sint32           m_draggingCenter; /* center of primary thing being dragged */
00223     bool                m_bBeforeFirstMotion;
00224     UT_sint32           m_draggingCell;
00225     bool                m_bGuide;   /* true ==> guide line XORed onscreen */
00226     UT_sint32           m_yGuide;   /* valid iff m_bGuide */
00227 
00228     bool                m_bValidMouseClick;
00229     bool                m_bEventIgnored;
00230     UT_Rect             m_draggingRect;
00231     UT_sint32           m_minPageLength;
00232     PT_DocPosition       m_draggingDocPos;
00233     bool                m_bIsHidden;
00234 #if XAP_DONTUSE_XOR
00235     UT_Rect             m_guideCacheRect;
00236     GR_Image*           m_guideCache;
00237 #endif
00238 };
00239 
00240 #endif /* AP_LEFTRULER_H */

Generated on Sun May 27 2012 for AbiWord by  doxygen 1.7.1