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,2005 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.28 2005/01/16 16:06:06 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 }; 00051 00052 00053 class FXFont; 00054 00055 00056 /** 00057 * The ruler widget is placed alongside a document to measure position 00058 * and size of entities within the document, such as margins, paragraph 00059 * indents, and tickmarks. 00060 * The ruler widget sends a SEL_CHANGED when the indentation or margins 00061 * are interactively changed by the user. 00062 */ 00063 class FXAPI FXRuler : public FXFrame { 00064 FXDECLARE(FXRuler) 00065 protected: 00066 FXFont *font; // Font for numbers 00067 FXint documentSize; // Size of document 00068 FXint edgeSpacing; // Edge spacing around document 00069 FXint marginLower; // Lower margin 00070 FXint marginUpper; // Upper margin 00071 FXint indentFirst; // First line paragraph indent 00072 FXint indentLower; // Lower paragraph indent 00073 FXint indentUpper; // Upper paragraph indent 00074 FXdouble pixelPerTick; // Number of pixels per tick increment 00075 FXint numberTicks; // Tick increments between numbers 00076 FXint majorTicks; // Tick increments between major ticks 00077 FXint mediumTicks; // Tick increments between medium ticks 00078 FXint tinyTicks; // Tick increments between tiny ticks 00079 FXint arrowPos; // Arrow position 00080 FXColor textColor; // Color for numbers and ticks 00081 FXint pos; // Scroll position 00082 FXint off; // Offset item was grabbed 00083 FXString tip; // Tooltip text 00084 FXString help; // Help text 00085 FXuchar mode; // Mode widget is in 00086 protected: 00087 FXRuler(); 00088 FXint picked(FXint x,FXint y); 00089 void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y); 00090 void drawRightArrow(FXDCWindow& dc,FXint x,FXint y); 00091 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y); 00092 void drawDownArrow(FXDCWindow& dc,FXint x,FXint y); 00093 void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y); 00094 void drawRightMarker(FXDCWindow& dc,FXint x,FXint y); 00095 void drawUpMarker(FXDCWindow& dc,FXint x,FXint y); 00096 void drawDownMarker(FXDCWindow& dc,FXint x,FXint y); 00097 protected: 00098 enum{ 00099 MOUSE_NONE, // No mouse operation 00100 MOUSE_MARG_LOWER, // Drag lower margin 00101 MOUSE_MARG_UPPER, // Drag upper margin 00102 MOUSE_PARA_FIRST, // Drag first indent 00103 MOUSE_PARA_LOWER, // Drag lower indent 00104 MOUSE_PARA_UPPER // Drag upper indent 00105 }; 00106 private: 00107 FXRuler(const FXRuler&); 00108 FXRuler &operator=(const FXRuler&); 00109 public: 00110 long onPaint(FXObject*,FXSelector,void*); 00111 long onLeftBtnPress(FXObject*,FXSelector,void*); 00112 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00113 long onMotion(FXObject*,FXSelector,void*); 00114 long onCmdSetValue(FXObject*,FXSelector,void*); 00115 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00116 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00117 long onCmdSetHelp(FXObject*,FXSelector,void*); 00118 long onCmdGetHelp(FXObject*,FXSelector,void*); 00119 long onCmdSetTip(FXObject*,FXSelector,void*); 00120 long onCmdGetTip(FXObject*,FXSelector,void*); 00121 long onQueryHelp(FXObject*,FXSelector,void*); 00122 long onQueryTip(FXObject*,FXSelector,void*); 00123 public: 00124 enum{ 00125 ID_ARROW=FXFrame::ID_LAST, 00126 ID_LAST 00127 }; 00128 public: 00129 00130 /// Construct label with given text and icon 00131 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); 00132 00133 /// Create server-side resources 00134 virtual void create(); 00135 00136 /// Detach server-side resources 00137 virtual void detach(); 00138 00139 /// Return default width 00140 virtual FXint getDefaultWidth(); 00141 00142 /// Return default height 00143 virtual FXint getDefaultHeight(); 00144 00145 /// Set the current position 00146 void setPosition(FXint pos); 00147 00148 /// Return the current position 00149 FXint getPosition() const { return pos; } 00150 00151 /// Change/return document size 00152 void setDocumentSize(FXint size,FXbool notify=FALSE); 00153 FXint getDocumentSize() const { return documentSize; } 00154 00155 /// Change/return document edge spacing 00156 void setEdgeSpacing(FXint space,FXbool notify=FALSE); 00157 FXint getEdgeSpacing() const { return edgeSpacing; } 00158 00159 /// Change/return lower document margin 00160 void setMarginLower(FXint mgn,FXbool notify=FALSE); 00161 FXint getMarginLower() const { return marginLower; } 00162 00163 /// Change/return upper document margin 00164 void setMarginUpper(FXint mgn,FXbool notify=FALSE); 00165 FXint getMarginUpper() const { return marginUpper; } 00166 00167 /// Change/return first line indent 00168 void setIndentFirst(FXint ind,FXbool notify=FALSE); 00169 FXint getIndentFirst() const { return indentFirst; } 00170 00171 /// Change/return lower indent 00172 void setIndentLower(FXint ind,FXbool notify=FALSE); 00173 FXint getIndentLower() const { return indentLower; } 00174 00175 /// Change/return upper indent 00176 void setIndentUpper(FXint ind,FXbool notify=FALSE); 00177 FXint getIndentUpper() const { return indentUpper; } 00178 00179 /// Change/return document number placement 00180 void setNumberTicks(FXint ticks,FXbool notify=FALSE); 00181 FXint getNumberTicks() const { return numberTicks; } 00182 00183 /// Change/return document major ticks 00184 void setMajorTicks(FXint ticks,FXbool notify=FALSE); 00185 FXint getMajorTicks() const { return majorTicks; } 00186 00187 /// Change/return document medium ticks 00188 void setMediumTicks(FXint ticks,FXbool notify=FALSE); 00189 FXint getMediumTicks() const { return mediumTicks; } 00190 00191 /// Change/return document tiny ticks 00192 void setTinyTicks(FXint ticks,FXbool notify=FALSE); 00193 FXint getTinyTicks() const { return tinyTicks; } 00194 00195 /// Change/return pixel per tick spacing 00196 void setPixelPerTick(FXdouble space,FXbool notify=FALSE); 00197 FXdouble getPixelPerTick() const { return pixelPerTick; } 00198 00199 /// Set the text font 00200 void setFont(FXFont *fnt); 00201 00202 /// Get the text font 00203 FXFont* getFont() const { return font; } 00204 00205 /// Change slider value 00206 void setValue(FXint value); 00207 00208 /// Return slider value 00209 FXint getValue() const { return arrowPos; } 00210 00211 /// Set ruler style 00212 void setRulerStyle(FXuint style); 00213 00214 /// Get ruler style 00215 FXuint getRulerStyle() const; 00216 00217 /// Get the current text color 00218 FXColor getTextColor() const { return textColor; } 00219 00220 /// Set the current text color 00221 void setTextColor(FXColor clr); 00222 00223 /// Set the status line help text for this label 00224 void setHelpText(const FXString& text); 00225 00226 /// Get the status line help text for this label 00227 const FXString& getHelpText() const { return help; } 00228 00229 /// Set the tool tip message for this label 00230 void setTipText(const FXString& text); 00231 00232 /// Get the tool tip message for this label 00233 const FXString& getTipText() const { return tip; } 00234 00235 /// Save label to a stream 00236 virtual void save(FXStream& store) const; 00237 00238 /// Load label from a stream 00239 virtual void load(FXStream& store); 00240 00241 /// Destructor 00242 virtual ~FXRuler(); 00243 }; 00244 00245 } 00246 00247 #endif
Copyright © 1997-2005 Jeroen van der Zijp |