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//#pragma pack(pop)
90
114
115 typedef struct _ChWidget_{
116 int x;
117 int y;
118 int w;
119 int h;
123 bool hover;
129 void(*ChActionHandler)(struct _ChWidget_ *widget,ChWindow* win);
130 void(*ChMouseEvent)(struct _ChWidget_* widget,ChWindow* win, int x, int y, int button);
131 void(*ChTouchEvent)(struct _ChWidget_* widget, ChWindow* win, int x, int y);
132 void(*ChScrollEvent)(struct _ChWidget_* widget, ChWindow* win, int scrollval, uint8_t scrolltype);
133 void(*ChPaintHandler)(struct _ChWidget_* widget,ChWindow* win);
134 void(*ChDestroy)(struct _ChWidget_* widget,ChWindow* win);
136
155
156#pragma pack(push,1)
170#pragma pack(pop)
171
184
185#ifdef __cplusplus
186 XE_EXTERN{
187#endif
188
189 /*
190 * ChCreateWindow -- create a new chitralekha window
191 * @param app -- pointer to Chitralekha app
192 * @param attrib -- window attributes
193 * @param title -- title of the window
194 * @param x -- x position of the window
195 * @param y -- y position of the window
196 * @param w -- width of the window
197 * @param h -- height of the window
198 */
199 XE_LIB ChWindow* ChCreateWindow(ChitralekhaApp *app, uint16_t attrib, char* title, int x, int y, int w, int h);
200
201 /*
202 * ChWindowAddSubWindow -- add sub window to parent window list
203 * @param parent -- Pointer to main window
204 * @param win -- Pointer to sub window
205 */
207
208 /*
209 * ChWindowBroadcastIcon -- broadcast icon information to
210 * broadcast listener
211 * @param app -- pointer to chitralekha application
212 * @param iconfile -- path of the icon file, supported formats
213 * are : 32bit- bmp file
214 */
215 XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp* app, char* iconfile);
216
217 /*
218 * ChWindowPaint -- paint the entire window
219 * @param win -- Pointer to window
220 */
222
223 /*
224 * ChWindowUpdate -- update a portion or whole window
225 * @param win -- Pointer to window
226 * @param x -- x position of the dirty area
227 * @param y -- y position of the dirty area
228 * @param w - width of the dirty area
229 * @param h -- height of the dirty area
230 * @param updateEntireWin -- update entire window
231 * @param dirty -- dirty specifies small areas of the window
232 */
233 XE_LIB void ChWindowUpdate(ChWindow* win, int x, int y, int w, int h, bool updateEntireWin, bool dirty);
234
235
236 /*
237 * ChWindowHide -- hide the window
238 * basically it sends command to deodhai
239 * @param win -- Pointer to window structure
240 */
242
243 /*
244 * ChGetWindowHandle -- get a specific window handle from
245 * the system looking by its name
246 * @param app -- Pointer to application instance
247 * @param title -- desired window title
248 */
250 /*
251 * ChWindowHandleMouse -- handle mouse event
252 * @param win -- Pointer to window
253 * @param x -- X coord of the mouse
254 * @param y -- Y coord of the mouse
255 * @param button -- button state of the mouse
256 */
257 XE_LIB void ChWindowHandleMouse(ChWindow* win, int x, int y, int button);
258
259
260 /*
261 * ChWindowHandleTouch -- handle touch event
262 * @param win -- Pointer to window
263 * @param x -- X coord of the mouse
264 * @param y -- Y coord of the mouse
265 * @param button -- button state of the mouse
266 */
267 XE_LIB void ChWindowHandleTouch(ChWindow* win, int x, int y, int button);
268
269 /*
270 * ChWindowSetFocused -- bring a window to focused state
271 * @param win -- Pointer to window
272 */
274 /*
275 * ChWindowHandleFocus -- handle focus changed events
276 * @param win -- Pointer to window
277 * @param focus_val -- focus bit, 1 -- focused, 0 -- not focused
278 * @param handle -- handle number of the window
279 */
280 XE_LIB void ChWindowHandleFocus(ChWindow* win, bool focus_val, uint32_t handle);
281
282 /*
283 * ChWindowGetBackgroundColor -- returns the current
284 * background color
285 * @param win -- Pointer to Chitralekha Window
286 */
288
289
290 /*
291 * ChWindowAddWidget -- adds a widget to window
292 * @param win -- Pointer to root window
293 * @param wid -- Pointer to widget needs to be added
294 */
296
297 /*
298 * ChWindowAddSubWindow -- add sub window to parent window list
299 * @param parent -- Pointer to main window
300 * @param win -- Pointer to sub window
301 */
303
304 /*
305 * ChGetWindowByHandle -- returns window by looking sub windows list
306 * @param mainWin -- pointer to main window
307 * @param handle -- Handle of the window
308 */
310
311 /*
312 * ChGetPopupWindowByHandle -- looks for popup window by its handle
313 * @param mainWin -- Pointer to main window
314 * @param handle -- Handle of the popup window
315 */
317
318 /*
319 * ChPopupWindowHandleMouse -- Handle popup window's mouse event externally
320 * @param win -- Pointer to popup window
321 * @param mainWin -- Pointer to main Window
322 * @param x -- Mouse x coordinate
323 * @param y -- Mouse y coordinate
324 * @param button -- Mouse button state
325 */
326 XE_LIB void ChPopupWindowHandleMouse(ChWindow* win,int x, int y, int button);
327
328 /*
329 * ChWindowSetFlags -- set window flags
330 * @param win -- Pointer to window
331 * @param flags -- flags to set
332 */
334
335 /*
336 * ChWindowMove -- moves target window to a new location
337 * @param win -- Pointer to the window
338 * @param newX -- new x location relative to screen coord
339 * @param newY -- new y location relative to screen coord
340 */
341 XE_LIB void ChWindowMove(ChWindow* win, int newX, int newY);
342
343 /*
344 * ChWindowRegisterJump -- register long jump address
345 * @param win -- Pointer to main window
346 */
348
349 /*
350 * ChWindowCloseWindow -- clears window related data and
351 * sends close message to deodhai
352 * @param win -- Pointer to window data
353 */
355
356 /*
357 * ChCreatePopupWindow -- *Create a popup window
358 * @param app -- Pointer to application
359 * @param win -- Pointer to Window
360 * @param x -- X coordinate
361 * @param y -- Y coordinate
362 * @param w -- Width of the window
363 * @param h -- Height of the window
364 * @param type -- type of the window
365 */
366 XE_LIB ChWindow* ChCreatePopupWindow(ChWindow* win, int x, int y, int w, int h, uint16_t flags, char* title);
367
368 /*
369 * ChPopupWindowUpdate -- update the popup window
370 * @param pw -- Pointer to Chitralekha Popup Window
371 * @param x -- X location
372 * @param y -- Y location
373 * @param w -- Width of the popup window
374 * @param h -- Height of the popup window
375 */
376 XE_LIB void ChPopupWindowUpdate(ChPopupWindow* pw, int x, int y, int w, int h);
377
378 /*
379 * ChPopupWindowShow -- show the popup window
380 * @param pw -- Pointer to Popup Window
381 * @param win -- Pointer to Chitralekha Main Window
382 */
384
385 /*
386 * ChPopupWindowUpdateLocation -- update the location of popup window relative to
387 * main window
388 * @param pwin -- Pointer to Popup Window
389 * @param win -- Pointer to Main Window
390 * @param x -- X location
391 * @param y -- Y location
392 */
393 XE_LIB void ChPopupWindowUpdateLocation(ChWindow* pwin, ChWindow* win, int x, int y);
394
395 /*
396 * ChPopupWindowHide -- hide the popup window
397 * @param pw -- Pointer to Popup Window
398 * @param perent -- Parent Window
399 */
400 XE_LIB void ChPopupWindowHide(ChWindow* pw, ChWindow* parent);
401
402#ifdef __cplusplus
403}
404#endif
405
406#endif
XE_LIB void ChWindowHide(ChWindow *win)
Definition window.cpp:359
struct _popup_win_ ChPopupWindow
XE_LIB void ChWindowHandleTouch(ChWindow *win, int x, int y, int button)
Definition window.cpp:513
XE_LIB void ChPopupWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:605
XE_LIB void ChPopupWindowUpdate(ChPopupWindow *pw, int x, int y, int w, int h)
Definition window.cpp:934
XE_LIB void ChWindowCloseWindow(ChWindow *win)
Definition window.cpp:782
struct _ChSharedWin_ ChSharedWinInfo
XE_LIB void ChWindowSetFlags(ChWindow *win, uint16_t flags)
Definition window.cpp:677
struct _chwin_ ChWindow
XE_LIB void ChWindowRegisterJump(ChWindow *win)
Definition window.cpp:668
XE_LIB void ChWindowHandleMouse(ChWindow *win, int x, int y, int button)
Definition window.cpp:419
XE_LIB void ChWindowHandleFocus(ChWindow *win, bool focus_val, uint32_t handle)
Definition window.cpp:645
XE_LIB void ChPopupWindowHide(ChWindow *pw, ChWindow *parent)
Definition window.cpp:993
XE_LIB void ChWindowMove(ChWindow *win, int newX, int newY)
Definition window.cpp:694
XE_LIB void ChWindowBroadcastIcon(ChitralekhaApp *app, char *iconfile)
Definition window.cpp:227
XE_LIB ChWindow * ChGetWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:323
XE_LIB ChWindow * ChGetPopupWindowByHandle(ChWindow *mainWin, int handle)
Definition window.cpp:344
XE_LIB ChWindow * ChCreateWindow(ChitralekhaApp *app, uint16_t attrib, char *title, int x, int y, int w, int h)
Definition window.cpp:161
XE_LIB void ChPopupWindowUpdateLocation(ChWindow *pwin, ChWindow *win, int x, int y)
Definition window.cpp:982
XE_LIB void ChWindowSetFocused(ChWindow *win)
Definition window.cpp:402
XE_LIB uint32_t ChWindowGetBackgroundColor(ChWindow *win)
Definition window.cpp:874
XE_LIB uint32_t ChGetWindowHandle(ChitralekhaApp *app, char *title)
Definition window.cpp:375
XE_LIB void ChWindowAddWidget(ChWindow *win, ChWidget *wid)
Definition window.cpp:660
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:889
XE_LIB void ChWindowAddSubWindow(ChWindow *parent, ChWindow *win)
Definition window.cpp:311
XE_LIB void ChPopupWindowShow(ChWindow *pw, ChWindow *win)
Definition window.cpp:964
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:246
XE_LIB void ChWindowPaint(ChWindow *win)
Definition window.cpp:288
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:45
long long jmp_buf[_JBLEN]
Definition setjmp.h:35
Definition base.h:73
Definition chitralekha.h:43
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:115
void(* ChTouchEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y)
Definition window.h:131
void(* ChPaintHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:133
void(* ChMouseEvent)(struct _ChWidget_ *widget, ChWindow *win, int x, int y, int button)
Definition window.h:130
int x
Definition window.h:116
int w
Definition window.h:118
bool visible
Definition window.h:126
bool hoverPainted
Definition window.h:124
int lastMouseX
Definition window.h:120
uint8_t type
Definition window.h:128
void(* ChDestroy)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:134
bool hover
Definition window.h:123
bool touched
Definition window.h:127
void(* ChScrollEvent)(struct _ChWidget_ *widget, ChWindow *win, int scrollval, uint8_t scrolltype)
Definition window.h:132
int y
Definition window.h:117
int h
Definition window.h:119
int lastMouseY
Definition window.h:121
void(* ChActionHandler)(struct _ChWidget_ *widget, ChWindow *win)
Definition window.h:129
bool KillFocus
Definition window.h:125
bool clicked
Definition window.h:122
Definition draw.h:43
Definition window.h:91
void * selectedMenuItem
Definition window.h:108
void * sharedwin
Definition window.h:94
uint32_t color
Definition window.h:100
ChSharedWinInfo * info
Definition window.h:97
list_t * popup
Definition window.h:105
list_t * widgets
Definition window.h:103
list_t * GlobalControls
Definition window.h:102
void(* ChWinPaint)(struct _chwin_ *win)
Definition window.h:111
list_t * subwindow
Definition window.h:104
ChitralekhaApp * app
Definition window.h:98
struct _chwin_ * parent
Definition window.h:106
jmp_buf jump
Definition window.h:110
bool focused
Definition window.h:101
void * focusedWidget
Definition window.h:109
char * title
Definition window.h:96
ChCanvas * canv
Definition window.h:95
void(* ChCloseWin)(struct _chwin_ *win)
Definition window.h:112
void * currentPopupMenu
Definition window.h:107
uint16_t flags
Definition window.h:92
uint32_t * buffer
Definition window.h:93
uint32_t handle
Definition window.h:99
Definition window.h:137
uint32_t hoverOutlineColor
Definition window.h:147
void(* ChGlobalMouseEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y, int button)
Definition window.h:151
uint32_t clickedFillColor
Definition window.h:148
int x
Definition window.h:138
uint32_t fillColor
Definition window.h:145
bool hover
Definition window.h:143
uint32_t clickedOutlineColor
Definition window.h:149
int w
Definition window.h:140
bool clicked
Definition window.h:144
int y
Definition window.h:139
void(* ChGlobalTouchEvent)(ChWindow *win, struct _global_ctrl_ *glbl, int x, int y)
Definition window.h:152
void(* ChGlobalActionEvent)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:153
int h
Definition window.h:141
uint8_t type
Definition window.h:142
void(* ChGlobalButtonPaint)(ChWindow *win, struct _global_ctrl_ *glbl)
Definition window.h:150
uint32_t outlineColor
Definition window.h:146
Definition list.h:46
Definition window.h:157
ChRect rect[100]
Definition window.h:158
int w
Definition window.h:162
uint32_t rect_count
Definition window.h:159
bool hide
Definition window.h:166
bool dirty
Definition window.h:164
int x
Definition window.h:160
int h
Definition window.h:163
bool alpha
Definition window.h:168
bool popuped
Definition window.h:167
int y
Definition window.h:161
bool close
Definition window.h:165
Definition window.h:172
uint32_t * buffer
Definition window.h:175
list_t * widgets
Definition window.h:178
ChWidget wid
Definition window.h:173
uint16_t buffWinKey
Definition window.h:177
uint16_t shwinKey
Definition window.h:176
ChPopupSharedWin * shwin
Definition window.h:174
void(* ChPopupWindowPaint)(struct _popup_win_ *pwin, ChWindow *win)
Definition window.h:182
int handle
Definition window.h:179
ChCanvas * canv
Definition window.h:180
bool hidden
Definition window.h:181
int x
Definition term.cpp:49
bool dirty
Definition term.cpp:58