ubit
uicon.hpp
1 /************************************************************************
2  *
3  * uicon.hpp: Icon widget
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uicon_hpp_
18 #define _uicon_hpp_
19 #include <ubit/udoc.hpp>
20 namespace ubit {
21 
24  class UIcon : public UItem {
25  public:
26  UCLASS(UIcon)
27 
28  UIcon(const UStr& name = "", UArgs content = UArgs::none);
30 
31  virtual ~UIcon();
32  static UStyle* createStyle();
33 
34  virtual int loadImage(const UStr& image_path);
36 
37  const UStr& getName() const {return *pname;}
38 
39  bool isDir() const {return is_dir;}
40  void setDir(bool state) {is_dir = state;}
41 
42  protected:
43  uptr<UBox> ima_box, text_box;
44  uptr<UStr> pname;
45  bool is_dir;
46  };
47 
48 
49  /* ==================================================== ======== ======= */
52  class UIconbox : public UDocbox {
53  public:
54  UCLASS(UIconbox)
55 
57  virtual ~UIconbox();
58  static UStyle* createStyle();
59 
60  virtual int readDir(const UStr& pathname, bool remote_dir = false);
61 
62  // inherited:
63  // virtual UBox& titlebar() {return *ptitle_bar;}
64  // virtual UBox& content() {return *pcontent;}
65  // virtual UScrollpane& scrollpane() {return *pspane;}
66  // virtual UScale& scale() {return *pscale;}
67 
68  virtual UStr& pathname() {return *ppathname;}
69  virtual UStr& title() {return *ptitle;}
70  virtual UListbox& icons() {return *picons;}
71  virtual UChoice& choice();
72  virtual const UChoice& choice() const;
73 
74  virtual void addIcon(class UIcon&);
75  virtual void removeIcon(class UIcon&, bool auto_delete=true);
76  virtual void removeAllIcons(bool auto_delete = true);
77 
78  virtual class UIcon* getSelectedIcon();
79  virtual class UIcon* getPreviousIcon();
80  virtual class UIcon* getNextIcon();
81  virtual class UIcon* getIcon(int) const;
82 
83  virtual void selectIcon(UIcon&);
84  virtual void selectIcon(const UStr& name);
85  virtual void selectPreviousIcon();
86  virtual void selectNextIcon();
87 
88  // - - - impl. - - - - - - - - - - - - - - - - - - - - - - - - - -
89  protected:
90  friend class UFinder;
91  uptr<UStr> ppathname, ptitle;
92  uptr<UListbox> picons;
93  uptr<UHspacing> icon_hspacing;
94  uptr<UVspacing> icon_vspacing;
95  unsigned long filetime;
96  bool show_parent_dir;
97  virtual void okBehavior(UInputEvent&);
98  };
99 
100 }
101 #endif
102 
103 
virtual int loadImage(const UStr &image_path)
load and shows the icon image, returns file loading status.
Definition: uicon.cpp:214
file finder.
Definition: ufinder.hpp:47
Makes the children of a widget (exclusively) selectable.
Definition: uchoice.hpp:30
Item Button widget (a kind of button that is used in UListbox(es)).
Definition: uinteractors.hpp:303
Icon box.
Definition: uicon.hpp:52
List widget: enforces a list layout and makes buttons (and items, checkboxes, etc) contained in this ...
Definition: ulistbox.hpp:117
Argument list (for passing arguments to constructor or add functions).
Definition: uargs.hpp:43
UIcon(const UStr &name="", UArgs content=UArgs::none)
creates a new icon.
Definition: uicon.cpp:180
Definition: uhardfont.hpp:31
Base class for UMouseEvent and UKeyEvent Note that this class inherits from class UModifier that defi...
Definition: uevent.hpp:75
static const UArgs none
the empty arglist.
Definition: uargs.hpp:45
Compiled Object Style.
Definition: ustyle.hpp:44
document box gadget.
Definition: uboxes.hpp:161
Ubit String.
Definition: ustr.hpp:72
UIcon (for UIconbox)
Definition: uicon.hpp:24