44 #define NULL (void *)0
47 static unsigned char sizex, sizey;
49 unsigned char ctk_draw_windowborder_height = 1;
50 unsigned char ctk_draw_windowborder_width = 1;
51 unsigned char ctk_draw_windowtitle_height = 1;
56 cputsn(
char *str,
unsigned char len)
58 unsigned char cnt = 0;
76 (void)bgcolor(SCREENCOLOR);
77 (void)bordercolor(BORDERCOLOR);
78 (void)textcolor(WINDOWCOLOR_FOCUS);
79 screensize(&sizex, &sizey);
86 unsigned char x,
unsigned char y,
87 unsigned char clipx,
unsigned char clipy,
88 unsigned char clipy1,
unsigned char clipy2,
91 unsigned char xpos, ypos, xscroll;
101 (void)textcolor(WIDGETCOLOR_FWIN);
103 (void)textcolor(WIDGETCOLOR_FOCUS);
108 (void)textcolor(WIDGETCOLOR_DIALOG);
109 if(focus & CTK_FOCUS_WIDGET) {
110 (void)textcolor(WIDGETCOLOR_FOCUS);
115 (void)textcolor(WIDGETCOLOR);
123 if(ypos >= clipy1 && ypos < clipy2) {
124 chlinexy(xpos, ypos, w->
w);
128 text = w->
widget.label.text;
129 for(j = 0; j < w->
h; ++j) {
130 if(ypos >= clipy1 && ypos < clipy2) {
132 i = cputsn(text, w->
w);
142 if(ypos >= clipy1 && ypos < clipy2) {
144 cputcxy(xpos, ypos,
'[');
151 if(ypos >= clipy1 && ypos < clipy2) {
154 (void)textcolor(WIDGETCOLOR_HLINK);
160 text = w->
widget.textentry.text;
162 if(w->
widget.textentry.xpos >= w->
w - 1) {
163 xscroll = w->
widget.textentry.xpos - w->
w + 1;
165 for(j = 0; j < w->
h; ++j) {
166 if(ypos >= clipy1 && ypos < clipy2) {
167 if(w->
widget.textentry.state == CTK_TEXTENTRY_EDIT &&
168 w->
widget.textentry.ypos == j) {
170 cputcxy(xpos, ypos,
'>');
172 for(i = 0; i < w->
w; ++i) {
174 c = text[i + xscroll];
176 revers(i == w->
widget.textentry.xpos - xscroll);
186 revers(wfocus != 0 && j == w->
widget.textentry.ypos);
187 cvlinexy(xpos, ypos, 1);
188 gotoxy(xpos + 1, ypos);
189 i = cputsn(text, w->
w);
197 text += w->
widget.textentry.len + 1;
203 if(ypos >= clipy1 && ypos < clipy2) {
205 #if CTK_CONF_ICON_TEXTMAPS
207 for(i = 0; i < 3; ++i) {
209 if(ypos >= clipy1 && ypos < clipy2) {
210 cputc(w->
widget.icon.textmap[0 + 3 * i]);
211 cputc(w->
widget.icon.textmap[1 + 3 * i]);
212 cputc(w->
widget.icon.textmap[2 + 3 * i]);
219 len = (
unsigned char)strlen(w->
widget.icon.title);
220 if(xpos + len >= sizex) {
225 if(ypos >= clipy1 && ypos < clipy2) {
226 cputs(w->
widget.icon.title);
240 unsigned char clipy1,
unsigned char clipy2)
243 unsigned char posx, posy;
247 posy = win->y + 1 + CTK_CONF_MENUS;
257 draw_widget(w, posx, posy, posx + win->
w, posy + win->
h, clipy1, clipy2, focus);
259 #ifdef CTK_CONIO_CONF_UPDATE
260 CTK_CONIO_CONF_UPDATE();
266 unsigned char clipy1,
unsigned char clipy2)
273 if(focus & CTK_FOCUS_WINDOW) {
274 (void)textcolor(WINDOWCOLOR_FOCUS);
276 (void)textcolor(WINDOWCOLOR);
280 h = window->y + 1 + CTK_CONF_MENUS + window->
h;
283 for(i = window->y + 1 + CTK_CONF_MENUS; i < h; ++i) {
284 if(i >= clipy1 && i < clipy2) {
285 cclearxy(window->x + 1, i, window->
w);
289 for(i = 0; i < window->
h; ++i) {
290 if(i >= clipy1 && i < clipy2) {
291 cclearxy(0, i, window->
w);
298 draw_window_contents(
struct ctk_window *window,
unsigned char focus,
299 unsigned char clipy1,
unsigned char clipy2,
300 unsigned char x1,
unsigned char x2,
301 unsigned char y1,
unsigned char y2)
304 unsigned char wfocus;
308 draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, focus);
318 draw_widget(w, x1, y1, x2, y2, clipy1, clipy2, wfocus);
321 #ifdef CTK_CONIO_CONF_UPDATE
322 CTK_CONIO_CONF_UPDATE();
328 unsigned char clipy1,
unsigned char clipy2,
329 unsigned char draw_borders)
333 unsigned char x1, y1, x2, y2;
336 if(window->y + CTK_CONF_MENUS >= clipy2) {
341 y = window->y + CTK_CONF_MENUS;
350 if(focus & CTK_FOCUS_WINDOW) {
351 (void)textcolor(WINDOWCOLOR_FOCUS);
353 (void)textcolor(WINDOWCOLOR);
357 cputcxy(x, y, (
char)CH_ULCORNER);
358 gotoxy(wherex() + window->
titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
359 chline(window->
w - (wherex() - x) - 2);
360 cputcxy(x2, y, (
char)CH_URCORNER);
366 if(clipy1 - y1 < h) {
374 if(clipy2 < y1 + h) {
385 if(y + window->
h >= clipy1 && y + window->
h < clipy2) {
386 cputcxy(x, y2, (
char)CH_LLCORNER);
387 chlinexy(x1, y2, window->
w);
388 cputcxy(x2, y2, (
char)CH_LRCORNER);
392 draw_window_contents(window, focus, clipy1, clipy2, x1, x2, y + 1, y2);
396 draw_window_contents(window, focus, clipy1, clipy2, 0, window->
w, 0, window->
h);
407 unsigned char x1, y1, x2, y2;
409 (void)textcolor(DIALOGCOLOR);
412 y = dialog->y + CTK_CONF_MENUS;
420 cvlinexy(x, y1, dialog->
h);
421 cvlinexy(x2, y1, dialog->
h);
423 chlinexy(x1, y, dialog->
w);
424 chlinexy(x1, y2, dialog->
w);
426 cputcxy(x, y, (
char)CH_ULCORNER);
427 cputcxy(x, y2, (
char)CH_LLCORNER);
428 cputcxy(x2, y, (
char)CH_URCORNER);
429 cputcxy(x2, y2, (
char)CH_LRCORNER);
432 for(i = y1; i < y2; ++i) {
433 cclearxy(x1, i, dialog->
w);
436 draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey, x1, x2, y1, y2);
445 for(i = y1; i < y2; ++i) {
446 cclearxy(0, i, sizex);
452 draw_menu(
struct ctk_menu *m,
unsigned char open)
454 unsigned char x, x2,
y;
458 if(x2 + CTK_CONF_MENUWIDTH > sizex) {
459 x2 = sizex - CTK_CONF_MENUWIDTH;
462 for(y = 0; y < m->
nitems; ++
y) {
464 (void)textcolor(ACTIVEMENUITEMCOLOR);
467 (void)textcolor(MENUCOLOR);
472 chline(CTK_CONF_MENUWIDTH);
476 if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
477 cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
482 (void)textcolor(OPENMENUCOLOR);
488 (void)textcolor(MENUCOLOR);
498 (void)textcolor(MENUCOLOR);
503 draw_menu(m, m == menus->
open);
510 cclear(sizex - wherex() -
520 ctk_draw_height(
void)
#define CTK_WIDGET_TEXTENTRY
Widget number: The CTK textentry widget.
unsigned char titlelen
The length of the title, cached for speed reasons.
struct ctk_menu * desktopmenu
A pointer to the "Desktop" menu that can be used for drawing the desktop menu in a special way (such ...
Representation of the menu bar.
unsigned char w
The width of the window, excluding window borders.
struct ctk_menu * menus
A pointer to a linked list of all menus, including the open menu and the desktop menu.
struct ctk_widget * next
The next widget in the linked list of widgets that is contained in the ctk_window structure...
struct ctk_widget * inactive
The list if widgets that cannot be selected by the user.
unsigned char active
The currently active menu item.
void ctk_draw_clear(unsigned char y1, unsigned char y2)
Clear the screen between the clip bounds.
unsigned char x
The x position of the widget within the containing window, in character coordinates.
struct ctk_menuitem items[CTK_MAXMENUITEMS]
The array which contains all the menu items.
#define CTK_FOCUS_WINDOW
Widget focus flag: widget's window is the foremost one.
unsigned char nitems
The total number of menu items in the menu.
#define NULL
The null pointer.
void ctk_draw_widget(struct ctk_widget *w, unsigned char focus, unsigned char clipy1, unsigned char clipy2)
Draw a widget on a window.
struct ctk_menu * next
Apointer to the next menu, or is NULL if this is the last menu, and should be used by the ctk-draw mo...
char * title
The menu title.
unsigned char type
The type of the widget: CTK_WIDGET_SEPARATOR, CTK_WIDGET_LABEL, CTK_WIDGET_BUTTON, CTK_WIDGET_HYPERLINK, CTK_WIDGET_TEXTENTRY, CTK_WIDGET_BITMAP or CTK_WIDGET_ICON.
void ctk_draw_window(struct ctk_window *window, unsigned char focus, unsigned char clipy1, unsigned char clipy2, unsigned char draw_borders)
Draw a window onto the screen.
unsigned char y
The y position of the widget within the containing window, in character coordinates.
#define CTK_WIDGET_SEPARATOR
Widget number: The CTK separator widget.
char * text
The button text.
struct ctk_widget * focused
A pointer to the widget on the active list that is currently selected, or NULL if no widget is select...
#define CTK_FOCUS_DIALOG
Widget focus flag: widget is in a dialog.
struct ctk_menu * open
The currently open menu, if any.
#define CTK_WIDGET_BUTTON
Widget number: The CTK button widget.
union ctk_widget::@20 widget
The union which contains the actual widget structure, as determined by the type field.
CTK screen drawing module interface, ctk-draw.
Representation of an individual menu.
void ctk_draw_init(void)
The initialization function.
void ctk_draw_dialog(struct ctk_window *dialog)
Draw a dialog onto the screen.
#define CTK_WIDGET_HYPERLINK
Widget number: The CTK hyperlink widget.
Representation of a CTK window.
struct ctk_window * window
The window in which the widget is contained.
#define CTK_FOCUS_WIDGET
Widget focus flag: widget has focus.
#define CTK_WIDGET_LABEL
Widget number: The CTK label widget.
void ctk_draw_clear_window(struct ctk_window *window, unsigned char focus, unsigned char clipy1, unsigned char clipy2)
Draw the window background.
The generic CTK widget structure that contains all other widget structures.
unsigned char w
The width of the widget in character coordinates.
unsigned char h
The height of the window, excluding window borders.
char * title
The menu items text.
struct ctk_widget * active
The list of widgets that can be selected by the user.
#define CTK_WIDGET_ICON
Widget number: The CTK icon widget.
unsigned char h
The height of the widget in character coordinates.