[GB.GTK]
* NEW: GTK3+ support continues. git-svn-id: svn://localhost/gambas/trunk@6064 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
5b7b339424
commit
e3dfc5b9f6
@ -589,13 +589,17 @@ static void style_handle(int x, int y, int w, int h, int vertical, int state)
|
||||
static void style_box(int x, int y, int w, int h, int state, GB_COLOR color)
|
||||
{
|
||||
STYLE_T *style = get_style(GTK_TYPE_ENTRY);
|
||||
#ifdef GTK3
|
||||
bool oxygen = false;
|
||||
#endif
|
||||
|
||||
if (strcmp(gApplication::getStyleName(), "oxygen-gtk") == 0)
|
||||
{
|
||||
x -= 3;
|
||||
w += 6;
|
||||
#ifdef GTK3
|
||||
oxygen = true;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef GTK3
|
||||
|
@ -394,7 +394,7 @@ gButton::gButton(gContainer *par, Type typ) : gControl(par)
|
||||
else
|
||||
{
|
||||
g_signal_connect(G_OBJECT(widget),"clicked",G_CALLBACK(cb_click),(gpointer)this);
|
||||
setBackgroundButton();
|
||||
setColorButton();
|
||||
}
|
||||
|
||||
|
||||
|
@ -129,19 +129,21 @@ char *gComboBox::indexToKey(int index)
|
||||
void gComboBox::create(bool readOnly)
|
||||
{
|
||||
bool first = !border;
|
||||
int ind = -1;
|
||||
//bool focus = hasFocus();
|
||||
char *save = NULL;
|
||||
GB_COLOR bg, fg;
|
||||
|
||||
//fprintf(stderr, "create: %d hasFocus = %d\n", readOnly, focus );
|
||||
|
||||
lock();
|
||||
|
||||
if (first)
|
||||
{
|
||||
border = gtk_alignment_new(0, 0, 1, 1); //gtk_event_box_new();
|
||||
}
|
||||
else
|
||||
ind = index();
|
||||
{
|
||||
save = g_strdup(text());
|
||||
bg = background();
|
||||
fg = foreground();
|
||||
}
|
||||
|
||||
if (widget)
|
||||
{
|
||||
@ -204,22 +206,26 @@ void gComboBox::create(bool readOnly)
|
||||
if (entry)
|
||||
{
|
||||
initEntry();
|
||||
setBackgroundBase();
|
||||
setColorBase();
|
||||
//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();
|
||||
setColorButton();
|
||||
|
||||
updateFocusHandler();
|
||||
setBackground(background());
|
||||
setForeground(foreground());
|
||||
updateFont();
|
||||
|
||||
if (ind >= 0)
|
||||
setIndex(ind);
|
||||
if (!first)
|
||||
{
|
||||
setBackground(bg);
|
||||
setForeground(fg);
|
||||
updateFont();
|
||||
}
|
||||
|
||||
setText(save);
|
||||
g_free(save);
|
||||
|
||||
unlock();
|
||||
}
|
||||
@ -272,7 +278,10 @@ void gComboBox::updateColor()
|
||||
{
|
||||
gTextBox::updateColor();
|
||||
if (entry)
|
||||
gt_widget_set_background(entry, background(), _bg_name, &_bg_default);
|
||||
{
|
||||
gt_widget_set_color(entry, FALSE, background(), _bg_name, &_bg_default);
|
||||
gt_widget_set_color(entry, TRUE, foreground(), _fg_name, &_fg_default);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void gComboBox::setRealBackground(gColor color)
|
||||
@ -367,6 +376,9 @@ void gComboBox::setIndex(int vl)
|
||||
|
||||
updateModel();
|
||||
gtk_combo_box_set_active(GTK_COMBO_BOX(widget), vl);
|
||||
|
||||
if (entry)
|
||||
gTextBox::setText(itemText(vl));
|
||||
}
|
||||
|
||||
void gComboBox::checkIndex()
|
||||
|
@ -1750,10 +1750,33 @@ 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);
|
||||
gt_widget_set_color(border, FALSE, _bg, _bg_name, &_bg_default);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
gColor gControl::realForeground()
|
||||
{
|
||||
if (_fg != COLOR_DEFAULT)
|
||||
return _fg;
|
||||
else if (pr)
|
||||
return pr->realForeground();
|
||||
else
|
||||
return gDesktop::fgColor();
|
||||
}
|
||||
|
||||
gColor gControl::foreground()
|
||||
{
|
||||
return _fg;
|
||||
}
|
||||
|
||||
void gControl::setRealForeground(gColor color)
|
||||
{
|
||||
}
|
||||
|
||||
void gControl::setForeground(gColor color)
|
||||
{
|
||||
_fg = color;
|
||||
gt_widget_set_color(border, TRUE, _fg, _fg_name, &_fg_default);
|
||||
updateColor();
|
||||
}
|
||||
|
||||
@ -1807,8 +1830,6 @@ void gControl::setBackground(gColor color)
|
||||
setRealBackground(color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
gColor gControl::realForeground()
|
||||
{
|
||||
if (_fg_set)
|
||||
@ -1857,6 +1878,8 @@ void gControl::setForeground(gColor color)
|
||||
setRealForeground(color);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void gControl::emit(void *signal)
|
||||
{
|
||||
if (!signal || locked())
|
||||
@ -2297,30 +2320,36 @@ void gControl::updateColor()
|
||||
{
|
||||
}
|
||||
|
||||
void gControl::setBackgroundName(const char *names[])
|
||||
void gControl::setColorNames(const char *bg_names[], const char *fg_names[])
|
||||
{
|
||||
_bg_name_list = names;
|
||||
if (!names)
|
||||
_bg_name_list = bg_names;
|
||||
_fg_name_list = fg_names;
|
||||
|
||||
if (!bg_names)
|
||||
{
|
||||
_bg_name = NULL;
|
||||
_fg_name = NULL;
|
||||
use_base = FALSE;
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gt_style_lookup_color(gtk_widget_get_style_context(widget), names, &_bg_name, &_bg_default))
|
||||
return;
|
||||
gt_style_lookup_color(gtk_widget_get_style_context(widget), bg_names, &_bg_name, &_bg_default);
|
||||
gt_style_lookup_color(gtk_widget_get_style_context(widget), fg_names, &_fg_name, &_fg_default);
|
||||
}
|
||||
|
||||
void gControl::setBackgroundBase()
|
||||
void gControl::setColorBase()
|
||||
{
|
||||
static const char *bg_names[] = { "base_color", "theme_base_color", NULL };
|
||||
setBackgroundName(bg_names);
|
||||
static const char *fg_names[] = { "text_color", "theme_text_color", NULL };
|
||||
setColorNames(bg_names, fg_names);
|
||||
use_base = TRUE;
|
||||
}
|
||||
|
||||
void gControl::setBackgroundButton()
|
||||
void gControl::setColorButton()
|
||||
{
|
||||
const char *bg_names[] = { "button_bg_color", "theme_button_bg_color", "theme_bg_color", NULL };
|
||||
setBackgroundName(bg_names);
|
||||
const char *fg_names[] = { "button_fg_color", "theme_button_fg_color", "theme_fg_color", NULL };
|
||||
setColorNames(bg_names, fg_names);
|
||||
use_base = FALSE;
|
||||
}
|
||||
#endif
|
@ -122,13 +122,13 @@ public:
|
||||
virtual void updateSize();
|
||||
#ifdef GTK3
|
||||
virtual void updateColor();
|
||||
void setBackgroundName(const char *names[]);
|
||||
void setBackgroundBase();
|
||||
void setBackgroundButton();
|
||||
void setColorNames(const char *bg_names[], const char *fg_names[]);
|
||||
void setColorBase();
|
||||
void setColorButton();
|
||||
#else
|
||||
void setBackgroundName(const char **) {}
|
||||
void setBackgroundBase() { use_base = TRUE; }
|
||||
void setBackgroundButton() {}
|
||||
void setColorNames(const char **, const char **) {}
|
||||
void setColorBase() { use_base = TRUE; }
|
||||
void setColorButton() { use_base = FALSE; }
|
||||
#endif
|
||||
|
||||
bool canFocus() const;
|
||||
|
@ -253,10 +253,19 @@ void gFont::initFlags()
|
||||
|
||||
gFont::gFont() : gShare()
|
||||
{
|
||||
GtkStyle *sty = gtk_widget_get_default_style();
|
||||
realize();
|
||||
#ifdef GTK3
|
||||
char *font;
|
||||
g_object_get(gtk_settings_get_default(), "gtk-font-name", &font, (char *)NULL);
|
||||
realize();
|
||||
ct = gdk_pango_context_get();
|
||||
pango_context_set_font_description(ct,sty->font_desc);
|
||||
pango_context_set_font_description(ct, pango_font_description_from_string(font));
|
||||
g_free(font);
|
||||
#else
|
||||
GtkStyle *sty = gtk_widget_get_default_style();
|
||||
realize();
|
||||
ct = gdk_pango_context_get();
|
||||
pango_context_set_font_description(ct, sty->font_desc);
|
||||
#endif
|
||||
}
|
||||
|
||||
gFont::gFont(GtkWidget *wid) : gShare()
|
||||
|
@ -209,7 +209,7 @@ void gFrame::updateFont()
|
||||
void gFrame::updateColor()
|
||||
{
|
||||
gContainer::updateColor();
|
||||
gt_widget_set_background(fr, background());
|
||||
gt_widget_set_color(fr, FALSE, background());
|
||||
}
|
||||
#else
|
||||
void gFrame::setRealForeground(gColor color)
|
||||
|
@ -354,10 +354,10 @@ void gLabel::setWrap(bool v)
|
||||
updateSize(true);
|
||||
}
|
||||
|
||||
gColor gLabel::getFrameColor()
|
||||
/*gColor gLabel::getFrameColor()
|
||||
{
|
||||
return realForeground();
|
||||
}
|
||||
}*/
|
||||
|
||||
void gLabel::updateSize()
|
||||
{
|
||||
|
@ -55,7 +55,7 @@ public:
|
||||
virtual void afterRefresh();
|
||||
|
||||
//"Private"
|
||||
virtual gColor getFrameColor();
|
||||
//virtual gColor getFrameColor();
|
||||
virtual void updateSize();
|
||||
void updateSize(bool adjust, bool noresize = false);
|
||||
void updateLayout();
|
||||
|
@ -966,6 +966,8 @@ void gMainWindow::drawMask()
|
||||
if (mask)
|
||||
cairo_region_destroy(mask);
|
||||
|
||||
refresh();
|
||||
|
||||
#else
|
||||
|
||||
GdkBitmap *mask = (_mask && _picture) ? _picture->getMask() : NULL;
|
||||
|
@ -80,7 +80,7 @@ gSpinBox::gSpinBox(gContainer *parent) : gControl(parent)
|
||||
#endif
|
||||
|
||||
realize();
|
||||
setBackgroundBase();
|
||||
setColorBase();
|
||||
|
||||
onChange = NULL;
|
||||
|
||||
|
@ -331,7 +331,7 @@ gTabStripPage::~gTabStripPage()
|
||||
void gTabStripPage::updateColors()
|
||||
{
|
||||
#ifdef GTK3
|
||||
gt_widget_set_background(widget, parent->realBackground());
|
||||
gt_widget_set_color(widget, FALSE, parent->realBackground());
|
||||
#else
|
||||
set_gdk_bg_color(widget, parent->realBackground());
|
||||
set_gdk_fg_color(label, parent->realForeground());
|
||||
@ -799,8 +799,8 @@ GtkWidget *gTabStrip::getContainer()
|
||||
void gTabStrip::updateColor()
|
||||
{
|
||||
//fprintf(stderr, "%s: updateColors\n", name());
|
||||
gt_widget_set_background(border, realBackground());
|
||||
gt_widget_set_background(widget, realBackground());
|
||||
gt_widget_set_color(border, false, realBackground());
|
||||
gt_widget_set_color(widget, false, realBackground());
|
||||
|
||||
for (int i = 0; i < count(); i++)
|
||||
get(i)->updateColors();
|
||||
|
@ -326,7 +326,7 @@ gTextArea::gTextArea(gContainer *parent) : gControl(parent)
|
||||
textview = gtk_text_view_new();
|
||||
realizeScrolledWindow(textview);
|
||||
|
||||
setBackgroundBase();
|
||||
setColorBase();
|
||||
|
||||
//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);
|
||||
@ -859,7 +859,7 @@ void gTextArea::clear()
|
||||
#ifdef GTK3
|
||||
void gTextArea::updateColor()
|
||||
{
|
||||
gt_widget_set_background(textview, background(), _bg_name, &_bg_default);
|
||||
gt_widget_set_color(textview, FALSE, background(), _bg_name, &_bg_default);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -147,7 +147,7 @@ gTextBox::gTextBox(gContainer *parent, bool combo) : gControl(parent)
|
||||
|
||||
entry = widget = gtk_entry_new();
|
||||
realize();
|
||||
setBackgroundBase();
|
||||
setColorBase();
|
||||
initEntry();
|
||||
}
|
||||
|
||||
|
@ -2099,12 +2099,14 @@ void gt_draw_border(cairo_t *cr, GtkStyleContext *st, GtkStateFlags state, int b
|
||||
|
||||
#ifdef GTK3
|
||||
|
||||
void gt_widget_set_background(GtkWidget *widget, gColor color, const char *name, const GdkRGBA *def_color)
|
||||
void gt_widget_set_color(GtkWidget *widget, bool fg, 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 if (fg)
|
||||
gtk_widget_override_color(widget, GTK_STATE_FLAG_NORMAL, NULL);
|
||||
else
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, NULL);
|
||||
}
|
||||
@ -2114,6 +2116,8 @@ void gt_widget_set_background(GtkWidget *widget, gColor color, const char *name,
|
||||
gt_from_color(color, &rgba);
|
||||
if (name)
|
||||
gtk_widget_override_symbolic_color(widget, name, &rgba);
|
||||
else if (fg)
|
||||
gtk_widget_override_color(widget, GTK_STATE_FLAG_NORMAL, &rgba);
|
||||
else
|
||||
gtk_widget_override_background_color(widget, GTK_STATE_FLAG_NORMAL, &rgba);
|
||||
}
|
||||
|
@ -175,7 +175,7 @@ gColor gt_frgba_to_color(double r, double g, double b, double a);
|
||||
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);
|
||||
void gt_widget_set_color(GtkWidget *widget, bool fg, 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
|
||||
|
Loading…
x
Reference in New Issue
Block a user