XenevaOS
Loading...
Searching...
No Matches
window.h
Go to the documentation of this file.
1
30#ifndef __CH_WINDOW_H__
31#define __CH_WINDOW_H__
32
33#include <stdint.h>
34#include "../chitralekha.h"
35#include "../color.h"
36#include "../draw.h"
37#include "base.h"
38#include "list.h"
39#include <setjmp.h>
40
41#define CHITRALEKHA_DEFAULT_WIN_WIDTH 400
42#define CHITRALEKHA_DEFAULT_WIN_HEIGHT 300
43#define CHITRALEKHA_WINDOW_DEFAULT_PAD_Y 26
44#define CHITRALEKHA_WINDOW_DEFAULT_PAD_X 1
45
46#define WINDOW_GLOBAL_CONTROL_CLOSE 1
47#define WINDOW_GLOBAL_CONTROL_MAXIMIZE 2
48#define WINDOW_GLOBAL_CONTROL_MINIMIZE 3
49#define WINDOW_GLOBAL_CONTROL_CUSTOM 4
50
51#define WINDOW_FLAG_MOVABLE (1 << 0)
52#define WINDOW_FLAG_STATIC (1 << 1)
53#define WINDOW_FLAG_ALWAYS_ON_TOP (1 << 2)
54#define WINDOW_FLAG_NON_RESIZABLE (1 << 3)
55#define WINDOW_FLAG_BROADCAST_LISTENER (1 << 4)
56#define WINDOW_FLAG_ANIMATED (1 << 5)
57#define WINDOW_FLAG_BLOCKED (1 << 6)
58#define WINDOW_FLAG_MESSAGEBOX (1 << 7)
59#define WINDOW_FLAG_DIALOGBOX (1 << 8)
60#define WINDOW_FLAG_ANIMATION_FADE_IN (1 << 9)
61#define WINDOW_FLAG_ANIMATION_FADE_OUT (1 << 10)
62#define WINDOW_FLAG_POPUP (1 << 11)
63#define WINDOW_FLAG_GLASS (1 << 12)
64
65#define CHITRALEKHA_WIDGET_TYPE_CONTROL (1 << 1)
66#define CHITRALEKHA_WIDGET_TYPE_POPUP (1 << 2)
67
68#define CHITRALEKHA_WIDGET_SCROLL_HORIZONTAL 0
69#define CHITRALEKHA_WIDGET_SCROLL_VERTICAL 1
70
71#define WINDOW_HANDLE_TYPE_NORMAL 1
72#define WINDOW_HANDLE_TYPE_POPUP 2
73
74//#pragma pack(push,1)
89
90static inline bool ChSharedFlagLoad(const bool* flag) {
91 return __atomic_load_n(flag, __ATOMIC_ACQUIRE);
92}
93
94static inline void ChSharedFlagStore(bool* flag, bool value) {
95 __atomic_store_n(flag, value, __ATOMIC_RELEASE);
96}
97//#pragma pack(pop)
98
122
123typedef struct _ChWidget_ {
124 int x;
125 int y;
126 int w;
127 int h;
131 bool hover;
137 void (*ChActionHandler)(struct _ChWidget_* widget, ChWindow* win);
138 void (*ChMouseEvent)(struct _ChWidget_* widget, ChWindow* win, int x, int y, int button);
139 void (*ChTouchEvent)(struct _ChWidget_* widget, ChWindow* win, int x, int y);
140 void (*ChScrollEvent)(struct _ChWidget_* widget,
141 ChWindow* win,
142 int scrollval,
143 uint8_t scrolltype);
144 void (*ChPaintHandler)(struct _ChWidget_* widget, ChWindow* win);
145 void (*ChDestroy)(struct _ChWidget_* widget, ChWindow* win);
147
166
167#pragma pack(push, 1)
181#pragma pack(pop)
182
195
196#ifdef __cplusplus
197XE_EXTERN {
198#endif
199
200 /*
201 * ChCreateWindow -- create a new chitralekha window
202 * @param app -- pointer to Chitralekha app
203 * @param attrib -- window attributes
204 * @param title -- title of the window
205 * @param x -- x position of the window
206 * @param y -- y position of the window
207 * @param w -- width of the window
208 * @param h -- height of the window
209 */
211 ChitralekhaApp * app, uint16_t attrib, char* title, int x, int y, int w, int h);
212
213 /*
214 * ChWindowAddSubWindow -- add sub window to parent window list
215 * @param parent -- Pointer to main window
216 * @param win -- Pointer to sub window
217 */
219
220 /*
221 * ChWindowBroadcastIcon -- broadcast icon information to
222 * broadcast listener
223 * @param app -- pointer to chitralekha application
224 * @param iconfile -- path of the icon file, supported formats
225 * are : 32bit- bmp file
226 */
227 XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp * app, char* iconfile);
228
229 /*
230 * ChWindowPaint -- paint the entire window
231 * @param win -- Pointer to window
232 */
234
235 /*
236 * ChWindowUpdate -- update a portion or whole window
237 * @param win -- Pointer to window
238 * @param x -- x position of the dirty area
239 * @param y -- y position of the dirty area
240 * @param w - width of the dirty area
241 * @param h -- height of the dirty area
242 * @param updateEntireWin -- update entire window
243 * @param dirty -- dirty specifies small areas of the window
244 */
246 ChWindow * win, int x, int y, int w, int h, bool updateEntireWin, bool dirty);
247
248 /*
249 * ChWindowHide -- hide the window
250 * basically it sends command to deodhai
251 * @param win -- Pointer to window structure
252 */
254
255 /*
256 * ChGetWindowHandle -- get a specific window handle from
257 * the system looking by its name
258 * @param app -- Pointer to application instance
259 * @param title -- desired window title
260 */
262 /*
263 * ChWindowHandleMouse -- handle mouse event
264 * @param win -- Pointer to window
265 * @param x -- X coord of the mouse
266 * @param y -- Y coord of the mouse
267 * @param button -- button state of the mouse
268 */
269 XE_LIB void ChWindowHandleMouse(ChWindow * win, int x, int y, int button);
270
271 /*
272 * ChWindowHandleTouch -- handle touch event
273 * @param win -- Pointer to window
274 * @param x -- X coord of the mouse
275 * @param y -- Y coord of the mouse
276 * @param button -- button state of the mouse
277 */
278 XE_LIB void ChWindowHandleTouch(ChWindow * win, int x, int y, int button);
279
280 /*
281 * ChWindowSetFocused -- bring a window to focused state
282 * @param win -- Pointer to window
283 */
285 /*
286 * ChWindowHandleFocus -- handle focus changed events
287 * @param win -- Pointer to window
288 * @param focus_val -- focus bit, 1 -- focused, 0 -- not focused
289 * @param handle -- handle number of the window
290 */
291 XE_LIB void ChWindowHandleFocus(ChWindow * win, bool focus_val, uint32_t handle);
292
293 /*
294 * ChWindowGetBackgroundColor -- returns the current
295 * background color
296 * @param win -- Pointer to Chitralekha Window
297 */
299
300 /*
301 * ChWindowAddWidget -- adds a widget to window
302 * @param win -- Pointer to root window
303 * @param wid -- Pointer to widget needs to be added
304 */
306
307 /*
308 * ChWindowAddSubWindow -- add sub window to parent window list
309 * @param parent -- Pointer to main window
310 * @param win -- Pointer to sub window
311 */
313
314 /*
315 * ChGetWindowByHandle -- returns window by looking sub windows list
316 * @param mainWin -- pointer to main window
317 * @param handle -- Handle of the window
318 */
320
321 /*
322 * ChGetPopupWindowByHandle -- looks for popup window by its handle
323 * @param mainWin -- Pointer to main window
324 * @param handle -- Handle of the popup window
325 */
327
328 /*
329 * ChPopupWindowHandleMouse -- Handle popup window's mouse event externally
330 * @param win -- Pointer to popup window
331 * @param mainWin -- Pointer to main Window
332 * @param x -- Mouse x coordinate
333 * @param y -- Mouse y coordinate
334 * @param button -- Mouse button state
335 */
336 XE_LIB void ChPopupWindowHandleMouse(ChWindow * win, int x, int y, int button);
337
338 /*
339 * ChWindowSetFlags -- set window flags
340 * @param win -- Pointer to window
341 * @param flags -- flags to set
342 */
344
345 /*
346 * ChWindowMove -- moves target window to a new location
347 * @param win -- Pointer to the window
348 * @param newX -- new x location relative to screen coord
349 * @param newY -- new y location relative to screen coord
350 */
351 XE_LIB void ChWindowMove(ChWindow * win, int newX, int newY);
352
353 /*
354 * ChWindowRegisterJump -- register long jump address
355 * @param win -- Pointer to main window
356 */
358
359 /*
360 * ChWindowCloseWindow -- clears window related data and
361 * sends close message to deodhai
362 * @param win -- Pointer to window data
363 */
365
366 /*
367 * ChCreatePopupWindow -- *Create a popup window
368 * @param app -- Pointer to application
369 * @param win -- Pointer to Window
370 * @param x -- X coordinate
371 * @param y -- Y coordinate
372 * @param w -- Width of the window
373 * @param h -- Height of the window
374 * @param type -- type of the window
375 */
377 ChWindow * win, int x, int y, int w, int h, uint16_t flags, char* title);
378
379 /*
380 * ChPopupWindowUpdate -- update the popup window
381 * @param pw -- Pointer to Chitralekha Popup Window
382 * @param x -- X location
383 * @param y -- Y location
384 * @param w -- Width of the popup window
385 * @param h -- Height of the popup window
386 */
387 XE_LIB void ChPopupWindowUpdate(ChPopupWindow * pw, int x, int y, int w, int h);
388
389 /*
390 * ChPopupWindowShow -- show the popup window
391 * @param pw -- Pointer to Popup Window
392 * @param win -- Pointer to Chitralekha Main Window
393 */
395
396 /*
397 * ChPopupWindowUpdateLocation -- update the location of popup window relative to
398 * main window
399 * @param pwin -- Pointer to Popup Window
400 * @param win -- Pointer to Main Window
401 * @param x -- X location
402 * @param y -- Y location
403 */
404 XE_LIB void ChPopupWindowUpdateLocation(ChWindow * pwin, ChWindow * win, int x, int y);
405
406 /*
407 * ChPopupWindowHide -- hide the popup window
408 * @param pw -- Pointer to Popup Window
409 * @param perent -- Parent Window
410 */
411 XE_LIB void ChPopupWindowHide(ChWindow * pw, ChWindow * parent);
412
413#ifdef __cplusplus
414}
415#endif
416
417#endif
XE_LIB void ChWindowHide(ChWindow *win)
Definition window.cpp:403
struct _popup_win_ ChPopupWindow
XE_LIB void ChWindowHandleTouch(ChWindow *win, int x, int y, int button)
Definition window.cpp:560
XE_LIB void ChPopupWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:657
XE_LIB void ChPopupWindowUpdate(ChPopupWindow *pw, int x, int y, int w, int h)
Definition window.cpp:983
XE_LIB void ChWindowCloseWindow(ChWindow *win)
Definition window.cpp:830
struct _ChSharedWin_ ChSharedWinInfo
XE_LIB void ChWindowSetFlags(ChWindow *win, uint16_t flags)
Definition window.cpp:726
struct _chwin_ ChWindow
XE_LIB void ChWindowRegisterJump(ChWindow *win)
Definition window.cpp:717
XE_LIB void ChWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:462
XE_LIB void ChWindowHandleFocus(ChWindow *win, bool focus_val, uint32_t handle)
Definition window.cpp:695
XE_LIB void ChPopupWindowHide(ChWindow *pw, ChWindow *parent)
Definition window.cpp:1039
XE_LIB void ChWindowMove(ChWindow *win, int newX, int newY)
Definition window.cpp:743
XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp *app, char *iconfile)
Definition window.cpp:248
XE_LIB ChWindow * ChGetWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:367
XE_LIB ChWindow * ChGetPopupWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:388
XE_LIB ChWindow * ChCreateWindow(ChitralekhaApp *app, uint16_t attrib, char *title, int x, int y, int w, int h)
Definition window.cpp:163
XE_LIB void ChPopupWindowUpdateLocation(ChWindow *pwin, ChWindow *win, int x, int y)
Definition window.cpp:1029
XE_LIB void ChWindowSetFocused(ChWindow *win)
Definition window.cpp:445
XE_LIB uint32_t ChWindowGetBackgroundColor(ChWindow *win)
Definition window.cpp:919
XE_LIB uint32_t ChGetWindowHandle(ChitralekhaApp *app, char *title)
Definition window.cpp:418
XE_LIB void ChWindowAddWidget(ChWindow *win, ChWidget *wid)
Definition window.cpp:709
struct _global_ctrl_ ChWinGlobalControl
XE_LIB ChWindow * ChCreatePopupWindow(ChWindow *win, int x, int y, int w, int h, uint16_t flags, char *title)
Definition window.cpp:934
XE_LIB void ChWindowAddSubWindow(ChWindow *parent, ChWindow *win)
Definition window.cpp:355
XE_LIB void ChPopupWindowShow(ChWindow *pw, ChWindow *win)
Definition window.cpp:1012
struct _popup_sh_win_ ChPopupSharedWin
XE_LIB void ChWindowUpdate(ChWindow *win, int x, int y, int w, int h, bool updateEntireWin, bool dirty)
Definition window.cpp:268
XE_LIB void ChWindowPaint(ChWindow *win)
Definition window.cpp:332
struct _ChWidget_ ChWidget
ChWindow * mainWin
Definition main.cpp:54
ChitralekhaApp * app
Definition main.cpp:53
#define XE_LIB
Definition _xeneva.h:55
#define XE_EXTERN
Definition _xeneva.h:50
unsigned int uint32_t
Definition acefiex.h:163
unsigned char uint8_t
Definition acefiex.h:161
unsigned short int uint16_t
Definition acefiex.h:162
ChWindow * win
Definition namdapha.cpp:54
long long jmp_buf[_JBLEN]
Definition setjmp.h:35
Definition base.h:72
Definition chitralekha.h:40
Definition window.h:75
bool windowReady
Definition window.h:87
bool alpha
Definition window.h:84
int width
Definition window.h:82
int y
Definition window.h:81
bool dirty
Definition window.h:78
int x
Definition window.h:80
double alphaValue
Definition window.h:86
int height
Definition window.h:83
ChRect rect[256]
Definition window.h:76
uint32_t rect_count
Definition window.h:77
bool hide
Definition window.h:85
bool updateEntireWindow
Definition window.h:79
Definition window.h:123
void(* ChTouchEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y)
Definition window.h:139
void(* ChPaintHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:144
void(* ChMouseEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y, int button)
Definition window.h:138
int x
Definition window.h:124
int w
Definition window.h:126
bool visible
Definition window.h:134
bool hoverPainted
Definition window.h:132
int lastMouseX
Definition window.h:128
uint8_t type
Definition window.h:136
void(* ChDestroy)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:145
bool hover
Definition window.h:131
bool touched
Definition window.h:135
void(* ChScrollEvent)(struct _ChWidget_ *widget, ChWindow *win, int scrollval, uint8_t scrolltype)
Definition window.h:140
int y
Definition window.h:125
int h
Definition window.h:127
int lastMouseY
Definition window.h:129
void(* ChActionHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:137
bool KillFocus
Definition window.h:133
bool clicked
Definition window.h:130
Definition draw.h:42
Definition window.h:99
void * selectedMenuItem
Definition window.h:116
void * sharedwin
Definition window.h:102
uint32_t color
Definition window.h:108
ChSharedWinInfo * info
Definition window.h:105
list_t * popup
Definition window.h:113
list_t * widgets
Definition window.h:111
list_t * GlobalControls
Definition window.h:110
void(* ChWinPaint)(struct _chwin_ *win)
Definition window.h:119
list_t * subwindow
Definition window.h:112
ChitralekhaApp * app
Definition window.h:106
struct _chwin_ * parent
Definition window.h:114
jmp_buf jump
Definition window.h:118
bool focused
Definition window.h:109
void * focusedWidget
Definition window.h:117
char * title
Definition window.h:104
ChCanvas * canv
Definition window.h:103
void(* ChCloseWin)(struct _chwin_ *win)
Definition window.h:120
void * currentPopupMenu
Definition window.h:115
uint16_t flags
Definition window.h:100
uint32_t * buffer
Definition window.h:101
uint32_t handle
Definition window.h:107
Definition window.h:148
uint32_t hoverOutlineColor
Definition window.h:158
void(* ChGlobalMouseEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y, int button)
Definition window.h:162
uint32_t clickedFillColor
Definition window.h:159
int x
Definition window.h:149
uint32_t fillColor
Definition window.h:156
bool hover
Definition window.h:154
uint32_t clickedOutlineColor
Definition window.h:160
int w
Definition window.h:151
bool clicked
Definition window.h:155
int y
Definition window.h:150
void(* ChGlobalTouchEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y)
Definition window.h:163
void(* ChGlobalActionEvent)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:164
int h
Definition window.h:152
uint8_t type
Definition window.h:153
void(* ChGlobalButtonPaint)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:161
uint32_t outlineColor
Definition window.h:157
Definition list.h:46
Definition window.h:168
ChRect rect[100]
Definition window.h:169
int w
Definition window.h:173
uint32_t rect_count
Definition window.h:170
bool hide
Definition window.h:177
bool dirty
Definition window.h:175
int x
Definition window.h:171
int h
Definition window.h:174
bool alpha
Definition window.h:179
bool popuped
Definition window.h:178
int y
Definition window.h:172
bool close
Definition window.h:176
Definition window.h:183
uint32_t * buffer
Definition window.h:186
list_t * widgets
Definition window.h:189
ChWidget wid
Definition window.h:184
uint16_t buffWinKey
Definition window.h:188
uint16_t shwinKey
Definition window.h:187
ChPopupSharedWin * shwin
Definition window.h:185
void(* ChPopupWindowPaint)(struct _popup_win_ *pwin, ChWindow *win)
Definition window.h:193
int handle
Definition window.h:190
ChCanvas * canv
Definition window.h:191
bool hidden
Definition window.h:192
bool dirty
Definition term.cpp:54