ubit
ufinder.hpp
1 /************************************************************************
2  *
3  * ufinder.hpp: UFinder element
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 _ufinder_hpp_
18 #define _ufinder_hpp_
19 #include <ubit/ucolor.hpp>
20 #include <ubit/ubackground.hpp>
21 #include <ubit/umenu.hpp>
22 #include <ubit/udoc.hpp>
23 #include <ubit/uicon.hpp>
24 namespace ubit {
25 
26  class UFinderDir;
27  class UFinderHost;
28  class UFinderFullwin;
29  class UFinderControls;
30  class UFinderCom;
31 
32 /* ==================================================== ===== ======= */
36  virtual ~UFinderListener() {}
37  virtual void fileRequest(const UStr& pathname) {}
38  virtual void docLoaded(const UStr& pathname, UDoc*) {}
39  virtual void docShown(const UStr& pathname, UDoc*) {}
40  virtual void dirLoaded(const UStr& pathname) {}
41  virtual void dirShown(const UStr& pathname) {}
42 };
43 
44 /* ==================================================== ===== ======= */
47 class UFinder : public UBox {
48 public:
49  UCLASS(UFinder)
50 
51  struct Options : UElem {
52  friend class UFinder;
53  Options();
54  USize clone_frame_size;
55  UBackground default_background;
56  UColor default_color;
57  bool show_icon_images;
58  };
59 
60  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
61 
62  UFinder(const UStr& pathname = ".");
63  virtual ~UFinder();
64 
65  virtual void open(const UStr& pathname);
67 
68  virtual void openParent();
69  virtual void openEntry();
70  virtual void nextEntry();
71  virtual void previousEntry();
73 
74  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
75 
76  virtual bool browseHosts();
77  virtual UFinderHost* addHost(const UStr& hostname);
78  virtual UFinderHost* addHostCB(const UStr* hostname);
79  virtual void removeHost(UFinderHost*);
80  virtual void addHosts(const std::vector<UStr*>& hostnames);
81  virtual void addHosts(const char* hostnames[]);
82 
83  virtual void createClone(const UStr& hostname);
85 
86  // virtual void compactEvents(bool = true);
87  // compact events to avoid delays.
88 
89  virtual void setTracking(bool);
90  virtual void setTracking(bool doc, bool icons);
92 
93  virtual UFinderListener* getListener();
94  virtual void setListener(UFinderListener*);
101  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
102 
103  Options& getOptions() {return opts;}
105 
106  UDocbox* getDocbox() {return pdocbox;}
107  UIconbox* getIconbox() {return piconbox;}
108 
109  UDocbox* getCurrentBox();
111 
112  UIcon* getSelectedIcon();
114 
115  UDoc* getDoc() {return pdocument;}
117 
118  virtual void zoom(float zoom = 1.);
119  virtual void zoomIn();
120  virtual void zoomOut();
121  virtual void setZoomQuantum(float);
122 
123  UCtlmenu& getContextMenu() {return *ctlmenu;}
125 
126  virtual void openContextMenuIn(UBox&);
127  virtual UCtlmenu& createContextMenu();
128 
129  void showSideBar(bool state);
131 
132  void showAlert(const UStr& msg);
133  void hideAlert();
135 
136  //void showDocGlass(bool state);
137  // shows/hides the document glass.
138  //UBox* getGlass() {return docglass;}
139  //returns the glass box that is on top of the document box.
140 
141  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
142 protected:
143  // documents.
144  void openFBox(UFilebox&);
145  void openMsg(UMessageEvent&);
146  virtual void openImpl(const UStr& path, int path_mode, int path_type);
147  virtual int openFile(const UStr& path, int path_type);
148  virtual int openDir(const UStr& path, int path_type);
149  virtual int openDir(UFinderDir*);
150  virtual void showFile(const UStr& path, UDoc*);
151  virtual void showDir(const UStr& path);
152  virtual void showPreview(UIcon*);
153  virtual void showPreviewRequest(UIcon*);
154  virtual void showIconPreviews();
155 
156  // dirs and icons.
157  virtual void addToHistory(UFinderDir*);
158  virtual void removeFromHistory(UFinderDir*);
159  virtual UFinderDir* findDir(const UStr& path);
160  virtual void showDirInfo(UFinderDir*);
161  virtual void removeIconbox(UFinderDir*, bool upd);
162  virtual void iconSelectCB(UIconbox*);
163  virtual void iconActionCB(UIconbox*);
164  virtual void linkActionCB(UInputEvent&, UDoc*);
165 
166  // hosts and clones.
167  virtual void browseCB(UMessageEvent&);
168  bool isBrowsing() const;
169  virtual void createCloneRequest(UMessageEvent&);
170  virtual UFrame* createCloneFrame(const UStr& title);
171 
172  virtual void initOptbox();
173  void showSelectedIcon();
174  void showDirBox();
175  void showDocBox();
176 
177  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
178 private:
179  friend class UFinderDir;
180  friend class UFinderHost;
181  friend class UFinderCom;
182  static UPix& doc_pix;
183  enum {NoMode, DirMode, DocMode} mode;
184  bool is_tracking, open_in_fullwin;
185  Options opts;
186  UBar toolbar;
187  UBox mainbox, optbox, folderlist, hostlist, filelist;
188  uptr<UBox> optbox_btn, filelist_btn;
189  uptr<UDialog> ask_dialog;
190  uptr<UStr> ask_dialog_msg;
191  UFinderListener* listener;
192  uptr<UAlertbox> alertbox;
193  uptr<UCtlmenu> ctlmenu;
194  UMService *local_ums, *remote_ums;
195 
196  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
197  // current selection
198  uptr<UDoc> pdocument;
199  uptr<UDocbox> pdocbox;
200  uptr<UIconbox> piconbox;
201  //uptr<UBox> docglass;
202  uptr<UFinderDir>last_direntry;
203  UIcon* last_preview_request;
204  UIcon* last_preview;
205  UChildIter previews_current, previews_end;
206  uptr<UTimer> preview_timer;
207  };
208 
209 }
210 #endif
UCtlmenu & getContextMenu()
returns the Contextual menu of the Finder.
Definition: ufinder.hpp:123
Box container.
Definition: ubox.hpp:64
UFrame: toplevel and main window.
Definition: udialogs.hpp:117
file finder.
Definition: ufinder.hpp:47
Widget background.
Definition: ubackground.hpp:30
Definition: ufinder.hpp:51
UBar = horizontal toolbar or status bar.
Definition: uboxes.hpp:58
Icon box.
Definition: uicon.hpp:52
UMService: Ubit Mouse/Message Service.
Definition: umservice.hpp:25
Color attribute of an element or a widget.
Definition: ucolor.hpp:73
Generic Document.
Definition: udoc.hpp:122
lightweight general purpose container.
Definition: uelem.hpp:44
Definition: ufinderImpl.hpp:54
Options & getOptions()
returns the options of the UFinder.
Definition: ufinder.hpp:103
Definition: uhardfont.hpp:31
Base class for UMouseEvent and UKeyEvent Note that this class inherits from class UModifier that defi...
Definition: uevent.hpp:75
Definition: ufinderImpl.hpp:84
Definition: ufilebox.hpp:49
Definition: ufinderImpl.hpp:28
Pixmap Image.
Definition: upix.hpp:31
UFinder Listener.
Definition: ufinder.hpp:35
Widget Size.
Definition: uboxgeom.hpp:228
UDoc * getDoc()
return the document box that is currently shown (if any, null otherwise).
Definition: ufinder.hpp:115
Control menu.
Definition: uctlmenu.hpp:73
document box gadget.
Definition: uboxes.hpp:161
Ubit String.
Definition: ustr.hpp:72
Ubit Message events.
Definition: uevent.hpp:462
UIcon (for UIconbox)
Definition: uicon.hpp:24