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 */
if (first_time) {
brush_preview = jwidget_new(JI_WIDGET);
brush_preview = new jwidget(JI_WIDGET);
brush_preview->min_w = 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)
{
JWidget widget = jwidget_new(anieditor_type());
JWidget widget = new jwidget(anieditor_type());
AniEditor* anieditor = new AniEditor;
anieditor->sprite = sprite;

View File

@ -152,7 +152,7 @@ void dialogs_tips(bool forced)
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_focusrest(widget, TRUE);

View File

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

View File

@ -37,6 +37,7 @@
#include "jinete/jmessage.h"
#include "jinete/jrect.h"
#include "jinete/jwidget.h"
#include "jinete/jtheme.h"
static bool box_msg_proc(JWidget widget, JMessage msg);
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 widget = jwidget_new(JI_BOX);
JWidget widget = new jwidget(JI_BOX);
jwidget_add_hook(widget, JI_BOX, box_msg_proc, NULL);
jwidget_set_align(widget, align);
@ -55,7 +56,7 @@ JWidget jbox_new(int align)
static bool box_msg_proc(JWidget widget, JMessage msg)
{
switch(msg->type) {
switch (msg->type) {
case JM_REQSIZE:
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:
box_set_position(widget, &msg->setpos.rect);
return true;
case JM_DRAW:
widget->theme->draw_box(widget, &msg->draw.rect);
return true;
}
return false;

View File

@ -57,6 +57,7 @@ typedef struct ButtonCommand
typedef struct Button
{
/* generic */
int draw_type;
BITMAP *icon;
int icon_align;
/* button */
@ -77,11 +78,10 @@ JWidget ji_generic_button_new(const char *text,
int behavior_type,
int draw_type)
{
JWidget widget = jwidget_new(behavior_type);
JWidget widget = new jwidget(behavior_type);
Button *button = jnew(Button, 1);
widget->draw_type = draw_type;
button->draw_type = draw_type;
button->icon = NULL;
button->icon_align = JI_LEFT | JI_MIDDLE;
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_text(widget, text);
jwidget_focusrest(widget, true);
// initialize theme
widget->type = button->draw_type;
jwidget_init_theme(widget);
widget->type = behavior_type;
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);
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:
if (widget->type == JI_RADIO) {
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_h = 0;
switch (widget->draw_type) {
switch (button->draw_type) {
case JI_BUTTON:
if (button->icon) {

View File

@ -72,7 +72,7 @@ static void comboitem_free(ComboItem *item);
JWidget jcombobox_new()
{
JWidget widget = jwidget_new(JI_COMBOBOX);
JWidget widget = new jwidget(JI_COMBOBOX);
ComboBox *combobox = jnew(ComboBox, 1);
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 widget = jwidget_new(JI_ENTRY);
JWidget widget = new jwidget(JI_ENTRY);
Entry* entry = (Entry*)jnew(Entry, 1);
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);
return true;
case JM_DRAW:
widget->theme->draw_entry(widget, &msg->draw.rect);
return true;
case JM_TIMER:
if (jwidget_has_focus(widget) &&
msg->timer.timer_id == entry->timer_id) {

View File

@ -40,6 +40,7 @@
#include "jinete/jmessage.h"
#include "jinete/jrect.h"
#include "jinete/jwidget.h"
#include "jinete/jtheme.h"
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 widget = jwidget_new(JI_GRID);
JWidget widget = new jwidget(JI_GRID);
Grid *grid = jnew(Grid, 1);
int col;
@ -173,6 +174,10 @@ static bool grid_msg_proc(JWidget widget, JMessage msg)
grid_set_position(widget, &msg->setpos.rect);
return true;
case JM_DRAW:
widget->theme->draw_grid(widget, &msg->draw.rect);
return true;
}
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 widget = jwidget_new(JI_IMAGE);
JWidget widget = new jwidget(JI_IMAGE);
jwidget_add_hook(widget, JI_IMAGE, image_msg_proc, bmp);
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);
//////////////////////////////////////////////////////////////////////
// jwidget.c
void _jwidget_add_hook(JWidget widget, JHook hook);
void _jwidget_remove_hook(JWidget widget, JHook hook);
//////////////////////////////////////////////////////////////////////
// jwindow.c

View File

@ -39,7 +39,7 @@ static bool label_msg_proc(JWidget widget, JMessage msg);
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_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.h += widget->border_width.t + widget->border_width.b;
return true;
case JM_DRAW:
widget->theme->draw_label(widget, &msg->draw.rect);
return true;
}
return false;

View File

@ -52,7 +52,7 @@ static void listitem_request_size(JWidget widget, int *w, int *h);
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_focusrest(widget, true);
@ -63,7 +63,7 @@ JWidget jlistbox_new()
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_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);
return true;
case JM_DRAW:
widget->theme->draw_listbox(widget, &msg->draw.rect);
return true;
case JM_DIRTYCHILDREN:
listbox_dirty_children(widget);
return true;
@ -407,6 +411,10 @@ static bool listitem_msg_proc(JWidget widget, JMessage msg)
jrect_free(crect);
return true;
}
case JM_DRAW:
widget->theme->draw_listitem(widget, &msg->draw.rect);
return true;
}
return false;

View File

@ -192,7 +192,7 @@ JWidget jmanager_new()
n_timers = 0;
}
widget = jwidget_new(JI_MANAGER);
widget = new jwidget(JI_MANAGER);
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 widget = jwidget_new(JI_MENU);
JWidget widget = new jwidget(JI_MENU);
Menu *menu = jnew(Menu, 1);
menu->menuitem = NULL;
@ -179,7 +179,7 @@ JWidget jmenubar_new()
JWidget jmenubox_new()
{
JWidget widget = jwidget_new(JI_MENUBOX);
JWidget widget = new jwidget(JI_MENUBOX);
MenuBox *menubox = jnew(MenuBox, 1);
menubox->base = NULL;
@ -193,7 +193,7 @@ JWidget jmenubox_new()
JWidget jmenuitem_new(const char *text)
{
JWidget widget = jwidget_new(JI_MENUITEM);
JWidget widget = new jwidget(JI_MENUITEM);
MenuItem *menuitem = jnew(MenuItem, 1);
menuitem->accel = NULL;
@ -396,6 +396,10 @@ static bool menu_msg_proc(JWidget widget, JMessage msg)
menu_set_position(widget, &msg->setpos.rect);
return true;
case JM_DRAW:
widget->theme->draw_menu(widget, &msg->draw.rect);
return true;
}
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);
return true;
case JM_DRAW:
widget->theme->draw_menuitem(widget, &msg->draw.rect);
return true;
case JM_MOUSEENTER:
case JM_MOUSELEAVE:
/* TODO theme specific!! */

View File

@ -49,7 +49,7 @@ static void panel_set_position(JWidget widget, JRect rect);
JWidget jpanel_new(int align)
{
JWidget widget = jwidget_new(JI_PANEL);
JWidget widget = new jwidget(JI_PANEL);
Panel *panel = jnew(Panel, 1);
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);
return true;
case JM_DRAW:
widget->theme->draw_panel(widget, &msg->draw.rect);
return true;
case JM_BUTTONPRESSED:
if (jwidget_is_enabled(widget)) {
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 widget = jwidget_new(JI_SEPARATOR);
JWidget widget = new jwidget(JI_SEPARATOR);
jwidget_add_hook(widget, JI_SEPARATOR, separator_msg_proc, NULL);
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;
return true;
}
case JM_DRAW:
widget->theme->draw_separator(widget, &msg->draw.rect);
return true;
}
return false;

View File

@ -58,7 +58,7 @@ static void slider_setcursor(JWidget widget);
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->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);
return true;
case JM_DRAW:
widget->theme->draw_slider(widget, &msg->draw.rect);
return true;
case JM_FOCUSENTER:
case JM_FOCUSLEAVE:
if (jwidget_is_enabled(widget))

