00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef _uappli_hpp_
00026 #define _uappli_hpp_
00027
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
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
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
00209
00210 static class UInput* openInput(int input_source);
00222 static void closeInput(class UInput*);
00227
00228
00229
00230 static UTimer* openTimer(u_time delay, int ntimes = 1);
00250 static void closeTimer(class UTimer*);
00255
00256
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
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288 static class UMSclient* openUMS(const UStr& ums_hostname, int ums_port = 0);
00301
00302
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
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
00374
00375 private:
00376
00377
00378 static UAppli* default_appli;
00379
00380
00381
00382
00383 static UDispList displist;
00384
00385 static std::vector<void*> safe_delete_list;
00386
00387 class UFrame* main_frame;
00388 static class UGroup *inputs, *timers;
00389 class UNatAppli* natappli;
00390 static const char *pixmapPath, *bitmapPath;
00391 static struct UAPP_VAR* varDB;
00392 static int varDB_count;
00393
00394
00395
00396 UChain modalwin_list;
00397 class UWin* modalwin;
00398
00399
00400
00401 enum {LOOP_STOP = -2, LOOP_RUN = -1, LOOP_QUIT = 0};
00402 int main_status;
00403 int modal_status;
00404 #endif
00405 };
00406
00407
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
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
00477