uicon.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  uicon.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
00007 * ***********************************************************************
00008 * COPYRIGHT NOTICE :
00009 * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
00010 * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00011 * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
00012 * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
00013 * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00014 * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00015 * ***********************************************************************
00016 * ==================================================== [(c)Elc] ======= *
00017 * ==================================================== ======== ======= */
00018 
00019 #ifndef _uicon_hpp_
00020 #define _uicon_hpp_
00021 //pragma ident  "@(#)uicon.hpp  ubit:05.05.00"
00022 #include <ubit/udoc.hpp>
00023 namespace ubit {
00024 
00025 /* ==================================================== ======== ======= */
00028 class UIcon : public UItem {
00029 public:
00030   UBIT_ELEMENT_CLASS(UIcon, UItem)
00031 
00032   struct Props : public UBrick {
00033     Props(bool large_icon = true);
00034     Props(const UOrient&,
00035           const UWidth& ima_width, const UHeight& ima_height,
00036           const UWidth& text_width, const UHeight& text_height);
00037     Props(const UIcon::Props&);
00038     Props& operator=(const UIcon::Props&);
00039 
00040     uptr<UOrient> orient;
00041     uptr<UWidth>  ima_width, text_width;
00042     uptr<UHeight> ima_height, text_height;
00043   };
00044 
00045   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00046 
00047   UIcon(const UArgs& = UArgs::none);
00048   UIcon(UIcon::Props*, const UArgs& = UArgs::none);
00055   virtual ~UIcon();
00056 
00057   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00058 
00059   virtual int read(const UStr& name, const UStr& pathname);
00065   virtual void set(const UStr& name, UGroup& content);
00066   virtual void set(const UStr& name, UData& content);
00067   virtual void set(const UStr& name, UFileMode);
00075   virtual void clear();
00076 
00077   UStr& name() {return *pname;}
00078   const UStr& getName() const {return *pname;}
00079 
00080   void setMode(UFileMode);
00081   UFileMode getMode() const {return filemode;}
00082   
00083   class UIma* findIconImage();
00084 
00085   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00086 protected:
00087   uptr<Props> props;
00088   uptr<UBox>  ima_box, text_box;
00089   uptr<UStr>  pname;
00090   uptr<class  UEdit> name_edit;
00091   UFileMode   filemode;
00092   
00093   virtual void constructs(UIcon::Props*);
00094   virtual void selectNameCB(UEvent& e, bool);
00095 };
00096 
00097 /* ==================================================== [Elc:04] ======= */
00098 /* ==================================================== ======== ======= */
00101 class UIconbox : public UDocbox {
00102 public:
00103   UBIT_ELEMENT_CLASS(UIconbox, UDocbox)
00104 
00105   UIconbox(const UArgs& = UArgs::none);
00106   virtual ~UIconbox();
00107 
00108   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00109 
00110   virtual int readDir(const UStr& pathname, int path_type = 0);
00111 
00112   // inherited:
00113   // virtual UBox& titlebar() {return *ptitle_bar;}
00114   // virtual UBox& content()  {return *pcontent;}
00115   // virtual UScrollpane& scrollpane()  {return *pspane;}
00116   // virtual UScale& scale()  {return *pscale;}
00117 
00118   virtual UStr& pathname()  {return *ppathname;}
00119   virtual UStr& title()     {return *ptitle;}
00120   virtual UListbox& icons() {return *picons;}
00121   virtual UChoice& choice() {return picons->choice();}
00122   virtual const UChoice& choice() const {return picons->choice();}
00123 
00124   virtual void addIcon(class UIcon&);
00125   virtual void removeIcon(class UIcon&, bool auto_delete=true);
00126   virtual void removeAllIcons(bool auto_delete = true);
00127   
00128   virtual class UIcon* getSelectedIcon();
00129   virtual class UIcon* getPreviousIcon();
00130   virtual class UIcon* getNextIcon();
00131   virtual class UIcon* getIcon(int) const;
00132 
00133   virtual void selectIcon(UIcon&);
00134   virtual void selectIcon(const UStr& name);
00135   virtual void selectPreviousIcon();
00136   virtual void selectNextIcon();
00137 
00138   virtual void showDirs(bool);
00139   virtual void showParentDir(bool);
00140   virtual void showFiles(bool);
00141   virtual void showSmallIcons(bool);
00142 
00143   virtual void setIconSpacing(UHspacing&, UVspacing&);
00144   virtual void setLargeIconProps(UIcon::Props*);
00145   virtual void setSmallIconProps(UIcon::Props*);
00152   // - - - impl.  - - - - - - - - - - - - - - - - - - - - - - - - - -
00153 
00154   static UStyle* createStyle();
00155 
00156 protected:
00157   friend class UFinder;
00158   static const UFlag DontShowDirs, DontShowDocs;
00159   UFlagdef show_dirs, show_docs;
00160   uptr<UStr>ppathname, ptitle;
00161   uptr<UListbox> picons;
00162   uptr<UIcon::Props> icon_props, small_icon_props, large_icon_props;
00163   uptr<UHspacing> icon_hspacing;
00164   uptr<UVspacing> icon_vspacing;
00165   UFileMode filemode;
00166   UTime filetime;
00167   bool show_parent_dir;
00168 
00169   virtual void okBehavior(UEvent&);  // A REVOIR
00170   virtual void constructs(UIcon::Props*, const UArgs& args);
00171 };
00172 
00173 }
00174 #endif
00175 /* ==================================================== [TheEnd] ======= */
00176 
00177 

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