View File

@ -258,12 +258,12 @@ int jmouse_set_cursor(int type)
else {
show_mouse(NULL);
if (theme->set_cursor) {
{
BITMAP *sprite;
int x = 0;
int y = 0;
sprite = (*theme->set_cursor)(type, &x, &y);
sprite = theme->set_cursor(type, &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 widget = jwidget_new(JI_TEXTBOX);
JWidget widget = new jwidget(JI_TEXTBOX);
jwidget_add_hook(widget, JI_TEXTBOX, textbox_msg_proc, NULL);
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);
return true;
case JM_DRAW:
widget->theme->draw_textbox(widget, &msg->draw.rect);
return true;
case JM_SIGNAL:
if (msg->signal.num == JI_SIGNAL_SET_TEXT) {
JWidget view = jwidget_get_view(widget);

View File

@ -57,73 +57,27 @@ int _ji_theme_init()
void _ji_theme_exit()
{
if (ji_standard_theme) {
jtheme_free(ji_standard_theme);
delete ji_standard_theme;
ji_standard_theme = NULL;
}
}
JTheme jtheme_new()
jtheme::jtheme()
{
JTheme theme = (JTheme)jmalloc(sizeof(struct jtheme));
if (!theme)
return NULL;
theme->name = "Theme";
theme->default_font = font; /* default Allegro font */
theme->desktop_color = 0;
theme->textbox_fg_color = 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;
this->name = "Theme";
this->default_font = font; /* default Allegro font */
this->desktop_color = 0;
this->textbox_fg_color = 0;
this->textbox_bg_color = 0;
this->check_icon_size = 0;
this->radio_icon_size = 0;
this->scrollbar_size = 0;
}
void jtheme_free(JTheme theme)
jtheme::~jtheme()
{
if (theme->destroy)
(*theme->destroy)();
if (ji_current_theme == theme)
if (ji_current_theme == this)
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) {
ji_regen_theme();
/* TODO any better idea? */
if (manager && jwidget_get_theme(manager) == NULL)
jwidget_set_theme(manager, theme);
}
@ -162,44 +115,28 @@ JTheme ji_get_theme()
void ji_regen_theme()
{
if (ji_current_theme) {
/* hide the cursor */
/* if () { */
/* show_mouse(NULL); */
/* set_mouse_sprite(NULL); */
/* } */
int type = jmouse_get_cursor();
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);
}
}
int ji_color_foreground()
{
if (ji_current_theme && ji_current_theme->color_foreground)
return (*ji_current_theme->color_foreground)();
else
return makecol(0, 0, 0);
return ji_current_theme->color_foreground();
}
int ji_color_disabled()
{
if (ji_current_theme && ji_current_theme->color_disabled)
return (*ji_current_theme->color_disabled)();
else
return makecol(128, 128, 128);
return ji_current_theme->color_disabled();
}
int ji_color_face()
{
if (ji_current_theme && ji_current_theme->color_face)
return (*ji_current_theme->color_face)();
else
return makecol(255, 255, 255);
return ji_current_theme->color_face();
}
int ji_color_facelight()
@ -220,26 +157,17 @@ int ji_color_faceshadow()
int ji_color_hotface()
{
if (ji_current_theme && ji_current_theme->color_hotface)
return (*ji_current_theme->color_hotface)();
else
return makecol(255, 255, 255);
return ji_current_theme->color_hotface();
}
int ji_color_selected()
{
if (ji_current_theme && ji_current_theme->color_selected)
return (*ji_current_theme->color_selected)();
else
return makecol(0, 0, 255);
return ji_current_theme->color_selected();
}
int ji_color_background()
{
if (ji_current_theme && ji_current_theme->color_background)
return (*ji_current_theme->color_background)();
else
return makecol(255, 255, 255);
return ji_current_theme->color_background();
}
void _ji_theme_draw_sprite_color(BITMAP *bmp, BITMAP *sprite,

View File

@ -37,41 +37,57 @@
struct FONT;
struct BITMAP;
struct jtheme
class jtheme
{
const char *name;
struct FONT *default_font;
public:
const char* name;
struct FONT* default_font;
int desktop_color;
int textbox_fg_color;
int textbox_bg_color;
int check_icon_size;
int radio_icon_size;
int scrollbar_size;
void (*destroy)();
void (*regen)();
struct BITMAP *(*set_cursor)(int type, int *focus_x, int *focus_y);
void (*init_widget)(JWidget widget);
JRegion (*get_window_mask)(JWidget widget);
void (*map_decorative_widget)(JWidget widget);
int (*color_foreground)();
int (*color_disabled)();
int (*color_face)();
int (*color_hotface)();
int (*color_selected)();
int (*color_background)();
int nmethods;
JDrawFunc *methods;
jtheme();
virtual ~jtheme();
virtual void regen() = 0;
virtual BITMAP* set_cursor(int type, int *focus_x, int *focus_y) = 0;
virtual void init_widget(JWidget widget) = 0;
virtual JRegion get_window_mask(JWidget widget) = 0;
virtual void map_decorative_widget(JWidget widget) = 0;
virtual int color_foreground() = 0;
virtual int color_disabled() = 0;
virtual int color_face() = 0;
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_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_standard_theme();

View File

@ -73,7 +73,7 @@ static void displace_widgets(JWidget widget, int x, int y);
JWidget jview_new()
{
JWidget widget = jwidget_new(JI_VIEW);
JWidget widget = new jwidget(JI_VIEW);
View *view = jnew(View, 1);
view->viewport = viewport_new();
@ -374,6 +374,10 @@ static bool view_msg_proc(JWidget widget, JMessage msg)
}
return true;
case JM_DRAW:
widget->theme->draw_view(widget, &msg->draw.rect);
return true;
case JM_FOCUSENTER:
case JM_FOCUSLEAVE:
/* 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()
{
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_init_theme(widget);
@ -411,6 +415,10 @@ static bool viewport_msg_proc(JWidget widget, JMessage msg)
case JM_SETPOS:
viewport_set_position(widget, &msg->setpos.rect);
return true;
case JM_DRAW:
widget->theme->draw_view_viewport(widget, &msg->draw.rect);
return true;
}
return false;
@ -468,7 +476,7 @@ static void viewport_set_position(JWidget widget, JRect rect)
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_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) */
jwidget_invalidate(widget);
break;
case JM_DRAW:
widget->theme->draw_view_scrollbar(widget, &msg->draw.rect);
return true;
}
return false;

View File

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

View File

@ -49,7 +49,6 @@ struct BITMAP;
int ji_register_widget_type();
JWidget jwidget_new(int type);
void jwidget_free(JWidget widget);
void jwidget_free_deferred(JWidget widget);
@ -210,9 +209,6 @@ public:
/* virtual properties */
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 */
private:
@ -266,6 +262,9 @@ public:
struct FONT* font();
void font(struct FONT* font);
/**
* Gets the background color of the widget.
*/
int bg_color()
{
if (m_bg_color < 0 && parent)
@ -274,12 +273,17 @@ public:
return m_bg_color;
}
/**
* Sets the background color of the widget.
*/
void bg_color(int 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)
{
return jwidget_find_name(jwidget_get_window(this), name);
@ -287,6 +291,8 @@ public:
void dirty() { jwidget_dirty(this); }
virtual bool msg_proc(JMessage msg);
};
#endif

View File

@ -269,7 +269,7 @@ bool jwindow_is_wantfocus(JWidget widget)
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->killer = NULL;
@ -461,6 +461,10 @@ static bool window_msg_proc(JWidget widget, JMessage msg)
}
break;
case JM_DRAW:
widget->theme->draw_window(widget, &msg->draw.rect);
return true;
}
return false;

View File

@ -92,109 +92,81 @@ static struct {
{ false, default_theme_icombobox },
};
static BITMAP *icons_bitmap[ICONS];
class jstandard_theme : public jtheme
{
BITMAP *icons_bitmap[ICONS];
static void theme_destroy();
static void theme_regen();
static BITMAP *theme_set_cursor(int type, int *focus_x, int *focus_y);
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);
public:
jstandard_theme();
~jstandard_theme();
static int get_bg_color(JWidget widget);
static void draw_textstring(const char *t, int fg_color, int bg_color,
bool fill_bg, JWidget widget, const JRect rect,
int selected_offset);
static void draw_entry_cursor(JWidget widget, int x, int y);
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);
static void less_bevel(int *bevel);
void regen();
BITMAP *set_cursor(int type, int *focus_x, int *focus_y);
void init_widget(JWidget widget);
JRegion get_window_mask(JWidget widget);
void map_decorative_widget(JWidget widget);
int color_foreground();
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);
JTheme jtheme_new_standard()
{
JTheme 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;
return new jstandard_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]) {
destroy_bitmap(icons_bitmap[c]);
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();
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;
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;
}
static void theme_init_widget(JWidget widget)
void jstandard_theme::init_widget(JWidget widget)
{
#define BORDER(n) \
widget->border_width.l = n; \
@ -304,7 +276,7 @@ static void theme_init_widget(JWidget widget)
(widget->type != JI_SEPARATOR))
return;
switch (widget->draw_type) {
switch (widget->type) {
case JI_BOX:
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);
}
static void theme_map_decorative_widget(JWidget widget)
void jstandard_theme::map_decorative_widget(JWidget widget)
{
if (widget->name != NULL &&
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;
}
static int theme_color_disabled()
int jstandard_theme::color_disabled()
{
return COLOR_DISABLED;
}
static int theme_color_face()
int jstandard_theme::color_face()
{
return COLOR_FACE;
}
static int theme_color_hotface()
int jstandard_theme::color_hotface()
{
return COLOR_HOTFACE;
}
static int theme_color_selected()
int jstandard_theme::color_selected()
{
return COLOR_SELECTED;
}
static int theme_color_background()
int jstandard_theme::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);
}
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);
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;
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);
}
static void theme_draw_grid(JWidget widget, JRect clip)
void jstandard_theme::draw_grid(JWidget widget, JRect clip)
{
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);
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);
}
static void theme_draw_label(JWidget widget, JRect clip)
void jstandard_theme::draw_label(JWidget widget, JRect clip)
{
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);
}
static void theme_draw_listbox(JWidget widget, JRect clip)
void jstandard_theme::draw_listbox(JWidget widget, JRect clip)
{
int bg;
@ -762,7 +734,7 @@ static void theme_draw_listbox(JWidget widget, JRect clip)
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 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);
}
static void theme_draw_menuitem(JWidget widget, JRect clip)
void jstandard_theme::draw_menuitem(JWidget widget, JRect clip)
{
int c, bg, fg, bar;
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;
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;
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);
}
static void theme_draw_separator(JWidget widget, JRect clip)
void jstandard_theme::draw_separator(JWidget widget, JRect clip)
{
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
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 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,
widget->theme->textbox_bg_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);
@ -1212,7 +1184,7 @@ static void theme_draw_view(JWidget widget, JRect clip)
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 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);
}
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);
}
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 cpos = jwidget_get_child_rect(widget);
@ -1312,7 +1284,7 @@ static void theme_draw_window(JWidget widget, JRect clip)
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 decorative = jwidget_is_decorative(widget);
@ -1321,9 +1293,9 @@ static int get_bg_color(JWidget widget)
COLOR_FACE);
}
static void draw_textstring(const char *t, int fg_color, int bg_color,
bool fill_bg, JWidget widget, const JRect rect,
int selected_offset)
void jstandard_theme::draw_textstring(const char *t, int fg_color, int bg_color,
bool fill_bg, JWidget widget, const JRect rect,
int selected_offset)
{
if (t || widget->has_text()) {
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);
@ -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);
}
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);
@ -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);
}
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[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 */
}
static void less_bevel(int *bevel)
void jstandard_theme::less_bevel(int *bevel)
{
if (bevel[0] > 0) --bevel[0];
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 widget = jwidget_new(colorbar_type());
JWidget widget = new jwidget(colorbar_type());
ColorBar *colorbar = jnew0(ColorBar, 1);
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 widget = jwidget_new(colorviewer_type());
JWidget widget = new jwidget(colorviewer_type());
ColorViewer *colorviewer = jnew(ColorViewer, 1);
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 widget = jwidget_new(curve_editor_type());
JWidget widget = new jwidget(curve_editor_type());
CurveEditor* curve_editor = jnew(CurveEditor, 1);
jwidget_add_hook(widget, curve_editor_type(),

View File

@ -90,7 +90,7 @@ JWidget editor_view_new()
JWidget editor_new()
{
JWidget widget = jwidget_new(editor_type());
JWidget widget = new jwidget(editor_type());
Editor* editor = jnew0(Editor, 1);
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 widget = jwidget_new(fileview_type());
JWidget widget = new jwidget(fileview_type());
FileView* fileview = new FileView;
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 widget = jwidget_new(paledit_type());
JWidget widget = new jwidget(paledit_type());
PalEdit *paledit = jnew(PalEdit, 1);
paledit->widget = widget;

View File

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

View File

@ -69,7 +69,7 @@ JWidget statusbar_new()
BUTTON_NEW((name), NULL, (action)); \
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);
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 widget = jwidget_new(tabs_type());
JWidget widget = new jwidget(tabs_type());
Tabs *tabs = jnew0(Tabs, 1);
tabs->list_of_tabs = jlist_new();