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