1 /******************************************************************************** 2 * * 3 * C h a r t B a s e W i d g e t * 4 * * 5 ********************************************************************************* 6 * Copyright (C) 2003,2021 by Jeroen van der Zijp. All Rights Reserved. * 7 ********************************************************************************* 8 * This library is free software; you can redistribute it and/or modify * 9 * it under the terms of the GNU Lesser General Public License as published by * 10 * the Free Software Foundation; either version 3 of the License, or * 11 * (at your option) any later version. * 12 * * 13 * This library is distributed in the hope that it will be useful, * 14 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 16 * GNU Lesser General Public License for more details. * 17 * * 18 * You should have received a copy of the GNU Lesser General Public License * 19 * along with this program. If not, see <http://www.gnu.org/licenses/> * 20 ********************************************************************************/ 21 #ifndef FXCHART_H 22 #define FXCHART_H 23 24 25 namespace FXCHART { 26 27 28 class FXAxis; 29 30 /// Chart caption options 31 enum { 32 CAPTION_NONE = 0, /// No caption 33 CAPTION_ABOVE = 0x00001000, /// Caption above chart 34 CAPTION_BELOW = 0x00002000, /// Caption below chart 35 CAPTION_LEFT = 0x00004000, /// Caption left of chart 36 CAPTION_RIGHT = 0x00008000, /// Caption right of chart 37 CAPTION_SHOWN = 0x00010000 /// Show caption 38 }; 39 40 41 /// Base class for the various chart widgets 42 class FXCHARTAPI FXChart : public FXComposite { 43 FXDECLARE(FXChart) 44 protected: 45 FXString caption; // Caption over plot 46 FXFont *captionfont; // Caption font 47 FXColor captioncolor; // Caption color 48 FXint captionoffset; // Caption offset 49 FXImage *chart; // Chart image 50 FillStyle backstyle; // Plot background fill style 51 FXint margintop; // Margins top 52 FXint marginbottom; // Margin bottom 53 FXint marginleft; // Margin left 54 FXint marginright; // Margin right 55 FXString tip; // Tooltip value 56 FXString help; // Help value 57 protected: 58 FXChart(); 59 virtual void updateChart(); 60 virtual void drawSelf(FXDC& dc) const; 61 private: 62 FXChart(const FXChart&); 63 FXChart &operator=(const FXChart&); 64 public: 65 long onPaint(FXObject*,FXSelector,void*); 66 long onQueryHelp(FXObject*,FXSelector,void*); 67 long onQueryTip(FXObject*,FXSelector,void*); 68 long onClipboardLost(FXObject*,FXSelector,void*); 69 long onClipboardRequest(FXObject*,FXSelector,void*); 70 public: 71 static FXDragType bmpType; 72 static FXDragType gifType; 73 static FXDragType jpgType; 74 static FXDragType pngType; 75 static FXDragType tifType; 76 static FXDragType csvType; 77 public: 78 79 /// Construct chart widget 80 FXChart(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=CAPTION_ABOVE|CAPTION_SHOWN,FXint x=0,FXint y=0,FXint w=0,FXint h=0,FXint pl=4,FXint pr=4,FXint pt=4,FXint pb=4); 81 82 /// Create server-side resources 83 virtual void create(); 84 85 /// Detach server-side resources 86 virtual void detach(); 87 88 /// Perform layout 89 virtual void layout(); 90 91 /// Change caption 92 void setCaption(const FXString& cap); 93 94 /// Return caption getCaption()95 const FXString& getCaption() const { return caption; } 96 97 /// Set fill style 98 void setBackStyle(const FillStyle& bs); 99 100 /// Get fill style getBackStyle()101 const FillStyle& getBackStyle() const { return backstyle; } 102 103 /// Change caption font 104 void setCaptionFont(FXFont* font); 105 106 /// Get caption font getCaptionFont()107 FXFont* getCaptionFont() const { return captionfont; } 108 109 /// Change caption color 110 void setCaptionColor(FXColor clr); 111 112 /// Get caption color getCaptionColor()113 FXColor getCaptionColor() const { return captioncolor; } 114 115 /// Change caption style 116 void setCaptionStyle(FXuint sty); 117 118 /// Get caption style 119 FXuint getCaptionStyle() const; 120 121 /// Change top margin 122 void setMarginTop(FXint pt); 123 124 /// Return top margin getMarginTop()125 FXint getMarginTop() const { return margintop; } 126 127 /// Change bottom margin 128 void setMarginBottom(FXint pb); 129 130 /// Return bottom margin getMarginBottom()131 FXint getMarginBottom() const { return marginbottom; } 132 133 /// Change left margin 134 void setMarginLeft(FXint pl); 135 136 /// Return left margin getMarginLeft()137 FXint getMarginLeft() const { return marginleft; } 138 139 /// Change right margin 140 void setMarginRight(FXint pr); 141 142 /// Return right margin getMarginRight()143 FXint getMarginRight() const { return marginright; } 144 145 /// Change caption offset 146 void setCaptionOffset(FXint off); 147 148 /// Get caption offset getCaptionOffset()149 FXint getCaptionOffset() const { return captionoffset; } 150 151 /// Set status line help text for this chart 152 void setHelpText(const FXString& text); 153 154 /// Get status line help text for this chart getHelpText()155 FXString getHelpText() const { return help; } 156 157 /// Set tool tip message for this chart 158 void setTipText(const FXString& text); 159 160 /// Get tool tip message for this chart getTipText()161 FXString getTipText() const { return tip; } 162 163 /// Save chart to a stream 164 virtual void save(FXStream& store) const; 165 166 /// Load chart from a stream 167 virtual void load(FXStream& store); 168 169 /// Destructor 170 virtual ~FXChart(); 171 }; 172 173 } 174 175 #endif 176