Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

uappli.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uappli.hpp
00004  *  Ubit Project  [Elc][2003]
00005  *  Author: Eric Lecolinet
00006  *
00007  *  Part of the Ubit Toolkit: A Brick Construction Game Model for Creating GUIs
00008  *
00009  *  (C) 1999-2003 Eric Lecolinet @ ENST Paris
00010  *  WWW: http://www.enst.fr/~elc/ubit   Email: elc@enst.fr (subject: ubit)
00011  *
00012  * ***********************************************************************
00013  * COPYRIGHT NOTICE : 
00014  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE 
00015  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. 
00016  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU 
00017  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION; 
00018  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
00019  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
00020  * ***********************************************************************
00021  *
00022  * ==================================================== [Elc:03] ======= *
00023  * ==================================================== ======== ======= */
00024 
00025 #ifndef _uappli_hpp_
00026 #define _uappli_hpp_
00027 //pragma ident  "@(#)uappli.hpp ubit:03.05.06"
00028 #include <ubit/udisp.hpp>
00029 #include <ubit/ustr.hpp>
00030 #include <ubit/ugroup.hpp>
00031 #include <ubit/uconf.hpp>
00032 
00033 /* ==================================================== ======== ======= */
00070 class UAppli: public UDisp {
00071 public:
00072 
00073   UAppli(UConf& conf);
00074   UAppli(int* argc, char** argv);
00075   UAppli(int& argc, char** argv);
00108   virtual ~UAppli();
00110 
00111   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00112 
00113   const class UConf& getConf() const      {return conf;}
00114   static const class UConf& getDefaults() {return default_appli->conf;}
00119   static class UAppli* getApp();
00129   const char* getCommandName() const;
00130   const char* getCommandPath() const;
00135   class UFrame* getMainFrame() const;
00140   void setTitle(const UStr &title);
00145   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00146   // main loop
00147 
00148   virtual int mainLoop();
00149   virtual int start() {return mainLoop();}
00154   virtual void quitLoop(int status);
00155   static void quit(int status);
00164   virtual void realize();
00174   virtual bool isRealized() const;
00176 
00177   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00178   // Windows
00179 
00180   virtual void add(class UWin*);
00181   virtual void add(class UWin&);
00196   virtual void remove(UWin& child, int remove_mode);
00197   virtual void remove(UWin* child, int remove_mode);
00199 
00200   virtual void updateAll();
00201   virtual void updateAll(UUpdate upmode); 
00203 
00204   class UGroup* getOpenedMenu();
00206 
00207   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00208   // File and socket Input
00209 
00210   static class UInput* openInput(int input_source);
00222   static void closeInput(class UInput*);
00227   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00228   // Timers
00229 
00230   static UTimer* openTimer(u_time delay, int ntimes = 1);
00250   static void closeTimer(class UTimer*);
00255   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00256   // Multiple Displays.
00257 
00258   static class UDisp* openDisp(const UStr& display_name);
00265   static void closeDisp(class UDisp*);
00267 
00268   static class UDisp& getDefaultDisp()  {return *displist[0];}
00269   static class UDisp* getDisp(int disp_id);
00270 
00271   static unsigned int getDispCount();
00272   static const UDispList& getDisps()  {return displist;}
00273 
00274   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00275   // Multiple Event Flows.
00276   // inherited from UDisp
00277 
00278   // class UFlow* openFlow(int flow_id);
00279   // void closeFlow(class UFlow*);
00280   // class UFlow& getDefaultFlow() const {return *flowlist[0];}
00281   // class UFlow* getFlow(int flow_id) const;
00282   // unsigned int getFlowCount() const;
00283   // const UFlowList& getFlows() const {return flowlist;}
00284 
00285   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00286   // connection to an UMS server.
00287 
00288   static class UMSclient* openUMS(const UStr& ums_hostname, int ums_port = 0);
00301   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00302   // variable database
00303 
00304   static const char* getVar(const char *name, bool get_from_shell = true);
00311   static const char* getImaPath();
00315   static const char* setVar(const char *name, const char *value);
00324   static const char* setImaPath(const UStr& value);
00325   static const char* setImaPath(const char* value);
00335   static char *makeImaPath(const char* filename);
00340   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00341   // implementation
00342 
00343 #ifndef NO_DOC
00344   friend class UDisp;
00345   friend class UFlow;
00346   friend class UNatAppli;
00347   friend class UInput;
00348   friend class UTimer;
00349 
00350   virtual void constructs();
00352 
00353   virtual int subLoop();
00355 
00356   void addModalwin(class UWin*);
00357   void removeModalwin(class UWin*);
00358   int  getModalStatus() const  {return modal_status;}
00359   void setModalStatus(int _s)  {modal_status = _s;}
00360 
00361   static void safeDeleteRequest(void*);
00362   static void processSafeDeleteRequests();
00363 
00364   static void deleteNotifyAll(class UView*  deleted_view);
00365   static void deleteNotifyAll(class UGroup* deleted_group);
00366   static void deleteNotifyAll(class UDisp*  deleted_disp);
00369 
00370   void closeRelatedMenus(class UMenu*);
00371 
00372   //class UNatAppli* getNatAppli() const {return natappli;}
00374   
00375 private:  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
00376 
00377   // only one UAppli should be created
00378   static UAppli* default_appli;
00379   
00380   // the display list must be static to avoid seg faults if the UAppli
00381   // is distroyed before the widgets by the client program (nb: this is
00382   // OK as there is only one UAppli)
00383   static UDispList displist;
00384 
00385   static std::vector<void*> safe_delete_list;
00386 
00387   class UFrame* main_frame;                    // the main frame of the appli
00388   static class UGroup *inputs, *timers;        // input and timer callback lists
00389   class UNatAppli* natappli;                   // native appli data
00390   static const char *pixmapPath, *bitmapPath;  // image paths
00391   static struct UAPP_VAR* varDB;               // variable DataBase array
00392   static int varDB_count;                      // ... and its cardinal
00393 
00394   // current modal dialog in the Display
00395   // (null if no modal window currently activated)
00396   UChain modalwin_list;
00397   class UWin* modalwin;
00398 
00399   // value is init. to LOOP_IDLE by UAppli(), then to LOOP_RUN
00400   // by mainLoop() and a value >= LOOP_QUIT quits the mainLoop
00401   enum {LOOP_STOP = -2, LOOP_RUN = -1, LOOP_QUIT = 0};
00402   int main_status;    // status of the event loop of the UAppli
00403   int modal_status;   // status of the inner loop the current modal dialog
00404 #endif
00405 };
00406 
00407 /* ==================================================== [Elc:03] ======= */
00408 /* ==================================================== ======== ======= */
00412 class UInput : public UBrick {
00413 public:
00414   UInput(UAppli&, int source);
00416 
00417   virtual ~UInput();
00418 
00419   void onAction(UCall&);
00421 
00422   void onInput(UCall& c) {onAction(c);}
00424 
00425   virtual void close();
00426   int getSource() const {return source;}
00427 
00428 protected:
00429   virtual bool verifies(const UContext*, const UCtrl*) const {return false;}
00430 
00431 private:
00432   friend class UNatAppli;
00433   UAppli& appli;
00434   int source;
00435 };
00436 
00437 /* ==================================================== [Elc:03] ======= */
00438 /* ==================================================== ======== ======= */
00443 class UTimer : public UBrick {
00444 public:
00445   UTimer(UAppli&, u_time delay, int ntimes);
00447 
00448   virtual ~UTimer();
00449 
00450   void onAction(UCall&);
00452 
00453   void onTimeout(UCall& c) {onAction(c);}
00455 
00456   virtual void close();
00457   virtual void reset(u_time delay, int ntimes);
00458 
00459   u_time getDelay() const {return delay;}
00460   int getTimes() const {return ntimes;}
00461 
00462 protected:
00463   virtual bool verifies(const UContext*, const UCtrl*) const {return false;}
00464 
00465 private:
00466   friend class UAppli;
00467   friend class UNatAppli;
00468   UAppli& appli;
00469   struct timeval* timeout;
00470   u_time delay;
00471   int  ntimes;
00472   bool must_rearm;
00473 };
00474 
00475 #endif
00476 /* ==================================================== [TheEnd] ======= */
00477 /* ==================================================== [Elc:03] ======= */

Generated on Thu May 19 11:39:24 2005 for Ubit[Eric.Lecolinet@enst.fr] by  doxygen 1.4.2