33 #include "window.h" |
33 #include "window.h" |
34 #include "stock.h" |
34 #include "stock.h" |
35 |
35 |
36 #include "../common/document.h" |
36 #include "../common/document.h" |
37 #include "../common/properties.h" |
37 #include "../common/properties.h" |
|
38 #include "../common/menu.h" |
|
39 #include "../common/toolbar.h" |
38 |
40 |
39 static const char *application_name; |
41 static const char *application_name; |
40 |
42 |
41 static ui_callback startup_func; |
43 static ui_callback startup_func; |
42 static void *startup_data; |
44 static void *startup_data; |
113 |
117 |
114 } |
118 } |
115 |
119 |
116 |
120 |
117 |
121 |
|
122 /* --------------------- Implemtation UiEventWrapper --------------------- */ |
118 |
123 |
119 UiEventWrapper::UiEventWrapper(UiObject *obj, ui_callback f, void* userdata) { |
124 UiEventWrapper::UiEventWrapper(UiObject *obj, ui_callback f, void* userdata) { |
120 this->obj = obj; |
125 this->obj = obj; |
121 this->callback = f; |
126 this->callback = f; |
122 this->userdata = userdata; |
127 this->userdata = userdata; |
123 } |
128 } |
124 |
129 |
125 void UiEventWrapper::slot() { |
130 void UiEventWrapper::slot() { |
|
131 if(!callback) { |
|
132 return; |
|
133 } |
|
134 |
126 UiEvent e; |
135 UiEvent e; |
127 e.obj = obj; |
136 e.obj = obj; |
128 e.window = obj->window; |
137 e.window = obj->window; |
129 e.document = obj->ctx->document; |
138 e.document = obj->ctx->document; |
130 e.eventdata = NULL; |
139 e.eventdata = NULL; |
139 } |
148 } |
140 |
149 |
141 void UiEventWrapper::destroy() { |
150 void UiEventWrapper::destroy() { |
142 delete this; |
151 delete this; |
143 } |
152 } |
|
153 |
|
154 |
|
155 /* --------------------- Implemtation UiAction --------------------- */ |
|
156 |
|
157 UiAction::UiAction(UiObject *obj, QString &label, ui_callback f, void *userdata) : QAction(label, NULL) { |
|
158 this->obj = obj; |
|
159 this->callback = f; |
|
160 this->userdata = userdata; |
|
161 } |
|
162 |
|
163 UiAction::~UiAction() { |
|
164 |
|
165 } |
|
166 |
|
167 void UiAction::trigger() { |
|
168 if(!callback) { |
|
169 return; |
|
170 } |
|
171 |
|
172 UiEvent e; |
|
173 e.obj = obj; |
|
174 e.window = obj->window; |
|
175 e.document = obj->ctx->document; |
|
176 e.eventdata = NULL; |
|
177 e.intval = 0; |
|
178 e.set = ui_get_setop(); |
|
179 callback(&e, userdata); |
|
180 |
|
181 // TODO: notify var observers |
|
182 } |