Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members

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 
00034 /// Ruler options
00035 enum {
00036   RULER_NORMAL        = 0,                                      /// Default appearance (default)
00037   RULER_HORIZONTAL    = 0,                                      /// Ruler is horizontal (default)
00038   RULER_VERTICAL      = 0x00008000,                             /// Ruler is vertical
00039   RULER_TICKS_OFF     = 0,                                      /// Tick marks off (default)
00040   RULER_TICKS_TOP     = 0x00010000,                             /// Ticks on the top (if horizontal)
00041   RULER_TICKS_BOTTOM  = 0x00020000,                             /// Ticks on the bottom (if horizontal)
00042   RULER_TICKS_LEFT    = RULER_TICKS_TOP,                        /// Ticks on the left (if vertical)
00043   RULER_TICKS_RIGHT   = RULER_TICKS_BOTTOM,                     /// Ticks on the right (if vertical)
00044   RULER_TICKS_CENTER  = RULER_TICKS_TOP|RULER_TICKS_BOTTOM,     /// Tickmarks centered
00045   RULER_NUMBERS       = 0x00040000,                             /// Show numbers
00046   RULER_ARROW         = 0x00080000,                             /// Draw small arrow for cursor position
00047   RULER_MARKERS       =  0x00100000,                            /// Draw markers for indentation settings
00048   RULER_METRIC        = 0,                                      /// Metric subdivision (default)
00049   RULER_ENGLISH       = 0x00200000,                             /// English subdivision
00050   RULER_MARGIN_ADJUST = 0x00400000,                             /// Allow margin adjustment
00051   RULER_ALIGN_CENTER  = 0,                                      /// Center document horizontally
00052   RULER_ALIGN_LEFT    = 0x00800000,                             /// Align document to the left
00053   RULER_ALIGN_RIGHT   = 0x01000000,                             /// Align document to the right
00054   RULER_ALIGN_TOP     = RULER_ALIGN_LEFT,                       /// Align document to the top
00055   RULER_ALIGN_BOTTOM  = RULER_ALIGN_RIGHT,                      /// Align document to the bottom
00056   RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT,     /// Stretch document to fit horizontally
00057   RULER_ALIGN_NORMAL  = RULER_ALIGN_CENTER                      /// Normally, document is centered both ways
00058   };
00059 
00060 
00061 class FXFont;
00062 
00063 
00064 /**
00065 * The ruler widget is placed alongside a document to measure position
00066 * and size of entities within the document, such as margins, paragraph
00067 * indents, and tickmarks.
00068 * The ruler widget sends a SEL_CHANGED when the indentation or margins
00069 * are interactively changed by the user.
00070 * If the document size exceeds the available space, it is possible to
00071 * scroll the document using setPosition().  When the document size is
00072 * less than the available space, the alignment options can be used to
00073 * center, left-adjust, or right-adjust the document.
00074 * Finally, a special option exists to stretch the document to the
00075 * available space, that is to say, the document will always be fitten
00076 * with given left and right edges substracted from the available space.
00077 */
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 
00146   /// Construct label with given text and icon
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 
00149   /// Perform layout
00150   virtual void layout();
00151 
00152   /// Create server-side resources
00153   virtual void create();
00154 
00155   /// Detach server-side resources
00156   virtual void detach();
00157 
00158   /// Return default width
00159   virtual FXint getDefaultWidth();
00160 
00161   /// Return default height
00162   virtual FXint getDefaultHeight();
00163 
00164   /// Set the current position
00165   void setPosition(FXint pos,FXbool notify=FALSE);
00166 
00167   /// Return the current position
00168   FXint getPosition() const { return pos; }
00169 
00170   /// Change/return content size
00171   void setContentSize(FXint size,FXbool notify=FALSE);
00172   FXint getContentSize() const;
00173 
00174   /// Get lower edge of document
00175   FXint getDocumentLower() const;
00176 
00177   /// Get upper edge of document
00178   FXint getDocumentUpper() const;
00179 
00180   /// Change/return document size
00181   void setDocumentSize(FXint size,FXbool notify=FALSE);
00182   FXint getDocumentSize() const { return documentSize; }
00183 
00184   /// Change/return document edge spacing
00185   void setEdgeSpacing(FXint space,FXbool notify=FALSE);
00186   FXint getEdgeSpacing() const { return edgeSpacing; }
00187 
00188   /// Change/return lower document margin
00189   void setMarginLower(FXint mgn,FXbool notify=FALSE);
00190   FXint getMarginLower() const { return marginLower; }
00191 
00192   /// Change/return upper document margin
00193   void setMarginUpper(FXint mgn,FXbool notify=FALSE);
00194   FXint getMarginUpper() const { return marginUpper; }
00195 
00196   /// Change/return first line indent
00197   void setIndentFirst(FXint ind,FXbool notify=FALSE);
00198   FXint getIndentFirst() const { return indentFirst; }
00199 
00200   /// Change/return lower indent
00201   void setIndentLower(FXint ind,FXbool notify=FALSE);
00202   FXint getIndentLower() const { return indentLower; }
00203 
00204   /// Change/return upper indent
00205   void setIndentUpper(FXint ind,FXbool notify=FALSE);
00206   FXint getIndentUpper() const { return indentUpper; }
00207 
00208   /// Change/return document number placement
00209   void setNumberTicks(FXint ticks,FXbool notify=FALSE);
00210   FXint getNumberTicks() const { return numberTicks; }
00211 
00212   /// Change/return document major ticks
00213   void setMajorTicks(FXint ticks,FXbool notify=FALSE);
00214   FXint getMajorTicks() const { return majorTicks; }
00215 
00216   /// Change/return document medium ticks
00217   void setMediumTicks(FXint ticks,FXbool notify=FALSE);
00218   FXint getMediumTicks() const { return mediumTicks; }
00219 
00220   /// Change/return document tiny ticks
00221   void setTinyTicks(FXint ticks,FXbool notify=FALSE);
00222   FXint getTinyTicks() const { return tinyTicks; }
00223 
00224   /// Change/return pixel per tick spacing
00225   void setPixelPerTick(FXdouble space,FXbool notify=FALSE);
00226   FXdouble getPixelPerTick() const { return pixelPerTick; }
00227 
00228   /// Set the text font
00229   void setFont(FXFont *fnt,FXbool notify=FALSE);
00230 
00231   /// Get the text font
00232   FXFont* getFont() const { return font; }
00233 
00234   /// Change arrow value, relative to document position
00235   void setValue(FXint value);
00236 
00237   /// Return arrow value in document
00238   FXint getValue() const { return arrowPos; }
00239 
00240   /// Set ruler style
00241   void setRulerStyle(FXuint style);
00242 
00243   /// Get ruler style
00244   FXuint getRulerStyle() const;
00245 
00246   /// Set ruler alignment
00247   void setRulerAlignment(FXuint alignment,FXbool notify=FALSE);
00248 
00249   /// Get ruler alignment
00250   FXuint getRulerAlignment() const;
00251 
00252   /// Get the current text color
00253   FXColor getTextColor() const { return textColor; }
00254 
00255   /// Set the current text color
00256   void setTextColor(FXColor clr);
00257 
00258   /// Set the status line help text for the ruler
00259   void setHelpText(const FXString& text){ help=text; }
00260 
00261   /// Get the status line help text for the ruler
00262   const FXString& getHelpText() const { return help; }
00263 
00264   /// Set the tool tip message for the ruler
00265   void setTipText(const FXString& text){ tip=text; }
00266 
00267   /// Get the tool tip message for the ruler
00268   const FXString& getTipText() const { return tip; }
00269 
00270   /// Save label to a stream
00271   virtual void save(FXStream& store) const;
00272 
00273   /// Load label from a stream
00274   virtual void load(FXStream& store);
00275 
00276   /// Destructor
00277   virtual ~FXRuler();
00278   };
00279 
00280 }
00281 
00282 #endif

Copyright © 1997-2005 Jeroen van der Zijp