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

FXRuler.h

00001 /******************************************************************************** 00002 * * 00003 * R u l e r W i d g e t * 00004 * * 00005 ********************************************************************************* 00006 * Copyright (C) 2002,2004 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.19 2004/02/08 17:17:34 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 arrowPos; // Arrow position 00074 FXdouble pixelPerTick; // Number of pixels between ticks 00075 FXint majorTicks; // Interval between major ticks 00076 FXint mediumTicks; // Interval between medium ticks 00077 FXint tinyTicks; // Interval between tiny ticks 00078 FXint shift; // Shift amount 00079 FXString tip; // Tooltip text 00080 FXString help; // Help text 00081 protected: 00082 FXRuler(); 00083 void drawLeftArrow(FXDCWindow& dc,FXint x,FXint y); 00084 void drawRightArrow(FXDCWindow& dc,FXint x,FXint y); 00085 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y); 00086 void drawDownArrow(FXDCWindow& dc,FXint x,FXint y); 00087 void drawLeftMarker(FXDCWindow& dc,FXint x,FXint y); 00088 void drawRightMarker(FXDCWindow& dc,FXint x,FXint y); 00089 void drawUpMarker(FXDCWindow& dc,FXint x,FXint y); 00090 void drawDownMarker(FXDCWindow& dc,FXint x,FXint y); 00091 // void drawHzTicks(FXDCWindow& dc 00092 private: 00093 FXRuler(const FXRuler&); 00094 FXRuler &operator=(const FXRuler&); 00095 public: 00096 long onPaint(FXObject*,FXSelector,void*); 00097 long onLeftBtnPress(FXObject*,FXSelector,void*); 00098 long onLeftBtnRelease(FXObject*,FXSelector,void*); 00099 long onMotion(FXObject*,FXSelector,void*); 00100 long onCmdSetValue(FXObject*,FXSelector,void*); 00101 long onCmdSetIntValue(FXObject*,FXSelector,void*); 00102 long onCmdGetIntValue(FXObject*,FXSelector,void*); 00103 long onCmdSetHelp(FXObject*,FXSelector,void*); 00104 long onCmdGetHelp(FXObject*,FXSelector,void*); 00105 long onCmdSetTip(FXObject*,FXSelector,void*); 00106 long onCmdGetTip(FXObject*,FXSelector,void*); 00107 long onQueryHelp(FXObject*,FXSelector,void*); 00108 long onQueryTip(FXObject*,FXSelector,void*); 00109 public: 00110 enum { 00111 ID_ARROW=FXFrame::ID_LAST, 00112 ID_LAST 00113 }; 00114 public: 00115 00116 /// Construct label with given text and icon 00117 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); 00118 00119 /// Create server-side resources 00120 virtual void create(); 00121 00122 /// Detach server-side resources 00123 virtual void detach(); 00124 00125 /// Return default width 00126 virtual FXint getDefaultWidth(); 00127 00128 /// Return default height 00129 virtual FXint getDefaultHeight(); 00130 00131 /// Set the text font 00132 void setFont(FXFont *fnt); 00133 00134 /// Get the text font 00135 FXFont* getFont() const { return font; } 00136 00137 /// Change slider value 00138 void setValue(FXint value); 00139 00140 /// Return slider value 00141 FXint getValue() const { return arrowPos; } 00142 00143 /// Set ruler style 00144 void setRulerStyle(FXuint style); 00145 00146 /// Get ruler style 00147 FXuint getRulerStyle() const; 00148 00149 /// Get the current text color 00150 FXColor getTextColor() const { return textColor; } 00151 00152 /// Set the current text color 00153 void setTextColor(FXColor clr); 00154 00155 /// Set the status line help text for this label 00156 void setHelpText(const FXString& text); 00157 00158 /// Get the status line help text for this label 00159 FXString getHelpText() const { return help; } 00160 00161 /// Set the tool tip message for this label 00162 void setTipText(const FXString& text); 00163 00164 /// Get the tool tip message for this label 00165 FXString getTipText() const { return tip; } 00166 00167 /// Save label to a stream 00168 virtual void save(FXStream& store) const; 00169 00170 /// Load label from a stream 00171 virtual void load(FXStream& store); 00172 00173 /// Destructor 00174 virtual ~FXRuler(); 00175 }; 00176 00177 } 00178 00179 #endif

Copyright © 1997-2004 Jeroen van der Zijp