- Timestamp:
- 07/16/09 21:18:01 (4 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/objective-cplusplus/i3/trunk/src/mil/include/mil/gui-cocoa/GuiModule.h
r34305 r34447 3 3 #include "../ModuleCommon.h" 4 4 5 namespace mil 6 { 5 namespace mil { 7 6 8 7 /** … … 10 9 */ 11 10 template <typename Child> 12 class GuiModule : public ModuleCommon<GuiModule<Child>, thread::Cocoa> 13 { 11 class GuiModule : public ModuleCommon<GuiModule<Child>, thread::Cocoa> { 14 12 public: 15 13 Tls tls; 16 14 private: 17 15 template <typename T> 18 class Event : boost::noncopyable 19 { 16 class Event : boost::noncopyable { 20 17 public: 21 18 typedef T DataType; … … 32 29 33 30 public: 34 NSWindow* getWindow() 35 { 31 NSWindow* getWindow() { 36 32 return window; 37 33 } 38 39 void requestExit(void* event_memory) 40 { 34 35 void requestExit(void* event_memory) { 41 36 ExitEvent e; 42 37 post(e, *this); 43 38 } 44 39 45 GuiModule() : tls(this->thread_id), repost(false), window(NULL) 46 { 40 GuiModule() : tls(this->thread_id), repost(false), window(NULL) { 47 41 set_auto_join(this); 48 42 } 49 43 50 Child& getChild() 51 { 44 Child& getChild() { 52 45 return *static_cast<Child*>(this); 53 46 } 54 47 55 48 protected: 56 void repostEvent() 57 { 49 void repostEvent() { 58 50 repost = true; 59 51 } 60 52 61 53 template <typename Data, typename Sender> 62 static void dispatcher(void* event_, void* target_) 63 { 54 static void dispatcher(void* event_, void* target_) { 64 55 typedef Child Target; 65 56 66 if (!event_ || !target_) 67 { 57 if (!event_ || !target_) { 68 58 return; 69 59 } … … 75 65 target.repost = false; 76 66 ModuleExecuteProxy<Data, Target>::execute(event.data, target); 77 if (target.repost) 78 { 67 if (target.repost) { 79 68 target.post(event.data, target); 80 69 return; … … 82 71 } 83 72 public: 84 void requestExit() 85 { 73 void requestExit() { 86 74 ExitEvent e; 87 75 post(e, *this); … … 89 77 90 78 template <typename T, typename Sender> 91 void post(const T& event, Sender& sender, void* memory = NULL, intptr_t owner_id = 0) 92 { 79 void post(const T& event, Sender& sender, void* memory = NULL, intptr_t owner_id = 0) { 93 80 NSWindow* localWindow = sender.tls.thread[this->thread_id].window; 94 81 if (!localWindow) { … … 102 89 } 103 90 public: 104 void destroy() 105 { 106 if (!window) 107 { 91 void destroy() { 92 if (!window) { 108 93 return; 109 94 } … … 112 97 } 113 98 114 ~GuiModule() 115 { 99 ~GuiModule() { 116 100 do_auto_join(); 117 101 } 118 102 119 void execute_front() 120 { 103 void execute_front() { 121 104 } 122 105 123 void mouseDown(NSEvent*) 124 { 106 void mouseDown(NSEvent*) { 125 107 } 126 108 protected: 127 void loop() 128 { 109 void loop() { 129 110 [[NSRunLoop currentRunLoop] run]; 130 111 destroy();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)