ufinder.hpp

00001 /* ==================================================== ======== ======= *
00002 *
00003 *  ufinder.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 _ufinder_hpp_
00022 #define _ufinder_hpp_
00023 //pragma ident  "@(#)ufinder.hpp        ubit:05.05.00"
00024 #include <ubit/ubox.hpp>
00025 #include <ubit/umenu.hpp>
00026 #include <ubit/udoc.hpp>
00027 #include <ubit/uicon.hpp>
00028 namespace ubit {
00029 
00030  class UFinderDir;
00031  class UFinderHost;
00032  class UFinderFullwin;
00033  class UFinderControls;
00034  class UFinderCom;
00035 
00036 /* ==================================================== ===== ======= */
00039 struct UFinderListener {
00040   virtual ~UFinderListener() {}
00041   virtual void fileRequest(const UStr& pathname) {}
00042   virtual void docLoaded(const UStr& pathname, UDoc*) {}
00043   virtual void docShown(const UStr& pathname, UDoc*) {}
00044   virtual void dirLoaded(const UStr& pathname) {}
00045   virtual void dirShown(const UStr& pathname) {}
00046 };
00047 
00048 /* ==================================================== ===== ======= */
00051 class UFinder : public UBox {
00052 public:
00053   UBIT_ELEMENT_CLASS(UFinder, UBox)
00054 
00055   struct Options : UGroup {
00056     friend class UFinder;
00057     Options();
00058     UWidth        clone_frame_width;
00059     UHeight       clone_frame_height;
00060     UBackground   default_background;
00061     UColor        default_color;
00062     UWidth        controls_width;
00063     UHeight       controls_folder_height;
00064     bool          show_icon_images;
00065   };
00066 
00067   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00068 
00069   UFinder(const UStr& pathname = ".");
00070   virtual ~UFinder();
00071   
00072   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00073   
00074   virtual void open(const UStr& pathname);
00076 
00077   virtual void openParent();
00078   virtual void openEntry();  
00079   virtual void nextEntry();
00080   virtual void previousEntry();
00082 
00083   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00084 
00085   virtual bool browseHosts();
00086   virtual UFinderHost* addHost(const UStr& hostname, int pos = -1);
00087   virtual UFinderHost* addHostCB(const UStr* hostname, int pos = -1);
00088   virtual void removeHost(UFinderHost*);
00089   virtual void addHosts(const std::vector<UStr*>& hostnames);
00090   virtual void addHosts(const char* hostnames[]);
00091 
00092   virtual void createClone(const UStr& hostname);
00094 
00095   // virtual void compactEvents(bool = true);
00096   // compact events to avoid delays.
00097 
00098   virtual void setTracking(bool);
00099   virtual void setTracking(bool doc, bool icons);
00101 
00102   virtual UFinderListener* getListener();
00103   virtual void setListener(UFinderListener*);
00110   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00111 
00112   Options& getOptions() {return opts;}
00114   
00115   UDocbox*     getCurrentBox();
00120   UIconbox*    getIconbox()   {return selected_iconbox;}
00121   UIcon*       getSelectedIcon();
00123 
00124   UDocbox*     getDocbox()    {return &docpane;}
00125   UDoc*        getDoc()       {return &document;}
00127 
00128   UBox*        getGlass()  {return &docglass;}
00130 
00131   virtual void zoom(float zoom = 1.);
00132   virtual void zoomIn();
00133   virtual void zoomOut();
00134   virtual void setZoomQuantum(float);
00135     
00136   UCtlmenu& getContextMenu() {return *ctlmenu;}
00138   
00139   virtual void openContextMenuIn(UBox&);
00140   virtual UCtlmenu& createContextMenu();
00141 
00142   void showDocGlass(bool state);
00144 
00145   void showSideBar(bool state);
00147 
00148   void showAlert(const UStr& msg);
00149   void hideAlert();
00151   
00152   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00153 protected:
00154 
00155   // documents.
00156   void openFBox(UFilebox&);
00157   void openMsg(UMessageEvent&);
00158   virtual void openImpl(const UStr& path, int path_mode, int path_type);
00159   virtual int openFile(const UStr& path, int path_type);
00160   virtual int openDir(const UStr& path, int path_type);
00161   virtual int openDir(UFinderDir*);
00162   virtual void showFile(const UStr& path, UDoc*);
00163   virtual void showDir(const UStr& path);
00164   virtual void showPreview(UIcon*);
00165   virtual void showPreviewRequest(UIcon*);
00166   virtual void showIconPreviews();  
00167   
00168   // dirs and icons.
00169   virtual void addToHistory(UFinderDir*);
00170   virtual void removeFromHistory(UFinderDir*);
00171   virtual UFinderDir* findDir(const UStr& path);
00172   virtual void showDirInfo(UFinderDir*);
00173   virtual void removeIconbox(UFinderDir*, bool upd);
00174   virtual void iconSelectCB(UIconbox*);
00175   virtual void iconActionCB(UIconbox*);
00176   virtual void elementAction(UEvent&, UDoc*);
00177 
00178   // hosts and clones.
00179   virtual void browseCB(UMessageEvent&);
00180   bool isBrowsing() const;
00181   virtual void createCloneRequest(UMessageEvent&);
00182   virtual UFrame* createCloneFrame(const UStr& title);
00183   
00184   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00185 
00186 private:
00187   static UPix& doc_pix;
00188   enum {NoMode, DirMode, DocMode} mode;
00189   bool is_tracking, open_in_fullwin; //is_compactevents
00190   Options opts;
00191   UVbox main_panel;
00192   UDialog ask_dialog;
00193   UStr ask_dialog_msg;
00194   UFlagdef title_location;
00195   uptr<UDoc> document;
00196   uptr<UBox> docglass;
00197   uptr<UDocbox> docpane;
00198   uptr<UBox> iconbox_panel;
00199   UFinderListener* listener;
00200   uptr<UFinderControls> ctrls;
00201   uptr<UAlertbox> alertbox;
00202   uptr<UCtlmenu>  ctlmenu;
00203   UMService *local_ums, *remote_ums;
00204   
00205   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00206   // current selection
00207   uptr<UIconbox>  selected_iconbox;
00208   uptr<UFinderDir>last_direntry;
00209   UIcon* last_preview_request;
00210   UIcon* last_preview;
00211   UChildIter previews_current, previews_end;
00212   uptr<UTimer> preview_timer;
00213 
00214   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00215   // friends
00216   friend class UFinderDir;
00217   friend class UFinderHost;
00218   friend class UFinderFullwin;
00219   friend class UFinderControls;
00220   friend class UFinderCom;
00221 };
00222 
00223 }
00224 #endif
00225 /* ==================================================== [TheEnd] ======= */
00226 /* ==================================================== [(c)Elc] ======= */

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