[GB.GTK]
* NEW: Support for GTK+3 continues. git-svn-id: svn://localhost/gambas/trunk@6046 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
0f21a59469
commit
41d97ec87e
@ -385,14 +385,17 @@ gButton::gButton(gContainer *par, Type typ) : gControl(par)
|
||||
realize();
|
||||
|
||||
gtk_widget_add_events(widget, GDK_POINTER_MOTION_MASK);
|
||||
onClick=NULL;
|
||||
onClick = NULL;
|
||||
|
||||
if (type == Radio)
|
||||
g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(cb_click_radio),(gpointer)this);
|
||||
else if (type == Check)
|
||||
g_signal_connect(G_OBJECT(widget), "clicked", G_CALLBACK(cb_click_check), (gpointer)this);
|
||||
else
|
||||
{
|
||||
g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(cb_click),(gpointer)this);
|
||||
setBackgroundButton();
|
||||
}
|
||||
|
||||
|
||||
setText(NULL);
|
||||
|
@ -155,7 +155,6 @@ void gComboBox::create(bool readOnly)
|
||||
{
|
||||
widget = gtk_combo_box_new_with_model(GTK_TREE_MODEL(tree->store));
|
||||
entry = NULL;
|
||||
use_base = false;
|
||||
|
||||
cell = gtk_cell_renderer_text_new ();
|
||||
g_object_ref_sink(cell);
|
||||
@ -177,7 +176,6 @@ void gComboBox::create(bool readOnly)
|
||||
#ifdef GTK3
|
||||
gtk_widget_set_hexpand(entry, FALSE);
|
||||
#endif
|
||||
use_base = true;
|
||||
|
||||
g_signal_handler_disconnect(widget, g_signal_handler_find(widget, G_SIGNAL_MATCH_ID, g_signal_lookup("changed", G_OBJECT_TYPE(widget)), 0, 0, 0, 0));
|
||||
|
||||
@ -189,7 +187,7 @@ void gComboBox::create(bool readOnly)
|
||||
//g_object_set(cell, "ypad", 0, (void *)NULL);
|
||||
gtk_cell_layout_set_cell_data_func(GTK_CELL_LAYOUT(widget), cell, (GtkCellLayoutDataFunc)combo_cell_text, (gpointer)tree, NULL);
|
||||
}
|
||||
|
||||
|
||||
if (first)
|
||||
{
|
||||
realize(false);
|
||||
@ -206,11 +204,14 @@ void gComboBox::create(bool readOnly)
|
||||
if (entry)
|
||||
{
|
||||
initEntry();
|
||||
setBackgroundBase();
|
||||
//g_signal_connect(G_OBJECT(entry), "key-press-event", G_CALLBACK(gcb_keypress), (gpointer)this);
|
||||
//g_signal_connect(G_OBJECT(entry), "key-release-event", G_CALLBACK(gcb_keyrelease), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(entry), "focus-in-event", G_CALLBACK(gcb_focus_in), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(entry), "focus-out-event", G_CALLBACK(gcb_focus_out), (gpointer)this);
|
||||
}
|
||||
else
|
||||
setBackgroundButton();
|
||||
|
||||
updateFocusHandler();
|
||||
setBackground(background());
|
||||
@ -225,21 +226,11 @@ void gComboBox::create(bool readOnly)
|
||||
|
||||
gComboBox::gComboBox(gContainer *parent) : gTextBox(parent, true)
|
||||
{
|
||||
/*if (!_style_init)
|
||||
{
|
||||
gtk_rc_parse_string(
|
||||
"style \"gambas-default-combo-box-style\" {\n"
|
||||
" GtkComboBox::appears-as-list = 1\n"
|
||||
"}\n"
|
||||
"class \"GtkComboBox\" style : gtk \"gambas-default-combo-box-style\"\n"
|
||||
);
|
||||
_style_init = TRUE;
|
||||
}*/
|
||||
|
||||
onChange = NULL;
|
||||
onClick = NULL;
|
||||
onActivate = NULL;
|
||||
|
||||
_no_background = TRUE;
|
||||
_last_key = 0;
|
||||
_model_dirty = false;
|
||||
_model_dirty_timeout = 0;
|
||||
@ -276,13 +267,21 @@ void gComboBox::popup()
|
||||
gtk_combo_box_popup(GTK_COMBO_BOX(widget));
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
void gComboBox::updateColor()
|
||||
{
|
||||
gTextBox::updateColor();
|
||||
if (entry)
|
||||
gt_widget_set_background(entry, background(), _bg_name, &_bg_default);
|
||||
}
|
||||
#else
|
||||
void gComboBox::setRealBackground(gColor color)
|
||||
{
|
||||
gControl::setRealBackground(color);
|
||||
if (entry)
|
||||
set_gdk_base_color(entry, color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void gComboBox::setRealForeground(gColor color)
|
||||
{
|
||||
|
@ -60,7 +60,11 @@ public:
|
||||
void remove(int pos);
|
||||
|
||||
virtual void resize(int w, int h);
|
||||
#ifdef GTK3
|
||||
virtual void updateColor();
|
||||
#else
|
||||
virtual void setRealBackground(gColor vl);
|
||||
#endif
|
||||
virtual void setRealForeground(gColor vl);
|
||||
virtual void setFocus();
|
||||
|
||||
|
@ -495,9 +495,11 @@ void gContainer::insert(gControl *child, bool realize)
|
||||
gtk_widget_realize(child->border);
|
||||
gtk_widget_show_all(child->border);
|
||||
}
|
||||
|
||||
|
||||
#ifndef GTK3
|
||||
if (hasBackground() && !child->_bg_set) child->setBackground();
|
||||
if (hasForeground() && !child->_fg_set) child->setForeground();
|
||||
#endif
|
||||
child->updateFont();
|
||||
}
|
||||
|
||||
@ -539,6 +541,7 @@ gControl *gContainer::find(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
#ifndef GTK3
|
||||
void gContainer::setBackground(gColor color)
|
||||
{
|
||||
int i;
|
||||
@ -551,8 +554,19 @@ void gContainer::setBackground(gColor color)
|
||||
ch = gContainer::child(i);
|
||||
if (!ch->_bg_set)
|
||||
ch->setBackground();
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GTK3
|
||||
void gContainer::updateColor()
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < childCount(); i++)
|
||||
gContainer::child(i)->updateColor();
|
||||
}
|
||||
#endif
|
||||
|
||||
void gContainer::setForeground(gColor color)
|
||||
{
|
||||
|
@ -86,7 +86,11 @@ public:
|
||||
|
||||
virtual void performArrange();
|
||||
|
||||
#ifndef GTK3
|
||||
virtual void setBackground(gColor color = COLOR_DEFAULT);
|
||||
#else
|
||||
virtual void updateColor();
|
||||
#endif
|
||||
virtual void setForeground(gColor color = COLOR_DEFAULT);
|
||||
virtual void updateFont();
|
||||
|
||||
|
@ -284,6 +284,11 @@ void gControl::initAll(gContainer *parent)
|
||||
hFree = NULL;
|
||||
_grab = false;
|
||||
|
||||
#ifdef GTK3
|
||||
_fg = _bg = COLOR_DEFAULT;
|
||||
_fg_name = _bg_name = NULL;
|
||||
#endif
|
||||
|
||||
controls = g_list_append(controls,this);
|
||||
}
|
||||
|
||||
@ -1609,13 +1614,16 @@ void gControl::realizeScrolledWindow(GtkWidget *wid, bool doNotRealize)
|
||||
{
|
||||
_scroll = GTK_SCROLLED_WINDOW(gtk_scrolled_window_new(NULL, NULL));
|
||||
|
||||
border = GTK_WIDGET(_scroll);
|
||||
border = gtk_alignment_new(0, 0, 1, 1);
|
||||
gtk_widget_set_redraw_on_allocate(border, TRUE);
|
||||
widget = wid;
|
||||
frame = 0;
|
||||
frame = border;
|
||||
_no_auto_grab = true;
|
||||
|
||||
//gtk_container_add(GTK_CONTAINER(border), GTK_WIDGET(_scroll));
|
||||
gtk_scrolled_window_set_policy(_scroll, GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
|
||||
gtk_scrolled_window_set_shadow_type(_scroll, GTK_SHADOW_NONE);
|
||||
gtk_container_add(GTK_CONTAINER(border), GTK_WIDGET(_scroll));
|
||||
gtk_container_add(GTK_CONTAINER(_scroll), widget);
|
||||
|
||||
if (!doNotRealize)
|
||||
@ -1692,24 +1700,12 @@ void gControl::setFrameBorder(int border)
|
||||
|
||||
bool gControl::hasBorder() const
|
||||
{
|
||||
if (_scroll)
|
||||
return gtk_scrolled_window_get_shadow_type(_scroll) != GTK_SHADOW_NONE;
|
||||
else
|
||||
return getFrameBorder() != BORDER_NONE;
|
||||
return getFrameBorder() != BORDER_NONE;
|
||||
}
|
||||
|
||||
void gControl::setBorder(bool vl)
|
||||
{
|
||||
if (_scroll)
|
||||
{
|
||||
if (vl)
|
||||
gtk_scrolled_window_set_shadow_type(_scroll, GTK_SHADOW_IN);
|
||||
else
|
||||
gtk_scrolled_window_set_shadow_type(_scroll, GTK_SHADOW_NONE);
|
||||
}
|
||||
else
|
||||
setFrameBorder(vl ? BORDER_SUNKEN : BORDER_NONE);
|
||||
|
||||
setFrameBorder(vl ? BORDER_SUNKEN : BORDER_NONE);
|
||||
_has_border = vl;
|
||||
}
|
||||
|
||||
@ -1730,6 +1726,38 @@ void gControl::setName(char *name)
|
||||
if (name) _name = g_strdup(name);
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
|
||||
gColor gControl::realBackground()
|
||||
{
|
||||
if (_bg != COLOR_DEFAULT)
|
||||
return _bg;
|
||||
else if (pr)
|
||||
return pr->realBackground();
|
||||
else
|
||||
return gDesktop::bgColor();
|
||||
}
|
||||
|
||||
gColor gControl::background()
|
||||
{
|
||||
return _bg;
|
||||
}
|
||||
|
||||
void gControl::setRealBackground(gColor color)
|
||||
{
|
||||
}
|
||||
|
||||
void gControl::setBackground(gColor color)
|
||||
{
|
||||
_bg = color;
|
||||
//if (gtk_widget_get_has_window(border))
|
||||
//gt_widget_set_background(border, realBackground());
|
||||
//else
|
||||
gt_widget_set_background(border, _bg, _bg_name, &_bg_default);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
gColor gControl::realBackground()
|
||||
{
|
||||
@ -1779,6 +1807,8 @@ void gControl::setBackground(gColor color)
|
||||
setRealBackground(color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
gColor gControl::realForeground()
|
||||
{
|
||||
if (_fg_set)
|
||||
@ -2262,3 +2292,35 @@ void gControl::setCanFocus(bool vl)
|
||||
gtk_widget_set_can_focus(widget, vl);
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
void gControl::updateColor()
|
||||
{
|
||||
}
|
||||
|
||||
void gControl::setBackgroundName(const char *names[])
|
||||
{
|
||||
_bg_name_list = names;
|
||||
if (!names)
|
||||
{
|
||||
_bg_name = NULL;
|
||||
use_base = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gt_style_lookup_color(gtk_widget_get_style_context(widget), names, &_bg_name, &_bg_default))
|
||||
return;
|
||||
}
|
||||
|
||||
void gControl::setBackgroundBase()
|
||||
{
|
||||
static const char *bg_names[] = { "base_color", "theme_base_color", NULL };
|
||||
setBackgroundName(bg_names);
|
||||
use_base = TRUE;
|
||||
}
|
||||
|
||||
void gControl::setBackgroundButton()
|
||||
{
|
||||
const char *bg_names[] = { "button_bg_color", "theme_button_bg_color", "theme_bg_color", NULL };
|
||||
setBackgroundName(bg_names);
|
||||
}
|
||||
#endif
|
@ -120,6 +120,16 @@ public:
|
||||
bool ownFont() { return _font != NULL; }
|
||||
virtual void updateFont();
|
||||
virtual void updateSize();
|
||||
#ifdef GTK3
|
||||
virtual void updateColor();
|
||||
void setBackgroundName(const char *names[]);
|
||||
void setBackgroundBase();
|
||||
void setBackgroundButton();
|
||||
#else
|
||||
void setBackgroundName(const char **) {}
|
||||
void setBackgroundBase() { use_base = TRUE; }
|
||||
void setBackgroundButton() {}
|
||||
#endif
|
||||
|
||||
bool canFocus() const;
|
||||
void setCanFocus(bool vl);
|
||||
@ -196,6 +206,15 @@ public:
|
||||
short g_typ;
|
||||
short _mouse;
|
||||
gControl *_proxy, *_proxy_for;
|
||||
#ifdef GTK3
|
||||
gColor _bg, _fg;
|
||||
const char *_bg_name;
|
||||
const char **_bg_name_list;
|
||||
GdkRGBA _bg_default;
|
||||
const char *_fg_name;
|
||||
const char **_fg_name_list;
|
||||
GdkRGBA _fg_default;
|
||||
#endif
|
||||
|
||||
unsigned dsg : 1;
|
||||
unsigned expa : 1;
|
||||
|
@ -106,9 +106,20 @@ gMainWindow* gDesktop::activeWindow()
|
||||
#ifdef GTK3
|
||||
static gColor get_color(GType type, gColor default_color, GtkStateFlags state, bool fg, bool text)
|
||||
{
|
||||
static const char *bg_names[] = { "bg_color", "theme_bg_color", NULL };
|
||||
static const char *fg_names[] = { "fg_color", "theme_fg_color", NULL };
|
||||
|
||||
GtkStyleContext *st = gt_get_style(type);
|
||||
GdkRGBA rgba;
|
||||
|
||||
if (type == GTK_TYPE_WINDOW)
|
||||
{
|
||||
if (gt_style_lookup_color(st, fg ? fg_names : bg_names, NULL, &rgba))
|
||||
return default_color;
|
||||
else
|
||||
return gt_to_color(&rgba);
|
||||
}
|
||||
|
||||
if (!st)
|
||||
return default_color;
|
||||
|
||||
@ -158,12 +169,12 @@ gColor gDesktop::buttonbgColor()
|
||||
|
||||
gColor gDesktop::fgColor()
|
||||
{
|
||||
return get_color(GTK_TYPE_LAYOUT, 0, STATE_NORMAL, true, false);
|
||||
return get_color(GTK_TYPE_WINDOW, 0, STATE_NORMAL, true, false);
|
||||
}
|
||||
|
||||
gColor gDesktop::bgColor()
|
||||
{
|
||||
return get_color(GTK_TYPE_LAYOUT, 0xC0C0C0, STATE_NORMAL, false, false);
|
||||
return get_color(GTK_TYPE_WINDOW, 0xC0C0C0, STATE_NORMAL, false, false);
|
||||
}
|
||||
|
||||
gColor gDesktop::textfgColor()
|
||||
|
@ -205,8 +205,16 @@ void gFrame::updateFont()
|
||||
gtk_widget_modify_font(label, font()->desc());
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
void gFrame::updateColor()
|
||||
{
|
||||
gContainer::updateColor();
|
||||
gt_widget_set_background(fr, background());
|
||||
}
|
||||
#else
|
||||
void gFrame::setRealForeground(gColor color)
|
||||
{
|
||||
gControl::setRealForeground(color);
|
||||
if (label) set_gdk_fg_color(label, color);
|
||||
}
|
||||
#endif
|
||||
|
@ -50,7 +50,11 @@ public:
|
||||
void setText(char* vl);
|
||||
|
||||
virtual void updateFont();
|
||||
#ifdef GTK3
|
||||
virtual void updateColor();
|
||||
#else
|
||||
virtual void setRealForeground(gColor color);
|
||||
#endif
|
||||
|
||||
//"Private"
|
||||
GtkWidget *fr;
|
||||
|
@ -27,6 +27,7 @@
|
||||
gProgressBar::gProgressBar(gContainer *parent) : gControl(parent)
|
||||
{
|
||||
_label = true;
|
||||
_no_background = TRUE;
|
||||
|
||||
g_typ = Type_gProgressBar;
|
||||
|
||||
|
@ -61,7 +61,7 @@ gSpinBox::gSpinBox(gContainer *parent) : gControl(parent)
|
||||
{
|
||||
g_typ=Type_gSpinBox;
|
||||
have_cursor = true;
|
||||
use_base = true;
|
||||
_no_background = TRUE;
|
||||
|
||||
_min = 0;
|
||||
_max = 100;
|
||||
@ -80,6 +80,7 @@ gSpinBox::gSpinBox(gContainer *parent) : gControl(parent)
|
||||
#endif
|
||||
|
||||
realize();
|
||||
setBackgroundBase();
|
||||
|
||||
onChange = NULL;
|
||||
|
||||
@ -197,3 +198,16 @@ void gSpinBox::setBorder(bool vl)
|
||||
{
|
||||
gtk_entry_set_has_frame(GTK_ENTRY(widget), vl);
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
void gSpinBox::resize(int w, int h)
|
||||
{
|
||||
int mw;
|
||||
|
||||
gtk_widget_get_preferred_width(widget, NULL, &mw);
|
||||
if (w < mw)
|
||||
w = mw;
|
||||
|
||||
gControl::resize(w, h);
|
||||
}
|
||||
#endif
|
@ -52,6 +52,8 @@ public:
|
||||
|
||||
#ifndef GTK3
|
||||
virtual void updateCursor(GdkCursor *cursor);
|
||||
#else
|
||||
virtual void resize(int w, int h);
|
||||
#endif
|
||||
|
||||
//"Private"
|
||||
|
@ -327,8 +327,12 @@ gTabStripPage::~gTabStripPage()
|
||||
|
||||
void gTabStripPage::updateColors()
|
||||
{
|
||||
#ifdef GTK3
|
||||
gt_widget_set_background(widget, parent->realBackground());
|
||||
#else
|
||||
set_gdk_bg_color(widget, parent->realBackground());
|
||||
set_gdk_fg_color(label, parent->realForeground());
|
||||
#endif
|
||||
}
|
||||
|
||||
void gTabStripPage::updateFont()
|
||||
@ -788,13 +792,25 @@ GtkWidget *gTabStrip::getContainer()
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void gTabStrip::setRealBackground(gColor color)
|
||||
#ifdef GTK3
|
||||
void gTabStrip::updateColor()
|
||||
{
|
||||
gControl::setRealBackground(color);
|
||||
|
||||
//fprintf(stderr, "%s: updateColors\n", name());
|
||||
gt_widget_set_background(border, realBackground());
|
||||
gt_widget_set_background(widget, realBackground());
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
get(i)->updateColors();
|
||||
}
|
||||
#else
|
||||
void gTabStrip::setRealBackground(gColor color)
|
||||
{
|
||||
gControl::setRealBackground(color);
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
get(i)->updateColors();
|
||||
}
|
||||
#endif
|
||||
|
||||
void gTabStrip::setRealForeground(gColor color)
|
||||
{
|
||||
|
@ -60,7 +60,11 @@ public:
|
||||
virtual int childCount() const;
|
||||
virtual gControl *child(int index) const;
|
||||
|
||||
#ifndef GTK3
|
||||
virtual void setRealBackground(gColor color);
|
||||
#else
|
||||
virtual void updateColor();
|
||||
#endif
|
||||
virtual void setRealForeground(gColor color);
|
||||
virtual void updateFont();
|
||||
|
||||
|
@ -315,7 +315,6 @@ gTextArea::gTextArea(gContainer *parent) : gControl(parent)
|
||||
_align_normal = false;
|
||||
|
||||
have_cursor = true;
|
||||
use_base = true;
|
||||
_undo_stack = NULL;
|
||||
_redo_stack = NULL;
|
||||
_not_undoable_action = 0;
|
||||
@ -327,6 +326,8 @@ gTextArea::gTextArea(gContainer *parent) : gControl(parent)
|
||||
textview = gtk_text_view_new();
|
||||
realizeScrolledWindow(textview);
|
||||
|
||||
setBackgroundBase();
|
||||
|
||||
//g_signal_connect_after(G_OBJECT(textview), "motion-notify-event", G_CALLBACK(cb_motion_notify_event), (gpointer)this);
|
||||
g_signal_connect(G_OBJECT(textview), "key-press-event", G_CALLBACK(cb_keypress), (gpointer)this);
|
||||
|
||||
@ -854,3 +855,11 @@ void gTextArea::clear()
|
||||
clearUndoStack();
|
||||
clearRedoStack();
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
void gTextArea::updateColor()
|
||||
{
|
||||
gt_widget_set_background(textview, background(), _bg_name, &_bg_default);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -91,6 +91,9 @@ public:
|
||||
|
||||
//"Private"
|
||||
virtual void updateCursor(GdkCursor *cursor);
|
||||
#ifdef GTK3
|
||||
virtual void updateColor();
|
||||
#endif
|
||||
//void waitForLayout(int *tw, int *th);
|
||||
void clearUndoStack();
|
||||
void clearRedoStack();
|
||||
|
@ -143,10 +143,11 @@ gTextBox::gTextBox(gContainer *parent, bool combo) : gControl(parent)
|
||||
g_typ=Type_gTextBox;
|
||||
|
||||
have_cursor = true;
|
||||
use_base = true;
|
||||
_no_background = TRUE;
|
||||
|
||||
entry = widget = gtk_entry_new();
|
||||
realize();
|
||||
setBackgroundBase();
|
||||
initEntry();
|
||||
}
|
||||
|
||||
|
@ -256,6 +256,7 @@ void gt_color_to_frgba(gColor color, double *r, double *g, double *b, double *a)
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
|
||||
void gt_from_color(gColor color, GdkRGBA *rgba)
|
||||
{
|
||||
gt_color_to_frgba(color, &rgba->red, &rgba->green, &rgba->blue, &rgba->alpha);
|
||||
@ -265,6 +266,7 @@ gColor gt_to_color(GdkRGBA *rgba)
|
||||
{
|
||||
return gt_frgba_to_color(rgba->red, rgba->green, rgba->blue, rgba->alpha);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
gColor gt_frgba_to_color(double r, double g, double b, double a)
|
||||
@ -1924,12 +1926,14 @@ void gt_cairo_draw_pixbuf(cairo_t *cr, GdkPixbuf *pixbuf, float x, float y, floa
|
||||
|
||||
// Style management
|
||||
|
||||
#define NUM_STYLES 12
|
||||
|
||||
#ifdef GTK3
|
||||
static int _style_context_loaded = 0;
|
||||
static GtkStyleContext *_style_context[11];
|
||||
static GtkStyleContext *_style_context[NUM_STYLES];
|
||||
#endif
|
||||
static int _style_loaded = 0;
|
||||
static GtkStyle *_style[11];
|
||||
static GtkStyle *_style[NUM_STYLES];
|
||||
|
||||
static int type_to_index(GType type)
|
||||
{
|
||||
@ -1953,6 +1957,8 @@ static int type_to_index(GType type)
|
||||
return 9;
|
||||
else if (type == GTK_TYPE_BUTTON)
|
||||
return 10;
|
||||
else if (type == GTK_TYPE_WINDOW)
|
||||
return 11;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
@ -1964,7 +1970,7 @@ const char *gt_get_style_class(GType type)
|
||||
static const char *_class[] = {
|
||||
GTK_STYLE_CLASS_DEFAULT, GTK_STYLE_CLASS_ENTRY, GTK_STYLE_CLASS_BACKGROUND, GTK_STYLE_CLASS_TOOLTIP,
|
||||
GTK_STYLE_CLASS_SCROLLBAR, GTK_STYLE_CLASS_DEFAULT, GTK_STYLE_CLASS_CHECK, GTK_STYLE_CLASS_RADIO,
|
||||
GTK_STYLE_CLASS_FRAME, GTK_STYLE_CLASS_BACKGROUND, GTK_STYLE_CLASS_BUTTON
|
||||
GTK_STYLE_CLASS_FRAME, GTK_STYLE_CLASS_BACKGROUND, GTK_STYLE_CLASS_BUTTON, GTK_STYLE_CLASS_DEFAULT
|
||||
};
|
||||
|
||||
int index = type_to_index(type);
|
||||
@ -2089,3 +2095,47 @@ void gt_draw_border(cairo_t *cr, GtkStyleContext *st, GtkStateFlags state, int b
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef GTK3
|
||||
|
||||
void gt_widget_set_background(GtkWidget *widget, gColor color, const char *name, const GdkRGBA *def_color)
|
||||
{
|
||||
if (color == COLOR_DEFAULT)
|
||||
{
|
||||
if (name)
|
||||
gtk_widget_override_symbolic_color(widget, name, def_color);
|
||||
else
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
GdkRGBA rgba;
|
||||
gt_from_color(color, &rgba);
|
||||
if (name)
|
||||
gtk_widget_override_symbolic_color(widget, name, &rgba);
|
||||
else
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, &rgba);
|
||||
}
|
||||
}
|
||||
|
||||
bool gt_style_lookup_color(GtkStyleContext *style, const char **names, const char **pname, GdkRGBA *rgba)
|
||||
{
|
||||
const char **p = names;
|
||||
const char *name;
|
||||
|
||||
while((name = *p++))
|
||||
{
|
||||
if (gtk_style_context_lookup_color(style, name, rgba))
|
||||
break;
|
||||
}
|
||||
|
||||
if (name)
|
||||
{
|
||||
if (pname)
|
||||
*pname = name;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#endif
|
@ -171,8 +171,13 @@ void gt_color_to_frgba(gColor color, double *r, double *g, double *b, double *a)
|
||||
gColor gt_frgba_to_color(double r, double g, double b, double a);
|
||||
|
||||
#ifdef GTK3
|
||||
|
||||
void gt_from_color(gColor color, GdkRGBA *rgba);
|
||||
gColor gt_to_color(GdkRGBA *rgba);
|
||||
|
||||
void gt_widget_set_background(GtkWidget *widget, gColor color, const char *name = NULL, const GdkRGBA *def_color = NULL);
|
||||
bool gt_style_lookup_color(GtkStyleContext *style, const char **names, const char **pname, GdkRGBA *rgba);
|
||||
|
||||
#endif
|
||||
|
||||
// Draw a control border
|
||||
|
Loading…
x
Reference in New Issue
Block a user