uappli.hpp

00001 /* ==================================================== ======== ======= *
00002  *
00003  *  uappli.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 _uappli_hpp_
00022 #define _uappli_hpp_
00023 //pragma ident  "@(#)uappli.hpp ubit:05.05.00"
00024 #include <ubit/udisp.hpp>
00025 #include <ubit/uconf.hpp>
00026 #include <ubit/uerror.hpp>
00027 namespace ubit {
00028 
00029 /* ==================================================== ======== ======= */
00032 typedef std::vector<UEventFlow*> UFlowList;
00033 typedef std::vector<UDisp*> UDispList;
00034 
00035 /* ==================================================== ======== ======= */
00081 class UAppli: public UDisp {
00082 public:
00083   static UConf conf;
00093   UAppli(int& argc, char** argv,
00094          UOption* command_line_options = null, 
00095          const char* configuration_file = null);
00118   virtual ~UAppli();
00119 
00120   static bool usingGL() {return conf.using_gl;}
00122   
00123   static bool using3D() {return conf.using_3d;}
00125   
00126   static UAppli& getApp() throw (UFatalError);
00132   static UFrame* getMainFrame();
00137   static const UStr& getName();
00139 
00140   static const char* getVersion();
00142 
00143   
00144   static void setTitle(const UStr& title);
00149   static const UStr& getImaPath();
00150   static void setImaPath(const UStr& pathname);
00156   static USelection* getSelection(int ID = 0);
00164   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00165   // main loop
00166 
00167   static int start();
00168   static int mainLoop() {return start();}
00173   static void quit(int status = 0);
00178   static bool isRunning();
00179   //< returns true if the main loop is running.
00180   
00181   static UTime getTime();
00183   
00184   static void setMotionLag(UTime app_lag, UTime nat_lag);
00190   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00191   // Windows
00192 
00193   virtual void add(UWin&);
00210   virtual void remove(UWin& child, bool auto_delete);
00215   virtual void updateAll(const UUpdate& upatemode = UUpdate::layoutAndPaint); 
00220   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00221   // Errors
00222   
00223   static UErrorLog log;
00233   static void error(const char* location, const char* format, ...);
00234   static void warning(const char* location, const char* format, ...);
00235   static void fatalError(const char* location, const char* format, ...) throw (UFatalError);
00245   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00246   // Styles and Classes.  
00247   
00248   static UStyleSheet& getStyleSheet();
00250 
00251   static const UStyle& getDefaultStyle();
00253 
00254   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00255   // postponing and timeouts
00256   
00257   static void postpone(UCall& callback);
00267   static void onTimeout(UTime msec_delay, int ntimes, UCall& callback);
00280   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00281   // Ubit messages.
00282   
00283   static void onMessage(const UStr& port_name, UCall& callback);
00289   static UMessagePort& getMessagePort(const UStr& name);
00290   static UMessagePort* findMessagePort(const UStr& name);
00292 
00293   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00294   // Multiple Displays
00295 
00296   static const UDispList& getDispList();
00297   //< returns the list of Displays that are connected with this UAppli.
00298 
00299   static UDisp* getDisp(int ID);
00300   //< returns the display with this ID (null if not found).
00301 
00302   static UDisp* openDisp(const UStr& display);
00314   static void closeDisp(UDisp*);
00316 
00317   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00318   // Multiple Event Flows.
00319 
00320   static const UFlowList& getFlowList();
00322   
00323   static UEventFlow* getFlow(int ID);
00333   // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
00334   // implementation
00335 
00336   UNatAppli* getNatAppli() const;
00338   
00339   UGroup* getOpenedMenu();
00341   
00342   static bool hasTelePointers();
00344 
00345   static bool isTerminated();
00347   
00348   virtual bool isRealized() const;
00350 
00351   virtual void realize();
00353 
00354 #ifndef NO_DOC
00355   friend class UEventFlow;  
00356 
00357   static void internalError(const char* location, const char* format, ...);
00358                     
00359   virtual UConf& initConf(int& argc, char** argv, UOption*, const char* confile);
00361 
00362   virtual void constructs();
00364 
00365   static void deleteNotify(UView*  deleted_view);
00366   static void deleteNotify(UGroup* deleted_group);
00367   static void deleteNotify(UDisp*  deleted_disp);
00369   
00370   void addModalwin(UWin*);
00371   void removeModalwin(UWin*);
00373   
00374   int startSubLoop();
00375   void quitSubLoop(int status);
00377 
00378   static class UAppliImpl& impl;
00379 #endif
00380 };
00381 
00382 }
00383 #endif
00384 /* ==================================================== [TheEnd] ======= */
00385 /* ==================================================== [(c)Elc] ======= */

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