00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef FXGRADIENTBAR_H
00025 #define FXGRADIENTBAR_H
00026
00027 #ifndef FXFRAME_H
00028 #include "FXFrame.h"
00029 #endif
00030
00031
00032 namespace FX {
00033
00034
00035
00037 enum {
00038 GRADIENTBAR_HORIZONTAL = 0,
00039 GRADIENTBAR_VERTICAL = 0x00008000,
00040 GRADIENTBAR_NO_CONTROLS = 0,
00041 GRADIENTBAR_CONTROLS_TOP = 0x00010000,
00042 GRADIENTBAR_CONTROLS_BOTTOM = 0x00020000,
00043 GRADIENTBAR_CONTROLS_LEFT = GRADIENTBAR_CONTROLS_TOP,
00044 GRADIENTBAR_CONTROLS_RIGHT = GRADIENTBAR_CONTROLS_BOTTOM
00045 };
00046
00047
00049 enum {
00050 GRADIENT_BLEND_LINEAR,
00051 GRADIENT_BLEND_POWER,
00052 GRADIENT_BLEND_SINE,
00053 GRADIENT_BLEND_INCREASING,
00054 GRADIENT_BLEND_DECREASING
00055 };
00056
00057
00058
00059
00060 struct FXGradient {
00061 FXdouble lower;
00062 FXdouble middle;
00063 FXdouble upper;
00064 FXColor lowerColor;
00065 FXColor upperColor;
00066 FXuchar blend;
00067 };
00068
00069
00070 class FXImage;
00071
00072
00077 class FXAPI FXGradientBar : public FXFrame {
00078 FXDECLARE(FXGradientBar)
00079 protected:
00080 FXImage *bar;
00081 FXGradient *seg;
00082 FXint nsegs;
00083 FXint sellower;
00084 FXint selupper;
00085 FXint dropped;
00086 FXint current;
00087 FXint anchor;
00088 FXint grip;
00089 FXint where;
00090 FXString tip;
00091 FXString help;
00092 FXColor selectColor;
00093 FXint offset;
00094 protected:
00095 FXGradientBar();
00096 void updatebar();
00097 FXdouble getValue(FXint x,FXint y) const;
00098 FXint getSegmentLowerPos(FXint sg) const;
00099 FXint getSegmentUpperPos(FXint sg) const;
00100 FXint getSegmentMiddlePos(FXint sg) const;
00101 void drawUpArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00102 void drawDnArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00103 void drawRtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00104 void drawLtArrow(FXDCWindow& dc,FXint x,FXint y,FXColor clr);
00105 void drawBottomArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00106 void drawTopArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00107 void drawLeftArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00108 void drawRightArrows(FXDCWindow& dc,FXint x,FXint y,FXint w,FXint h);
00109 static FXdouble blendlinear(FXdouble middle,FXdouble pos);
00110 static FXdouble blendpower(FXdouble middle,FXdouble pos);
00111 static FXdouble blendsine(FXdouble middle,FXdouble pos);
00112 static FXdouble blendincreasing(FXdouble middle,FXdouble pos);
00113 static FXdouble blenddecreasing(FXdouble middle,FXdouble pos);
00114 private:
00115 FXGradientBar(const FXGradientBar&);
00116 FXGradientBar &operator=(const FXGradientBar&);
00117 public:
00118 enum {
00119 GRIP_NONE,
00120 GRIP_LOWER,
00121 GRIP_SEG_LOWER,
00122 GRIP_MIDDLE,
00123 GRIP_SEG_UPPER,
00124 GRIP_UPPER
00125 };
00126 public:
00127 long onPaint(FXObject*,FXSelector,void*);
00128 long onLeftBtnPress(FXObject*,FXSelector,void*);
00129 long onLeftBtnRelease(FXObject*,FXSelector,void*);
00130 long onMotion(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 onCmdSetHelp(FXObject*,FXSelector,void*);
00148 long onCmdGetHelp(FXObject*,FXSelector,void*);
00149 long onCmdSetTip(FXObject*,FXSelector,void*);
00150 long onCmdGetTip(FXObject*,FXSelector,void*);
00151 long onQueryHelp(FXObject*,FXSelector,void*);
00152 long onQueryTip(FXObject*,FXSelector,void*);
00153 public:
00154 enum{
00155 ID_LOWER_COLOR=FXFrame::ID_LAST,
00156 ID_UPPER_COLOR,
00157 ID_BLEND_LINEAR,
00158 ID_BLEND_POWER,
00159 ID_BLEND_SINE,
00160 ID_BLEND_INCREASING,
00161 ID_BLEND_DECREASING,
00162 ID_RECENTER,
00163 ID_SPLIT,
00164 ID_MERGE,
00165 ID_UNIFORM,
00166 ID_LAST
00167 };
00168 public:
00169
00171 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);
00172
00174 virtual void create();
00175
00177 virtual void layout();
00178
00180 virtual FXint getDefaultWidth();
00181
00183 virtual FXint getDefaultHeight();
00184
00189 FXint getSegment(FXint x,FXint y) const;
00190
00196 FXint getGrip(FXint sg,FXint x,FXint y) const;
00197
00199 FXint getNumSegments() const { return nsegs; }
00200
00205 void setGradients(const FXGradient *segments,FXint nsegments);
00206
00212 void getGradients(FXGradient*& segments,FXint& nsegments) const;
00213
00215 void setCurrentSegment(FXint index,FXbool notify=FALSE);
00216
00218 FXint getCurrentSegment() const { return current; }
00219
00221 void setAnchorSegment(FXint index);
00222
00224 FXint getAnchorSegment() const { return anchor; }
00225
00227 FXbool selectSegments(FXint fm,FXint to,FXbool notify=FALSE);
00228
00230 FXbool deselectSegments(FXbool notify);
00231
00233 FXbool isSegmentSelected(FXint s) const;
00234
00236 void setSegmentLowerColor(FXint s,FXColor clr,FXbool notify=FALSE);
00237
00239 void setSegmentUpperColor(FXint s,FXColor clr,FXbool notify=FALSE);
00240
00242 FXColor getSegmentLowerColor(FXint s) const;
00243
00245 FXColor getSegmentUpperColor(FXint s) const;
00246
00248 void moveSegmentLower(FXint sg,FXdouble val,FXbool notify=FALSE);
00249
00251 void moveSegmentMiddle(FXint sg,FXdouble val,FXbool notify=FALSE);
00252
00254 void moveSegmentUpper(FXint sg,FXdouble val,FXbool notify=FALSE);
00255
00257 void moveSegments(FXint sglo,FXint sghi,FXdouble val,FXbool notify=FALSE);
00258
00260 FXdouble getSegmentLower(FXint sg) const;
00261
00263 FXdouble getSegmentMiddle(FXint sg) const;
00264
00266 FXdouble getSegmentUpper(FXint sg) const;
00267
00273 void gradient(FXColor *ramp,FXint nramp);
00274
00280 FXuint getSegmentBlend(FXint s) const;
00281
00283 void splitSegments(FXint sglo,FXint sghi,FXbool notify=FALSE);
00284
00286 void mergeSegments(FXint sglo,FXint sghi,FXbool notify=FALSE);
00287
00289 void uniformSegments(FXint sglo,FXint sghi,FXbool notify=FALSE);
00290
00292 void blendSegments(FXint sglo,FXint sghi,FXuint blend=GRADIENT_BLEND_LINEAR,FXbool notify=FALSE);
00293
00295 FXuint getBarStyle() const;
00296
00298 void setBarStyle(FXuint style);
00299
00301 void setSelectColor(FXColor clr);
00302
00304 FXColor getSelectColor() const { return selectColor; }
00305
00307 void setHelpText(const FXString& text){ help=text; }
00308
00310 const FXString& getHelpText() const { return help; }
00311
00313 void setTipText(const FXString& text){ tip=text; }
00314
00316 const FXString& getTipText() const { return tip; }
00317
00319 virtual void save(FXStream& store) const;
00320
00322 virtual void load(FXStream& store);
00323
00325 virtual ~FXGradientBar();
00326 };
00327
00328
00329 }
00330
00331 #endif