uscrollbar.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uscrollbar.cpp
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 _uscrollbar_hpp_
00021 #define _uscrollbar_hpp_
00022 //pragma ident "@(#)uscrollbar.hpp              ubit:05.05.00"
00023 #include <ubit/ubox.hpp>
00024 #include <ubit/uboxLayout.hpp>
00025 #include <ubit/uboxGeom.hpp>
00026 #include <ubit/ucolor.hpp>
00027 #include <ubit/ustyle.hpp>
00028 #include <ubit/uview.hpp>
00029 namespace ubit {
00030 
00031 /* ==================================================== ===== ======= */
00036 class UScrollbar: public UBox {
00037 public:
00038   UBIT_ELEMENT_CLASS(UScrollbar, UBox)
00039 
00040   UScrollbar(const UArgs& = UArgs::none);
00046   UScrollbar(UFloat& value, const UArgs& = UArgs::none);
00054   friend UScrollbar& uscrollbar(const UArgs& a = UArgs::none);
00056 
00057   friend UScrollbar& uscrollbar(UFloat& value, const UArgs& a = UArgs::none);
00059   
00060   friend UScrollbar& uhscrollbar(const UArgs& a = UArgs::none);
00062 
00063   friend UScrollbar& uvscrollbar(const UArgs& a = UArgs::none);
00065 
00066   virtual ~UScrollbar();
00067   
00068   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00069   
00070   bool isVertical() const;
00071   bool isHorizontal() const;
00072 
00073   UFloat& value() {return *pvalue;}
00074   virtual float getValue() const;
00076 
00077   virtual void setValue(float percent);
00082   virtual int getUnitIncrement() const;
00083   virtual int getBlockIncrement() const;
00085 
00086   virtual void setUnitIncrement(int);
00087   virtual void setBlockIncrement(int);
00089 
00090   virtual void setTracking(bool);
00091   virtual bool isTracking() const;
00093 
00094   virtual void setTransparent(bool state);
00095   virtual bool isTransparent() const;
00097   
00098   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00099   // implementation
00100 
00101   static  UStyle* createStyle();
00102 
00103   virtual UBox* getKnob()         {return pknob;}
00104   virtual UBox* getRail()         {return prail;}
00105   virtual UBox* getLessScroller() {return pless_btn;}
00106   virtual UBox* getMoreScroller() {return pmore_btn;}
00108 
00109   virtual UBox* createKnob(bool vertical);
00110   virtual UBox* createRail(bool vertical);
00111   virtual UBox* createLessScroller(bool vertical);
00112   virtual UBox* createMoreScroller(bool vertical);
00113   /* fonctions that create the knob, the rail and the 2 scrollers.
00114    * can be redefined by subclasses to use other widgets
00115    */
00116 
00117   virtual void setPane(UScrollpane*);
00118   UScrollpane* getPane() {return ppane;}
00120 
00121   virtual void setValueImpl(float percent, bool update_pane);
00123   
00124   virtual void pressScroller(int dir);
00126    
00127 private:
00128   friend class UScrollbarView;
00129   friend class UScrollpane;
00130   uptr<UFloat> pvalue;          // scrollbar value (percentage)
00131   uptr<UScrollpane> ppane;      // the pane controlled by this scrollbar
00132   uptr<UBox> pless_btn, pmore_btn, pknob, prail;
00133   UPos knob_pos;                // current position of the knob
00134   int unit_increment, block_increment;
00135   int delta_mouse;
00136   bool press_rail_goto_pos;     // dont scroll but goes to pos is trus
00137   bool is_transparent, show_rail, tracking_mode; //enter_feedback, drag_feedback
00138   
00139   void constructs();
00140   //nb: inutile que contructs soit virtuel car appele par constructeur!
00141 
00142   virtual void pressKnob(UMouseEvent&);
00143   virtual void releaseKnob(UMouseEvent&);
00144   virtual void dragKnob(UMouseEvent&);
00145   virtual void pressRail(UMouseEvent&);
00146   virtual void releaseRail(UMouseEvent&);
00147   virtual float getPercent(UMouseEvent&, UView* knob_view, 
00148                            UView* rail_view, int delta_mouse);
00149   virtual float getIncrementPercent(int increment);
00150 };
00151 
00152 /* ==================================================== ===== ======= */
00157 class UScrollbarView : public UView {
00158 public:
00159   static  UViewStyle style;  // renderer
00160   virtual UViewStyle* getViewStyle() {return &style;}
00161 
00162   UScrollbarView(UChild*, UView* parview, UHardWinImpl*);
00163   static UView* createView(UChild*, UView* parview, UHardWinImpl*);
00164 
00165   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00166 
00167 #ifndef NO_DOC
00168   friend class UScrollbar;
00169   virtual void doUpdate(UContext&, URegion r, URegion clip, UViewUpdate&);
00170 #endif
00171 };
00172 }
00173 #endif
00174 /* ==================================================== [TheEnd] ======= */
00175 /* ==================================================== [(c)Elc] ======= */
00176 
00177 

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