ufilebox.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  ufilebox.hpp
00004  *  Ubit Project
00005  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00006  *  (C) 1999-2006 / EricLecolinet / ENST Paris / http://www.enst.fr/~elc/ubit
00007  *
00008  * ***********************************************************************
00009  * COPYRIGHT NOTICE : 
00010  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00011  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00012  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00013  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00014  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00015  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00016  * ***********************************************************************
00017  * ==================================================== [(c)Elc] ======= *
00018  * ==================================================== ======== ======= */
00019 
00020 #ifndef _ufilebox_hpp_
00021 #define _ufilebox_hpp_
00022 #include <ubit/uchoice.hpp>
00023 //pragma ident  "@(#)ufilebox.hpp       ubit:05.05.00"
00024 namespace ubit {
00025 
00026 /* ==================================================== ======== ======= */
00027 /* File chooser.
00028 * A UFilebox can be included into a UDialog or a UMenu as follows:
00029 * examples:
00030 * <pre>
00031 *   class Demo {
00032 *   public:
00033 *     void openFile(UEvent& e) {...}   // the UEvent& parameter is optional
00034 *     ...
00035 *   };
00036 *
00037 *   Demo* d = new Demo();
00038 *
00039 *   // NB: ufilebox(...) is a shortcut for *new UFilebox(...)
00040 *   UBox& fbox = ufilebox( utitle("Open File")
00041 *                          + UOn::action / ucall(this, &Demo::openFile)
00042 *                         );
00043 *   UDialog& fdialog = udialog(fbox)
00044 *   // and/or:
00045 *   UMenu& fmenu = umenu(fbox)
00046 * </pre>
00047 *
00048 * this->openFile() is called when a file is double clicked or when
00049 * the OK button of the filebox is clicked.
00050 *
00051 * @see: UCall for more info on callback methods/functions and their parameters
00052 */
00053 class UFilebox : public UBox {
00054 public:
00055   UBIT_ELEMENT_CLASS(UFilebox, UBox)
00056 
00057   UFilebox(const UArgs& arglist = UArgs::none);
00058   friend UFilebox& ufilebox(const UArgs& arglist = UArgs::none);
00064   virtual ~UFilebox();
00065 
00066   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00067 
00068   const UStr& getDir() const {return *fdir2;}
00070 
00071   const UStr& getName() const {return *fname;}
00073 
00074   const UStr& getPath() const {return *fpath;}
00075   UStr& path() {return *fpath;}
00077 
00078   const UStr& getFilter() const {return *ffilter;}
00080 
00081   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00082 
00083   virtual void setDir(const UStr&);
00085 
00086   virtual void setName(const UStr&);
00087 
00088   virtual void setFilter(const UStr&);
00090 
00091   virtual void showList(bool);
00092   virtual void showHiddenFiles(bool);
00093 
00094   virtual void rescan();
00096 
00097   void setAutoClose(bool stat) {autoclose = stat;}
00098   
00099   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00100 protected:
00101   UStr fspec;
00102   uptr<UStr> fname, fdir2, ffilter, fpath;
00103   UScrollpane* scrollpane;
00104   UBox *viewport, *show_list, *show_hidden_files;
00105   URadioSelect new_sel;
00106   bool autoclose;
00107   
00108   virtual void cancelBehavior(UEvent&);
00109   virtual void okBehavior(UEvent&);
00110   virtual void selectBehavior(UEvent&, const UStr* pathname);
00111 
00112   virtual void setDirImpl(const UStr*);
00113   virtual void changeDirImpl(const UStr*);
00118 };
00119 
00120 }
00121 #endif
00122 /* ==================================================== [TheEnd] ======= */
00123 /* ==================================================== [(c)Elc] ======= */
00124 
00125 

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