[GB.DRAW]
* NEW: New flags for Draw.Style states. Draw.Focus, for widgets having the focus, and Draw.Hover for widgets flied over by the mouse. git-svn-id: svn://localhost/gambas/trunk@3097 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
055e187a6a
commit
d9cae60bbe
@ -316,6 +316,18 @@ static void set_clipping_enabled(GB_DRAW *d, int enable)
|
||||
DR(d)->setClipEnabled(enable);
|
||||
}
|
||||
|
||||
static GtkStateType get_state(int state)
|
||||
{
|
||||
if (state & GB_DRAW_STATE_DISABLED)
|
||||
return GTK_STATE_INSENSITIVE;
|
||||
if (state & GB_DRAW_STATE_ACTIVE)
|
||||
return GTK_STATE_ACTIVE;
|
||||
if (state & GB_DRAW_STATE_HOVER)
|
||||
return GTK_STATE_PRELIGHT;
|
||||
|
||||
return GTK_STATE_NORMAL;
|
||||
}
|
||||
|
||||
static void style_arrow(GB_DRAW *d, int x, int y, int w, int h, int type, int state)
|
||||
{
|
||||
GtkArrowType arrow;
|
||||
@ -331,13 +343,11 @@ static void style_arrow(GB_DRAW *d, int x, int y, int w, int h, int type, int st
|
||||
return;
|
||||
}
|
||||
|
||||
gtk_paint_arrow(DR(d)->style(), DR(d)->drawable(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
gtk_paint_arrow(DR(d)->style(), DR(d)->drawable(), get_state(state),
|
||||
GTK_SHADOW_NONE, NULL, NULL, NULL,
|
||||
arrow, TRUE, x, y, w, h);
|
||||
if (DR(d)->mask())
|
||||
gtk_paint_arrow(DR(d)->style(), DR(d)->mask(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
gtk_paint_arrow(DR(d)->style(), DR(d)->mask(), get_state(state),
|
||||
GTK_SHADOW_NONE, NULL, NULL, NULL,
|
||||
arrow, TRUE, x, y, w, h);
|
||||
}
|
||||
@ -345,7 +355,7 @@ static void style_arrow(GB_DRAW *d, int x, int y, int w, int h, int type, int st
|
||||
static void style_check(GB_DRAW *d, int x, int y, int w, int h, int value, int state)
|
||||
{
|
||||
GtkShadowType shadow;
|
||||
GtkStateType st = state ? GTK_STATE_INSENSITIVE : (value ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
|
||||
GtkStateType st = get_state(state | (value ? GB_DRAW_STATE_ACTIVE : 0));
|
||||
|
||||
switch (value)
|
||||
{
|
||||
@ -368,7 +378,7 @@ static void style_check(GB_DRAW *d, int x, int y, int w, int h, int value, int s
|
||||
static void style_option(GB_DRAW *d, int x, int y, int w, int h, int value, int state)
|
||||
{
|
||||
GtkShadowType shadow;
|
||||
GtkStateType st = state ? GTK_STATE_INSENSITIVE : (value ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
|
||||
GtkStateType st = get_state(state | (value ? GB_DRAW_STATE_ACTIVE : 0));
|
||||
|
||||
shadow = value ? GTK_SHADOW_IN : GTK_SHADOW_OUT;
|
||||
|
||||
@ -383,7 +393,7 @@ static void style_option(GB_DRAW *d, int x, int y, int w, int h, int value, int
|
||||
|
||||
static void style_separator(GB_DRAW *d, int x, int y, int w, int h, int vertical, int state)
|
||||
{
|
||||
GtkStateType st = state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL;
|
||||
GtkStateType st = get_state(state);
|
||||
|
||||
if (vertical)
|
||||
{
|
||||
@ -426,7 +436,7 @@ static void style_focus(GB_DRAW *d, int x, int y, int w, int h)
|
||||
|
||||
static void style_button(GB_DRAW *d, int x, int y, int w, int h, int value, int state)
|
||||
{
|
||||
GtkStateType st = state ? GTK_STATE_INSENSITIVE : (value ? GTK_STATE_ACTIVE : GTK_STATE_NORMAL);
|
||||
GtkStateType st = get_state(state | (value ? GB_DRAW_STATE_ACTIVE : 0));
|
||||
|
||||
gtk_paint_box(DR(d)->style(), DR(d)->drawable(),
|
||||
st, value ? GTK_SHADOW_IN : GTK_SHADOW_OUT,
|
||||
@ -471,14 +481,14 @@ static void style_panel(GB_DRAW *d, int x, int y, int w, int h, int border, int
|
||||
|
||||
static void style_handle(GB_DRAW *d, int x, int y, int w, int h, int vertical, int state)
|
||||
{
|
||||
gtk_paint_handle(DR(d)->style(), DR(d)->drawable(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
GtkStateType st = get_state(state);
|
||||
|
||||
gtk_paint_handle(DR(d)->style(), DR(d)->drawable(), st,
|
||||
GTK_SHADOW_NONE, NULL, NULL, NULL,
|
||||
x, y, w, h,
|
||||
(!vertical) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
|
||||
if (DR(d)->mask())
|
||||
gtk_paint_handle(DR(d)->style(), DR(d)->mask(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
gtk_paint_handle(DR(d)->style(), DR(d)->mask(), st,
|
||||
GTK_SHADOW_NONE, NULL, NULL, NULL,
|
||||
x, y, w, h,
|
||||
(!vertical) ? GTK_ORIENTATION_HORIZONTAL : GTK_ORIENTATION_VERTICAL);
|
||||
@ -486,12 +496,12 @@ static void style_handle(GB_DRAW *d, int x, int y, int w, int h, int vertical, i
|
||||
|
||||
static void style_box(GB_DRAW *d, int x, int y, int w, int h, int state)
|
||||
{
|
||||
gtk_paint_shadow(DR(d)->style(), DR(d)->drawable(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
GtkStateType st = get_state(state);
|
||||
|
||||
gtk_paint_shadow(DR(d)->style(), DR(d)->drawable(), st,
|
||||
GTK_SHADOW_IN, NULL, NULL, "entry", x, y, w, h);
|
||||
if (DR(d)->mask())
|
||||
gtk_paint_shadow(DR(d)->style(), DR(d)->mask(),
|
||||
state ? GTK_STATE_INSENSITIVE : GTK_STATE_NORMAL,
|
||||
gtk_paint_shadow(DR(d)->style(), DR(d)->mask(), st,
|
||||
GTK_SHADOW_IN, NULL, NULL, "entry", x, y, w, h);
|
||||
}
|
||||
|
||||
|
@ -960,8 +960,17 @@ static void set_clipping_enabled(GB_DRAW *d, int enable)
|
||||
static void init_option(QStyleOption &opt, int x, int y, int w, int h, int state)
|
||||
{
|
||||
opt.rect = QRect(x, y, w ,h);
|
||||
if (!state)
|
||||
opt.state |= QStyle::State_Enabled;
|
||||
if (state & GB_DRAW_STATE_DISABLED)
|
||||
return;
|
||||
|
||||
opt.state |= QStyle::State_Enabled;
|
||||
|
||||
if (state & GB_DRAW_STATE_FOCUS)
|
||||
opt.state |= QStyle::State_HasFocus;
|
||||
if (state & GB_DRAW_STATE_HOVER)
|
||||
opt.state |= QStyle::State_MouseOver;
|
||||
if (state & GB_DRAW_STATE_ACTIVE)
|
||||
opt.state |= QStyle::State_On | QStyle::State_Sunken | QStyle::State_Active;
|
||||
}
|
||||
|
||||
static void style_arrow(GB_DRAW *d, int x, int y, int w, int h, int type, int state)
|
||||
|
@ -1195,8 +1195,10 @@ GB_DESC CDrawDesc[] =
|
||||
GB_STATIC_METHOD("Translate", NULL, CDRAW_translate, "(DX)f(DY)f"),
|
||||
GB_STATIC_METHOD("Scale", NULL, CDRAW_scale, "(SX)f(SY)f"),
|
||||
|
||||
GB_CONSTANT("Normal", "i", GB_DRAW_STATE_NORMAL),
|
||||
GB_CONSTANT("Normale", "i", GB_DRAW_STATE_NORMAL),
|
||||
GB_CONSTANT("Disabled", "i", GB_DRAW_STATE_DISABLED),
|
||||
GB_CONSTANT("Focus", "i", GB_DRAW_STATE_FOCUS),
|
||||
GB_CONSTANT("Hover", "i", GB_DRAW_STATE_HOVER),
|
||||
//GB_CONSTANT("ToolButton", "i", GB_DRAW_STATE_TOOL_BUTTON),
|
||||
|
||||
#if 0
|
||||
|
@ -32,7 +32,9 @@
|
||||
enum {
|
||||
GB_DRAW_STATE_NORMAL = 0,
|
||||
GB_DRAW_STATE_DISABLED = 1,
|
||||
GB_DRAW_STATE_TOOL_BUTTON = 2
|
||||
GB_DRAW_STATE_FOCUS = 2,
|
||||
GB_DRAW_STATE_HOVER = 4,
|
||||
GB_DRAW_STATE_ACTIVE = 8
|
||||
};
|
||||
|
||||
typedef
|
||||
|
Loading…
x
Reference in New Issue
Block a user