![]() |
Main Page Class Hierarchy Alphabetical List Compound List File List Compound Members
![]() |
00001 /******************************************************************************** 00002 * * 00003 * R u l e r W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002,2009 by Jeroen van der Zijp. All Rights Reserved. * 00007 ********************************************************************************* 00008 * This library is free software; you can redistribute it and/or modify * 00009 * it under the terms of the GNU Lesser General Public License as published by * 00010 * the Free Software Foundation; either version 3 of the License, or * 00011 * (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 * 00016 * GNU Lesser General Public License for more details. * 00017 * * 00018 * You should have received a copy of the GNU Lesser General Public License * 00019 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00020 ********************************************************************************* 00021 * $Id: FXRuler.h,v 1.42 2009/01/06 13:07:27 fox Exp $ * 00022 ********************************************************************************/ 00023 #ifndef FXRULER_H 00024 #define FXRULER_H 00025 00026 #ifndef FXFRAME_H 00027 #include "FXFrame.h" 00028 #endif 00029 00030 namespace FX { 00031 00032 00033 /// Ruler options 00034 enum { 00035 RULER_NORMAL = 0, /// Default appearance (default) 00036 RULER_HORIZONTAL = 0, /// Ruler is horizontal (default) 00037 RULER_VERTICAL = 0x00008000, /// Ruler is vertical 00038 RULER_TICKS_OFF = 0, /// Tick marks off (default) 00039 RULER_TICKS_TOP = 0x00010000, /// Ticks on the top (if horizontal) 00040 RULER_TICKS_BOTTOM = 0x00020000, /// Ticks on the bottom (if horizontal) 00041 RULER_TICKS_LEFT = RULER_TICKS_TOP, /// Ticks on the left (if vertical) 00042 RULER_TICKS_RIGHT = RULER_TICKS_BOTTOM, /// Ticks on the right (if vertical) 00043 RULER_TICKS_CENTER = RULER_TICKS_TOP|RULER_TICKS_BOTTOM, /// Tickmarks centered 00044 RULER_NUMBERS = 0x00040000, /// Show numbers 00045 RULER_ARROW = 0x00080000, /// Draw small arrow for cursor position 00046 RULER_MARKERS = 0x00100000, /// Draw markers for indentation settings 00047 RULER_METRIC = 0, /// Metric subdivision (default) 00048 RULER_ENGLISH = 0x00200000, /// English subdivision 00049 RULER_MARGIN_ADJUST = 0x00400000, /// Allow margin adjustment 00050 RULER_ALIGN_CENTER = 0, /// Center document horizontally 00051 RULER_ALIGN_LEFT = 0x00800000, /// Align document to the left 00052 RULER_ALIGN_RIGHT = 0x01000000, /// Align document to the right 00053 RULER_ALIGN_TOP = RULER_ALIGN_LEFT, /// Align document to the top 00054 RULER_ALIGN_BOTTOM = RULER_ALIGN_RIGHT, /// Align document to the bottom 00055 RULER_ALIGN_STRETCH = RULER_ALIGN_LEFT|RULER_ALIGN_RIGHT, /// Stretch document to fit horizontally 00056 RULER_ALIGN_NORMAL = RULER_ALIGN_CENTER /// Normally, document is centered both ways 00057 }; 00058 00059 00060 class FXFont; 00061 00062 00063 /** 00064 * The ruler widget is placed alongside a document to measure position 00065 * and size of entities within the document, such as margins, paragraph 00066 * indents, and tickmarks. 00067 * The ruler widget sends a SEL_CHANGED when the indentation or margins 00068 * are interactively changed by the user. 00069 * If the document size exceeds the available space, it is possible to 00070 * scroll the document using setPosition(). When the document size is 00071 * less than the available space, the alignment options can be used to 00072 * center, left-adjust, or right-adjust the document. 00073 * Finally, a special option exists to stretch the document to the 00074 * available space, that is to say, the document will always be fitten 00075 * with given left and right edges substracted from the available space. 00076 */ 00077 class FXAPI FXRuler : public FXFrame { 00078 FXDECLARE(FXRuler) 00079 protected: 00080 FXFont *font; // Font for numbers 00081 FXint documentSize; // Size of document 00082 FXint edgeSpacing; // Edge spacing around document 00083 FXint marginLower; // Lower margin 00084 FXint marginUpper; // Upper margin 00085 FXint indentFirst; // First line paragraph indent 00086 FXint indentLower; // Lower paragraph indent 00087 FXint indentUpper; // Upper paragraph indent 00088 FXdouble pixelPerTick; // Number of pixels per tick increment 00089 FXint numberTicks; // Tick increments between numbers 00090 FXint majorTicks; // Tick increments between major ticks 00091 FXint mediumTicks; // Tick increments between medium ticks 00092 FXint tinyTicks; // Tick increments between tiny ticks 00093 FXint arrowPos; // Arrow position 00094 FXColor textColor; // Color for numbers and ticks 00095 FXint shift; // Left edge of content 00096 FXint pos; // Scroll position 00097 FXint off; // Offset item was grabbed 00098 FXString tip; // Tooltip text 00099 FXString help; // Help text 00100 FXuchar mode; // Mode widget is in 00101 protected: 00102 FXRuler(); 00103 FXint picked(FXint x,FXint y); 00104 void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y); 00105 void drawRightArrow(FXDCWindow& dc,FXint x,FXint y); 00106 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y); 00107 void drawDownArrow(FXDCWindow& dc,FXint x,FXint y); 00108 void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y); 00109 void drawRightMarker(FXDCWindow& dc,FXint x,FXint y); 00110 void drawUpMarker(FXDCWindow& dc,FXint x,FXint y); 00111 void drawDownMarker(FXDCWindow& dc,FXint x,FXint y); 00112 protected: 00113 enum{ 00114 MOUSE_NONE, // No mouse operation 00115 MOUSE_MARG_LOWER, // Drag lower margin 00116 MOUSE_MARG_UPPER, // Drag upper margin 00117 MOUSE_PARA_FIRST, // Drag first indent 00118 MOUSE_PARA_LOWER, // Drag lower indent 00119 MOUSE_PARA_UPPER // Drag upper indent 00120 }; 00121 private: 00122 FXRuler(const FXRuler&); 00123 FXRuler &operator=(const FXRuler&); 00124 public: 00125 long onPaint(FXObject*,FXSelector,void*); 00126 long onLeftBtnPress(FXObject*,FXSelector,void*); 00127 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00128 long onMotion(FXObject*,FXSelector,void*); 00129 long onCmdSetValue(FXObject*,FXSelector,void*); 00130 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00131 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00132 long onCmdSetHelp(FXObject*,FXSelector,void*); 00133 long onCmdGetHelp(FXObject*,FXSelector,void*); 00134 long onCmdSetTip(FXObject*,FXSelector,void*); 00135 long onCmdGetTip(FXObject*,FXSelector,void*); 00136 long onQueryHelp(FXObject*,FXSelector,void*); 00137 long onQueryTip(FXObject*,FXSelector,void*); 00138 public: 00139 enum{ 00140 ID_ARROW=FXFrame::ID_LAST, 00141 ID_LAST 00142 }; 00143 public: 00144 00145 /// Construct label with given text and icon 00146 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); 00147 00148 /// Perform layout 00149 virtual void layout(); 00150 00151 /// Create server-side resources 00152 virtual void create(); 00153 00154 /// Detach server-side resources 00155 virtual void detach(); 00156 00157 /// Return default width 00158 virtual FXint getDefaultWidth(); 00159 00160 /// Return default height 00161 virtual FXint getDefaultHeight(); 00162 00163 /// Set the current position 00164 void setPosition(FXint pos,FXbool notify=false); 00165 00166 /// Return the current position 00167 FXint getPosition() const { return pos; } 00168 00169 /// Change/return content size 00170 void setContentSize(FXint size,FXbool notify=false); 00171 FXint getContentSize() const; 00172 00173 /// Get lower edge of document 00174 FXint getDocumentLower() const; 00175 00176 /// Get upper edge of document 00177 FXint getDocumentUpper() const; 00178 00179 /// Change/return document size 00180 void setDocumentSize(FXint size,FXbool notify=false); 00181 FXint getDocumentSize() const { return documentSize; } 00182 00183 /// Change/return document edge spacing 00184 void setEdgeSpacing(FXint space,FXbool notify=false); 00185 FXint getEdgeSpacing() const { return edgeSpacing; } 00186 00187 /// Change/return lower document margin 00188 void setMarginLower(FXint mgn,FXbool notify=false); 00189 FXint getMarginLower() const { return marginLower; } 00190 00191 /// Change/return upper document margin 00192 void setMarginUpper(FXint mgn,FXbool notify=false); 00193 FXint getMarginUpper() const { return marginUpper; } 00194 00195 /// Change/return first line indent 00196 void setIndentFirst(FXint ind,FXbool notify=false); 00197 FXint getIndentFirst() const { return indentFirst; } 00198 00199 /// Change/return lower indent 00200 void setIndentLower(FXint ind,FXbool notify=false); 00201 FXint getIndentLower() const { return indentLower; } 00202 00203 /// Change/return upper indent 00204 void setIndentUpper(FXint ind,FXbool notify=false); 00205 FXint getIndentUpper() const { return indentUpper; } 00206 00207 /// Change/return document number placement 00208 void setNumberTicks(FXint ticks,FXbool notify=false); 00209 FXint getNumberTicks() const { return numberTicks; } 00210 00211 /// Change/return document major ticks 00212 void setMajorTicks(FXint ticks,FXbool notify=false); 00213 FXint getMajorTicks() const { return majorTicks; } 00214 00215 /// Change/return document medium ticks 00216 void setMediumTicks(FXint ticks,FXbool notify=false); 00217 FXint getMediumTicks() const { return mediumTicks; } 00218 00219 /// Change/return document tiny ticks 00220 void setTinyTicks(FXint ticks,FXbool notify=false); 00221 FXint getTinyTicks() const { return tinyTicks; } 00222 00223 /// Change/return pixel per tick spacing 00224 void setPixelPerTick(FXdouble space,FXbool notify=false); 00225 FXdouble getPixelPerTick() const { return pixelPerTick; } 00226 00227 /// Set the text font 00228 void setFont(FXFont *fnt,FXbool notify=false); 00229 00230 /// Get the text font 00231 FXFont* getFont() const { return font; } 00232 00233 /// Change arrow value, relative to document position 00234 void setValue(FXint value); 00235 00236 /// Return arrow value in document 00237 FXint getValue() const { return arrowPos; } 00238 00239 /// Set ruler style 00240 void setRulerStyle(FXuint style); 00241 00242 /// Get ruler style 00243 FXuint getRulerStyle() const; 00244 00245 /// Set ruler alignment 00246 void setRulerAlignment(FXuint alignment,FXbool notify=false); 00247 00248 /// Get ruler alignment 00249 FXuint getRulerAlignment() const; 00250 00251 /// Get the current text color 00252 FXColor getTextColor() const { return textColor; } 00253 00254 /// Set the current text color 00255 void setTextColor(FXColor clr); 00256 00257 /// Set the status line help text for the ruler 00258 void setHelpText(const FXString& text){ help=text; } 00259 00260 /// Get the status line help text for the ruler 00261 const FXString& getHelpText() const { return help; } 00262 00263 /// Set the tool tip message for the ruler 00264 void setTipText(const FXString& text){ tip=text; } 00265 00266 /// Get the tool tip message for the ruler 00267 const FXString& getTipText() const { return tip; } 00268 00269 /// Save label to a stream 00270 virtual void save(FXStream& store) const; 00271 00272 /// Load label from a stream 00273 virtual void load(FXStream& store); 00274 00275 /// Destructor 00276 virtual ~FXRuler(); 00277 }; 00278 00279 } 00280 00281 #endif
![]() |