ubit
uappliImpl.hpp
1 /* ==================================================== ======== ======= *
2  *
3  * uappliImpl.hpp
4  * Ubit GUI Toolkit - Version 6
5  * (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
6  *
7  * ***********************************************************************
8  * COPYRIGHT NOTICE :
9  * THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
10  * IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
11  * YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
12  * GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
13  * EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
14  * SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
15  * ***********************************************************************/
16 
17 #ifndef _uappliImpl_hpp_
18 #define _uappliImpl_hpp_ 1
19 #include <vector>
20 #include <sys/time.h> // fd_set
21 #include <ubit/uappli.hpp>
22 #include <ubit/uappliImpl.hpp>
23 #include <ubit/uclassImpl.hpp>
24 #include <ubit/uwin.hpp>
25 #include <ubit/uupdate.hpp>
26 #include <ubit/ustyle.hpp>
27 #include <ubit/umessage.hpp>
28 #include <ubit/utimer.hpp>
29 namespace ubit {
30 
31  class UpdateRequest {
32  public:
33  UBox* obj;
34  UUpdate upd;
35  UpdateRequest(UBox* _obj, const UUpdate& _upd, bool remove_paint)
36  : obj(_obj), upd(_upd) {if (remove_paint) upd.modes &= ~UUpdate::PAINT;}
37  };
38 
39 
40  class UAppliImpl {
41  public:
42  UAppliImpl();
43 
44  bool isTerminated() const {return is_terminated;}
45 
46  bool hasPendingRequest() {return request_mask != 0;}
48 
49  void processPendingRequests();
51 
52  void addDeleteRequest(UObject*);
53  void addDeleteRequest(UView*);
54  void processDeleteRequests();
55 
56  void addUpdateRequest(UBox*, const UUpdate&);
57  void removeUpdateRequests(UBox*);
58  void processUpdateRequests();
59  bool isProcessingUpdateRequests() const {return is_processing_update_requests;}
60  bool isProcessingLayoutUpdateRequests() const {return is_processing_layout_update_requests;}
61 
62  int startModalWinLoop(UWin&);
63  void addModalWin(UWin&);
64  void removeModalWin(UWin&);
65  void setModalStatus(int);
66 
67  void resetSources(UElem* sources, fd_set& read_set, int& maxfd);
68  void cleanSources(UElem* sources);
69  void fireSources(UElem* sources, fd_set& read_set);
70 
71  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
72  //private:
73  friend class UAppli;
74  friend class UDisp;
75  friend class UView;
76  friend class UEventFlow;
77  friend class UTimer;
78  friend class USource;
79  friend class UMService;
80 
81  typedef std::vector<UpdateRequest> UpdateRequests;
82  typedef std::vector<UObject*> DeletedObjects;
83  typedef std::vector<UView*> DeletedViews;
84 
85  UAppli* appli; // only ONE UAppli object should be created
86  UDisp* disp;
87  UStr *app_name;
88  bool is_terminated; // true if the UAppli has been terminated
89  uptr<UErrorHandler> error_handler;
90  UFrame* main_frame; // the main frame of the UAppli
91  // Note: the display list must be static to avoid seg faults if the UAppli
92  // is distroyed before the widgets by the client program
93  UDispList displist;
94  UFlowList flowlist; // list of event flows
95  UStyleSheet stylesheet;
96  UStr imapath;
97  UElem* sources;
98  UTimerImpl timer_impl;
99  class UWinList *modalwins; // modal windows
100  UMessagePortMap* messmap; // the message port of the UAppli
101  unsigned long app_motion_lag, nat_motion_lag;
102 
103  int main_status; // status of the event loop of the UAppli
104  int modal_status; // status of the inner loop the current modal dialog
105  bool mainloop_running, subloop_running;
106 
107  enum {DELETE_REQUEST = 1<<0, UPDATE_REQUEST = 1<<1, PAINT_REQUEST = 1<<2};
108  int request_mask;
109  bool is_processing_update_requests, is_processing_layout_update_requests;
110  UpdateRequests update_list; // boxes and wins that will be updated
111  DeletedObjects del_obj_list; // objects that will be deleted
112  DeletedViews del_view_list; // views that will be deleted
113  };
114 
115 }
116 #endif
117 
118 
a UTimer object fires callbacks after a given delay.
Definition: utimer.hpp:45
Box container.
Definition: ubox.hpp:64
UFrame: toplevel and main window.
Definition: udialogs.hpp:117
Definition: uappliImpl.hpp:40
Display Context.
Definition: udisp.hpp:44
Definition: utimer.hpp:127
UMService: Ubit Mouse/Message Service.
Definition: umservice.hpp:25
Impl.
Definition: umessage.hpp:50
specifies how to update UElem, UBox, UWin objects and subclasses.
Definition: uupdate.hpp:25
bool hasPendingRequest()
true if there is a delete, update or paint request
Definition: uappliImpl.hpp:46
The Application Context.
Definition: uappli.hpp:79
Definition: uwinImpl.hpp:28
lightweight general purpose container.
Definition: uelem.hpp:44
Smart Pointer for UObject instances (.
Definition: uobject.hpp:365
a USource object fires callbacks when a file or a socket gets data.
Definition: usource.hpp:35
Definition: uappliImpl.hpp:31
Event Flow.
Definition: ueventflow.hpp:34
Box View.
Definition: uview.hpp:65
Definition: uclassImpl.hpp:155
Definition: uhardfont.hpp:31
Base class for windows and menus.
Definition: uwin.hpp:47
Ubit String.
Definition: ustr.hpp:72
Base class of most Ubit objects (SEE DETAILS!).
Definition: uobject.hpp:113