Now jtheme is a class with member functions; and jwidget has a virtual msg_proc.

This commit is contained in:
David Capello 2009-11-19 02:59:20 +00:00
parent 33ca3cf8e0
commit 6d04c3815c
36 changed files with 309 additions and 339 deletions

View File

@ -148,7 +148,7 @@ void ConfigureTools::execute(Context* context)
/* brush-preview */ /* brush-preview */
if (first_time) { if (first_time) {
brush_preview = jwidget_new(JI_WIDGET); brush_preview = new jwidget(JI_WIDGET);
brush_preview->min_w = 32 + 4; brush_preview->min_w = 32 + 4;
brush_preview->min_h = 32 + 4; brush_preview->min_h = 32 + 4;

View File

@ -200,7 +200,7 @@ void switch_between_animation_and_sprite_editor()
static JWidget anieditor_new(const Sprite* sprite) static JWidget anieditor_new(const Sprite* sprite)
{ {
JWidget widget = jwidget_new(anieditor_type()); JWidget widget = new jwidget(anieditor_type());
AniEditor* anieditor = new AniEditor; AniEditor* anieditor = new AniEditor;
anieditor->sprite = sprite; anieditor->sprite = sprite;

View File

@ -152,7 +152,7 @@ void dialogs_tips(bool forced)
static JWidget tips_new() static JWidget tips_new()
{ {
JWidget widget = jwidget_new(tips_type()); JWidget widget = new jwidget(tips_type());
jwidget_add_hook(widget, tips_type(), tips_msg_proc, NULL); jwidget_add_hook(widget, tips_type(), tips_msg_proc, NULL);
jwidget_focusrest(widget, TRUE); jwidget_focusrest(widget, TRUE);

View File

@ -72,7 +72,7 @@ struct jlist;
union jmessage; union jmessage;
struct jrect; struct jrect;
struct jregion; struct jregion;
struct jtheme; class jtheme;
class jwidget; class jwidget;
/* alignment */ /* alignment */
@ -232,7 +232,7 @@ typedef union jmessage* JMessage;
typedef struct jstream* JStream; typedef struct jstream* JStream;
typedef struct jrect* JRect; typedef struct jrect* JRect;
typedef struct jregion* JRegion; typedef struct jregion* JRegion;
typedef struct jtheme* JTheme; typedef class jtheme* JTheme;
typedef class jwidget* JWidget; typedef class jwidget* JWidget;
typedef struct jxml* JXml; typedef struct jxml* JXml;
typedef struct jxmlattr* JXmlAttr; typedef struct jxmlattr* JXmlAttr;

View File

@ -37,6 +37,7 @@
#include "jinete/jmessage.h" #include "jinete/jmessage.h"
#include "jinete/jrect.h" #include "jinete/jrect.h"
#include "jinete/jwidget.h" #include "jinete/jwidget.h"
#include "jinete/jtheme.h"
static bool box_msg_proc(JWidget widget, JMessage msg); static bool box_msg_proc(JWidget widget, JMessage msg);
static void box_request_size(JWidget widget, int *w, int *h); static void box_request_size(JWidget widget, int *w, int *h);
@ -44,7 +45,7 @@ static void box_set_position(JWidget widget, JRect rect);
JWidget jbox_new(int align) JWidget jbox_new(int align)
{ {
JWidget widget = jwidget_new(JI_BOX); JWidget widget = new jwidget(JI_BOX);
jwidget_add_hook(widget, JI_BOX, box_msg_proc, NULL); jwidget_add_hook(widget, JI_BOX, box_msg_proc, NULL);
jwidget_set_align(widget, align); jwidget_set_align(widget, align);
@ -55,7 +56,7 @@ JWidget jbox_new(int align)
static bool box_msg_proc(JWidget widget, JMessage msg) static bool box_msg_proc(JWidget widget, JMessage msg)
{ {
switch(msg->type) { switch (msg->type) {
case JM_REQSIZE: case JM_REQSIZE:
box_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); box_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
@ -64,6 +65,11 @@ static bool box_msg_proc(JWidget widget, JMessage msg)
case JM_SETPOS: case JM_SETPOS:
box_set_position(widget, &msg->setpos.rect); box_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_box(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -57,6 +57,7 @@ typedef struct ButtonCommand
typedef struct Button typedef struct Button
{ {
/* generic */ /* generic */
int draw_type;
BITMAP *icon; BITMAP *icon;
int icon_align; int icon_align;
/* button */ /* button */
@ -77,11 +78,10 @@ JWidget ji_generic_button_new(const char *text,
int behavior_type, int behavior_type,
int draw_type) int draw_type)
{ {
JWidget widget = jwidget_new(behavior_type); JWidget widget = new jwidget(behavior_type);
Button *button = jnew(Button, 1); Button *button = jnew(Button, 1);
widget->draw_type = draw_type; button->draw_type = draw_type;
button->icon = NULL; button->icon = NULL;
button->icon_align = JI_LEFT | JI_MIDDLE; button->icon_align = JI_LEFT | JI_MIDDLE;
button->commands = jlist_new(); button->commands = jlist_new();
@ -95,7 +95,11 @@ JWidget ji_generic_button_new(const char *text,
jwidget_set_align(widget, JI_CENTER | JI_MIDDLE); jwidget_set_align(widget, JI_CENTER | JI_MIDDLE);
jwidget_set_text(widget, text); jwidget_set_text(widget, text);
jwidget_focusrest(widget, true); jwidget_focusrest(widget, true);
// initialize theme
widget->type = button->draw_type;
jwidget_init_theme(widget); jwidget_init_theme(widget);
widget->type = behavior_type;
return widget; return widget;
} }
@ -264,6 +268,16 @@ static bool button_msg_proc(JWidget widget, JMessage msg)
button_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); button_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
return true; return true;
case JM_DRAW: {
Button* button = reinterpret_cast<Button*>(jwidget_get_data(widget, widget->type));
switch (button->draw_type) {
case JI_BUTTON: widget->theme->draw_button(widget, &msg->draw.rect); break;
case JI_CHECK: widget->theme->draw_check(widget, &msg->draw.rect); break;
case JI_RADIO: widget->theme->draw_radio(widget, &msg->draw.rect); break;
}
return true;
}
case JM_SIGNAL: case JM_SIGNAL:
if (widget->type == JI_RADIO) { if (widget->type == JI_RADIO) {
if (msg->signal.num == JI_SIGNAL_SELECT) { if (msg->signal.num == JI_SIGNAL_SELECT) {
@ -458,7 +472,7 @@ static void button_request_size(JWidget widget, int *w, int *h)
int icon_w = 0; int icon_w = 0;
int icon_h = 0; int icon_h = 0;
switch (widget->draw_type) { switch (button->draw_type) {
case JI_BUTTON: case JI_BUTTON:
if (button->icon) { if (button->icon) {

View File

@ -72,7 +72,7 @@ static void comboitem_free(ComboItem *item);
JWidget jcombobox_new() JWidget jcombobox_new()
{ {
JWidget widget = jwidget_new(JI_COMBOBOX); JWidget widget = new jwidget(JI_COMBOBOX);
ComboBox *combobox = jnew(ComboBox, 1); ComboBox *combobox = jnew(ComboBox, 1);
combobox->entry = jentry_new(256, ""); combobox->entry = jentry_new(256, "");

View File

@ -91,7 +91,7 @@ static void entry_backward_word(JWidget widget);
JWidget jentry_new(size_t maxsize, const char *format, ...) JWidget jentry_new(size_t maxsize, const char *format, ...)
{ {
JWidget widget = jwidget_new(JI_ENTRY); JWidget widget = new jwidget(JI_ENTRY);
Entry* entry = (Entry*)jnew(Entry, 1); Entry* entry = (Entry*)jnew(Entry, 1);
char buf[4096]; char buf[4096];
@ -264,6 +264,10 @@ static bool entry_msg_proc(JWidget widget, JMessage msg)
entry_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); entry_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
return true; return true;
case JM_DRAW:
widget->theme->draw_entry(widget, &msg->draw.rect);
return true;
case JM_TIMER: case JM_TIMER:
if (jwidget_has_focus(widget) && if (jwidget_has_focus(widget) &&
msg->timer.timer_id == entry->timer_id) { msg->timer.timer_id == entry->timer_id) {

View File

@ -40,6 +40,7 @@
#include "jinete/jmessage.h" #include "jinete/jmessage.h"
#include "jinete/jrect.h" #include "jinete/jrect.h"
#include "jinete/jwidget.h" #include "jinete/jwidget.h"
#include "jinete/jtheme.h"
struct Cell struct Cell
{ {
@ -79,7 +80,7 @@ static void grid_inc_row_size(Grid *grid, int row, int size);
JWidget jgrid_new(int columns, bool same_width_columns) JWidget jgrid_new(int columns, bool same_width_columns)
{ {
JWidget widget = jwidget_new(JI_GRID); JWidget widget = new jwidget(JI_GRID);
Grid *grid = jnew(Grid, 1); Grid *grid = jnew(Grid, 1);
int col; int col;
@ -173,6 +174,10 @@ static bool grid_msg_proc(JWidget widget, JMessage msg)
grid_set_position(widget, &msg->setpos.rect); grid_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_grid(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -45,7 +45,7 @@ static bool image_msg_proc(JWidget widget, JMessage msg);
JWidget jimage_new(BITMAP *bmp, int align) JWidget jimage_new(BITMAP *bmp, int align)
{ {
JWidget widget = jwidget_new(JI_IMAGE); JWidget widget = new jwidget(JI_IMAGE);
jwidget_add_hook(widget, JI_IMAGE, image_msg_proc, bmp); jwidget_add_hook(widget, JI_IMAGE, image_msg_proc, bmp);
jwidget_set_align(widget, align); jwidget_set_align(widget, align);

View File

@ -49,12 +49,6 @@ bool _ji_is_valid_widget(JWidget widget);
void _ji_set_font_of_all_widgets(struct FONT *f); void _ji_set_font_of_all_widgets(struct FONT *f);
//////////////////////////////////////////////////////////////////////
// jwidget.c
void _jwidget_add_hook(JWidget widget, JHook hook);
void _jwidget_remove_hook(JWidget widget, JHook hook);
////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////
// jwindow.c // jwindow.c

View File

@ -39,7 +39,7 @@ static bool label_msg_proc(JWidget widget, JMessage msg);
JWidget jlabel_new(const char *text) JWidget jlabel_new(const char *text)
{ {
JWidget widget = jwidget_new(JI_LABEL); JWidget widget = new jwidget(JI_LABEL);
jwidget_add_hook(widget, JI_LABEL, label_msg_proc, NULL); jwidget_add_hook(widget, JI_LABEL, label_msg_proc, NULL);
jwidget_set_align(widget, JI_LEFT | JI_MIDDLE); jwidget_set_align(widget, JI_LEFT | JI_MIDDLE);
@ -64,6 +64,10 @@ static bool label_msg_proc(JWidget widget, JMessage msg)
msg->reqsize.w += widget->border_width.l + widget->border_width.r; msg->reqsize.w += widget->border_width.l + widget->border_width.r;
msg->reqsize.h += widget->border_width.t + widget->border_width.b; msg->reqsize.h += widget->border_width.t + widget->border_width.b;
return true; return true;
case JM_DRAW:
widget->theme->draw_label(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -52,7 +52,7 @@ static void listitem_request_size(JWidget widget, int *w, int *h);
JWidget jlistbox_new() JWidget jlistbox_new()
{ {
JWidget widget = jwidget_new(JI_LISTBOX); JWidget widget = new jwidget(JI_LISTBOX);
jwidget_add_hook(widget, JI_LISTBOX, listbox_msg_proc, NULL); jwidget_add_hook(widget, JI_LISTBOX, listbox_msg_proc, NULL);
jwidget_focusrest(widget, true); jwidget_focusrest(widget, true);
@ -63,7 +63,7 @@ JWidget jlistbox_new()
JWidget jlistitem_new(const char *text) JWidget jlistitem_new(const char *text)
{ {
JWidget widget = jwidget_new(JI_LISTITEM); JWidget widget = new jwidget(JI_LISTITEM);
jwidget_add_hook(widget, JI_LISTITEM, listitem_msg_proc, NULL); jwidget_add_hook(widget, JI_LISTITEM, listitem_msg_proc, NULL);
jwidget_set_align(widget, JI_LEFT | JI_MIDDLE); jwidget_set_align(widget, JI_LEFT | JI_MIDDLE);
@ -176,6 +176,10 @@ static bool listbox_msg_proc(JWidget widget, JMessage msg)
listbox_set_position(widget, &msg->setpos.rect); listbox_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_listbox(widget, &msg->draw.rect);
return true;
case JM_DIRTYCHILDREN: case JM_DIRTYCHILDREN:
listbox_dirty_children(widget); listbox_dirty_children(widget);
return true; return true;
@ -407,6 +411,10 @@ static bool listitem_msg_proc(JWidget widget, JMessage msg)
jrect_free(crect); jrect_free(crect);
return true; return true;
} }
case JM_DRAW:
widget->theme->draw_listitem(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -192,7 +192,7 @@ JWidget jmanager_new()
n_timers = 0; n_timers = 0;
} }
widget = jwidget_new(JI_MANAGER); widget = new jwidget(JI_MANAGER);
jwidget_add_hook(widget, JI_MANAGER, manager_msg_proc, NULL); jwidget_add_hook(widget, JI_MANAGER, manager_msg_proc, NULL);

View File

@ -154,7 +154,7 @@ static JWidget find_previtem(JWidget menu, JWidget menuitem);
JWidget jmenu_new() JWidget jmenu_new()
{ {
JWidget widget = jwidget_new(JI_MENU); JWidget widget = new jwidget(JI_MENU);
Menu *menu = jnew(Menu, 1); Menu *menu = jnew(Menu, 1);
menu->menuitem = NULL; menu->menuitem = NULL;
@ -179,7 +179,7 @@ JWidget jmenubar_new()
JWidget jmenubox_new() JWidget jmenubox_new()
{ {
JWidget widget = jwidget_new(JI_MENUBOX); JWidget widget = new jwidget(JI_MENUBOX);
MenuBox *menubox = jnew(MenuBox, 1); MenuBox *menubox = jnew(MenuBox, 1);
menubox->base = NULL; menubox->base = NULL;
@ -193,7 +193,7 @@ JWidget jmenubox_new()
JWidget jmenuitem_new(const char *text) JWidget jmenuitem_new(const char *text)
{ {
JWidget widget = jwidget_new(JI_MENUITEM); JWidget widget = new jwidget(JI_MENUITEM);
MenuItem *menuitem = jnew(MenuItem, 1); MenuItem *menuitem = jnew(MenuItem, 1);
menuitem->accel = NULL; menuitem->accel = NULL;
@ -396,6 +396,10 @@ static bool menu_msg_proc(JWidget widget, JMessage msg)
menu_set_position(widget, &msg->setpos.rect); menu_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_menu(widget, &msg->draw.rect);
return true;
} }
return false; return false;
@ -822,6 +826,10 @@ static bool menuitem_msg_proc(JWidget widget, JMessage msg)
menuitem_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); menuitem_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
return true; return true;
case JM_DRAW:
widget->theme->draw_menuitem(widget, &msg->draw.rect);
return true;
case JM_MOUSEENTER: case JM_MOUSEENTER:
case JM_MOUSELEAVE: case JM_MOUSELEAVE:
/* TODO theme specific!! */ /* TODO theme specific!! */

View File

@ -49,7 +49,7 @@ static void panel_set_position(JWidget widget, JRect rect);
JWidget jpanel_new(int align) JWidget jpanel_new(int align)
{ {
JWidget widget = jwidget_new(JI_PANEL); JWidget widget = new jwidget(JI_PANEL);
Panel *panel = jnew(Panel, 1); Panel *panel = jnew(Panel, 1);
jwidget_add_hook(widget, JI_PANEL, panel_msg_proc, panel); jwidget_add_hook(widget, JI_PANEL, panel_msg_proc, panel);
@ -97,6 +97,10 @@ static bool panel_msg_proc(JWidget widget, JMessage msg)
panel_set_position(widget, &msg->setpos.rect); panel_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_panel(widget, &msg->draw.rect);
return true;
case JM_BUTTONPRESSED: case JM_BUTTONPRESSED:
if (jwidget_is_enabled(widget)) { if (jwidget_is_enabled(widget)) {
JWidget c1, c2; JWidget c1, c2;

View File

@ -41,7 +41,7 @@ static bool separator_msg_proc(JWidget widget, JMessage msg);
JWidget ji_separator_new(const char *text, int align) JWidget ji_separator_new(const char *text, int align)
{ {
JWidget widget = jwidget_new(JI_SEPARATOR); JWidget widget = new jwidget(JI_SEPARATOR);
jwidget_add_hook(widget, JI_SEPARATOR, separator_msg_proc, NULL); jwidget_add_hook(widget, JI_SEPARATOR, separator_msg_proc, NULL);
jwidget_set_align(widget, align); jwidget_set_align(widget, align);
@ -77,6 +77,10 @@ static bool separator_msg_proc(JWidget widget, JMessage msg)
msg->reqsize.h = widget->border_width.t + max_h + widget->border_width.b; msg->reqsize.h = widget->border_width.t + max_h + widget->border_width.b;
return true; return true;
} }
case JM_DRAW:
widget->theme->draw_separator(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -58,7 +58,7 @@ static void slider_setcursor(JWidget widget);
JWidget jslider_new(int min, int max, int value) JWidget jslider_new(int min, int max, int value)
{ {
JWidget widget = jwidget_new(JI_SLIDER); JWidget widget = new jwidget(JI_SLIDER);
Slider *slider = jnew(Slider, 1); Slider *slider = jnew(Slider, 1);
slider->min = min; slider->min = min;
@ -126,6 +126,10 @@ static bool slider_msg_proc(JWidget widget, JMessage msg)
slider_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); slider_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
return true; return true;
case JM_DRAW:
widget->theme->draw_slider(widget, &msg->draw.rect);
return true;
case JM_FOCUSENTER: case JM_FOCUSENTER:
case JM_FOCUSLEAVE: case JM_FOCUSLEAVE:
if (jwidget_is_enabled(widget)) if (jwidget_is_enabled(widget))

View File

@ -258,12 +258,12 @@ int jmouse_set_cursor(int type)
else { else {
show_mouse(NULL); show_mouse(NULL);
if (theme->set_cursor) { {
BITMAP *sprite; BITMAP *sprite;
int x = 0; int x = 0;
int y = 0; int y = 0;
sprite = (*theme->set_cursor)(type, &x, &y); sprite = theme->set_cursor(type, &x, &y);
set_cursor(sprite, x, y); set_cursor(sprite, x, y);
} }

View File

@ -49,7 +49,7 @@ static void textbox_request_size(JWidget widget, int *w, int *h);
JWidget jtextbox_new(const char *text, int align) JWidget jtextbox_new(const char *text, int align)
{ {
JWidget widget = jwidget_new(JI_TEXTBOX); JWidget widget = new jwidget(JI_TEXTBOX);
jwidget_add_hook(widget, JI_TEXTBOX, textbox_msg_proc, NULL); jwidget_add_hook(widget, JI_TEXTBOX, textbox_msg_proc, NULL);
jwidget_focusrest(widget, true); jwidget_focusrest(widget, true);
@ -69,6 +69,10 @@ static bool textbox_msg_proc(JWidget widget, JMessage msg)
textbox_request_size(widget, &msg->reqsize.w, &msg->reqsize.h); textbox_request_size(widget, &msg->reqsize.w, &msg->reqsize.h);
return true; return true;
case JM_DRAW:
widget->theme->draw_textbox(widget, &msg->draw.rect);
return true;
case JM_SIGNAL: case JM_SIGNAL:
if (msg->signal.num == JI_SIGNAL_SET_TEXT) { if (msg->signal.num == JI_SIGNAL_SET_TEXT) {
JWidget view = jwidget_get_view(widget); JWidget view = jwidget_get_view(widget);

View File

@ -57,73 +57,27 @@ int _ji_theme_init()
void _ji_theme_exit() void _ji_theme_exit()
{ {
if (ji_standard_theme) { if (ji_standard_theme) {
jtheme_free(ji_standard_theme); delete ji_standard_theme;
ji_standard_theme = NULL; ji_standard_theme = NULL;
} }
} }
JTheme jtheme_new() jtheme::jtheme()
{ {
JTheme theme = (JTheme)jmalloc(sizeof(struct jtheme)); this->name = "Theme";
if (!theme) this->default_font = font; /* default Allegro font */
return NULL; this->desktop_color = 0;
this->textbox_fg_color = 0;
theme->name = "Theme"; this->textbox_bg_color = 0;
theme->default_font = font; /* default Allegro font */ this->check_icon_size = 0;
theme->desktop_color = 0; this->radio_icon_size = 0;
theme->textbox_fg_color = 0; this->scrollbar_size = 0;
theme->textbox_bg_color = 0;
theme->check_icon_size = 0;
theme->radio_icon_size = 0;
theme->scrollbar_size = 0;
theme->destroy = NULL;
theme->regen = NULL;
theme->set_cursor = NULL;
theme->init_widget = NULL;
theme->get_window_mask = NULL;
theme->map_decorative_widget = NULL;
theme->nmethods = 0;
theme->methods = NULL;
return theme;
} }
void jtheme_free(JTheme theme) jtheme::~jtheme()
{ {
if (theme->destroy) if (ji_current_theme == this)
(*theme->destroy)();
if (ji_current_theme == theme)
ji_set_theme(NULL); ji_set_theme(NULL);
if (theme->methods)
jfree(theme->methods);
jfree(theme);
}
void jtheme_set_method(JTheme theme, int widget_type, JDrawFunc draw_widget)
{
if (widget_type >= theme->nmethods) {
int c, old_nmethods = theme->nmethods;
theme->nmethods = widget_type+1;
theme->methods = (JDrawFunc*)jrealloc(theme->methods,
sizeof(JDrawFunc) * theme->nmethods);
for (c=old_nmethods; c<theme->nmethods; c++)
theme->methods[c] = NULL;
}
theme->methods[widget_type] = draw_widget;
}
JDrawFunc jtheme_get_method(JTheme theme, int widget_type)
{
if (theme->methods && widget_type >= 0 && widget_type < theme->nmethods)
return theme->methods[widget_type];
else
return NULL;
} }
/**********************************************************************/ /**********************************************************************/
@ -137,7 +91,6 @@ void ji_set_theme(JTheme theme)
if (ji_current_theme) { if (ji_current_theme) {
ji_regen_theme(); ji_regen_theme();
/* TODO any better idea? */
if (manager && jwidget_get_theme(manager) == NULL) if (manager && jwidget_get_theme(manager) == NULL)
jwidget_set_theme(manager, theme); jwidget_set_theme(manager, theme);
} }
@ -162,44 +115,28 @@ JTheme ji_get_theme()
void ji_regen_theme() void ji_regen_theme()
{ {
if (ji_current_theme) { if (ji_current_theme) {
/* hide the cursor */
/* if () { */
/* show_mouse(NULL); */
/* set_mouse_sprite(NULL); */
/* } */
int type = jmouse_get_cursor(); int type = jmouse_get_cursor();
jmouse_set_cursor(JI_CURSOR_NULL); jmouse_set_cursor(JI_CURSOR_NULL);
if (ji_current_theme->regen) ji_current_theme->regen();
(*ji_current_theme->regen)();
/* ok, reset the mouse cursor */
jmouse_set_cursor(type); jmouse_set_cursor(type);
} }
} }
int ji_color_foreground() int ji_color_foreground()
{ {
if (ji_current_theme && ji_current_theme->color_foreground) return ji_current_theme->color_foreground();
return (*ji_current_theme->color_foreground)();
else
return makecol(0, 0, 0);
} }
int ji_color_disabled() int ji_color_disabled()
{ {
if (ji_current_theme && ji_current_theme->color_disabled) return ji_current_theme->color_disabled();
return (*ji_current_theme->color_disabled)();
else
return makecol(128, 128, 128);
} }
int ji_color_face() int ji_color_face()
{ {
if (ji_current_theme && ji_current_theme->color_face) return ji_current_theme->color_face();
return (*ji_current_theme->color_face)();
else
return makecol(255, 255, 255);
} }
int ji_color_facelight() int ji_color_facelight()
@ -220,26 +157,17 @@ int ji_color_faceshadow()
int ji_color_hotface() int ji_color_hotface()
{ {
if (ji_current_theme && ji_current_theme->color_hotface) return ji_current_theme->color_hotface();
return (*ji_current_theme->color_hotface)();
else
return makecol(255, 255, 255);
} }
int ji_color_selected() int ji_color_selected()
{ {
if (ji_current_theme && ji_current_theme->color_selected) return ji_current_theme->color_selected();
return (*ji_current_theme->color_selected)();
else
return makecol(0, 0, 255);
} }
int ji_color_background() int ji_color_background()
{ {
if (ji_current_theme && ji_current_theme->color_background) return ji_current_theme->color_background();
return (*ji_current_theme->color_background)();
else
return makecol(255, 255, 255);
} }
void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite, void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite,

View File

@ -37,41 +37,57 @@
struct FONT; struct FONT;
struct BITMAP; struct BITMAP;
struct jtheme class jtheme
{ {
const char *name; public:
struct FONT *default_font; const char* name;
struct FONT* default_font;
int desktop_color; int desktop_color;
int textbox_fg_color; int textbox_fg_color;
int textbox_bg_color; int textbox_bg_color;
int check_icon_size; int check_icon_size;
int radio_icon_size; int radio_icon_size;
int scrollbar_size; int scrollbar_size;
void (*destroy)();
void (*regen)(); jtheme();
struct BITMAP *(*set_cursor)(int type, int *focus_x, int *focus_y); virtual ~jtheme();
void (*init_widget)(JWidget widget);
JRegion (*get_window_mask)(JWidget widget); virtual void regen() = 0;
void (*map_decorative_widget)(JWidget widget); virtual BITMAP* set_cursor(int type, int *focus_x, int *focus_y) = 0;
int (*color_foreground)(); virtual void init_widget(JWidget widget) = 0;
int (*color_disabled)(); virtual JRegion get_window_mask(JWidget widget) = 0;
int (*color_face)(); virtual void map_decorative_widget(JWidget widget) = 0;
int (*color_hotface)();
int (*color_selected)(); virtual int color_foreground() = 0;
int (*color_background)(); virtual int color_disabled() = 0;
int nmethods; virtual int color_face() = 0;
JDrawFunc *methods; virtual int color_hotface() = 0;
virtual int color_selected() = 0;
virtual int color_background() = 0;
virtual void draw_box(JWidget widget, JRect clip) = 0;
virtual void draw_button(JWidget widget, JRect clip) = 0;
virtual void draw_check(JWidget widget, JRect clip) = 0;
virtual void draw_entry(JWidget widget, JRect clip) = 0;
virtual void draw_grid(JWidget widget, JRect clip) = 0;
virtual void draw_label(JWidget widget, JRect clip) = 0;
virtual void draw_listbox(JWidget widget, JRect clip) = 0;
virtual void draw_listitem(JWidget widget, JRect clip) = 0;
virtual void draw_menu(JWidget widget, JRect clip) = 0;
virtual void draw_menuitem(JWidget widget, JRect clip) = 0;
virtual void draw_panel(JWidget widget, JRect clip) = 0;
virtual void draw_radio(JWidget widget, JRect clip) = 0;
virtual void draw_separator(JWidget widget, JRect clip) = 0;
virtual void draw_slider(JWidget widget, JRect clip) = 0;
virtual void draw_textbox(JWidget widget, JRect clip) = 0;
virtual void draw_view(JWidget widget, JRect clip) = 0;
virtual void draw_view_scrollbar(JWidget widget, JRect clip) = 0;
virtual void draw_view_viewport(JWidget widget, JRect clip) = 0;
virtual void draw_window(JWidget widget, JRect clip) = 0;
}; };
JTheme jtheme_new();
JTheme jtheme_new_standard(); JTheme jtheme_new_standard();
JTheme jtheme_new_simple();
void jtheme_free(JTheme theme);
void jtheme_set_method(JTheme theme, int widget_type, JDrawFunc draw_widget);
JDrawFunc jtheme_get_method(JTheme theme, int widget_type);
/* current theme handle */
void ji_set_theme(JTheme theme); void ji_set_theme(JTheme theme);
void ji_set_standard_theme(); void ji_set_standard_theme();

View File

@ -73,7 +73,7 @@ static void displace_widgets(JWidget widget, int x, int y);
JWidget jview_new() JWidget jview_new()
{ {
JWidget widget = jwidget_new(JI_VIEW); JWidget widget = new jwidget(JI_VIEW);
View *view = jnew(View, 1); View *view = jnew(View, 1);
view->viewport = viewport_new(); view->viewport = viewport_new();
@ -374,6 +374,10 @@ static bool view_msg_proc(JWidget widget, JMessage msg)
} }
return true; return true;
case JM_DRAW:
widget->theme->draw_view(widget, &msg->draw.rect);
return true;
case JM_FOCUSENTER: case JM_FOCUSENTER:
case JM_FOCUSLEAVE: case JM_FOCUSLEAVE:
/* TODO add something to avoid this (theme specific stuff) */ /* TODO add something to avoid this (theme specific stuff) */
@ -391,7 +395,7 @@ static bool view_msg_proc(JWidget widget, JMessage msg)
static JWidget viewport_new() static JWidget viewport_new()
{ {
JWidget widget = jwidget_new(JI_VIEW_VIEWPORT); JWidget widget = new jwidget(JI_VIEW_VIEWPORT);
jwidget_add_hook(widget, JI_VIEW_VIEWPORT, viewport_msg_proc, NULL); jwidget_add_hook(widget, JI_VIEW_VIEWPORT, viewport_msg_proc, NULL);
jwidget_init_theme(widget); jwidget_init_theme(widget);
@ -411,6 +415,10 @@ static bool viewport_msg_proc(JWidget widget, JMessage msg)
case JM_SETPOS: case JM_SETPOS:
viewport_set_position(widget, &msg->setpos.rect); viewport_set_position(widget, &msg->setpos.rect);
return true; return true;
case JM_DRAW:
widget->theme->draw_view_viewport(widget, &msg->draw.rect);
return true;
} }
return false; return false;
@ -468,7 +476,7 @@ static void viewport_set_position(JWidget widget, JRect rect)
static JWidget scrollbar_new(int align) static JWidget scrollbar_new(int align)
{ {
JWidget widget = jwidget_new(JI_VIEW_SCROLLBAR); JWidget widget = new jwidget(JI_VIEW_SCROLLBAR);
jwidget_add_hook(widget, JI_VIEW_SCROLLBAR, scrollbar_msg_proc, NULL); jwidget_add_hook(widget, JI_VIEW_SCROLLBAR, scrollbar_msg_proc, NULL);
jwidget_set_align(widget, align); jwidget_set_align(widget, align);
@ -601,6 +609,10 @@ static bool scrollbar_msg_proc(JWidget widget, JMessage msg)
/* TODO add something to avoid this (theme specific stuff) */ /* TODO add something to avoid this (theme specific stuff) */
jwidget_invalidate(widget); jwidget_invalidate(widget);
break; break;
case JM_DRAW:
widget->theme->draw_view_scrollbar(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -57,12 +57,6 @@ int ji_register_widget_type()
return type++; return type++;
} }
/* creates a new widget with an unique JID */
JWidget jwidget_new(int type)
{
return new jwidget(type);
}
jwidget::jwidget(int type) jwidget::jwidget(int type)
{ {
_ji_add_widget(this); _ji_add_widget(this);
@ -85,8 +79,6 @@ jwidget::jwidget(int type)
this->parent = NULL; this->parent = NULL;
this->theme = ji_get_theme(); this->theme = ji_get_theme();
this->hooks = jlist_new(); this->hooks = jlist_new();
this->draw_type = type;
this->draw_method = NULL;
this->m_align = 0; this->m_align = 0;
this->m_text = ""; this->m_text = "";
@ -104,8 +96,6 @@ jwidget::jwidget(int type)
this->user_data[1] = NULL; this->user_data[1] = NULL;
this->user_data[2] = NULL; this->user_data[2] = NULL;
this->user_data[3] = NULL; this->user_data[3] = NULL;
jwidget_add_hook(this, JI_WIDGET, widget_msg_proc, NULL);
} }
void jwidget_free(JWidget widget) void jwidget_free(JWidget widget)
@ -177,17 +167,12 @@ void jwidget_init_theme(JWidget widget)
assert_valid_widget(widget); assert_valid_widget(widget);
if (widget->theme) { if (widget->theme) {
if (!widget->draw_method) widget->theme->init_widget(widget);
widget->draw_method = jtheme_get_method(widget->theme, widget->draw_type);
if (widget->theme->init_widget) { if (!(widget->flags & JI_INITIALIZED))
(*widget->theme->init_widget)(widget); widget->flags |= JI_INITIALIZED;
if (!(widget->flags & JI_INITIALIZED)) jwidget_emit_signal(widget, JI_SIGNAL_INIT_THEME);
widget->flags |= JI_INITIALIZED;
jwidget_emit_signal(widget, JI_SIGNAL_INIT_THEME);
}
} }
} }
@ -245,20 +230,6 @@ void *jwidget_get_data(JWidget widget, int type)
return NULL; return NULL;
} }
void _jwidget_add_hook(JWidget widget, JHook hook)
{
assert_valid_widget(widget);
jlist_prepend(widget->hooks, hook);
}
void _jwidget_remove_hook(JWidget widget, JHook hook)
{
assert_valid_widget(widget);
jlist_remove(widget->hooks, hook);
}
/**********************************************************************/ /**********************************************************************/
/* main properties */ /* main properties */
@ -821,8 +792,8 @@ JRegion jwidget_get_region(JWidget widget)
assert_valid_widget(widget); assert_valid_widget(widget);
if ((widget->type == JI_WINDOW) && (widget->theme->get_window_mask)) if (widget->type == JI_WINDOW)
region = (*widget->theme->get_window_mask)(widget); region = widget->theme->get_window_mask(widget);
else else
region = jregion_new(widget->rc, 1); region = jregion_new(widget->rc, 1);
@ -1359,6 +1330,9 @@ bool jwidget_send_message(JWidget widget, JMessage msg)
SENDMSG(); SENDMSG();
} }
if (!done)
done = widget->msg_proc(msg);
return done; return done;
} }
@ -1510,8 +1484,10 @@ bool jwidget_check_underscored(JWidget widget, int scancode)
/**********************************************************************/ /**********************************************************************/
/* widget message procedure */ /* widget message procedure */
static bool widget_msg_proc(JWidget widget, JMessage msg) bool jwidget::msg_proc(JMessage msg)
{ {
JWidget widget = this;
assert(msg != NULL); assert(msg != NULL);
assert_valid_widget(widget); assert_valid_widget(widget);
@ -1529,10 +1505,7 @@ static bool widget_msg_proc(JWidget widget, JMessage msg)
} }
case JM_DRAW: case JM_DRAW:
if (widget->draw_method) { // do nothing
(*widget->draw_method)(widget, &msg->draw.rect);
return true;
}
break; break;
case JM_REQSIZE: case JM_REQSIZE:

View File

@ -49,7 +49,6 @@ struct BITMAP;
int ji_register_widget_type(); int ji_register_widget_type();
JWidget jwidget_new(int type);
void jwidget_free(JWidget widget); void jwidget_free(JWidget widget);
void jwidget_free_deferred(JWidget widget); void jwidget_free_deferred(JWidget widget);
@ -210,9 +209,6 @@ public:
/* virtual properties */ /* virtual properties */
JList hooks; /* hooks with msg_proc and specific data */ JList hooks; /* hooks with msg_proc and specific data */
int draw_type;
JDrawFunc draw_method; /* virtual method to draw the widget
(the default msg_proc uses it) */
/* common widget properties */ /* common widget properties */
private: private:
@ -266,6 +262,9 @@ public:
struct FONT* font(); struct FONT* font();
void font(struct FONT* font); void font(struct FONT* font);
/**
* Gets the background color of the widget.
*/
int bg_color() int bg_color()
{ {
if (m_bg_color < 0 && parent) if (m_bg_color < 0 && parent)
@ -274,12 +273,17 @@ public:
return m_bg_color; return m_bg_color;
} }
/**
* Sets the background color of the widget.
*/
void bg_color(int bg_color) void bg_color(int bg_color)
{ {
m_bg_color = bg_color; m_bg_color = bg_color;
} }
// Returns a widget in the same window that is located "sibling". /**
* Returns a widget in the same window that is located "sibling".
*/
inline JWidget find_sibling(const char* name) inline JWidget find_sibling(const char* name)
{ {
return jwidget_find_name(jwidget_get_window(this), name); return jwidget_find_name(jwidget_get_window(this), name);
@ -287,6 +291,8 @@ public:
void dirty() { jwidget_dirty(this); } void dirty() { jwidget_dirty(this); }
virtual bool msg_proc(JMessage msg);
}; };
#endif #endif

View File

@ -269,7 +269,7 @@ bool jwindow_is_wantfocus(JWidget widget)
static JWidget window_new(bool desktop, const char *text) static JWidget window_new(bool desktop, const char *text)
{ {
JWidget widget = jwidget_new(JI_WINDOW); JWidget widget = new jwidget(JI_WINDOW);
Window *window = jnew(Window, 1); Window *window = jnew(Window, 1);
window->killer = NULL; window->killer = NULL;
@ -461,6 +461,10 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
} }
break; break;
case JM_DRAW:
widget->theme->draw_window(widget, &msg->draw.rect);
return true;
} }
return false; return false;

View File

@ -92,109 +92,81 @@ static struct {
{ false, default_theme_icombobox }, { false, default_theme_icombobox },
}; };
static BITMAP *icons_bitmap[ICONS]; class jstandard_theme : public jtheme
{
BITMAP *icons_bitmap[ICONS];
static void theme_destroy(); public:
static void theme_regen(); jstandard_theme();
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y); ~jstandard_theme();
static void theme_init_widget(JWidget widget);
static JRegion theme_get_window_mask(JWidget widget);
static void theme_map_decorative_widget(JWidget widget);
static int theme_color_foreground();
static int theme_color_disabled();
static int theme_color_face();
static int theme_color_hotface();
static int theme_color_selected();
static int theme_color_background();
static void theme_draw_box(JWidget widget, JRect clip);
static void theme_draw_button(JWidget widget, JRect clip);
static void theme_draw_check(JWidget widget, JRect clip);
static void theme_draw_entry(JWidget widget, JRect clip);
static void theme_draw_grid(JWidget widget, JRect clip);
static void theme_draw_label(JWidget widget, JRect clip);
static void theme_draw_listbox(JWidget widget, JRect clip);
static void theme_draw_listitem(JWidget widget, JRect clip);
static void theme_draw_menu(JWidget widget, JRect clip);
static void theme_draw_menuitem(JWidget widget, JRect clip);
static void theme_draw_panel(JWidget widget, JRect clip);
static void theme_draw_radio(JWidget widget, JRect clip);
static void theme_draw_separator(JWidget widget, JRect clip);
static void theme_draw_slider(JWidget widget, JRect clip);
static void theme_draw_textbox(JWidget widget, JRect clip);
static void theme_draw_view(JWidget widget, JRect clip);
static void theme_draw_view_scrollbar(JWidget widget, JRect clip);
static void theme_draw_view_viewport(JWidget widget, JRect clip);
static void theme_draw_window(JWidget widget, JRect clip);
static int get_bg_color(JWidget widget); void regen();
static void draw_textstring(const char *t, int fg_color, int bg_color, BITMAP *set_cursor(int type, int *focus_x, int *focus_y);
bool fill_bg, JWidget widget, const JRect rect, void init_widget(JWidget widget);
int selected_offset); JRegion get_window_mask(JWidget widget);
static void draw_entry_cursor(JWidget widget, int x, int y); void map_decorative_widget(JWidget widget);
static void draw_icons(int x, int y, JWidget widget, int edge_icon);
static void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel); int color_foreground();
static void less_bevel(int *bevel); int color_disabled();
int color_face();
int color_hotface();
int color_selected();
int color_background();
void draw_box(JWidget widget, JRect clip);
void draw_button(JWidget widget, JRect clip);
void draw_check(JWidget widget, JRect clip);
void draw_entry(JWidget widget, JRect clip);
void draw_grid(JWidget widget, JRect clip);
void draw_label(JWidget widget, JRect clip);
void draw_listbox(JWidget widget, JRect clip);
void draw_listitem(JWidget widget, JRect clip);
void draw_menu(JWidget widget, JRect clip);
void draw_menuitem(JWidget widget, JRect clip);
void draw_panel(JWidget widget, JRect clip);
void draw_radio(JWidget widget, JRect clip);
void draw_separator(JWidget widget, JRect clip);
void draw_slider(JWidget widget, JRect clip);
void draw_textbox(JWidget widget, JRect clip);
void draw_view(JWidget widget, JRect clip);
void draw_view_scrollbar(JWidget widget, JRect clip);
void draw_view_viewport(JWidget widget, JRect clip);
void draw_window(JWidget widget, JRect clip);
private:
int get_bg_color(JWidget widget);
void draw_textstring(const char *t, int fg_color, int bg_color,
bool fill_bg, JWidget widget, const JRect rect,
int selected_offset);
void draw_entry_cursor(JWidget widget, int x, int y);
void draw_icons(int x, int y, JWidget widget, int edge_icon);
void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel);
void less_bevel(int *bevel);
};
static bool theme_button_msg_proc(JWidget widget, JMessage msg); static bool theme_button_msg_proc(JWidget widget, JMessage msg);
JTheme jtheme_new_standard() JTheme jtheme_new_standard()
{ {
JTheme theme; return new jstandard_theme();
int c;
theme = jtheme_new();
if (!theme)
return NULL;
for (c=0; c<ICONS; c++)
icons_bitmap[c] = NULL;
theme->name = "Standard Theme";
theme->check_icon_size = 8;
theme->radio_icon_size = 8;
theme->scrollbar_size = 12;
theme->destroy = theme_destroy;
theme->regen = theme_regen;
theme->set_cursor = theme_set_cursor;
theme->init_widget = theme_init_widget;
theme->get_window_mask = theme_get_window_mask;
theme->map_decorative_widget = theme_map_decorative_widget;
theme->color_foreground = theme_color_foreground;
theme->color_disabled = theme_color_disabled;
theme->color_face = theme_color_face;
theme->color_hotface = theme_color_hotface;
theme->color_selected = theme_color_selected;
theme->color_background = theme_color_background;
jtheme_set_method(theme, JI_BOX, theme_draw_box);
jtheme_set_method(theme, JI_BUTTON, theme_draw_button);
jtheme_set_method(theme, JI_CHECK, theme_draw_check);
jtheme_set_method(theme, JI_ENTRY, theme_draw_entry);
jtheme_set_method(theme, JI_GRID, theme_draw_grid);
jtheme_set_method(theme, JI_LABEL, theme_draw_label);
jtheme_set_method(theme, JI_LISTBOX, theme_draw_listbox);
jtheme_set_method(theme, JI_LISTITEM, theme_draw_listitem);
jtheme_set_method(theme, JI_MENU, theme_draw_menu);
jtheme_set_method(theme, JI_MENUITEM, theme_draw_menuitem);
jtheme_set_method(theme, JI_PANEL, theme_draw_panel);
jtheme_set_method(theme, JI_RADIO, theme_draw_radio);
jtheme_set_method(theme, JI_SEPARATOR, theme_draw_separator);
jtheme_set_method(theme, JI_SLIDER, theme_draw_slider);
jtheme_set_method(theme, JI_TEXTBOX, theme_draw_textbox);
jtheme_set_method(theme, JI_VIEW, theme_draw_view);
jtheme_set_method(theme, JI_VIEW_SCROLLBAR, theme_draw_view_scrollbar);
jtheme_set_method(theme, JI_VIEW_VIEWPORT, theme_draw_view_viewport);
jtheme_set_method(theme, JI_WINDOW, theme_draw_window);
return theme;
} }
static void theme_destroy() jstandard_theme::jstandard_theme()
{ {
int c; for (int c=0; c<ICONS; c++)
icons_bitmap[c] = NULL;
for (c=0; c<ICONS; c++) { this->name = "Standard Theme";
this->check_icon_size = 8;
this->radio_icon_size = 8;
this->scrollbar_size = 12;
}
jstandard_theme::~jstandard_theme()
{
for (int c=0; c<ICONS; c++) {
if (icons_bitmap[c]) { if (icons_bitmap[c]) {
destroy_bitmap(icons_bitmap[c]); destroy_bitmap(icons_bitmap[c]);
icons_bitmap[c] = NULL; icons_bitmap[c] = NULL;
@ -202,7 +174,7 @@ static void theme_destroy()
} }
} }
static void theme_regen() void jstandard_theme::regen()
{ {
JTheme theme = ji_get_theme(); JTheme theme = ji_get_theme();
int c, cmap[8], mask_cmap[2]; int c, cmap[8], mask_cmap[2];
@ -235,7 +207,7 @@ static void theme_regen()
} }
} }
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y) BITMAP *jstandard_theme::set_cursor(int type, int *focus_x, int *focus_y)
{ {
BITMAP *sprite = NULL; BITMAP *sprite = NULL;
int icon_index = type-1+FIRST_CURSOR; int icon_index = type-1+FIRST_CURSOR;
@ -285,7 +257,7 @@ static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y)
return sprite; return sprite;
} }
static void theme_init_widget(JWidget widget) void jstandard_theme::init_widget(JWidget widget)
{ {
#define BORDER(n) \ #define BORDER(n) \
widget->border_width.l = n; \ widget->border_width.l = n; \
@ -304,7 +276,7 @@ static void theme_init_widget(JWidget widget)
(widget->type != JI_SEPARATOR)) (widget->type != JI_SEPARATOR))
return; return;
switch (widget->draw_type) { switch (widget->type) {
case JI_BOX: case JI_BOX:
BORDER(0); BORDER(0);
@ -452,12 +424,12 @@ static void theme_init_widget(JWidget widget)
} }
} }
static JRegion theme_get_window_mask(JWidget widget) JRegion jstandard_theme::get_window_mask(JWidget widget)
{ {
return jregion_new(widget->rc, 1); return jregion_new(widget->rc, 1);
} }
static void theme_map_decorative_widget(JWidget widget) void jstandard_theme::map_decorative_widget(JWidget widget)
{ {
if (widget->name != NULL && if (widget->name != NULL &&
strcmp(widget->name, "theme_close_button") == 0) { strcmp(widget->name, "theme_close_button") == 0) {
@ -476,42 +448,42 @@ static void theme_map_decorative_widget(JWidget widget)
} }
} }
static int theme_color_foreground() int jstandard_theme::color_foreground()
{ {
return COLOR_FOREGROUND; return COLOR_FOREGROUND;
} }
static int theme_color_disabled() int jstandard_theme::color_disabled()
{ {
return COLOR_DISABLED; return COLOR_DISABLED;
} }
static int theme_color_face() int jstandard_theme::color_face()
{ {
return COLOR_FACE; return COLOR_FACE;
} }
static int theme_color_hotface() int jstandard_theme::color_hotface()
{ {
return COLOR_HOTFACE; return COLOR_HOTFACE;
} }
static int theme_color_selected() int jstandard_theme::color_selected()
{ {
return COLOR_SELECTED; return COLOR_SELECTED;
} }
static int theme_color_background() int jstandard_theme::color_background()
{ {
return COLOR_BACKGROUND; return COLOR_BACKGROUND;
} }
static void theme_draw_box(JWidget widget, JRect clip) void jstandard_theme::draw_box(JWidget widget, JRect clip)
{ {
jdraw_rectfill(clip, BGCOLOR); jdraw_rectfill(clip, BGCOLOR);
} }
static void theme_draw_button(JWidget widget, JRect clip) void jstandard_theme::draw_button(JWidget widget, JRect clip)
{ {
BITMAP *icon_bmp = ji_generic_button_get_icon(widget); BITMAP *icon_bmp = ji_generic_button_get_icon(widget);
int icon_align = ji_generic_button_get_icon_align(widget); int icon_align = ji_generic_button_get_icon_align(widget);
@ -624,7 +596,7 @@ static void theme_draw_button(JWidget widget, JRect clip)
} }
} }
static void theme_draw_check(JWidget widget, JRect clip) void jstandard_theme::draw_check(JWidget widget, JRect clip)
{ {
struct jrect box, text, icon; struct jrect box, text, icon;
int bg; int bg;
@ -654,12 +626,12 @@ static void theme_draw_check(JWidget widget, JRect clip)
draw_icons(icon.x1, icon.y1, widget, ICON_CHECK_EDGE); draw_icons(icon.x1, icon.y1, widget, ICON_CHECK_EDGE);
} }
static void theme_draw_grid(JWidget widget, JRect clip) void jstandard_theme::draw_grid(JWidget widget, JRect clip)
{ {
jdraw_rectfill(clip, BGCOLOR); jdraw_rectfill(clip, BGCOLOR);
} }
static void theme_draw_entry(JWidget widget, JRect clip) void jstandard_theme::draw_entry(JWidget widget, JRect clip)
{ {
bool password = jentry_is_password(widget); bool password = jentry_is_password(widget);
int scroll, cursor, state, selbeg, selend; int scroll, cursor, state, selbeg, selend;
@ -741,7 +713,7 @@ static void theme_draw_entry(JWidget widget, JRect clip)
draw_entry_cursor(widget, x, y); draw_entry_cursor(widget, x, y);
} }
static void theme_draw_label(JWidget widget, JRect clip) void jstandard_theme::draw_label(JWidget widget, JRect clip)
{ {
int bg = BGCOLOR; int bg = BGCOLOR;
@ -750,7 +722,7 @@ static void theme_draw_label(JWidget widget, JRect clip)
draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0); draw_textstring(NULL, -1, bg, false, widget, widget->rc, 0);
} }
static void theme_draw_listbox(JWidget widget, JRect clip) void jstandard_theme::draw_listbox(JWidget widget, JRect clip)
{ {
int bg; int bg;
@ -762,7 +734,7 @@ static void theme_draw_listbox(JWidget widget, JRect clip)
jdraw_rectfill(widget->rc, COLOR_BACKGROUND); jdraw_rectfill(widget->rc, COLOR_BACKGROUND);
} }
static void theme_draw_listitem(JWidget widget, JRect clip) void jstandard_theme::draw_listitem(JWidget widget, JRect clip)
{ {
int fg, bg; int fg, bg;
int x, y; int x, y;
@ -802,12 +774,12 @@ static void theme_draw_listitem(JWidget widget, JRect clip)
} }
} }
static void theme_draw_menu(JWidget widget, JRect clip) void jstandard_theme::draw_menu(JWidget widget, JRect clip)
{ {
jdraw_rectfill(widget->rc, BGCOLOR); jdraw_rectfill(widget->rc, BGCOLOR);
} }
static void theme_draw_menuitem(JWidget widget, JRect clip) void jstandard_theme::draw_menuitem(JWidget widget, JRect clip)
{ {
int c, bg, fg, bar; int c, bg, fg, bar;
int x1, y1, x2, y2; int x1, y1, x2, y2;
@ -919,7 +891,7 @@ static void theme_draw_menuitem(JWidget widget, JRect clip)
} }
} }
static void theme_draw_panel(JWidget widget, JRect clip) void jstandard_theme::draw_panel(JWidget widget, JRect clip)
{ {
JWidget c1, c2; JWidget c1, c2;
JLink link; JLink link;
@ -975,7 +947,7 @@ static void theme_draw_panel(JWidget widget, JRect clip)
} }
} }
static void theme_draw_radio(JWidget widget, JRect clip) void jstandard_theme::draw_radio(JWidget widget, JRect clip)
{ {
struct jrect box, text, icon; struct jrect box, text, icon;
int bg = BGCOLOR; int bg = BGCOLOR;
@ -1004,7 +976,7 @@ static void theme_draw_radio(JWidget widget, JRect clip)
draw_icons(icon.x1, icon.y1, widget, ICON_RADIO_EDGE); draw_icons(icon.x1, icon.y1, widget, ICON_RADIO_EDGE);
} }
static void theme_draw_separator(JWidget widget, JRect clip) void jstandard_theme::draw_separator(JWidget widget, JRect clip)
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
@ -1074,7 +1046,7 @@ static int my_add_clip_rect(BITMAP *bitmap, int x1, int y1, int x2, int y2)
} }
#endif #endif
static void theme_draw_slider(JWidget widget, JRect clip) void jstandard_theme::draw_slider(JWidget widget, JRect clip)
{ {
int x, x1, y1, x2, y2, bg, c1, c2; int x, x1, y1, x2, y2, bg, c1, c2;
int min, max, value; int min, max, value;
@ -1177,14 +1149,14 @@ static void theme_draw_slider(JWidget widget, JRect clip)
} }
} }
static void theme_draw_textbox(JWidget widget, JRect clip) void jstandard_theme::draw_textbox(JWidget widget, JRect clip)
{ {
_ji_theme_textbox_draw(ji_screen, widget, NULL, NULL, _ji_theme_textbox_draw(ji_screen, widget, NULL, NULL,
widget->theme->textbox_bg_color, widget->theme->textbox_bg_color,
widget->theme->textbox_fg_color); widget->theme->textbox_fg_color);
} }
static void theme_draw_view(JWidget widget, JRect clip) void jstandard_theme::draw_view(JWidget widget, JRect clip)
{ {
JRect pos = jwidget_get_rect(widget); JRect pos = jwidget_get_rect(widget);
@ -1212,7 +1184,7 @@ static void theme_draw_view(JWidget widget, JRect clip)
jrect_free(pos); jrect_free(pos);
} }
static void theme_draw_view_scrollbar(JWidget widget, JRect clip) void jstandard_theme::draw_view_scrollbar(JWidget widget, JRect clip)
{ {
int x1, y1, x2, y2; int x1, y1, x2, y2;
int u1, v1, u2, v2; int u1, v1, u2, v2;
@ -1267,12 +1239,12 @@ static void theme_draw_view_scrollbar(JWidget widget, JRect clip)
rectfill(ji_screen, u1, v1, u2, v2, BGCOLOR); rectfill(ji_screen, u1, v1, u2, v2, BGCOLOR);
} }
static void theme_draw_view_viewport(JWidget widget, JRect clip) void jstandard_theme::draw_view_viewport(JWidget widget, JRect clip)
{ {
jdraw_rectfill(widget->rc, BGCOLOR); jdraw_rectfill(widget->rc, BGCOLOR);
} }
static void theme_draw_window(JWidget widget, JRect clip) void jstandard_theme::draw_window(JWidget widget, JRect clip)
{ {
JRect pos = jwidget_get_rect(widget); JRect pos = jwidget_get_rect(widget);
JRect cpos = jwidget_get_child_rect(widget); JRect cpos = jwidget_get_child_rect(widget);
@ -1312,7 +1284,7 @@ static void theme_draw_window(JWidget widget, JRect clip)
jrect_free(cpos); jrect_free(cpos);
} }
static int get_bg_color(JWidget widget) int jstandard_theme::get_bg_color(JWidget widget)
{ {
int c = jwidget_get_bg_color(widget); int c = jwidget_get_bg_color(widget);
int decorative = jwidget_is_decorative(widget); int decorative = jwidget_is_decorative(widget);
@ -1321,9 +1293,9 @@ static int get_bg_color(JWidget widget)
COLOR_FACE); COLOR_FACE);
} }
static void draw_textstring(const char *t, int fg_color, int bg_color, void jstandard_theme::draw_textstring(const char *t, int fg_color, int bg_color,
bool fill_bg, JWidget widget, const JRect rect, bool fill_bg, JWidget widget, const JRect rect,
int selected_offset) int selected_offset)
{ {
if (t || widget->has_text()) { if (t || widget->has_text()) {
int x, y, w, h; int x, y, w, h;
@ -1391,7 +1363,7 @@ static void draw_textstring(const char *t, int fg_color, int bg_color,
} }
} }
static void draw_entry_cursor(JWidget widget, int x, int y) void jstandard_theme::draw_entry_cursor(JWidget widget, int x, int y)
{ {
int h = jwidget_get_text_height(widget); int h = jwidget_get_text_height(widget);
@ -1399,7 +1371,7 @@ static void draw_entry_cursor(JWidget widget, int x, int y)
vline(ji_screen, x+1, y-1, y+h, COLOR_FOREGROUND); vline(ji_screen, x+1, y-1, y+h, COLOR_FOREGROUND);
} }
static void draw_icons(int x, int y, JWidget widget, int edge_icon) void jstandard_theme::draw_icons(int x, int y, JWidget widget, int edge_icon)
{ {
draw_sprite(ji_screen, icons_bitmap[edge_icon], x, y); draw_sprite(ji_screen, icons_bitmap[edge_icon], x, y);
@ -1407,7 +1379,7 @@ static void draw_icons(int x, int y, JWidget widget, int edge_icon)
draw_sprite(ji_screen, icons_bitmap[edge_icon+1], x, y); draw_sprite(ji_screen, icons_bitmap[edge_icon+1], x, y);
} }
static void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel) void jstandard_theme::draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *bevel)
{ {
hline(ji_screen, x1+bevel[0], y1, x2-bevel[1], c1); /* top */ hline(ji_screen, x1+bevel[0], y1, x2-bevel[1], c1); /* top */
hline(ji_screen, x1+bevel[2], y2, x2-bevel[3], c2); /* bottom */ hline(ji_screen, x1+bevel[2], y2, x2-bevel[3], c2); /* bottom */
@ -1422,7 +1394,7 @@ static void draw_bevel_box(int x1, int y1, int x2, int y2, int c1, int c2, int *
line(ji_screen, x2-bevel[3], y2, x2, y2-bevel[3], c2); /* bottom-right */ line(ji_screen, x2-bevel[3], y2, x2, y2-bevel[3], c2); /* bottom-right */
} }
static void less_bevel(int *bevel) void jstandard_theme::less_bevel(int *bevel)
{ {
if (bevel[0] > 0) --bevel[0]; if (bevel[0] > 0) --bevel[0];
if (bevel[1] > 0) --bevel[1]; if (bevel[1] > 0) --bevel[1];

View File

@ -87,7 +87,7 @@ static void get_info(JWidget widget, int *beg, int *end);
JWidget colorbar_new(int align) JWidget colorbar_new(int align)
{ {
JWidget widget = jwidget_new(colorbar_type()); JWidget widget = new jwidget(colorbar_type());
ColorBar *colorbar = jnew0(ColorBar, 1); ColorBar *colorbar = jnew0(ColorBar, 1);
colorbar->widget = widget; colorbar->widget = widget;

View File

@ -43,7 +43,7 @@ static bool colorviewer_msg_proc(JWidget widget, JMessage msg);
JWidget colorviewer_new(color_t color, int imgtype) JWidget colorviewer_new(color_t color, int imgtype)
{ {
JWidget widget = jwidget_new(colorviewer_type()); JWidget widget = new jwidget(colorviewer_type());
ColorViewer *colorviewer = jnew(ColorViewer, 1); ColorViewer *colorviewer = jnew(ColorViewer, 1);
colorviewer->color = color; colorviewer->color = color;

View File

@ -91,7 +91,7 @@ static int edit_node_manual(CurvePoint* point);
JWidget curve_editor_new(Curve *curve, int x1, int y1, int x2, int y2) JWidget curve_editor_new(Curve *curve, int x1, int y1, int x2, int y2)
{ {
JWidget widget = jwidget_new(curve_editor_type()); JWidget widget = new jwidget(curve_editor_type());
CurveEditor* curve_editor = jnew(CurveEditor, 1); CurveEditor* curve_editor = jnew(CurveEditor, 1);
jwidget_add_hook(widget, curve_editor_type(), jwidget_add_hook(widget, curve_editor_type(),

View File

@ -90,7 +90,7 @@ JWidget editor_view_new()
JWidget editor_new() JWidget editor_new()
{ {
JWidget widget = jwidget_new(editor_type()); JWidget widget = new jwidget(editor_type());
Editor* editor = jnew0(Editor, 1); Editor* editor = jnew0(Editor, 1);
editor->widget = widget; editor->widget = widget;

View File

@ -91,7 +91,7 @@ static void monitor_free_thumbnail_generation(void *data);
JWidget fileview_new(FileItem *start_folder, const jstring& exts) JWidget fileview_new(FileItem *start_folder, const jstring& exts)
{ {
JWidget widget = jwidget_new(fileview_type()); JWidget widget = new jwidget(fileview_type());
FileView* fileview = new FileView; FileView* fileview = new FileView;
if (!start_folder) if (!start_folder)

View File

@ -59,7 +59,7 @@ static void paledit_update_scroll(JWidget widget, int color);
JWidget paledit_new(Palette *palette, bool editable, int boxsize) JWidget paledit_new(Palette *palette, bool editable, int boxsize)
{ {
JWidget widget = jwidget_new(paledit_type()); JWidget widget = new jwidget(paledit_type());
PalEdit *paledit = jnew(PalEdit, 1); PalEdit *paledit = jnew(PalEdit, 1);
paledit->widget = widget; paledit->widget = widget;

View File

@ -42,7 +42,7 @@ static bool preview_msg_proc(JWidget widget, JMessage msg);
*/ */
JWidget preview_new(Effect *effect) JWidget preview_new(Effect *effect)
{ {
JWidget widget = jwidget_new(preview_type()); JWidget widget = new jwidget(preview_type());
Preview *preview = jnew(Preview, 1); Preview *preview = jnew(Preview, 1);
preview->effect = effect; preview->effect = effect;

View File

@ -69,7 +69,7 @@ JWidget statusbar_new()
BUTTON_NEW((name), NULL, (action)); \ BUTTON_NEW((name), NULL, (action)); \
add_gfxicon_to_button((name), (icon), JI_CENTER | JI_MIDDLE); add_gfxicon_to_button((name), (icon), JI_CENTER | JI_MIDDLE);
JWidget widget = jwidget_new(statusbar_type()); JWidget widget = new jwidget(statusbar_type());
StatusBar *statusbar = jnew(StatusBar, 1); StatusBar *statusbar = jnew(StatusBar, 1);
jwidget_add_hook(widget, statusbar_type(), jwidget_add_hook(widget, statusbar_type(),

View File

@ -75,7 +75,7 @@ static void tab_free(Tab *tab);
JWidget tabs_new(void (*select_callback)(JWidget tabs, void *data, int button)) JWidget tabs_new(void (*select_callback)(JWidget tabs, void *data, int button))
{ {
JWidget widget = jwidget_new(tabs_type()); JWidget widget = new jwidget(tabs_type());
Tabs *tabs = jnew0(Tabs, 1); Tabs *tabs = jnew0(Tabs, 1);
tabs->list_of_tabs = jlist_new(); tabs->list_of_tabs = jlist_new();