FXRuler.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *                            R u l e r   W i d g e t                            *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 2002,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library 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 GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: FXRuler.h,v 1.36 2006/01/28 20:30:21 fox Exp $                           *
00023 ********************************************************************************/
00024 #ifndef FXRULER_H
00025 #define FXRULER_H
00026 
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030 
00031 namespace FX {
00032 
00033 
00035 enum {
00036   RULER_NORMAL        = 0,                                      
00037   RULER_HORIZONTAL    = 0,                                      
00038   RULER_VERTICAL      = 0x00008000,                             
00039   RULER_TICKS_OFF     = 0,                                      
00040   RULER_TICKS_TOP     = 0x00010000,                             
00041   RULER_TICKS_BOTTOM  = 0x00020000,                             
00042   RULER_TICKS_LEFT    = RULER_TICKS_TOP,                        
00043   RULER_TICKS_RIGHT   = RULER_TICKS_BOTTOM,                     
00044   RULER_TICKS_CENTER  = RULER_TICKS_TOP|RULER_TICKS_BOTTOM,     
00045   RULER_NUMBERS       = 0x00040000,                             
00046   RULER_ARROW         = 0x00080000,                             
00047   RULER_MARKERS       =  0x00100000,                            
00048   RULER_METRIC        = 0,                                      
00049   RULER_ENGLISH       = 0x00200000,                             
00050   RULER_MARGIN_ADJUST = 0x00400000,                             
00051   RULER_ALIGN_CENTER  = 0,                                      
00052   RULER_ALIGN_LEFT    = 0x00800000,                             
00053   RULER_ALIGN_RIGHT   = 0x01000000,                             
00054   RULER_ALIGN_TOP     = RULER_ALIGN_LEFT,                       
00055   RULER_ALIGN_BOTTOM  = RULER_ALIGN_RIGHT,                      
00056   RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT,     
00057   RULER_ALIGN_NORMAL  = RULER_ALIGN_CENTER                      
00058   };
00059 
00060 
00061 class FXFont;
00062 
00063 
00078 class FXAPI FXRuler : public FXFrame {
00079   FXDECLARE(FXRuler)
00080 protected:
00081   FXFont  *font;                // Font for numbers
00082   FXint    documentSize;        // Size of document
00083   FXint    edgeSpacing;         // Edge spacing around document
00084   FXint    marginLower;         // Lower margin
00085   FXint    marginUpper;         // Upper margin
00086   FXint    indentFirst;         // First line paragraph indent
00087   FXint    indentLower;         // Lower paragraph indent
00088   FXint    indentUpper;         // Upper paragraph indent
00089   FXdouble pixelPerTick;        // Number of pixels per tick increment
00090   FXint    numberTicks;         // Tick increments between numbers
00091   FXint    majorTicks;          // Tick increments between major ticks
00092   FXint    mediumTicks;         // Tick increments between medium ticks
00093   FXint    tinyTicks;           // Tick increments between tiny ticks
00094   FXint    arrowPos;            // Arrow position
00095   FXColor  textColor;           // Color for numbers and ticks
00096   FXint    shift;               // Left edge of content
00097   FXint    pos;                 // Scroll position
00098   FXint    off;                 // Offset item was grabbed
00099   FXString tip;                 // Tooltip text
00100   FXString help;                // Help text
00101   FXuchar  mode;                // Mode widget is in
00102 protected:
00103   FXRuler();
00104   FXint picked(FXint x,FXint y);
00105   void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y);
00106   void drawRightArrow(FXDCWindow& dc,FXint x,FXint y);
00107   void drawUpArrow(FXDCWindow& dc,FXint x,FXint y);
00108   void drawDownArrow(FXDCWindow& dc,FXint x,FXint y);
00109   void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y);
00110   void drawRightMarker(FXDCWindow& dc,FXint x,FXint y);
00111   void drawUpMarker(FXDCWindow& dc,FXint x,FXint y);
00112   void drawDownMarker(FXDCWindow& dc,FXint x,FXint y);
00113 protected:
00114   enum{
00115     MOUSE_NONE,         // No mouse operation
00116     MOUSE_MARG_LOWER,   // Drag lower margin
00117     MOUSE_MARG_UPPER,   // Drag upper margin
00118     MOUSE_PARA_FIRST,   // Drag first indent
00119     MOUSE_PARA_LOWER,   // Drag lower indent
00120     MOUSE_PARA_UPPER    // Drag upper indent
00121     };
00122 private:
00123   FXRuler(const FXRuler&);
00124   FXRuler &operator=(const FXRuler&);
00125 public:
00126   long onPaint(FXObject*,FXSelector,void*);
00127   long onLeftBtnPress(FXObject*,FXSelector,void*);
00128   long onLeftBtnRelease(FXObject*,FXSelector,void*);
00129   long onMotion(FXObject*,FXSelector,void*);
00130   long onCmdSetValue(FXObject*,FXSelector,void*);
00131   long onCmdSetIntValue(FXObject*,FXSelector,void*);
00132   long onCmdGetIntValue(FXObject*,FXSelector,void*);
00133   long onCmdSetHelp(FXObject*,FXSelector,void*);
00134   long onCmdGetHelp(FXObject*,FXSelector,void*);
00135   long onCmdSetTip(FXObject*,FXSelector,void*);
00136   long onCmdGetTip(FXObject*,FXSelector,void*);
00137   long onQueryHelp(FXObject*,FXSelector,void*);
00138   long onQueryTip(FXObject*,FXSelector,void*);
00139 public:
00140   enum{
00141     ID_ARROW=FXFrame::ID_LAST,
00142     ID_LAST
00143     };
00144 public:
00145 
00147   FXRuler(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=RULER_NORMAL,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=DEFAULT_PAD,FXint pr=DEFAULT_PAD,FXint pt=DEFAULT_PAD,FXint pb=DEFAULT_PAD);
00148 
00150   virtual void layout();
00151 
00153   virtual void create();
00154 
00156   virtual void detach();
00157 
00159   virtual FXint getDefaultWidth();
00160 
00162   virtual FXint getDefaultHeight();
00163 
00165   void setPosition(FXint pos,FXbool notify=FALSE);
00166 
00168   FXint getPosition() const { return pos; }
00169 
00171   void setContentSize(FXint size,FXbool notify=FALSE);
00172   FXint getContentSize() const;
00173 
00175   FXint getDocumentLower() const;
00176 
00178   FXint getDocumentUpper() const;
00179 
00181   void setDocumentSize(FXint size,FXbool notify=FALSE);
00182   FXint getDocumentSize() const { return documentSize; }
00183 
00185   void setEdgeSpacing(FXint space,FXbool notify=FALSE);
00186   FXint getEdgeSpacing() const { return edgeSpacing; }
00187 
00189   void setMarginLower(FXint mgn,FXbool notify=FALSE);
00190   FXint getMarginLower() const { return marginLower; }
00191 
00193   void setMarginUpper(FXint mgn,FXbool notify=FALSE);
00194   FXint getMarginUpper() const { return marginUpper; }
00195 
00197   void setIndentFirst(FXint ind,FXbool notify=FALSE);
00198   FXint getIndentFirst() const { return indentFirst; }
00199 
00201   void setIndentLower(FXint ind,FXbool notify=FALSE);
00202   FXint getIndentLower() const { return indentLower; }
00203 
00205   void setIndentUpper(FXint ind,FXbool notify=FALSE);
00206   FXint getIndentUpper() const { return indentUpper; }
00207 
00209   void setNumberTicks(FXint ticks,FXbool notify=FALSE);
00210   FXint getNumberTicks() const { return numberTicks; }
00211 
00213   void setMajorTicks(FXint ticks,FXbool notify=FALSE);
00214   FXint getMajorTicks() const { return majorTicks; }
00215 
00217   void setMediumTicks(FXint ticks,FXbool notify=FALSE);
00218   FXint getMediumTicks() const { return mediumTicks; }
00219 
00221   void setTinyTicks(FXint ticks,FXbool notify=FALSE);
00222   FXint getTinyTicks() const { return tinyTicks; }
00223 
00225   void setPixelPerTick(FXdouble space,FXbool notify=FALSE);
00226   FXdouble getPixelPerTick() const { return pixelPerTick; }
00227 
00229   void setFont(FXFont *fnt,FXbool notify=FALSE);
00230 
00232   FXFont* getFont() const { return font; }
00233 
00235   void setValue(FXint value);
00236 
00238   FXint getValue() const { return arrowPos; }
00239 
00241   void setRulerStyle(FXuint style);
00242 
00244   FXuint getRulerStyle() const;
00245 
00247   void setRulerAlignment(FXuint alignment,FXbool notify=FALSE);
00248 
00250   FXuint getRulerAlignment() const;
00251 
00253   FXColor getTextColor() const { return textColor; }
00254 
00256   void setTextColor(FXColor clr);
00257 
00259   void setHelpText(const FXString& text){ help=text; }
00260 
00262   const FXString& getHelpText() const { return help; }
00263 
00265   void setTipText(const FXString& text){ tip=text; }
00266 
00268   const FXString& getTipText() const { return tip; }
00269 
00271   virtual void save(FXStream& store) const;
00272 
00274   virtual void load(FXStream& store);
00275 
00277   virtual ~FXRuler();
00278   };
00279 
00280 }
00281 
00282 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:24 2009 for TnFOX by doxygen v1.4.7