![]() |
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 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.12 2002/09/30 13:06:56 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. 00059 */ 00060 class FXAPI FXRuler : public FXFrame { 00061 FXDECLARE(FXRuler) 00062 protected: 00063 FXFont *font; // Font for numbers 00064 FXColor textColor; // Color for numbers and ticks 00065 FXint lowerMargin; // Lower margin 00066 FXint upperMargin; // Upper margin 00067 FXint firstPara; // First line paragraph indent 00068 FXint lowerPara; // Lower paragraph indent 00069 FXint upperPara; // Upper paragraph indent 00070 FXint docSpace; // Empty space around document 00071 FXint docSize; // Size of document 00072 FXint contentSize; // Size of content 00073 FXint pos; // Arrow position 00074 FXString tip; // Tooltip text 00075 FXString help; // Help text 00076 protected: 00077 FXRuler(); 00078 void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y); 00079 void drawRightArrow(FXDCWindow& dc,FXint x,FXint y); 00080 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y); 00081 void drawDownArrow(FXDCWindow& dc,FXint x,FXint y); 00082 void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y); 00083 void drawRightMarker(FXDCWindow& dc,FXint x,FXint y); 00084 void drawUpMarker(FXDCWindow& dc,FXint x,FXint y); 00085 void drawDownMarker(FXDCWindow& dc,FXint x,FXint y); 00086 private: 00087 FXRuler(const FXRuler&); 00088 FXRuler &operator=(const FXRuler&); 00089 public: 00090 long onPaint(FXObject*,FXSelector,void*); 00091 long onLeftBtnPress(FXObject*,FXSelector,void*); 00092 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00093 long onMotion(FXObject*,FXSelector,void*); 00094 long onQueryHelp(FXObject*,FXSelector,void*); 00095 long onQueryTip(FXObject*,FXSelector,void*); 00096 long onCmdSetValue(FXObject*,FXSelector,void*); 00097 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00098 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00099 public: 00100 enum { 00101 ID_ARROW=FXFrame::ID_LAST, 00102 ID_LAST 00103 }; 00104 public: 00105 00106 /// Construct label with given text and icon 00107 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); 00108 00109 /// Create server-side resources 00110 virtual void create(); 00111 00112 /// Detach server-side resources 00113 virtual void detach(); 00114 00115 /// Return default width 00116 virtual FXint getDefaultWidth(); 00117 00118 /// Return default height 00119 virtual FXint getDefaultHeight(); 00120 00121 /// Set the text font 00122 void setFont(FXFont *fnt); 00123 00124 /// Get the text font 00125 FXFont* getFont() const { return font; } 00126 00127 /// Change slider value 00128 void setValue(FXint value); 00129 00130 /// Return slider value 00131 FXint getValue() const { return pos; } 00132 00133 /// Set ruler style 00134 void setRulerStyle(FXuint style); 00135 00136 /// Get ruler style 00137 FXuint getRulerStyle() const; 00138 00139 /// Get the current text color 00140 FXColor getTextColor() const { return textColor; } 00141 00142 /// Set the current text color 00143 void setTextColor(FXColor clr); 00144 00145 /// Set the status line help text for this label 00146 void setHelpText(const FXString& text); 00147 00148 /// Get the status line help text for this label 00149 const FXString& getHelpText() const { return help; } 00150 00151 /// Set the tool tip message for this label 00152 void setTipText(const FXString& text); 00153 00154 /// Get the tool tip message for this label 00155 const FXString& getTipText() const { return tip; } 00156 00157 /// Save label to a stream 00158 virtual void save(FXStream& store) const; 00159 00160 /// Load label from a stream 00161 virtual void load(FXStream& store); 00162 00163 /// Destructor 00164 virtual ~FXRuler(); 00165 }; 00166 00167 } 00168 00169 #endif