uslider.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uslider.hpp
00004 *  Ubit Project
00005 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006 *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007 *
00008 * ***********************************************************************
00009 * COPYRIGHT NOTICE :
00010 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00011 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00012 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00013 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00014 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016 * ***********************************************************************
00017 * ==================================================== [(c)Elc] ======= *
00018 * ==================================================== ======== ======= */
00019 
00020 #ifndef _uslider_hpp_
00021 #define _uslider_hpp_
00022 //pragma ident "@(#)uslider.hpp         ubit:05.05.00"
00023 #include <ubit/unumber.hpp>
00024 #include <ubit/ubox.hpp>
00025 #include <ubit/uboxGeom.hpp>
00026 #include <ubit/ustyle.hpp>
00027 namespace ubit {
00028 
00029 /* ==================================================== ======== ======= */
00030   
00031 struct USliderStyle : public UStyle {
00032   USliderStyle();
00033   const UStyle& getStyle(UContext* ctx) const;
00034   // default is hstyle
00035   UStyle vstyle;
00036 };
00037   
00038 /* ==================================================== ===== ======= */
00050 class USlider: public UBox {
00051 public:
00052   UBIT_ELEMENT_CLASS(USlider, UBox)
00053 
00054   USlider(const UArgs& = UArgs::none);
00060   USlider(UFloat& value, const UArgs& = UArgs::none);
00068   friend USlider& uslider(const UArgs& a = UArgs::none);
00070   
00071   friend USlider& uslider(UFloat& value, const UArgs& a = UArgs::none);
00073   
00074   friend USlider& uhslider(const UArgs& a = UArgs::none);
00076   
00077   friend USlider& uvslider(const UArgs& a = UArgs::none);
00079 
00080    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00081     
00082   bool isVertical() const;
00083   bool isHorizontal() const;
00084 
00085   float getValue() const {return *pvalue;}
00087 
00088   USlider& setValue(float val) {*pvalue = val; return *this;}
00094   UFloat& value() {return *pvalue;}
00101   // - - - impl.  - - - - - - - - - - - - - - - - - - - - - - - - - - -
00102 
00103   static UStyle* createStyle() {return createSliderStyle();}
00104   static USliderStyle* createSliderStyle() {return new USliderStyle;}
00105     
00106   virtual UBox* createKnob();
00108   
00109   virtual UBox* createRail();
00111 
00112 protected:
00113   uptr<UFloat> pvalue;        // corresponding value (percent)
00114   uptr<UBox> prail, pknob;
00115   uptr<UPos> pknob_pos;
00116   uptr<UPosChooser> pknob_chooser;
00117 
00118   void constructs();
00119   virtual void gotoPos(UMouseEvent&);
00120   virtual void actionCB(UEvent&);
00121   virtual void changeCB(UEvent&);
00122 };
00123 
00124 }
00125 #endif
00126 /* ==================================================== [TheEnd] ======= */
00127 /* ==================================================== [(c)Elc] ======= */
00128 
00129 
00130 

Generated on Mon Jan 29 00:20:40 2007 for Ubit by  doxygen 1.4.7