00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef FXGRADIENTBAR_H
00022 #define FXGRADIENTBAR_H
00023
00024 #ifndef FXFRAME_H
00025 #include "FXFrame.h"
00026 #endif
00027
00028
00029 namespace FX {
00030
00031
00033 enum {
00034 GRADIENTBAR_HORIZONTAL = 0,
00035 GRADIENTBAR_VERTICAL = 0x00008000,
00036 GRADIENTBAR_NO_CONTROLS = 0,
00037 GRADIENTBAR_CONTROLS_TOP = 0x00010000,
00038 GRADIENTBAR_CONTROLS_BOTTOM = 0x00020000,
00039 GRADIENTBAR_CONTROLS_LEFT = GRADIENTBAR_CONTROLS_TOP,
00040 GRADIENTBAR_CONTROLS_RIGHT = GRADIENTBAR_CONTROLS_BOTTOM
00041 };
00042
00043
00045 enum {
00046 GRADIENT_BLEND_LINEAR,
00047 GRADIENT_BLEND_POWER,
00048 GRADIENT_BLEND_SINE,
00049 GRADIENT_BLEND_INCREASING,
00050 GRADIENT_BLEND_DECREASING
00051 };
00052
00053
00054
00055 struct FXGradient {
00056 FXdouble lower;
00057 FXdouble middle;
00058 FXdouble upper;
00059 FXColor lowerColor;
00060 FXColor upperColor;
00061 FXuchar blend;
00062 };
00063
00064
00065 class FXImage;
00066
00067
00072 class FXAPI FXGradientBar : public FXFrame {
00073 FXDECLARE(FXGradientBar)
00074 protected:
00075 FXImage *bar;
00076 FXGradient *seg;
00077 FXint nsegs;
00078 FXint sellower;
00079 FXint selupper;
00080 FXint dropped;
00081 FXint current;
00082 FXint anchor;
00083 FXint grip;
00084 FXint where;
00085 FXint barsize;
00086 FXint controlsize;
00087 FXColor selectColor;
00088 FXString tip;
00089 FXString help;
00090 FXint offset;
00091 protected:
00092 FXGradientBar();
00093 void updatebar();
00094 FXdouble getValue(FXint x,FXint y) const;
00095 FXint getSegmentLowerPos(FXint sg) const;
00096 FXint getSegmentUpperPos(FXint sg) const;
00097 FXint getSegmentMiddlePos(FXint sg) const;
00098 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00099 void drawDnArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00100 void drawRtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00101 void drawLtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00102 void drawBottomArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00103 void drawTopArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00104 void drawLeftArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00105 void drawRightArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00106 static FXdouble blendlinear(FXdouble middle,FXdouble pos);
00107 static FXdouble blendpower(FXdouble middle,FXdouble pos);
00108 static FXdouble blendsine(FXdouble middle,FXdouble pos);
00109 static FXdouble blendincreasing(FXdouble middle,FXdouble pos);
00110 static FXdouble blenddecreasing(FXdouble middle,FXdouble pos);
00111 static const FXGradient defaultGradient[3];
00112 private:
00113 FXGradientBar(const FXGradientBar&);
00114 FXGradientBar &operator=(const FXGradientBar&);
00115 public:
00116 enum {
00117 GRIP_NONE,
00118 GRIP_LOWER,
00119 GRIP_SEG_LOWER,
00120 GRIP_MIDDLE,
00121 GRIP_SEG_UPPER,
00122 GRIP_UPPER
00123 };
00124 public:
00125 long onPaint(FXObject*,FXSelector,void*);
00126 long onMotion(FXObject*,FXSelector,void*);
00127 long onLeftBtnPress(FXObject*,FXSelector,void*);
00128 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00129 long onRightBtnPress(FXObject*,FXSelector,void*);
00130 long onRightBtnRelease(FXObject*,FXSelector,void*);
00131 long onDNDEnter(FXObject*,FXSelector,void*);
00132 long onDNDLeave(FXObject*,FXSelector,void*);
00133 long onDNDMotion(FXObject*,FXSelector,void*);
00134 long onDNDDrop(FXObject*,FXSelector,void*);
00135 long onCmdBlending(FXObject*,FXSelector,void*);
00136 long onUpdBlending(FXObject*,FXSelector,void*);
00137 long onUpdSegColor(FXObject*,FXSelector,void*);
00138 long onCmdSegColor(FXObject*,FXSelector,void*);
00139 long onUpdRecenter(FXObject*,FXSelector,void*);
00140 long onCmdRecenter(FXObject*,FXSelector,void*);
00141 long onUpdSplit(FXObject*,FXSelector,void*);
00142 long onCmdSplit(FXObject*,FXSelector,void*);
00143 long onUpdMerge(FXObject*,FXSelector,void*);
00144 long onCmdMerge(FXObject*,FXSelector,void*);
00145 long onUpdUniform(FXObject*,FXSelector,void*);
00146 long onCmdUniform(FXObject*,FXSelector,void*);
00147 long onCmdReset(FXObject*,FXSelector,void*);
00148 long onCmdSetHelp(FXObject*,FXSelector,void*);
00149 long onCmdGetHelp(FXObject*,FXSelector,void*);
00150 long onCmdSetTip(FXObject*,FXSelector,void*);
00151 long onCmdGetTip(FXObject*,FXSelector,void*);
00152 long onQueryHelp(FXObject*,FXSelector,void*);
00153 long onQueryTip(FXObject*,FXSelector,void*);
00154 public:
00155 enum{
00156 ID_LOWER_COLOR=FXFrame::ID_LAST,
00157 ID_UPPER_COLOR,
00158 ID_BLEND_LINEAR,
00159 ID_BLEND_POWER,
00160 ID_BLEND_SINE,
00161 ID_BLEND_INCREASING,
00162 ID_BLEND_DECREASING,
00163 ID_RECENTER,
00164 ID_SPLIT,
00165 ID_MERGE,
00166 ID_UNIFORM,
00167 ID_RESET,
00168 ID_LAST
00169 };
00170 public:
00171
00173 FXGradientBar(FXComposite* p,FXObject* tgt=NULL,FXSelector sel=0,FXuint opts=FRAME_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);
00174
00176 virtual void create();
00177
00179 virtual void layout();
00180
00182 virtual FXint getDefaultWidth();
00183
00185 virtual FXint getDefaultHeight();
00186
00191 FXint getSegment(FXint x,FXint y) const;
00192
00198 FXint getGrip(FXint sg,FXint x,FXint y) const;
00199
00201 FXint getNumSegments() const { return nsegs; }
00202
00206 void resetGradients();
00207
00212 void setGradients(const FXGradient *segments,FXint nsegments);
00213
00219 void getGradients(FXGradient*& segments,FXint& nsegments) const;
00220
00222 void setCurrentSegment(FXint index,FXbool notify=false);
00223
00225 FXint getCurrentSegment() const { return current; }
00226
00228 void setAnchorSegment(FXint index);
00229
00231 FXint getAnchorSegment() const { return anchor; }
00232
00234 FXbool selectSegments(FXint fm,FXint to,FXbool notify=false);
00235
00237 FXbool deselectSegments(FXbool notify=false);
00238
00240 FXbool isSegmentSelected(FXint s) const;
00241
00243 void setSegmentLowerColor(FXint s,FXColor clr,FXbool notify=false);
00244
00246 void setSegmentUpperColor(FXint s,FXColor clr,FXbool notify=false);
00247
00249 FXColor getSegmentLowerColor(FXint s) const;
00250
00252 FXColor getSegmentUpperColor(FXint s) const;
00253
00255 void moveSegmentLower(FXint sg,FXdouble val,FXbool notify=false);
00256
00258 void moveSegmentMiddle(FXint sg,FXdouble val,FXbool notify=false);
00259
00261 void moveSegmentUpper(FXint sg,FXdouble val,FXbool notify=false);
00262
00264 void moveSegments(FXint sglo,FXint sghi,FXdouble val,FXbool notify=false);
00265
00267 FXdouble getSegmentLower(FXint sg) const;
00268
00270 FXdouble getSegmentMiddle(FXint sg) const;
00271
00273 FXdouble getSegmentUpper(FXint sg) const;
00274
00280 void gradient(FXColor *ramp,FXint nramp);
00281
00287 FXuint getSegmentBlend(FXint s) const;
00288
00290 void splitSegments(FXint sglo,FXint sghi,FXbool notify=false);
00291
00293 void mergeSegments(FXint sglo,FXint sghi,FXbool notify=false);
00294
00296 void uniformSegments(FXint sglo,FXint sghi,FXbool notify=false);
00297
00299 void blendSegments(FXint sglo,FXint sghi,FXuint blend=GRADIENT_BLEND_LINEAR,FXbool notify=false);
00300
00302 void setControlSize(FXint cs);
00303
00305 FXint getControlSize() const { return controlsize; }
00306
00308 void setBarSize(FXint bs);
00309
00311 FXint getBarSize() const { return barsize; }
00312
00314 FXuint getBarStyle() const;
00315
00317 void setBarStyle(FXuint style);
00318
00320 void setSelectColor(FXColor clr);
00321
00323 FXColor getSelectColor() const { return selectColor; }
00324
00326 void setHelpText(const FXString& text){ help=text; }
00327
00329 const FXString& getHelpText() const { return help; }
00330
00332 void setTipText(const FXString& text){ tip=text; }
00333
00335 const FXString& getTipText() const { return tip; }
00336
00338 virtual void save(FXStream& store) const;
00339
00341 virtual void load(FXStream& store);
00342
00344 virtual ~FXGradientBar();
00345 };
00346
00347
00348 }
00349
00350 #endif