ucontrol.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  ucontrol.hpp
00004 *  Ubit Project
00005 *  Author: Eric Lecolinet
00006 *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00007 *  (C) 1999-2006 / Eric Lecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00008 *
00009 * ***********************************************************************
00010 * COPYRIGHT NOTICE :
00011 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00012 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00013 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00014 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00015 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00016 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00017 * ***********************************************************************
00018 * ==================================================== [(c)Elc] ======= *
00019 * ==================================================== ======== ======= */
00020 
00021 #ifndef _ucontrol_hpp_
00022 #define _ucontrol_hpp_
00023 //pragma ident  "@(#)ucontrol.hpp       ubit:05.05.00"
00024 #include <ubit/ubrick.hpp>
00025 #include <ubit/umode.hpp>
00026 #include <ubit/update.hpp>
00027 namespace ubit {
00028 
00035 class UControl: public UBrick { // abstract class
00036 public:
00037   UControl();
00039 
00040   virtual void update(const UUpdate&) = 0;
00042 
00043   virtual void update() {update(UUpdate::layoutAndPaint);}
00045   
00046   virtual void updatePaint() {update(UUpdate::paint);}
00048   
00049   virtual void updateView(UEvent&, UView*, const UUpdate&) = 0;
00054   virtual bool isShown() const;
00063   bool isShowable() const {return (cmodes & UMode::CAN_SHOW) != 0;}
00071   bool isEnabled() const;
00078   virtual void setEnabled(bool state, bool call_callbacks = true);
00084   void enable(bool state = true) {setEnabled(state);} 
00085   void disable() {setEnabled(false);} 
00086 
00087   bool isSelected() const {return (cmodes & UMode::SELECTED) != 0;}
00093   virtual void setSelected(bool state, bool call_callbacks = true);
00099   void select(bool state, bool call_cb = true) {setSelected(state,call_cb);}
00101   
00102   bool isArmed() const;
00103   
00104   bool isArmable() const {return (cmodes & UMode::CAN_ARM) != 0;}
00113   bool isEntered() const;
00114   bool isActionPerformed() const;
00115   bool isDragged() const;
00116   
00117   // - - - Impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00118   
00119   // inherited from UBrick: hasBmode(), getBmodes(), etc.
00120   
00121   UMask getCModes() const {return cmodes;}
00123 
00124   bool hasCMode(UMask modes) const {return (cmodes & modes) != 0;}
00126     
00127   void addCModes(UMask modes) {cmodes |= modes;}
00129   
00130   void removeCModes(UMask modes) {cmodes &= ~modes;}
00132 
00133   short getInterState() const {return istate;}
00135   
00136   void setInterState(short);
00138   
00139   // - - - Impl - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00140 protected:
00141   friend class UMode;
00142   friend class UOn;
00143   friend class UAppli;
00144   friend class UEventFlow;
00145   UMask cmodes;
00146   short istate;
00147   
00148 public:
00149   enum InputType {NORMAL=0, BROWSE=1, TYPE=2};
00150   
00151   virtual void enterBehavior(UEventFlow&, UEvent&, int input_type = 0);
00152   virtual void leaveBehavior(UEventFlow&, UEvent&);
00153   virtual void keyPressBehavior(UEventFlow&, UEvent&);
00154   virtual void keyReleaseBehavior(UEventFlow&, UEvent&);
00155   virtual void armBehavior(UEventFlow&, UEvent&, int input_type = 0);
00156   virtual bool disarmBehavior(UEventFlow&, UEvent&, int input_type = 0);
00157   virtual void actionBehavior(UEventFlow&, UEvent&);
00158   virtual void changeBehavior(UEventFlow&, UEvent&);
00165 };
00166 
00167 }
00168 #endif
00169 /* ==================================================== [TheEnd] ======= */
00170 /* ==================================================== [(c)Elc] ======= */
00171 
00172 

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