Moved CTK service related stuff into backyard.
This commit is contained in:
parent
51af3d9142
commit
1fcece3f89
7 changed files with 7 additions and 7 deletions
|
@ -1,569 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2002, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the "ctk" console GUI toolkit for cc65
|
||||
*
|
||||
* $Id: ctk-conio-service.c,v 1.3 2006/08/30 22:15:25 oliverschmidt Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include <conio.h>
|
||||
|
||||
#include "ctk/ctk.h"
|
||||
#include "ctk/ctk-draw.h"
|
||||
|
||||
#include "ctk/ctk-draw-service.h"
|
||||
|
||||
#include "contiki-conf.h"
|
||||
#include <string.h>
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL (void *)0
|
||||
#endif /* NULL */
|
||||
|
||||
static unsigned char sizex, sizey;
|
||||
|
||||
/*unsigned char ctk_draw_windowborder_height = 1;
|
||||
unsigned char ctk_draw_windowborder_width = 1;
|
||||
unsigned char ctk_draw_windowtitle_height = 1;*/
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
cputsn(char *str, unsigned char len)
|
||||
{
|
||||
char c;
|
||||
|
||||
while(len > 0) {
|
||||
--len;
|
||||
c = *str;
|
||||
if(c == 0) {
|
||||
break;
|
||||
}
|
||||
cputc(c);
|
||||
++str;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_init(void)
|
||||
{
|
||||
(void)bgcolor(SCREENCOLOR);
|
||||
(void)bordercolor(BORDERCOLOR);
|
||||
screensize(&sizex, &sizey);
|
||||
ctk_draw_clear(0, sizey);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
draw_widget(struct ctk_widget *w,
|
||||
unsigned char x, unsigned char y,
|
||||
unsigned char clipx,
|
||||
unsigned char clipy,
|
||||
unsigned char clipy1, unsigned char clipy2,
|
||||
unsigned char focus)
|
||||
{
|
||||
unsigned char xpos, ypos, xscroll;
|
||||
unsigned char i, j;
|
||||
char c, *text;
|
||||
unsigned char len, wfocus;
|
||||
|
||||
wfocus = 0;
|
||||
if(focus & CTK_FOCUS_WINDOW) {
|
||||
(void)textcolor(WIDGETCOLOR_FWIN);
|
||||
if(focus & CTK_FOCUS_WIDGET) {
|
||||
(void)textcolor(WIDGETCOLOR_FOCUS);
|
||||
wfocus = 1;
|
||||
}
|
||||
} else if(focus & CTK_FOCUS_DIALOG) {
|
||||
(void)textcolor(WIDGETCOLOR_DIALOG);
|
||||
if(focus & CTK_FOCUS_WIDGET) {
|
||||
(void)textcolor(WIDGETCOLOR_FOCUS);
|
||||
wfocus = 1;
|
||||
}
|
||||
} else {
|
||||
(void)textcolor(WIDGETCOLOR);
|
||||
}
|
||||
|
||||
xpos = x + w->x;
|
||||
ypos = y + w->y;
|
||||
|
||||
switch(w->type) {
|
||||
case CTK_WIDGET_SEPARATOR:
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
chlinexy(xpos, ypos, w->w);
|
||||
}
|
||||
break;
|
||||
case CTK_WIDGET_LABEL:
|
||||
text = w->widget.label.text;
|
||||
for(i = 0; i < w->h; ++i) {
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
gotoxy(xpos, ypos);
|
||||
cputsn(text, w->w);
|
||||
if(w->w - (wherex() - xpos) > 0) {
|
||||
cclear(w->w - (wherex() - xpos));
|
||||
}
|
||||
}
|
||||
++ypos;
|
||||
text += w->w;
|
||||
}
|
||||
break;
|
||||
case CTK_WIDGET_BUTTON:
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
revers(wfocus != 0);
|
||||
cputcxy(xpos, ypos, '[');
|
||||
cputsn(w->widget.button.text, w->w);
|
||||
cputc(']');
|
||||
revers(0);
|
||||
}
|
||||
break;
|
||||
case CTK_WIDGET_HYPERLINK:
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
revers(wfocus == 0);
|
||||
gotoxy(xpos, ypos);
|
||||
(void)textcolor(WIDGETCOLOR_HLINK);
|
||||
cputsn(w->widget.button.text, w->w);
|
||||
revers(0);
|
||||
}
|
||||
break;
|
||||
case CTK_WIDGET_TEXTENTRY:
|
||||
text = w->widget.textentry.text;
|
||||
xscroll = 0;
|
||||
if(w->widget.textentry.xpos >= w->w - 1) {
|
||||
xscroll = w->widget.textentry.xpos - w->w + 1;
|
||||
}
|
||||
for(j = 0; j < w->h; ++j) {
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
if(w->widget.textentry.state == CTK_TEXTENTRY_EDIT &&
|
||||
w->widget.textentry.ypos == j) {
|
||||
revers(0);
|
||||
cputcxy(xpos, ypos, '>');
|
||||
c = 1;
|
||||
for(i = 0; i < w->w; ++i) {
|
||||
if(c != 0) {
|
||||
c = text[i + xscroll];
|
||||
}
|
||||
revers(i == w->widget.textentry.xpos - xscroll);
|
||||
if(c == 0) {
|
||||
cputc(' ');
|
||||
} else {
|
||||
cputc(c);
|
||||
}
|
||||
}
|
||||
revers(0);
|
||||
cputc('<');
|
||||
} else {
|
||||
revers(wfocus != 0 && j == w->widget.textentry.ypos);
|
||||
cvlinexy(xpos, ypos, 1);
|
||||
gotoxy(xpos + 1, ypos);
|
||||
cputsn(text, w->w);
|
||||
i = wherex();
|
||||
if(i - xpos - 1 < w->w) {
|
||||
cclear(w->w - (i - xpos) + 1);
|
||||
}
|
||||
cvline(1);
|
||||
}
|
||||
}
|
||||
++ypos;
|
||||
text += w->widget.textentry.len + 1;
|
||||
}
|
||||
revers(0);
|
||||
break;
|
||||
case CTK_WIDGET_ICON:
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
revers(wfocus != 0);
|
||||
gotoxy(xpos, ypos);
|
||||
if(w->widget.icon.textmap != NULL) {
|
||||
for(i = 0; i < 3; ++i) {
|
||||
gotoxy(xpos, ypos);
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
cputc(w->widget.icon.textmap[0 + 3 * i]);
|
||||
cputc(w->widget.icon.textmap[1 + 3 * i]);
|
||||
cputc(w->widget.icon.textmap[2 + 3 * i]);
|
||||
}
|
||||
++ypos;
|
||||
}
|
||||
}
|
||||
x = xpos;
|
||||
|
||||
len = (unsigned char)strlen(w->widget.icon.title);
|
||||
if(x + len >= sizex) {
|
||||
x = sizex - len;
|
||||
}
|
||||
|
||||
gotoxy(x, ypos);
|
||||
if(ypos >= clipy1 && ypos < clipy2) {
|
||||
cputs(w->widget.icon.title);
|
||||
}
|
||||
revers(0);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_widget(struct ctk_widget *w,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
struct ctk_window *win = w->window;
|
||||
unsigned char posx, posy;
|
||||
|
||||
posx = win->x + 1;
|
||||
posy = win->y + 2;
|
||||
|
||||
if(w == win->focused) {
|
||||
focus |= CTK_FOCUS_WIDGET;
|
||||
}
|
||||
|
||||
draw_widget(w, posx, posy,
|
||||
posx + win->w,
|
||||
posy + win->h,
|
||||
clipy1, clipy2,
|
||||
focus);
|
||||
|
||||
#ifdef CTK_CONIO_CONF_UPDATE
|
||||
CTK_CONIO_CONF_UPDATE();
|
||||
#endif /* CTK_CONIO_CONF_UPDATE */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_clear_window(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
unsigned char i;
|
||||
unsigned char h;
|
||||
|
||||
if(focus & CTK_FOCUS_WINDOW) {
|
||||
(void)textcolor(WINDOWCOLOR_FOCUS);
|
||||
} else {
|
||||
(void)textcolor(WINDOWCOLOR);
|
||||
}
|
||||
|
||||
h = window->y + 2 + window->h;
|
||||
|
||||
/* Clear window contents. */
|
||||
for(i = window->y + 2; i < h; ++i) {
|
||||
if(i >= clipy1 && i < clipy2) {
|
||||
cclearxy(window->x + 1, i, window->w);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
draw_window_contents(struct ctk_window *window, unsigned char focus,
|
||||
unsigned char clipy1, unsigned char clipy2,
|
||||
unsigned char x1, unsigned char x2,
|
||||
unsigned char y1, unsigned char y2)
|
||||
{
|
||||
struct ctk_widget *w;
|
||||
unsigned char wfocus;
|
||||
|
||||
/* Draw inactive widgets. */
|
||||
for(w = window->inactive; w != NULL; w = w->next) {
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
clipy1, clipy2,
|
||||
focus);
|
||||
}
|
||||
|
||||
/* Draw active widgets. */
|
||||
for(w = window->active; w != NULL; w = w->next) {
|
||||
wfocus = focus;
|
||||
if(w == window->focused) {
|
||||
wfocus |= CTK_FOCUS_WIDGET;
|
||||
}
|
||||
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
clipy1, clipy2,
|
||||
wfocus);
|
||||
}
|
||||
|
||||
#ifdef CTK_CONIO_CONF_UPDATE
|
||||
CTK_CONIO_CONF_UPDATE();
|
||||
#endif /* CTK_CONIO_CONF_UPDATE */
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_window(struct ctk_window *window, unsigned char focus,
|
||||
unsigned char clipy1, unsigned char clipy2,
|
||||
unsigned char draw_borders)
|
||||
{
|
||||
unsigned char x, y;
|
||||
unsigned char h;
|
||||
unsigned char x1, y1, x2, y2;
|
||||
|
||||
if(window->y + 1 >= clipy2) {
|
||||
return;
|
||||
}
|
||||
|
||||
x = window->x;
|
||||
y = window->y + 1;
|
||||
x1 = x + 1;
|
||||
y1 = y + 1;
|
||||
x2 = x1 + window->w;
|
||||
y2 = y1 + window->h;
|
||||
|
||||
if(draw_borders) {
|
||||
|
||||
/* Draw window frame. */
|
||||
if(focus & CTK_FOCUS_WINDOW) {
|
||||
(void)textcolor(WINDOWCOLOR_FOCUS);
|
||||
} else {
|
||||
(void)textcolor(WINDOWCOLOR);
|
||||
}
|
||||
|
||||
if(y >= clipy1) {
|
||||
cputcxy(x, y, CH_ULCORNER);
|
||||
gotoxy(wherex() + window->titlelen + CTK_CONF_WINDOWMOVE * 2, wherey());
|
||||
chline(window->w - (wherex() - x) - 2);
|
||||
cputcxy(x2, y, CH_URCORNER);
|
||||
}
|
||||
|
||||
h = window->h;
|
||||
|
||||
if(clipy1 > y1) {
|
||||
if(clipy1 - y1 < h) {
|
||||
h = clipy1 - y1;
|
||||
y1 = clipy1;
|
||||
} else {
|
||||
h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if(clipy2 < y1 + h) {
|
||||
if(y1 >= clipy2) {
|
||||
h = 0;
|
||||
} else {
|
||||
h = clipy2 - y1;
|
||||
}
|
||||
}
|
||||
|
||||
cvlinexy(x, y1, h);
|
||||
cvlinexy(x2, y1, h);
|
||||
|
||||
if(y + window->h >= clipy1 &&
|
||||
y + window->h < clipy2) {
|
||||
cputcxy(x, y2, CH_LLCORNER);
|
||||
chlinexy(x1, y2, window->w);
|
||||
cputcxy(x2, y2, CH_LRCORNER);
|
||||
}
|
||||
}
|
||||
|
||||
draw_window_contents(window, focus, clipy1, clipy2,
|
||||
x1, x2, y + 1, y2);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_dialog(struct ctk_window *dialog)
|
||||
{
|
||||
unsigned char x, y;
|
||||
unsigned char i;
|
||||
unsigned char x1, y1, x2, y2;
|
||||
|
||||
(void)textcolor(DIALOGCOLOR);
|
||||
|
||||
x = dialog->x;
|
||||
y = dialog->y + 1;
|
||||
|
||||
x1 = x + 1;
|
||||
y1 = y + 1;
|
||||
x2 = x1 + dialog->w;
|
||||
y2 = y1 + dialog->h;
|
||||
|
||||
/* Draw dialog frame. */
|
||||
cvlinexy(x, y1,
|
||||
dialog->h);
|
||||
cvlinexy(x2, y1,
|
||||
dialog->h);
|
||||
|
||||
chlinexy(x1, y,
|
||||
dialog->w);
|
||||
chlinexy(x1, y2,
|
||||
dialog->w);
|
||||
|
||||
cputcxy(x, y, CH_ULCORNER);
|
||||
cputcxy(x, y2, CH_LLCORNER);
|
||||
cputcxy(x2, y, CH_URCORNER);
|
||||
cputcxy(x2, y2, CH_LRCORNER);
|
||||
|
||||
/* Clear dialog contents. */
|
||||
for(i = y1; i < y2; ++i) {
|
||||
cclearxy(x1, i, dialog->w);
|
||||
}
|
||||
|
||||
draw_window_contents(dialog, CTK_FOCUS_DIALOG, 0, sizey,
|
||||
x1, x2, y1, y2);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_clear(unsigned char y1, unsigned char y2)
|
||||
{
|
||||
unsigned char i;
|
||||
|
||||
(void)textcolor(BACKGROUNDCOLOR);
|
||||
for(i = y1; i < y2; ++i) {
|
||||
cclearxy(0, i, sizex);
|
||||
}
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
draw_menu(struct ctk_menu *m, unsigned char open)
|
||||
{
|
||||
unsigned char x, x2, y;
|
||||
|
||||
if(open) {
|
||||
x = x2 = wherex();
|
||||
if(x2 + CTK_CONF_MENUWIDTH > sizex) {
|
||||
x2 = sizex - CTK_CONF_MENUWIDTH;
|
||||
}
|
||||
|
||||
for(y = 0; y < m->nitems; ++y) {
|
||||
if(y == m->active) {
|
||||
(void)textcolor(ACTIVEMENUITEMCOLOR);
|
||||
revers(0);
|
||||
} else {
|
||||
(void)textcolor(MENUCOLOR);
|
||||
revers(1);
|
||||
}
|
||||
gotoxy(x2, y + 1);
|
||||
if(m->items[y].title[0] == '-') {
|
||||
chline(CTK_CONF_MENUWIDTH);
|
||||
} else {
|
||||
cputs(m->items[y].title);
|
||||
}
|
||||
if(x2 + CTK_CONF_MENUWIDTH > wherex()) {
|
||||
cclear(x2 + CTK_CONF_MENUWIDTH - wherex());
|
||||
}
|
||||
}
|
||||
|
||||
gotoxy(x, 0);
|
||||
(void)textcolor(OPENMENUCOLOR);
|
||||
revers(0);
|
||||
}
|
||||
|
||||
cputs(m->title);
|
||||
cputc(' ');
|
||||
(void)textcolor(MENUCOLOR);
|
||||
revers(1);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_menus(struct ctk_menus *menus)
|
||||
{
|
||||
struct ctk_menu *m;
|
||||
|
||||
/* Draw menus */
|
||||
(void)textcolor(MENUCOLOR);
|
||||
gotoxy(0, 0);
|
||||
revers(1);
|
||||
cputc(' ');
|
||||
for(m = menus->menus->next; m != NULL; m = m->next) {
|
||||
draw_menu(m, m == menus->open);
|
||||
}
|
||||
|
||||
/* Draw desktopmenu */
|
||||
if(wherex() + strlen(menus->desktopmenu->title) + 1 >= sizex) {
|
||||
gotoxy(sizex - (unsigned char)strlen(menus->desktopmenu->title) - 1, 0);
|
||||
} else {
|
||||
cclear(sizex - wherex() -
|
||||
(unsigned char)strlen(menus->desktopmenu->title) - 1);
|
||||
}
|
||||
draw_menu(menus->desktopmenu, menus->desktopmenu == menus->open);
|
||||
|
||||
revers(0);
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static unsigned char
|
||||
s_ctk_draw_height(void)
|
||||
{
|
||||
return sizey;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static unsigned char
|
||||
s_ctk_draw_width(void)
|
||||
{
|
||||
return sizex;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
s_ctk_mouse_xtoc(unsigned short x)
|
||||
{
|
||||
return x / 8;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
s_ctk_mouse_ytoc(unsigned short y)
|
||||
{
|
||||
return y / 8;
|
||||
}
|
||||
/*-----------------------------------------------------------------------------------*/
|
||||
|
||||
SERVICE(ctk_conio_service, ctk_draw_service,
|
||||
{ 1,
|
||||
1,
|
||||
1,
|
||||
s_ctk_draw_init,
|
||||
s_ctk_draw_clear,
|
||||
s_ctk_draw_clear_window,
|
||||
s_ctk_draw_window,
|
||||
s_ctk_draw_dialog,
|
||||
s_ctk_draw_widget,
|
||||
s_ctk_draw_menus,
|
||||
s_ctk_draw_width,
|
||||
s_ctk_draw_height,
|
||||
s_ctk_mouse_xtoc,
|
||||
s_ctk_mouse_ytoc });
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
PROCESS(ctk_conio_service_process, "CTK CONIO service");
|
||||
|
||||
PROCESS_THREAD(ctk_conio_service_process, ev, data) {
|
||||
PROCESS_BEGIN();
|
||||
|
||||
s_ctk_draw_init();
|
||||
ctk_restore();
|
||||
|
||||
SERVICE_REGISTER(ctk_conio_service);
|
||||
|
||||
while(ev != PROCESS_EVENT_SERVICE_REMOVED &&
|
||||
ev != PROCESS_EVENT_EXIT) {
|
||||
PROCESS_WAIT_EVENT();
|
||||
}
|
||||
|
||||
SERVICE_REMOVE(ctk_conio_service);
|
||||
|
||||
PROCESS_END();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2006, Swedish Institute of Computer Science.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Oliver Schmidt <ol.sc@web.de>
|
||||
*
|
||||
* $Id: ctk-conio-service.h,v 1.1 2006/08/14 23:36:14 oliverschmidt Exp $
|
||||
*/
|
||||
#ifndef __CTK_CONIO_SERVICE_H__
|
||||
#define __CTK_CONIO_SERVICE_H__
|
||||
|
||||
#include "contiki.h"
|
||||
|
||||
PROCESS_NAME(ctk_conio_service_process);
|
||||
|
||||
#endif /* __CTK_CONIO_SERVICE_H__ */
|
|
@ -1,73 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ctk-draw-service.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __CTK_DRAW_SERVICE_H__
|
||||
#define __CTK_DRAW_SERVICE_H__
|
||||
|
||||
|
||||
#include "ctk/ctk.h"
|
||||
#include "sys/service.h"
|
||||
|
||||
#define ctk_draw_service_name "CTK driver"
|
||||
SERVICE_INTERFACE(ctk_draw_service, {
|
||||
unsigned char windowborder_width;
|
||||
unsigned char windowborder_height;
|
||||
unsigned char windowtitle_height;
|
||||
|
||||
void (* draw_init)(void);
|
||||
void (* draw_clear)(unsigned char clipy1, unsigned char clipy2);
|
||||
void (* draw_clear_window)(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2);
|
||||
void (* draw_window)(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2,
|
||||
unsigned char draw_borders);
|
||||
void (* draw_dialog)(struct ctk_window *dialog);
|
||||
void (* draw_widget)(struct ctk_widget *widget,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2);
|
||||
void (* draw_menus)(struct ctk_menus *menus);
|
||||
|
||||
unsigned char (* width)(void);
|
||||
unsigned char (* height)(void);
|
||||
|
||||
unsigned short (* mouse_xtoc)(unsigned short);
|
||||
unsigned short (* mouse_ytoc)(unsigned short);
|
||||
});
|
||||
|
||||
#endif /* __CTK_DRAW_SERVICE_H__ */
|
|
@ -1,173 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ctk-draw.c,v 1.2 2006/08/13 14:09:46 oliverschmidt Exp $
|
||||
*/
|
||||
|
||||
|
||||
#include "ctk/ctk-draw.h"
|
||||
#include "ctk/ctk.h"
|
||||
|
||||
#include "ctk/ctk-draw-service.h"
|
||||
|
||||
|
||||
unsigned char ctk_draw_windowborder_width = 1,
|
||||
ctk_draw_windowborder_height = 1,
|
||||
ctk_draw_windowtitle_height = 1;
|
||||
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_init(void)
|
||||
{
|
||||
const struct ctk_draw_service *i;
|
||||
struct service *s;
|
||||
|
||||
s = SERVICE_FIND(ctk_draw_service);
|
||||
|
||||
if(s != NULL) {
|
||||
i = s->interface;
|
||||
|
||||
i->draw_init();
|
||||
ctk_draw_windowborder_width = i->windowborder_width;
|
||||
ctk_draw_windowborder_height = i->windowborder_height;
|
||||
ctk_draw_windowtitle_height = i->windowtitle_height;
|
||||
}
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_clear(unsigned char clipy1, unsigned char clipy2)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_clear(clipy1, clipy2));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_clear_window(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_clear_window(window, focus,
|
||||
clipy1, clipy2));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_window(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2,
|
||||
unsigned char draw_borders)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_window(window, focus,
|
||||
clipy1, clipy2, draw_borders));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_dialog(struct ctk_window *dialog)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_dialog(dialog));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_widget(struct ctk_widget *widget,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_widget(widget, focus,
|
||||
clipy1, clipy2));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_menus(struct ctk_menus *menus)
|
||||
{
|
||||
SERVICE_CALL(ctk_draw_service, draw_menus(menus));
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
ctk_draw_width(void)
|
||||
{
|
||||
struct service *s;
|
||||
|
||||
s = SERVICE_FIND(ctk_draw_service);
|
||||
if(s != NULL) {
|
||||
return ((struct ctk_draw_service *)s->interface)->width();
|
||||
}
|
||||
|
||||
return 40;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned char
|
||||
ctk_draw_height(void)
|
||||
{
|
||||
struct service *s;
|
||||
|
||||
s = SERVICE_FIND(ctk_draw_service);
|
||||
if(s != NULL) {
|
||||
return ((struct ctk_draw_service *)s->interface)->height();
|
||||
}
|
||||
|
||||
return 24;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
ctk_mouse_xtoc(unsigned short x)
|
||||
{
|
||||
struct service *s;
|
||||
|
||||
s = SERVICE_FIND(ctk_draw_service);
|
||||
if(s != NULL) {
|
||||
return ((struct ctk_draw_service *)s->interface)->mouse_xtoc(x);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
unsigned short
|
||||
ctk_mouse_ytoc(unsigned short y)
|
||||
{
|
||||
struct service *s;
|
||||
|
||||
s = SERVICE_FIND(ctk_draw_service);
|
||||
if(s != NULL) {
|
||||
return ((struct ctk_draw_service *)s->interface)->mouse_ytoc(y);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
||||
void
|
||||
ctk_draw_quit(void)
|
||||
{
|
||||
/* process_post(service.id, EK_EVENT_REQUEST_EXIT, NULL);*/
|
||||
/* process_service_reset(&service); */
|
||||
}
|
||||
/*---------------------------------------------------------------------------*/
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. Neither the name of the Institute nor the names of its contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* Author: Adam Dunkels <adam@sics.se>
|
||||
*
|
||||
* $Id: ctk-graphic-draw.h,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
|
||||
*/
|
||||
#ifndef __CTK_GRAPHIC_DRAW_H__
|
||||
#define __CTK_GRAPHIC_DRAW_H__
|
||||
|
||||
enum {
|
||||
CTK_GRAPHIC_DRAW_FONT_NORMAL,
|
||||
CTK_GRAPHIC_DRAW_FONT_BOLD,
|
||||
CTK_GRAPHIC_DRAW_FONT_MENU,
|
||||
CTK_GRAPHIC_DRAW_FONT_MONOSPACE,
|
||||
CTK_GRAPHIC_DRAW_FONT_MONOSPACE_BOLD,
|
||||
};
|
||||
|
||||
enum {
|
||||
CTK_GRAPHIC_DRAW_COLOR_WHITE,
|
||||
CTK_GRAPHIC_DRAW_COLOR_LIGHTGRAY,
|
||||
CTK_GRAPHIC_DRAW_COLOR_MIDGRAY,
|
||||
CTK_GRAPHIC_DRAW_COLOR_DARKGRAY,
|
||||
CTK_GRAPHIC_DRAW_COLOR_BLACK,
|
||||
CTK_GRAPHIC_DRAW_COLOR_BLUE,
|
||||
}
|
||||
|
||||
/*struct ctk_graphic_draw_font;
|
||||
|
||||
extern struct ctk_graphic_draw_font ctk_graphic_draw_font_normal,
|
||||
ctk_graphic_draw_font_bold,
|
||||
ctk_graphic_draw_font_menu,
|
||||
ctk_graphic_draw_font_monospace,
|
||||
ctk_graphic_draw_font_monospace_bold;
|
||||
|
||||
struct ctk_graphic_draw_color;
|
||||
|
||||
extern struct ctk_graphic_draw_color ctk_graphic_draw_color_white,
|
||||
ctk_graphic_draw_color_lightgray,
|
||||
ctk_graphic_draw_color_midgray,
|
||||
ctk_graphic_draw_color_darkgray,
|
||||
ctk_graphic_draw_color_ddarkgray,
|
||||
ctk_graphic_draw_color_black,
|
||||
ctk_graphic_draw_color_blue;
|
||||
*/
|
||||
|
||||
void ctk_graphic_draw_init(void);
|
||||
|
||||
int ctk_graphic_draw_string_width(unsigned char font,
|
||||
char *str, unsigned char monospace);
|
||||
|
||||
void ctk_graphic_draw_string(unsigned char font,
|
||||
unsigned char color,
|
||||
unsigned int x,
|
||||
unsigned int y,
|
||||
char *str,
|
||||
unsigned char monospace);
|
||||
|
||||
void ctk_graphic_draw_line(unsigned char color,
|
||||
unsigned int x1, unsigned int y1,
|
||||
unsigned int x2, unsigned int y2);
|
||||
|
||||
void ctk_graphic_draw_rect(unsigned char color,
|
||||
unsigned char filled,
|
||||
unsigned int x1, unsigned int y1,
|
||||
unsigned int width, unsigned int height);
|
||||
|
||||
|
||||
#endif /* __CTK_GRAPHIC_DRAW_H__ */
|
|
@ -1,809 +0,0 @@
|
|||
/*
|
||||
* Copyright (c) 2004, Adam Dunkels.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials provided
|
||||
* with the distribution.
|
||||
* 3. The name of the author may not be used to endorse or promote
|
||||
* products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
|
||||
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
|
||||
* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* This file is part of the Contiki operating system.
|
||||
*
|
||||
* $Id: ctk-graphic.c,v 1.1 2006/06/17 22:41:15 adamdunkels Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
#include "ctk-draw-service.h"
|
||||
|
||||
#include "ctk-graphic-draw.h"
|
||||
|
||||
#include "ctk-graphic.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
||||
#define WINDOWBORDER_WIDTH 1
|
||||
#define WINDOWBORDER_HEIGHT 1
|
||||
#define WINDOWTITLE_HEIGHT 3
|
||||
#define MENU_HEIGHT 1
|
||||
#define MENUBAR_HEIGHT 12
|
||||
|
||||
#define FONT_BASELINE 12
|
||||
|
||||
#define MENUBAR_FONT_BASELINE 7
|
||||
|
||||
#define RASTER_X 8
|
||||
#define RASTER_Y 14
|
||||
|
||||
#define BUTTON_HEIGHT 12
|
||||
#define BUTTON_X_BORDER 4
|
||||
#define BUTTON_Y_BORDER 1
|
||||
|
||||
#define TEXTENTRY_HEIGHT 12
|
||||
#define TEXTENTRY_X_BORDER 4
|
||||
#define TEXTENTRY_Y_BORDER 1
|
||||
|
||||
static GdkGC *white, *lightgray, *midgray, *darkgray, *ddarkgray, *black,
|
||||
*blue;
|
||||
|
||||
static GdkPixbuf *background, *windowborder, *menubar;
|
||||
|
||||
static void
|
||||
draw_widget(struct ctk_widget *w,
|
||||
unsigned char winx,
|
||||
unsigned char winy,
|
||||
unsigned char clipx,
|
||||
unsigned char clipy,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2,
|
||||
unsigned char focus);
|
||||
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_init(void)
|
||||
{
|
||||
GtkWidget *image;
|
||||
|
||||
image = gtk_image_new_from_file("background.png");
|
||||
background = gtk_image_get_pixbuf(GTK_IMAGE(image));
|
||||
|
||||
image = gtk_image_new_from_file("windowborder.png");
|
||||
windowborder = gtk_image_get_pixbuf(GTK_IMAGE(image));
|
||||
|
||||
image = gtk_image_new_from_file("menubar.png");
|
||||
menubar = gtk_image_get_pixbuf(GTK_IMAGE(image));
|
||||
|
||||
ctk_graphic_draw_init();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_clear(unsigned char y1, unsigned char y2)
|
||||
{
|
||||
if(background == NULL) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
TRUE,
|
||||
0,
|
||||
y1 * RASTER_Y + MENUBAR_HEIGHT,
|
||||
CTK_GTKSIM_SCREEN_WIDTH,
|
||||
(y2 - y1) * RASTER_Y);
|
||||
} else {
|
||||
gdk_draw_pixbuf(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
background,
|
||||
0,
|
||||
y1 * RASTER_Y,
|
||||
0,
|
||||
y1 * RASTER_Y + MENUBAR_HEIGHT,
|
||||
CTK_GTKSIM_SCREEN_WIDTH,
|
||||
(y2 - y1) * RASTER_Y,
|
||||
NULL, 0, 0);
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_clear_window(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
int x, y;
|
||||
|
||||
x = window->x;
|
||||
y = window->y + MENU_HEIGHT;
|
||||
|
||||
/* Clear window */
|
||||
if(focus == CTK_FOCUS_WINDOW) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
x * RASTER_X - 1,
|
||||
y * RASTER_Y - 1 + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X + 2,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y + 2);
|
||||
} else {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
lightgray,
|
||||
TRUE,
|
||||
x * RASTER_X - 1,
|
||||
y * RASTER_Y - 1 + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X + 2,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y + 2);
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_window(struct ctk_window *window,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
struct ctk_widget *w;
|
||||
unsigned char wfocus;
|
||||
int x, y, x1, y1, x2, y2;
|
||||
|
||||
x = window->x;
|
||||
y = window->y + MENU_HEIGHT;
|
||||
|
||||
x1 = x + WINDOWBORDER_WIDTH;
|
||||
y1 = y + WINDOWTITLE_HEIGHT;
|
||||
x2 = x1 + window->w;
|
||||
y2 = y1 + window->h;
|
||||
|
||||
/* Draw window border */
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
FALSE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y);
|
||||
|
||||
if(ctk_mode_get() == CTK_MODE_WINDOWMOVE) {
|
||||
if(focus == CTK_FOCUS_WINDOW) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
x * RASTER_X + 1,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT + 1,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X - 2,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y - 2);
|
||||
} else {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
midgray,
|
||||
TRUE,
|
||||
x * RASTER_X + 1,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT + 1,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X - 2,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y - 2);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if(windowborder == NULL) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
midgray,
|
||||
TRUE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X,
|
||||
WINDOWTITLE_HEIGHT * RASTER_Y);
|
||||
} else {
|
||||
gdk_draw_pixbuf(ctk_gtksim_pixmap,
|
||||
midgray,
|
||||
windowborder,
|
||||
0, 0,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X,
|
||||
WINDOWTITLE_HEIGHT * RASTER_Y,
|
||||
NULL, 0, 0);
|
||||
}
|
||||
|
||||
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
x * RASTER_X,
|
||||
(y + WINDOWTITLE_HEIGHT) * RASTER_Y - 1 + MENUBAR_HEIGHT,
|
||||
(x + window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X,
|
||||
(y + WINDOWTITLE_HEIGHT) * RASTER_Y - 1 + MENUBAR_HEIGHT);
|
||||
|
||||
|
||||
/* Draw inactive widgets. */
|
||||
for(w = window->inactive; w != NULL; w = w->next) {
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
clipy1, clipy2,
|
||||
focus);
|
||||
}
|
||||
|
||||
/* Draw active widgets. */
|
||||
for(w = window->active; w != NULL; w = w->next) {
|
||||
wfocus = focus;
|
||||
if(w == window->focused) {
|
||||
wfocus |= CTK_FOCUS_WIDGET;
|
||||
}
|
||||
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
clipy1, clipy2,
|
||||
wfocus);
|
||||
}
|
||||
|
||||
ctk_gtksim_set_redrawflag();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_dialog(struct ctk_window *window)
|
||||
{
|
||||
struct ctk_widget *w;
|
||||
unsigned char wfocus, focus;
|
||||
int x, y, x1, y1, x2, y2;
|
||||
|
||||
focus = CTK_FOCUS_DIALOG;
|
||||
|
||||
x = window->x;
|
||||
y = window->y + MENU_HEIGHT;
|
||||
|
||||
x1 = x + WINDOWBORDER_WIDTH;
|
||||
y1 = y + WINDOWTITLE_HEIGHT;
|
||||
x2 = x1 + window->w;
|
||||
y2 = y1 + window->h;
|
||||
|
||||
/* Draw window border */
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
black,
|
||||
FALSE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y);
|
||||
|
||||
|
||||
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
x * RASTER_X + 1,
|
||||
y * RASTER_Y + 1 + MENUBAR_HEIGHT,
|
||||
(window->w + 2 * WINDOWBORDER_WIDTH) * RASTER_X - 2,
|
||||
(window->h + WINDOWTITLE_HEIGHT +
|
||||
WINDOWBORDER_HEIGHT) * RASTER_Y - 2);
|
||||
|
||||
/* Draw inactive widgets. */
|
||||
for(w = window->inactive; w != NULL; w = w->next) {
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
y1, y2,
|
||||
focus);
|
||||
}
|
||||
|
||||
/* Draw active widgets. */
|
||||
for(w = window->active; w != NULL; w = w->next) {
|
||||
wfocus = focus;
|
||||
if(w == window->focused) {
|
||||
wfocus |= CTK_FOCUS_WIDGET;
|
||||
}
|
||||
|
||||
draw_widget(w, x1, y1, x2, y2,
|
||||
y1, y2,
|
||||
wfocus);
|
||||
}
|
||||
|
||||
ctk_gtksim_set_redrawflag();
|
||||
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
draw_widget(struct ctk_widget *w,
|
||||
unsigned char winx, unsigned char winy,
|
||||
unsigned char clipx,
|
||||
unsigned char clipy,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2,
|
||||
unsigned char focus)
|
||||
{
|
||||
char text[1000];
|
||||
unsigned char x, y;
|
||||
int width, xpos;
|
||||
int i;
|
||||
GdkGC *bgcol, *buttoncol;
|
||||
struct ctk_gtksim_draw_font *buttonfont, *textfont, *textfont_bold;
|
||||
int monospace;
|
||||
|
||||
x = winx + w->x;
|
||||
y = winy + w->y;
|
||||
|
||||
if(focus & CTK_FOCUS_WINDOW) {
|
||||
bgcol = white;
|
||||
} else {
|
||||
bgcol = lightgray;
|
||||
}
|
||||
|
||||
if(focus & CTK_FOCUS_WINDOW) {
|
||||
buttoncol = lightgray;
|
||||
} else {
|
||||
buttoncol = midgray;
|
||||
}
|
||||
|
||||
monospace = w->flags & CTK_WIDGET_FLAG_MONOSPACE;
|
||||
if(monospace) {
|
||||
textfont = &ctk_gtksim_draw_font_monospace;
|
||||
textfont_bold = &ctk_gtksim_draw_font_monospace_bold;
|
||||
} else {
|
||||
textfont = &ctk_gtksim_draw_font_normal;
|
||||
textfont_bold = &ctk_gtksim_draw_font_bold;
|
||||
}
|
||||
|
||||
switch(w->type) {
|
||||
case CTK_WIDGET_SEPARATOR:
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + RASTER_Y / 2 + MENUBAR_HEIGHT,
|
||||
(x + w->w) * RASTER_X,
|
||||
y * RASTER_Y + RASTER_Y / 2 + MENUBAR_HEIGHT);
|
||||
break;
|
||||
case CTK_WIDGET_LABEL:
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
bgcol,
|
||||
TRUE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X,
|
||||
w->h * RASTER_Y);
|
||||
for(i = 0; i < w->h; ++i) {
|
||||
strncpy(text, &w->widget.label.text[i * w->w], w->w);
|
||||
text[w->w] = 0;
|
||||
ctk_gtksim_draw_string(textfont,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
RASTER_X * x,
|
||||
RASTER_Y * (y + i) + MENUBAR_HEIGHT,
|
||||
text, monospace);
|
||||
}
|
||||
|
||||
break;
|
||||
case CTK_WIDGET_BUTTON:
|
||||
if(w == (struct ctk_widget *)&w->window->titlebutton) {
|
||||
buttonfont = &ctk_gtksim_draw_font_bold;
|
||||
} else {
|
||||
buttonfont = textfont;
|
||||
}
|
||||
|
||||
++x;
|
||||
|
||||
width = ctk_gtksim_draw_string_width(buttonfont,
|
||||
w->widget.button.text,
|
||||
monospace);
|
||||
if(focus == (CTK_FOCUS_WIDGET|CTK_FOCUS_WINDOW)) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
black,
|
||||
FALSE,
|
||||
x * RASTER_X - BUTTON_X_BORDER,
|
||||
y * RASTER_Y - BUTTON_Y_BORDER + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X + BUTTON_X_BORDER * 2,
|
||||
BUTTON_HEIGHT + BUTTON_Y_BORDER);
|
||||
/* gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
ctk_gtksim_drawing_area->style->black_gc,
|
||||
FALSE,
|
||||
x * RASTER_X - BUTTON_X_BORDER - 1,
|
||||
y * RASTER_Y - BUTTON_Y_BORDER - 1,
|
||||
w->w * RASTER_X + BUTTON_X_BORDER * 2 + 1,
|
||||
RASTER_Y + BUTTON_Y_BORDER * 2 + 1);*/
|
||||
} else {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
FALSE,
|
||||
x * RASTER_X - BUTTON_X_BORDER,
|
||||
y * RASTER_Y - BUTTON_Y_BORDER + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X + BUTTON_X_BORDER * 2,
|
||||
BUTTON_HEIGHT + BUTTON_Y_BORDER);
|
||||
}
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
buttoncol,
|
||||
TRUE,
|
||||
x * RASTER_X - BUTTON_X_BORDER + 1,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X + BUTTON_X_BORDER * 2 - 2,
|
||||
BUTTON_HEIGHT);
|
||||
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
ddarkgray,
|
||||
x * RASTER_X - BUTTON_X_BORDER + 1,
|
||||
y * RASTER_Y + BUTTON_HEIGHT - 1 + MENUBAR_HEIGHT,
|
||||
x * RASTER_X + w->w * RASTER_X + BUTTON_X_BORDER - 1,
|
||||
y * RASTER_Y + BUTTON_HEIGHT - 1 + MENUBAR_HEIGHT);
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
ddarkgray,
|
||||
x * RASTER_X + w->w * RASTER_X + BUTTON_X_BORDER - 1,
|
||||
y * RASTER_Y + BUTTON_HEIGHT - 1 + MENUBAR_HEIGHT,
|
||||
x * RASTER_X + w->w * RASTER_X + BUTTON_X_BORDER - 1,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT);
|
||||
|
||||
ctk_gtksim_draw_string(buttonfont,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
RASTER_X * x +
|
||||
(w->w * RASTER_X) / 2 - width / 2,
|
||||
RASTER_Y * y + MENUBAR_HEIGHT,
|
||||
w->widget.button.text,
|
||||
monospace);
|
||||
break;
|
||||
case CTK_WIDGET_HYPERLINK:
|
||||
strncpy(text, w->widget.hyperlink.text, w->w);
|
||||
text[w->w] = 0;
|
||||
width = ctk_gtksim_draw_string_width(textfont, text, monospace);
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
bgcol,
|
||||
TRUE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
width,
|
||||
RASTER_Y);
|
||||
if(focus & CTK_FOCUS_WIDGET) {
|
||||
ctk_gtksim_draw_string(textfont_bold,
|
||||
&ctk_gtksim_draw_color_blue,
|
||||
RASTER_X * x,
|
||||
RASTER_Y * y + MENUBAR_HEIGHT,
|
||||
text, monospace);
|
||||
} else {
|
||||
ctk_gtksim_draw_string(textfont,
|
||||
&ctk_gtksim_draw_color_blue,
|
||||
RASTER_X * x,
|
||||
RASTER_Y * y + MENUBAR_HEIGHT,
|
||||
text, monospace);
|
||||
}
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
blue,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + FONT_BASELINE + 1 + MENUBAR_HEIGHT,
|
||||
x * RASTER_X + width,
|
||||
y * RASTER_Y + FONT_BASELINE + 1 + MENUBAR_HEIGHT);
|
||||
|
||||
break;
|
||||
case CTK_WIDGET_TEXTENTRY:
|
||||
strncpy(text, w->widget.textentry.text, sizeof(text));
|
||||
text[w->widget.textentry.xpos] = 0;
|
||||
width = ctk_gtksim_draw_string_width(textfont, text, monospace);
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
FALSE,
|
||||
x * RASTER_X - TEXTENTRY_X_BORDER + RASTER_X,
|
||||
y * RASTER_Y - TEXTENTRY_Y_BORDER + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X + TEXTENTRY_X_BORDER * 2 - 1,
|
||||
TEXTENTRY_HEIGHT + TEXTENTRY_Y_BORDER);
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
bgcol,
|
||||
TRUE,
|
||||
x * RASTER_X + RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
w->w * RASTER_X,
|
||||
TEXTENTRY_HEIGHT);
|
||||
ctk_gtksim_draw_string(textfont,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
RASTER_X * x + RASTER_X,
|
||||
RASTER_Y * y + MENUBAR_HEIGHT,
|
||||
w->widget.textentry.text,
|
||||
monospace);
|
||||
if(focus == (CTK_FOCUS_WIDGET|CTK_FOCUS_WINDOW)) {
|
||||
gdk_draw_line(ctk_gtksim_pixmap,
|
||||
black,
|
||||
x * RASTER_X + width + RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
x * RASTER_X + width + RASTER_X,
|
||||
y * RASTER_Y + TEXTENTRY_HEIGHT - 1 + MENUBAR_HEIGHT);
|
||||
}
|
||||
break;
|
||||
case CTK_WIDGET_ICON:
|
||||
width = ctk_gtksim_draw_string_width(&ctk_gtksim_draw_font_normal,
|
||||
w->widget.icon.title, monospace);
|
||||
|
||||
if(x * RASTER_X + width >= CTK_GTKSIM_SCREEN_WIDTH - RASTER_X) {
|
||||
xpos = CTK_GTKSIM_SCREEN_WIDTH - width - RASTER_X;
|
||||
} else {
|
||||
xpos = x * RASTER_X;
|
||||
}
|
||||
if((focus & CTK_FOCUS_WIDGET) == 0) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
bgcol,
|
||||
TRUE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
24, 24);
|
||||
} else {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
black,
|
||||
TRUE,
|
||||
x * RASTER_X,
|
||||
y * RASTER_Y + MENUBAR_HEIGHT,
|
||||
24, 24);
|
||||
}
|
||||
|
||||
/* gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
xpos,
|
||||
RASTER_Y * y + 24 + 1 + MENUBAR_HEIGHT,
|
||||
width,
|
||||
RASTER_Y);*/
|
||||
|
||||
ctk_gtksim_draw_string(textfont,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
xpos + 1,
|
||||
RASTER_Y * y + 24 + 1 + MENUBAR_HEIGHT,
|
||||
w->widget.icon.title,
|
||||
monospace);
|
||||
ctk_gtksim_draw_string(textfont,
|
||||
&ctk_gtksim_draw_color_white,
|
||||
xpos,
|
||||
RASTER_Y * y + 24 + MENUBAR_HEIGHT,
|
||||
w->widget.icon.title,
|
||||
monospace);
|
||||
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_widget(struct ctk_widget *w,
|
||||
unsigned char focus,
|
||||
unsigned char clipy1,
|
||||
unsigned char clipy2)
|
||||
{
|
||||
struct ctk_window *win = w->window;
|
||||
unsigned char posx, posy;
|
||||
|
||||
posx = win->x + WINDOWBORDER_WIDTH;
|
||||
posy = win->y + WINDOWTITLE_HEIGHT + MENU_HEIGHT;
|
||||
|
||||
if(w == win->focused) {
|
||||
focus |= CTK_FOCUS_WIDGET;
|
||||
}
|
||||
|
||||
draw_widget(w, posx, posy,
|
||||
posx + win->w,
|
||||
posy + win->h,
|
||||
clipy1, clipy2,
|
||||
focus);
|
||||
|
||||
ctk_gtksim_set_redrawflag();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
draw_menu(struct ctk_menu *m, int x, int open)
|
||||
{
|
||||
int i;
|
||||
int xpos;
|
||||
|
||||
if(x >= CTK_GTKSIM_SCREEN_WIDTH / RASTER_X - 16) {
|
||||
xpos = CTK_GTKSIM_SCREEN_WIDTH / RASTER_X - 16;
|
||||
} else {
|
||||
xpos = x;
|
||||
}
|
||||
|
||||
if(open) {
|
||||
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
black,
|
||||
TRUE,
|
||||
RASTER_X * x, 0,
|
||||
m->titlelen * RASTER_X,
|
||||
RASTER_Y + MENUBAR_HEIGHT);
|
||||
|
||||
ctk_gtksim_draw_string(&ctk_gtksim_draw_font_menu,
|
||||
&ctk_gtksim_draw_color_white,
|
||||
RASTER_X * x + 2,
|
||||
MENUBAR_FONT_BASELINE,
|
||||
m->title, 0);
|
||||
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
xpos * RASTER_X,
|
||||
RASTER_Y * MENU_HEIGHT + MENUBAR_HEIGHT,
|
||||
(xpos + 16) * RASTER_X,
|
||||
(m->nitems) * RASTER_Y);
|
||||
|
||||
for(i = 0; i < m->nitems; ++i) {
|
||||
if(i == m->active) {
|
||||
gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
black,
|
||||
TRUE,
|
||||
RASTER_X * xpos,
|
||||
(MENU_HEIGHT + i) * RASTER_Y + MENUBAR_HEIGHT,
|
||||
(xpos + 16) * RASTER_X,
|
||||
RASTER_Y);
|
||||
ctk_gtksim_draw_string(&ctk_gtksim_draw_font_normal,
|
||||
&ctk_gtksim_draw_color_white,
|
||||
RASTER_X * xpos + 2,
|
||||
(MENU_HEIGHT + i) * RASTER_Y +
|
||||
MENUBAR_HEIGHT,
|
||||
m->items[i].title, 0);
|
||||
|
||||
} else {
|
||||
ctk_gtksim_draw_string(&ctk_gtksim_draw_font_normal,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
RASTER_X * xpos + 2,
|
||||
(MENU_HEIGHT + i) * RASTER_Y + MENUBAR_HEIGHT,
|
||||
m->items[i].title, 0);
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
/* gdk_draw_rectangle(ctk_gtksim_pixmap,
|
||||
white,
|
||||
TRUE,
|
||||
RASTER_X * x, 0,
|
||||
m->titlelen * RASTER_X, RASTER_Y);*/
|
||||
|
||||
ctk_gtksim_draw_string(&ctk_gtksim_draw_font_menu,
|
||||
&ctk_gtksim_draw_color_black,
|
||||
RASTER_X * x, MENUBAR_FONT_BASELINE,
|
||||
m->title, 0);
|
||||
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static void
|
||||
s_ctk_draw_menus(struct ctk_menus *menus)
|
||||
{
|
||||
struct ctk_menu *m;
|
||||
int x;
|
||||
|
||||
if(menubar != NULL) {
|
||||
gdk_draw_pixbuf(ctk_gtksim_pixmap,
|
||||
darkgray,
|
||||
menubar,
|
||||
0, 0,
|
||||
0, 0,
|
||||
CTK_GTKSIM_SCREEN_WIDTH,
|
||||
RASTER_Y + MENUBAR_HEIGHT,
|
||||
NULL, 0, 0);
|
||||
}
|
||||
|
||||
x = 1;
|
||||
for(m = menus->menus->next; m != NULL; m = m->next) {
|
||||
draw_menu(m, x, m == menus->open);
|
||||
x += strlen(m->title);
|
||||
}
|
||||
|
||||
x = CTK_GTKSIM_SCREEN_WIDTH / RASTER_X - strlen(menus->menus->title);
|
||||
draw_menu(menus->menus, x, menus->menus == menus->open);
|
||||
|
||||
|
||||
|
||||
/* gdk_draw_line(ctk_gtksim_pixmap,
|
||||
ctk_gtksim_drawing_area->style->black_gc,
|
||||
0, RASTER_Y,
|
||||
CTK_GTKSIM_SCREEN_WIDTH,
|
||||
RASTER_Y);*/
|
||||
|
||||
ctk_gtksim_set_redrawflag();
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static unsigned char
|
||||
s_ctk_draw_width(void)
|
||||
{
|
||||
return CTK_GTKSIM_SCREEN_WIDTH / RASTER_X;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static unsigned char
|
||||
s_ctk_draw_height(void)
|
||||
{
|
||||
return CTK_GTKSIM_SCREEN_HEIGHT / RASTER_Y;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
s_ctk_mouse_xtoc(unsigned short x)
|
||||
{
|
||||
return x / RASTER_X;
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static unsigned short
|
||||
s_ctk_mouse_ytoc(unsigned short y)
|
||||
{
|
||||
if(y < MENUBAR_HEIGHT) {
|
||||
return 0;
|
||||
} else {
|
||||
return (y - MENUBAR_HEIGHT) / RASTER_Y;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static const struct ctk_draw_service_interface interface =
|
||||
{CTK_DRAW_SERVICE_VERSION,
|
||||
WINDOWBORDER_WIDTH,
|
||||
WINDOWBORDER_HEIGHT,
|
||||
WINDOWTITLE_HEIGHT,
|
||||
s_ctk_draw_init,
|
||||
s_ctk_draw_clear,
|
||||
s_ctk_draw_clear_window,
|
||||
s_ctk_draw_window,
|
||||
s_ctk_draw_dialog,
|
||||
s_ctk_draw_widget,
|
||||
s_ctk_draw_menus,
|
||||
s_ctk_draw_width,
|
||||
s_ctk_draw_height,
|
||||
s_ctk_mouse_xtoc,
|
||||
s_ctk_mouse_ytoc,
|
||||
};
|
||||
|
||||
EK_EVENTHANDLER(eventhandler, ev, data);
|
||||
EK_PROCESS(proc, CTK_DRAW_SERVICE_NAME, EK_PRIO_NORMAL,
|
||||
eventhandler, NULL, (void *)&interface);
|
||||
|
||||
/*--------------------------------------------------------------------------*/
|
||||
EK_PROCESS_INIT(ctk_gtksim_service_init, arg)
|
||||
{
|
||||
ek_service_start(CTK_DRAW_SERVICE_NAME, &proc);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static GdkGC *
|
||||
get_color(unsigned short r, unsigned short g, unsigned short b)
|
||||
{
|
||||
GdkGCValues values;
|
||||
GdkColor color;
|
||||
|
||||
color.pixel = 0;
|
||||
color.red = r;
|
||||
color.green = g;
|
||||
color.blue = b;
|
||||
|
||||
if(gdk_colormap_alloc_color(gdk_colormap_get_system(),
|
||||
&color, FALSE, TRUE)) {
|
||||
}
|
||||
|
||||
values.foreground = color;
|
||||
|
||||
return gdk_gc_new_with_values(ctk_gtksim_drawing_area->window,
|
||||
&values,
|
||||
GDK_GC_FOREGROUND);
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
EK_EVENTHANDLER(eventhandler, ev, data)
|
||||
{
|
||||
EK_EVENTHANDLER_ARGS(ev, data);
|
||||
|
||||
switch(ev) {
|
||||
case EK_EVENT_INIT:
|
||||
blue = get_color(0, 0, 0xffff);
|
||||
white = get_color(0xffff, 0xffff, 0xffff);
|
||||
lightgray = get_color(0xefff, 0xefff, 0xefff);
|
||||
midgray = get_color(0xdfff, 0xdfff, 0xdfff);
|
||||
darkgray = get_color(0xcfff, 0xcfff, 0xcfff);
|
||||
ddarkgray = get_color(0xafff, 0xafff, 0xafff);
|
||||
black = get_color(0, 0, 0);
|
||||
break;
|
||||
case EK_EVENT_REQUEST_REPLACE:
|
||||
ek_replace((struct ek_proc *)data, NULL);
|
||||
LOADER_UNLOAD();
|
||||
break;
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue