[Libreoffice-commits] .: 7 commits - vcl/inc vcl/unx
Cosimo Cecchi
cosimoc at kemper.freedesktop.org
Thu Nov 3 10:15:31 PDT 2011
vcl/inc/unx/gtk/gtkdata.hxx | 9
vcl/inc/unx/gtk/gtkgdi.hxx | 26 +
vcl/unx/gtk/window/gtkframe.cxx | 68 ++--
vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx | 423 ++++++++++++++++++++++++--
4 files changed, 466 insertions(+), 60 deletions(-)
New commits:
commit 06840c3b3d90ad79c58398d1420577c28d630d57
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Thu Nov 3 08:56:12 2011 -0400
gtk3: implement rendering for Listbox widgets
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 6722cea..878fa61 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -78,12 +78,13 @@ private:
static GtkStyleContext *mpMenuItemStyle;
static GtkStyleContext *mpSpinStyle;
static GtkStyleContext *mpComboboxStyle;
+ static GtkStyleContext *mpListboxStyle;
void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
- Rectangle NWGetComboBoxButtonRect( ControlPart nPart, Rectangle aAreaRect );
+ Rectangle NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect );
void PaintScrollbar(GtkStyleContext *context,
cairo_t *cr,
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 0cd171e..9e93a02 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -46,6 +46,7 @@ GtkStyleContext* GtkSalGraphics::mpMenuStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpSpinStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpComboboxStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpListboxStyle = NULL;
bool GtkSalGraphics::style_loaded = false;
/************************************************************************
@@ -644,7 +645,8 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
}
#define ARROW_SIZE 11 * 0.85
-Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlPart nPart,
+Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlType nType,
+ ControlPart nPart,
Rectangle aAreaRect )
{
Rectangle aButtonRect;
@@ -700,40 +702,60 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
// plus its actual draw rect excluding adornment
areaRect = rControlRectangle;
- buttonRect = NWGetComboBoxButtonRect( PART_BUTTON_DOWN, areaRect );
+ buttonRect = NWGetComboBoxButtonRect( nType, PART_BUTTON_DOWN, areaRect );
if( nPart == PART_BUTTON_DOWN )
buttonRect.Left() += 1;
Rectangle aEditBoxRect( areaRect );
aEditBoxRect.SetSize( Size( areaRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) );
- if( nPart == PART_ENTIRE_CONTROL )
- {
- PrepareComboboxStyle(context, true);
- gtk_render_background(context, cr,
- 0, 0,
- aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
- gtk_render_frame(context, cr,
- 0, 0,
- aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
- }
+ if ( nType == CTRL_COMBOBOX )
+ {
+ if( nPart == PART_ENTIRE_CONTROL )
+ {
+ PrepareComboboxStyle(context, true);
+ gtk_render_background(context, cr,
+ 0, 0,
+ aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ 0, 0,
+ aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
+ }
+
+ PrepareComboboxStyle(context, false);
+ gtk_render_background(context, cr,
+ (buttonRect.Left() - areaRect.Left()),
+ (buttonRect.Top() - areaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ (buttonRect.Left() - areaRect.Left()),
+ (buttonRect.Top() - areaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+ }
+ else if (nType == CTRL_LISTBOX)
+ {
+ if( nPart == PART_WINDOW )
+ {
+ /* render the popup window with the menu style */
+ gtk_render_frame(mpMenuStyle, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+ }
+ else
+ {
+ gtk_render_background(context, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+ gtk_render_frame(context, cr,
+ 0, 0,
+ areaRect.GetWidth(), areaRect.GetHeight());
+ }
+ }
arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
(gint)(ARROW_SIZE) ) );
arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
-
- PrepareComboboxStyle(context, false);
-
- gtk_render_background(context, cr,
- (buttonRect.Left() - areaRect.Left()),
- (buttonRect.Top() - areaRect.Top()),
- buttonRect.GetWidth(), buttonRect.GetHeight() );
- gtk_render_frame(context, cr,
- (buttonRect.Left() - areaRect.Left()),
- (buttonRect.Top() - areaRect.Top()),
- buttonRect.GetWidth(), buttonRect.GetHeight() );
-
gtk_render_arrow(context, cr,
G_PI,
(arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
@@ -772,6 +794,17 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
context = mpComboboxStyle;
renderType = RENDER_COMBOBOX;
break;
+ case CTRL_LISTBOX:
+ switch (nPart)
+ {
+ case PART_ENTIRE_CONTROL:
+ context = mpListboxStyle;
+ renderType = RENDER_COMBOBOX;
+ break;
+ default:
+ return sal_False;
+ }
+ break;
case CTRL_MENU_POPUP:
/* FIXME: missing ENTIRE_CONTROL, as it doesn't seem to work */
switch(nPart)
@@ -1066,10 +1099,15 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart
else if ( (nType==CTRL_COMBOBOX) &&
((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
{
- aEditRect = NWGetComboBoxButtonRect( nPart, rControlRegion );
+ aEditRect = NWGetComboBoxButtonRect( nType, nPart, rControlRegion );
}
-
- else {
+ else if ( (nType==CTRL_LISTBOX) &&
+ ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
+ {
+ aEditRect = NWGetComboBoxButtonRect( nType, nPart, rControlRegion );
+ }
+ else
+ {
return sal_False;
}
@@ -1384,7 +1422,6 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
{
- printf("Is native supported for Type: %d, Part %d\n", nType, nPart);
if(
(nType == CTRL_EDITBOX) ||
(nType == CTRL_PUSHBUTTON && nPart == PART_ENTIRE_CONTROL) ||
@@ -1398,6 +1435,9 @@ sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPar
((nType == CTRL_COMBOBOX) &&
((nPart == PART_ENTIRE_CONTROL) || (nPart == PART_ALL_BUTTONS) ||
(nPart == HAS_BACKGROUND_TEXTURE))) ||
+ ((nType==CTRL_LISTBOX) &&
+ ((nPart==PART_ENTIRE_CONTROL) || (nPart == PART_WINDOW) || (nPart == PART_BUTTON_DOWN) ||
+ (nPart==HAS_BACKGROUND_TEXTURE))) ||
((nType == CTRL_SCROLLBAR) &&
( (nPart == PART_DRAW_BACKGROUND_HORZ) || (nPart == PART_DRAW_BACKGROUND_VERT) ||
(nPart == PART_ENTIRE_CONTROL) || (nPart == HAS_THREE_BUTTONS))) ||
@@ -1406,6 +1446,8 @@ sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPar
(nPart == PART_MENU_SEPARATOR) || (nPart == PART_MENU_SUBMENU_ARROW))))
return sal_True;
+ printf("Unhandled is native supported for Type: %d, Part %d\n", nType, nPart);
+
return sal_False;
}
@@ -1492,6 +1534,14 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
mpComboboxStyle = gtk_style_context_new();
PrepareComboboxStyle(mpComboboxStyle, true);
+ /* Listbox */
+ mpListboxStyle = gtk_style_context_new();
+ path = gtk_widget_path_new();
+ gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX);
+ gtk_widget_path_append_type(path, GTK_TYPE_BUTTON);
+ gtk_widget_path_iter_add_class(path, 1, GTK_STYLE_CLASS_BUTTON);
+ gtk_style_context_set_path(mpListboxStyle, path);
+ gtk_widget_path_free(path);
}
static void print_cairo_region (cairo_region_t *region, const char *msg)
commit 322626013770a8e781031e52cfb3f1cebd7f0f60
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 22:28:04 2011 -0400
gtk3: translate the cairo context instead of rendering from (1, 1)
It's just way easier than doing it every time.
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index a7a9b0f..0cd171e 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -408,7 +408,6 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
sal_Bool has_slider = ( thumbRect.GetWidth() > 0 && thumbRect.GetHeight() > 0 );
x = y = 0;
-
w = scrollbarRect.GetWidth();
h = scrollbarRect.GetHeight();
@@ -580,7 +579,7 @@ void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context,
gtk_render_arrow(context, cr,
(nPart == PART_BUTTON_UP) ? 0 : G_PI,
- 1 + (arrowRect.Left() - aAreaRect.Left()), 1 + (arrowRect.Top() - aAreaRect.Top()),
+ (arrowRect.Left() - aAreaRect.Left()), (arrowRect.Top() - aAreaRect.Top()),
arrowSize);
gtk_style_context_restore(context);
@@ -633,10 +632,10 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
if ( shadowType != GTK_SHADOW_NONE )
{
gtk_render_background(context, cr,
- 1, 1,
+ 0, 0,
areaRect.GetWidth(), areaRect.GetHeight() );
gtk_render_frame(context, cr,
- 1, 1,
+ 0, 0,
areaRect.GetWidth(), areaRect.GetHeight() );
}
@@ -696,13 +695,10 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
Rectangle areaRect;
Rectangle buttonRect;
Rectangle arrowRect;
- gint x,y;
// Find the overall bounding rect of the buttons's drawing area,
// plus its actual draw rect excluding adornment
areaRect = rControlRectangle;
- x = 1;
- y = 1;
buttonRect = NWGetComboBoxButtonRect( PART_BUTTON_DOWN, areaRect );
if( nPart == PART_BUTTON_DOWN )
@@ -715,10 +711,10 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
{
PrepareComboboxStyle(context, true);
gtk_render_background(context, cr,
- x, y,
+ 0, 0,
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
gtk_render_frame(context, cr,
- x, y,
+ 0, 0,
aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
}
@@ -730,17 +726,17 @@ void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
PrepareComboboxStyle(context, false);
gtk_render_background(context, cr,
- x+(buttonRect.Left() - areaRect.Left()),
- y+(buttonRect.Top() - areaRect.Top()),
+ (buttonRect.Left() - areaRect.Left()),
+ (buttonRect.Top() - areaRect.Top()),
buttonRect.GetWidth(), buttonRect.GetHeight() );
gtk_render_frame(context, cr,
- x+(buttonRect.Left() - areaRect.Left()),
- y+(buttonRect.Top() - areaRect.Top()),
+ (buttonRect.Left() - areaRect.Left()),
+ (buttonRect.Top() - areaRect.Top()),
buttonRect.GetWidth(), buttonRect.GetHeight() );
gtk_render_arrow(context, cr,
G_PI,
- x+(arrowRect.Left() - areaRect.Left()), y+(arrowRect.Top() - areaRect.Top()),
+ (arrowRect.Left() - areaRect.Left()), (arrowRect.Top() - areaRect.Top()),
arrowRect.GetWidth() );
}
@@ -883,36 +879,38 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
if (styleClass)
gtk_style_context_add_class(context, styleClass);
+ cairo_translate(cr, 1, 1);
+
switch(renderType)
{
case RENDER_BACKGROUND:
case RENDER_BACKGROUND_AND_FRAME:
gtk_render_background(context, cr,
- 1, 1,
+ 0, 0,
rControlRegion.GetWidth(), rControlRegion.GetHeight());
if (renderType == RENDER_BACKGROUND_AND_FRAME)
gtk_render_frame(context, cr,
- 1, 1,
+ 0, 0,
rControlRegion.GetWidth(), rControlRegion.GetHeight());
break;
case RENDER_CHECK:
gtk_render_check(context, cr,
- 1, 1,
+ 0, 0,
rControlRegion.GetWidth(), rControlRegion.GetHeight());
break;
case RENDER_RADIO:
gtk_render_option(context, cr,
- 1, 1,
+ 0, 0,
rControlRegion.GetWidth(), rControlRegion.GetHeight());
break;
case RENDER_LINE:
gtk_render_line(context, cr,
- 4, 1 + rControlRegion.GetHeight() / 2,
- rControlRegion.GetWidth() - 6, 1 + rControlRegion.GetHeight() / 2);
+ 3, rControlRegion.GetHeight() / 2,
+ rControlRegion.GetWidth() - 3, rControlRegion.GetHeight() / 2);
break;
case RENDER_ARROW:
gtk_render_arrow(context, cr,
- G_PI / 2, 1, 1,
+ G_PI / 2, 0, 0,
MIN(rControlRegion.GetWidth(), 1 + rControlRegion.GetHeight()));
break;
case RENDER_SCROLLBAR:
commit d444079d0383bac55376b5cfdf6b52a3f0e71dc4
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 22:27:43 2011 -0400
gtk3: misc cleanups
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index c7e1eb2..6722cea 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -88,10 +88,12 @@ private:
void PaintScrollbar(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
+ ControlType nType,
ControlPart nPart,
const ImplControlValue& aValue );
void PaintOneSpinButton( GtkStyleContext *context,
cairo_t *cr,
+ ControlType nType,
ControlPart nPart,
Rectangle aAreaRect,
ControlState nState );
@@ -99,6 +101,7 @@ private:
cairo_t *cr,
const Rectangle& rControlRectangle,
ControlType nType,
+ ControlPart nPart,
const ImplControlValue& aValue );
void PaintCombobox( GtkStyleContext *context,
cairo_t *cr,
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 365f470..a7a9b0f 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -257,6 +257,7 @@ Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, Rectangle aA
void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
+ ControlType nType,
ControlPart nPart,
const ImplControlValue& aValue )
{
@@ -542,6 +543,7 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context,
cairo_t *cr,
+ ControlType nType,
ControlPart nPart,
Rectangle aAreaRect,
ControlState nState )
@@ -588,6 +590,7 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
ControlType nType,
+ ControlPart nPart,
const ImplControlValue& aValue )
{
Rectangle areaRect;
@@ -637,8 +640,8 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
areaRect.GetWidth(), areaRect.GetHeight() );
}
- PaintOneSpinButton(context, cr, upBtnPart, areaRect, upBtnState );
- PaintOneSpinButton(context, cr, downBtnPart, areaRect, downBtnState );
+ PaintOneSpinButton(context, cr, nType, upBtnPart, areaRect, upBtnState );
+ PaintOneSpinButton(context, cr, nType, downBtnPart, areaRect, downBtnState );
}
#define ARROW_SIZE 11 * 0.85
@@ -913,10 +916,10 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
MIN(rControlRegion.GetWidth(), 1 + rControlRegion.GetHeight()));
break;
case RENDER_SCROLLBAR:
- PaintScrollbar(context, cr, rControlRegion, nPart, aValue);
+ PaintScrollbar(context, cr, rControlRegion, nType, nPart, aValue);
break;
case RENDER_SPINBUTTON:
- PaintSpinButton(context, cr, rControlRegion, nType, aValue);
+ PaintSpinButton(context, cr, rControlRegion, nType, nPart, aValue);
break;
case RENDER_COMBOBOX:
PaintCombobox(context, cr, rControlRegion, nType, nPart, aValue);
commit 585140eb253d28644f8abce66786128271378c0b
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 22:26:59 2011 -0400
gtk3: implement rendering for Comboboxes
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 572484d..c7e1eb2 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -77,11 +77,14 @@ private:
static GtkStyleContext *mpMenuStyle;
static GtkStyleContext *mpMenuItemStyle;
static GtkStyleContext *mpSpinStyle;
+ static GtkStyleContext *mpComboboxStyle;
void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
+ Rectangle NWGetComboBoxButtonRect( ControlPart nPart, Rectangle aAreaRect );
+
void PaintScrollbar(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
@@ -97,6 +100,12 @@ private:
const Rectangle& rControlRectangle,
ControlType nType,
const ImplControlValue& aValue );
+ void PaintCombobox( GtkStyleContext *context,
+ cairo_t *cr,
+ const Rectangle& rControlRectangle,
+ ControlType nType,
+ ControlPart nPart,
+ const ImplControlValue& aValue );
static bool style_loaded;
};
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index 462a38a..365f470 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -45,6 +45,7 @@ GtkStyleContext* GtkSalGraphics::mpMenuBarItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpSpinStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpComboboxStyle = NULL;
bool GtkSalGraphics::style_loaded = false;
/************************************************************************
@@ -84,8 +85,40 @@ enum {
RENDER_RADIO = 6,
RENDER_SCROLLBAR = 7,
RENDER_SPINBUTTON = 8,
+ RENDER_COMBOBOX = 9,
};
+static void PrepareComboboxStyle( GtkStyleContext *context,
+ gboolean forEntry)
+{
+ GtkWidgetPath *path, *siblingsPath;
+
+ path = gtk_widget_path_new();
+ siblingsPath = gtk_widget_path_new();
+ gtk_widget_path_append_type(path, GTK_TYPE_COMBO_BOX);
+ gtk_widget_path_iter_add_class(path, 0, GTK_STYLE_CLASS_COMBOBOX_ENTRY);
+
+ gtk_widget_path_append_type(siblingsPath, GTK_TYPE_ENTRY);
+ gtk_widget_path_append_type(siblingsPath, GTK_TYPE_BUTTON);
+ gtk_widget_path_iter_add_class(siblingsPath, 0, GTK_STYLE_CLASS_ENTRY);
+ gtk_widget_path_iter_add_class(siblingsPath, 1, GTK_STYLE_CLASS_BUTTON);
+
+ if (forEntry)
+ {
+ gtk_widget_path_append_with_siblings(path, siblingsPath, 1);
+ gtk_widget_path_append_with_siblings(path, siblingsPath, 0);
+ }
+ else
+ {
+ gtk_widget_path_append_with_siblings(path, siblingsPath, 0);
+ gtk_widget_path_append_with_siblings(path, siblingsPath, 1);
+ }
+
+ gtk_style_context_set_path(context, path);
+ gtk_widget_path_free(path);
+ gtk_widget_path_free(siblingsPath);
+}
+
static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
{
// Size the arrow appropriately
@@ -608,6 +641,106 @@ void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
PaintOneSpinButton(context, cr, downBtnPart, areaRect, downBtnState );
}
+#define ARROW_SIZE 11 * 0.85
+Rectangle GtkSalGraphics::NWGetComboBoxButtonRect( ControlPart nPart,
+ Rectangle aAreaRect )
+{
+ Rectangle aButtonRect;
+ gint nArrowWidth;
+ gint nButtonWidth;
+ gint nFocusWidth;
+ gint nFocusPad;
+ GtkBorder padding;
+
+ // Grab some button style attributes
+ gtk_style_context_get_style( mpButtonStyle,
+ "focus-line-width", &nFocusWidth,
+ "focus-padding", &nFocusPad,
+ NULL );
+ gtk_style_context_get_padding( mpButtonStyle, GTK_STATE_FLAG_NORMAL, &padding);
+
+ nArrowWidth = ARROW_SIZE;
+ nButtonWidth = nArrowWidth + padding.left + padding.right + (2 * (nFocusWidth+nFocusPad));
+ if( nPart == PART_BUTTON_DOWN )
+ {
+ aButtonRect.SetSize( Size( nButtonWidth, aAreaRect.GetHeight() ) );
+ aButtonRect.SetPos( Point( aAreaRect.Left() + aAreaRect.GetWidth() - nButtonWidth,
+ aAreaRect.Top() ) );
+ }
+ else if( nPart == PART_SUB_EDIT )
+ {
+ gint adjust_x = (gint) ((padding.left + padding.right) / 2) + nFocusWidth + nFocusPad;
+ gint adjust_y = (gint) ((padding.top + padding.bottom) / 2) + nFocusWidth + nFocusPad;
+
+ aButtonRect.SetSize( Size( aAreaRect.GetWidth() - nButtonWidth - 2 * adjust_x,
+ aAreaRect.GetHeight() - 2 * adjust_y ) );
+ Point aEditPos = aAreaRect.TopLeft();
+ aEditPos.X() += adjust_x;
+ aEditPos.Y() += adjust_y;
+ aButtonRect.SetPos( aEditPos );
+ }
+
+ return( aButtonRect );
+}
+
+void GtkSalGraphics::PaintCombobox( GtkStyleContext *context,
+ cairo_t *cr,
+ const Rectangle& rControlRectangle,
+ ControlType nType,
+ ControlPart nPart,
+ const ImplControlValue& aValue )
+{
+ Rectangle areaRect;
+ Rectangle buttonRect;
+ Rectangle arrowRect;
+ gint x,y;
+
+ // Find the overall bounding rect of the buttons's drawing area,
+ // plus its actual draw rect excluding adornment
+ areaRect = rControlRectangle;
+ x = 1;
+ y = 1;
+
+ buttonRect = NWGetComboBoxButtonRect( PART_BUTTON_DOWN, areaRect );
+ if( nPart == PART_BUTTON_DOWN )
+ buttonRect.Left() += 1;
+
+ Rectangle aEditBoxRect( areaRect );
+ aEditBoxRect.SetSize( Size( areaRect.GetWidth() - buttonRect.GetWidth(), aEditBoxRect.GetHeight() ) );
+
+ if( nPart == PART_ENTIRE_CONTROL )
+ {
+ PrepareComboboxStyle(context, true);
+ gtk_render_background(context, cr,
+ x, y,
+ aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ x, y,
+ aEditBoxRect.GetWidth(), aEditBoxRect.GetHeight() );
+ }
+
+ arrowRect.SetSize( Size( (gint)(ARROW_SIZE),
+ (gint)(ARROW_SIZE) ) );
+ arrowRect.SetPos( Point( buttonRect.Left() + (gint)((buttonRect.GetWidth() - arrowRect.GetWidth()) / 2),
+ buttonRect.Top() + (gint)((buttonRect.GetHeight() - arrowRect.GetHeight()) / 2) ) );
+
+ PrepareComboboxStyle(context, false);
+
+ gtk_render_background(context, cr,
+ x+(buttonRect.Left() - areaRect.Left()),
+ y+(buttonRect.Top() - areaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ x+(buttonRect.Left() - areaRect.Left()),
+ y+(buttonRect.Top() - areaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+
+ gtk_render_arrow(context, cr,
+ G_PI,
+ x+(arrowRect.Left() - areaRect.Left()), y+(arrowRect.Top() - areaRect.Top()),
+ arrowRect.GetWidth() );
+}
+
sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue,
const rtl::OUString& )
@@ -636,6 +769,10 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
case CTRL_EDITBOX:
context = mpEntryStyle;
break;
+ case CTRL_COMBOBOX:
+ context = mpComboboxStyle;
+ renderType = RENDER_COMBOBOX;
+ break;
case CTRL_MENU_POPUP:
/* FIXME: missing ENTIRE_CONTROL, as it doesn't seem to work */
switch(nPart)
@@ -781,6 +918,9 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
case RENDER_SPINBUTTON:
PaintSpinButton(context, cr, rControlRegion, nType, aValue);
break;
+ case RENDER_COMBOBOX:
+ PaintCombobox(context, cr, rControlRegion, nType, nPart, aValue);
+ break;
default:
break;
}
@@ -922,6 +1062,12 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart
{
aEditRect = NWGetSpinButtonRect( nPart, rControlRegion );
}
+ else if ( (nType==CTRL_COMBOBOX) &&
+ ((nPart==PART_BUTTON_DOWN) || (nPart==PART_SUB_EDIT)) )
+ {
+ aEditRect = NWGetComboBoxButtonRect( nPart, rControlRegion );
+ }
+
else {
return sal_False;
}
@@ -1239,27 +1385,24 @@ sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPar
{
printf("Is native supported for Type: %d, Part %d\n", nType, nPart);
if(
+ (nType == CTRL_EDITBOX) ||
(nType == CTRL_PUSHBUTTON && nPart == PART_ENTIRE_CONTROL) ||
(nType == CTRL_CHECKBOX && nPart == PART_ENTIRE_CONTROL) ||
- (nType == CTRL_RADIOBUTTON && nPart == PART_ENTIRE_CONTROL) ||
- ((nType==CTRL_SPINBOX) &&
- ((nPart==PART_ENTIRE_CONTROL)
- || (nPart==PART_ALL_BUTTONS)
- || (nPart==HAS_BACKGROUND_TEXTURE))) ||
- ((nType==CTRL_SCROLLBAR) &&
- ( (nPart==PART_DRAW_BACKGROUND_HORZ)
- || (nPart==PART_DRAW_BACKGROUND_VERT)
- || (nPart==PART_ENTIRE_CONTROL)
- || (nPart==HAS_THREE_BUTTONS))) ||
- (nType == CTRL_EDITBOX) ||
- (nType == CTRL_MENU_POPUP &&
- (nPart == PART_MENU_ITEM_CHECK_MARK ||
- nPart == PART_MENU_ITEM_RADIO_MARK ||
- nPart == PART_MENU_SEPARATOR ||
- nPart == PART_MENU_SUBMENU_ARROW)) ||
+ (nType == CTRL_RADIOBUTTON && nPart == PART_ENTIRE_CONTROL) |
(nType == CTRL_TOOLBAR &&
- (nPart == PART_BUTTON ||
- nPart == PART_ENTIRE_CONTROL)))
+ (nPart == PART_BUTTON || nPart == PART_ENTIRE_CONTROL)) ||
+ ((nType == CTRL_SPINBOX) &&
+ ((nPart == PART_ENTIRE_CONTROL) || (nPart == PART_ALL_BUTTONS) ||
+ (nPart == HAS_BACKGROUND_TEXTURE))) ||
+ ((nType == CTRL_COMBOBOX) &&
+ ((nPart == PART_ENTIRE_CONTROL) || (nPart == PART_ALL_BUTTONS) ||
+ (nPart == HAS_BACKGROUND_TEXTURE))) ||
+ ((nType == CTRL_SCROLLBAR) &&
+ ( (nPart == PART_DRAW_BACKGROUND_HORZ) || (nPart == PART_DRAW_BACKGROUND_VERT) ||
+ (nPart == PART_ENTIRE_CONTROL) || (nPart == HAS_THREE_BUTTONS))) ||
+ (nType == CTRL_MENU_POPUP &&
+ ((nPart == PART_MENU_ITEM_CHECK_MARK) || (nPart == PART_MENU_ITEM_RADIO_MARK) ||
+ (nPart == PART_MENU_SEPARATOR) || (nPart == PART_MENU_SUBMENU_ARROW))))
return sal_True;
return sal_False;
@@ -1343,6 +1486,11 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
/* Spinbutton */
getStyleContext(&mpSpinStyle, gtk_spin_button_new(NULL, 0, 0));
+
+ /* Combobox */
+ mpComboboxStyle = gtk_style_context_new();
+ PrepareComboboxStyle(mpComboboxStyle, true);
+
}
static void print_cairo_region (cairo_region_t *region, const char *msg)
commit 73980c1526e90a2b4dded074e39e76b54930dafc
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 20:45:25 2011 -0400
gtk3: implement rendering for spinbuttons
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index cbf2500..572484d 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -76,16 +76,27 @@ private:
static GtkStyleContext *mpMenuBarItemStyle;
static GtkStyleContext *mpMenuStyle;
static GtkStyleContext *mpMenuItemStyle;
- static GtkStyleContext *mpTooltipStyle;
+ static GtkStyleContext *mpSpinStyle;
void renderAreaToPix( cairo_t* cr, cairo_rectangle_int_t *region );
void getStyleContext( GtkStyleContext** style, GtkWidget* widget );
Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
+ Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
void PaintScrollbar(GtkStyleContext *context,
cairo_t *cr,
const Rectangle& rControlRectangle,
ControlPart nPart,
const ImplControlValue& aValue );
+ void PaintOneSpinButton( GtkStyleContext *context,
+ cairo_t *cr,
+ ControlPart nPart,
+ Rectangle aAreaRect,
+ ControlState nState );
+ void PaintSpinButton(GtkStyleContext *context,
+ cairo_t *cr,
+ const Rectangle& rControlRectangle,
+ ControlType nType,
+ const ImplControlValue& aValue );
static bool style_loaded;
};
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index b9100f0..462a38a 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -44,6 +44,7 @@ GtkStyleContext* GtkSalGraphics::mpMenuBarStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuBarItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuItemStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpSpinStyle = NULL;
bool GtkSalGraphics::style_loaded = false;
/************************************************************************
@@ -82,6 +83,7 @@ enum {
RENDER_ARROW = 5,
RENDER_RADIO = 6,
RENDER_SCROLLBAR = 7,
+ RENDER_SPINBUTTON = 8,
};
static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
@@ -96,6 +98,50 @@ static void NWCalcArrowRect( const Rectangle& rButton, Rectangle& rArrow )
) );
}
+#define MIN_SPIN_ARROW_WIDTH 6
+
+Rectangle GtkSalGraphics::NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect)
+{
+ gint buttonSize;
+ Rectangle buttonRect;
+ const PangoFontDescription *fontDesc;
+ GtkBorder padding;
+
+ gtk_style_context_save(mpSpinStyle);
+ gtk_style_context_add_class(mpSpinStyle, GTK_STYLE_CLASS_BUTTON);
+
+ fontDesc = gtk_style_context_get_font( mpSpinStyle, GTK_STATE_FLAG_NORMAL);
+ gtk_style_context_get_padding(mpSpinStyle, GTK_STATE_FLAG_NORMAL, &padding);
+
+ buttonSize = MAX( PANGO_PIXELS(pango_font_description_get_size(fontDesc) ),
+ MIN_SPIN_ARROW_WIDTH );
+ buttonSize -= buttonSize % 2 - 1; /* force odd */
+ buttonRect.SetSize( Size( buttonSize + padding.left + padding.right,
+ buttonRect.GetHeight() ) );
+ buttonRect.setX( aAreaRect.Left() + (aAreaRect.GetWidth() - buttonRect.GetWidth()) );
+ if ( nPart == PART_BUTTON_UP )
+ {
+ buttonRect.setY( aAreaRect.Top() );
+ buttonRect.Bottom() = buttonRect.Top() + (aAreaRect.GetHeight() / 2);
+ }
+ else if( nPart == PART_BUTTON_DOWN )
+ {
+ buttonRect.setY( aAreaRect.Top() + (aAreaRect.GetHeight() / 2) );
+ buttonRect.Bottom() = aAreaRect.Bottom(); // cover area completely
+ }
+ else
+ {
+ buttonRect.Right() = buttonRect.Left()-1;
+ buttonRect.Left() = aAreaRect.Left();
+ buttonRect.Top() = aAreaRect.Top();
+ buttonRect.Bottom() = aAreaRect.Bottom();
+ }
+
+ gtk_style_context_restore(mpSpinStyle);
+
+ return( buttonRect );
+}
+
Rectangle GtkSalGraphics::NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect )
{
gint slider_width;
@@ -461,6 +507,107 @@ void GtkSalGraphics::PaintScrollbar(GtkStyleContext *context,
}
}
+void GtkSalGraphics::PaintOneSpinButton( GtkStyleContext *context,
+ cairo_t *cr,
+ ControlPart nPart,
+ Rectangle aAreaRect,
+ ControlState nState )
+{
+ Rectangle buttonRect;
+ GtkStateFlags stateFlags;
+ GtkShadowType shadowType;
+ Rectangle arrowRect;
+ gint arrowSize;
+ GtkBorder padding;
+
+ NWConvertVCLStateToGTKState( nState, &stateFlags, &shadowType );
+ buttonRect = NWGetSpinButtonRect( nPart, aAreaRect );
+
+ gtk_style_context_save(context);
+ gtk_style_context_set_state(context, stateFlags);
+ gtk_style_context_add_class(context, GTK_STYLE_CLASS_BUTTON);
+
+ gtk_render_background(context, cr,
+ (buttonRect.Left() - aAreaRect.Left()), (buttonRect.Top() - aAreaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ (buttonRect.Left() - aAreaRect.Left()), (buttonRect.Top() - aAreaRect.Top()),
+ buttonRect.GetWidth(), buttonRect.GetHeight() );
+
+ arrowSize = (gint) floor((buttonRect.GetWidth() - padding.left - padding.right) * 0.45);
+ arrowSize -= arrowSize % 2 - 1; /* force odd */
+ arrowRect.SetSize( Size( arrowSize, arrowSize ) );
+ arrowRect.setX( buttonRect.Left() + (buttonRect.GetWidth() - arrowRect.GetWidth()) / 2 );
+ if ( nPart == PART_BUTTON_UP )
+ arrowRect.setY( buttonRect.Top() + (buttonRect.GetHeight() - arrowRect.GetHeight()) / 2 + 1);
+ else
+ arrowRect.setY( buttonRect.Top() + (buttonRect.GetHeight() - arrowRect.GetHeight()) / 2 - 1);
+
+ gtk_render_arrow(context, cr,
+ (nPart == PART_BUTTON_UP) ? 0 : G_PI,
+ 1 + (arrowRect.Left() - aAreaRect.Left()), 1 + (arrowRect.Top() - aAreaRect.Top()),
+ arrowSize);
+
+ gtk_style_context_restore(context);
+}
+
+void GtkSalGraphics::PaintSpinButton(GtkStyleContext *context,
+ cairo_t *cr,
+ const Rectangle& rControlRectangle,
+ ControlType nType,
+ const ImplControlValue& aValue )
+{
+ Rectangle areaRect;
+ GtkShadowType shadowType;
+ const SpinbuttonValue * pSpinVal = (aValue.getType() == CTRL_SPINBUTTONS) ? static_cast<const SpinbuttonValue *>(&aValue) : NULL;
+ Rectangle upBtnRect;
+ ControlPart upBtnPart = PART_BUTTON_UP;
+ ControlState upBtnState = CTRL_STATE_ENABLED;
+ Rectangle downBtnRect;
+ ControlPart downBtnPart = PART_BUTTON_DOWN;
+ ControlState downBtnState = CTRL_STATE_ENABLED;
+
+ if ( pSpinVal )
+ {
+ upBtnPart = pSpinVal->mnUpperPart;
+ upBtnState = pSpinVal->mnUpperState;
+
+ downBtnPart = pSpinVal->mnLowerPart;
+ downBtnState = pSpinVal->mnLowerState;
+ }
+
+ // CTRL_SPINBUTTONS pass their area in pSpinVal, not in rControlRectangle
+ if ( nType == CTRL_SPINBUTTONS )
+ {
+ if ( !pSpinVal )
+ {
+ std::fprintf( stderr, "Tried to draw CTRL_SPINBUTTONS, but the SpinButtons data structure didn't exist!\n" );
+ return;
+ }
+ areaRect = pSpinVal->maUpperRect;
+ areaRect.Union( pSpinVal->maLowerRect );
+ }
+ else
+ areaRect = rControlRectangle;
+
+ gtk_style_context_get_style( context,
+ "shadow-type", &shadowType,
+ NULL );
+
+ if ( shadowType != GTK_SHADOW_NONE )
+ {
+ gtk_render_background(context, cr,
+ 1, 1,
+ areaRect.GetWidth(), areaRect.GetHeight() );
+ gtk_render_frame(context, cr,
+ 1, 1,
+ areaRect.GetWidth(), areaRect.GetHeight() );
+ }
+
+ PaintOneSpinButton(context, cr, upBtnPart, areaRect, upBtnState );
+ PaintOneSpinButton(context, cr, downBtnPart, areaRect, downBtnState );
+}
+
sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& aValue,
const rtl::OUString& )
@@ -475,10 +622,17 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
NWConvertVCLStateToGTKState(nState, &flags, &shadow);
- printf("Draw native for Type: %d, Part %d\n", nType, nPart);
-
switch(nType)
{
+ case CTRL_SPINBOX:
+ switch (nPart)
+ {
+ case PART_ENTIRE_CONTROL:
+ context = mpSpinStyle;
+ renderType = RENDER_SPINBUTTON;
+ break;
+ }
+ break;
case CTRL_EDITBOX:
context = mpEntryStyle;
break;
@@ -624,6 +778,9 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart
case RENDER_SCROLLBAR:
PaintScrollbar(context, cr, rControlRegion, nPart, aValue);
break;
+ case RENDER_SPINBUTTON:
+ PaintSpinButton(context, cr, rControlRegion, nType, aValue);
+ break;
default:
break;
}
@@ -758,7 +915,14 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart
(nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN) ) )
{
aEditRect = NWGetScrollButtonRect( nPart, rControlRegion );
- } else {
+ }
+ else if ( (nType==CTRL_SPINBOX) &&
+ ((nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN) ||
+ (nPart==PART_SUB_EDIT)) )
+ {
+ aEditRect = NWGetSpinButtonRect( nPart, rControlRegion );
+ }
+ else {
return sal_False;
}
@@ -1073,10 +1237,15 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nPart )
{
+ printf("Is native supported for Type: %d, Part %d\n", nType, nPart);
if(
(nType == CTRL_PUSHBUTTON && nPart == PART_ENTIRE_CONTROL) ||
(nType == CTRL_CHECKBOX && nPart == PART_ENTIRE_CONTROL) ||
(nType == CTRL_RADIOBUTTON && nPart == PART_ENTIRE_CONTROL) ||
+ ((nType==CTRL_SPINBOX) &&
+ ((nPart==PART_ENTIRE_CONTROL)
+ || (nPart==PART_ALL_BUTTONS)
+ || (nPart==HAS_BACKGROUND_TEXTURE))) ||
((nType==CTRL_SCROLLBAR) &&
( (nPart==PART_DRAW_BACKGROUND_HORZ)
|| (nPart==PART_DRAW_BACKGROUND_VERT)
@@ -1171,6 +1340,9 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
mpMenuBarItemStyle = gtk_style_context_new();
gtk_style_context_set_path(mpMenuBarItemStyle, path);
gtk_widget_path_free(path);
+
+ /* Spinbutton */
+ getStyleContext(&mpSpinStyle, gtk_spin_button_new(NULL, 0, 0));
}
static void print_cairo_region (cairo_region_t *region, const char *msg)
commit 671b1d26d0e8a1aad97b672172298d3c70e277f1
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 18:48:50 2011 -0400
gtk3: always set the wmclass using the X helper
The helper provided by GTK is only meant to be used before the toplevel
is realized, so it's not useful for this case. Instead, always call the
X helper.
This also gets rid of some GTK warnings we get on the terminal.
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 10fdbfd..a80e0be 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -1944,24 +1944,28 @@ void GtkSalFrame::updateWMClass()
rtl::OString aResClass = rtl::OUStringToOString(m_sWMClass, RTL_TEXTENCODING_ASCII_US);
const char *pResClass = aResClass.getLength() ? aResClass.getStr() :
SalGenericSystem::getFrameClassName();
+ Display *display;
+
+ if (!getDisplay()->IsX11Display())
+ return;
+
+#if GTK_CHECK_VERSION(3,0,0)
+ display = GDK_DISPLAY_XDISPLAY(getGdkDisplay());
+#else
+ display = getDisplay()->GetDisplay();
+#endif
-#if !GTK_CHECK_VERSION(3,0,0)
if( IS_WIDGET_REALIZED( m_pWindow ) )
{
XClassHint* pClass = XAllocClassHint();
rtl::OString aResName = SalGenericSystem::getFrameResName( m_nExtStyle );
pClass->res_name = const_cast<char*>(aResName.getStr());
pClass->res_class = const_cast<char*>(pResClass);
- XSetClassHint( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ XSetClassHint( display,
+ widget_get_xid(m_pWindow),
pClass );
XFree( pClass );
}
- else
-#endif
- gtk_window_set_wmclass( GTK_WINDOW(m_pWindow),
- SalGenericSystem::getFrameResName( m_nExtStyle ).getStr(),
- pResClass );
}
void GtkSalFrame::SetApplicationID( const rtl::OUString &rWMClass )
commit 56d287872accefc0269cd3454da3688acc839e65
Author: Cosimo Cecchi <cosimoc at gnome.org>
Date: Wed Nov 2 18:48:22 2011 -0400
gtk: add widget_get_xid()
And use it in GtkSalFrame
diff --git a/vcl/inc/unx/gtk/gtkdata.hxx b/vcl/inc/unx/gtk/gtkdata.hxx
index ff4d104..4f0d71c 100644
--- a/vcl/inc/unx/gtk/gtkdata.hxx
+++ b/vcl/inc/unx/gtk/gtkdata.hxx
@@ -56,6 +56,15 @@ inline GdkWindow * widget_get_window(GtkWidget *widget)
#endif
}
+inline XLIB_Window widget_get_xid(GtkWidget *widget)
+{
+#if GTK_CHECK_VERSION(3,0,0)
+ return GDK_WINDOW_XID(gtk_widget_get_window(widget));
+#else
+ return GDK_WINDOW_XWINDOW(widget->window);
+#endif
+}
+
inline void widget_set_can_focus(GtkWidget *widget, gboolean can_focus)
{
#if GTK_CHECK_VERSION(3,0,0)
diff --git a/vcl/unx/gtk/window/gtkframe.cxx b/vcl/unx/gtk/window/gtkframe.cxx
index 667b097..10fdbfd 100644
--- a/vcl/unx/gtk/window/gtkframe.cxx
+++ b/vcl/unx/gtk/window/gtkframe.cxx
@@ -506,7 +506,7 @@ GtkSalFrame::~GtkSalFrame()
if( m_hBackgroundPixmap )
{
XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
None );
XFreePixmap( getDisplay()->GetDisplay(), m_hBackgroundPixmap );
}
@@ -663,7 +663,7 @@ void GtkSalFrame::InitCommon()
m_aSystemData.pVisual = pDisp->GetVisual( m_nScreen ).GetVisual();
m_aSystemData.nDepth = pDisp->GetVisual( m_nScreen ).GetDepth();
m_aSystemData.aColormap = pDisp->GetColormap( m_nScreen ).GetXColormap();
- m_aSystemData.aWindow = GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow));
+ m_aSystemData.aWindow = window_get_xid(m_pWindow);
#endif
m_aSystemData.pSalFrame = this;
m_aSystemData.pWidget = m_pWindow;
@@ -713,7 +713,7 @@ void GtkSalFrame::InitCommon()
* some paint issues
*/
XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
m_hBackgroundPixmap );
#endif
}
@@ -751,7 +751,7 @@ static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBe
else if( ! bBeforeRealize )
{
Display* pDisplay = GetGtkSalData()->GetGtkDisplay()->GetDisplay();
- XLIB_Window aWindow = GDK_WINDOW_XWINDOW( widget_get_window(GTK_WIDGET(pWindow)) );
+ XLIB_Window aWindow = window_get_xid(m_pWindow);
XWMHints* pHints = XGetWMHints( pDisplay, aWindow );
if( ! pHints )
{
@@ -805,7 +805,7 @@ static void lcl_set_accept_focus( GtkWindow* pWindow, gboolean bAccept, bool bBe
#endif
}
-static void lcl_set_user_time( GdkWindow* i_pWindow, guint32 i_nTime )
+static void lcl_set_user_time( GtkWindow* i_pWindow, guint32 i_nTime )
{
#if !GTK_CHECK_VERSION(3,0,0)
if( bGetSetUserTimeFn )
@@ -814,15 +814,14 @@ static void lcl_set_user_time( GdkWindow* i_pWindow, guint32 i_nTime )
p_gdk_x11_window_set_user_time = (setUserTimeFn)osl_getAsciiFunctionSymbol( GetSalData()->m_pPlugin, "gdk_x11_window_set_user_time" );
}
if( p_gdk_x11_window_set_user_time )
- p_gdk_x11_window_set_user_time( i_pWindow, i_nTime );
+ p_gdk_x11_window_set_user_time( widget_get_window(i_pWindow), i_nTime );
else
{
Display* pDisplay = GetGtkSalData()->GetGtkDisplay()->GetDisplay();
- XLIB_Window aWindow = GDK_WINDOW_XWINDOW( i_pWindow );
Atom nUserTime = XInternAtom( pDisplay, "_NET_WM_USER_TIME", True );
if( nUserTime )
{
- XChangeProperty( pDisplay, aWindow,
+ XChangeProperty( pDisplay, widget_get_xid(i_pWindow),
nUserTime, XA_CARDINAL, 32,
PropModeReplace, (unsigned char*)&i_nTime, 1 );
}
@@ -948,7 +947,7 @@ void GtkSalFrame::Init( SalFrame* pParent, sal_uLong nStyle )
/* #i99360# ugly workaround an X11 library bug */
nUserTime= getDisplay()->GetLastUserEventTime( true );
}
- lcl_set_user_time(widget_get_window(GTK_WIDGET(m_pWindow)), nUserTime);
+ lcl_set_user_time(GTK_WINDOW(m_pWindow), nUserTime);
}
#endif
@@ -1040,7 +1039,7 @@ void GtkSalFrame::Init( SystemParentData* pSysData )
if( ! m_bWindowIsGtkPlug )
{
XReparentWindow( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
(XLIB_Window)pSysData->aWindow,
0, 0 );
}
@@ -1102,7 +1101,7 @@ SalGraphics* GtkSalFrame::GetGraphics()
AllocateFrame();
m_aGraphics[i].pGraphics->setDevice( m_aFrame );
#else // common case:
- m_aGraphics[i].pGraphics->Init( this, GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)), m_nScreen );
+ m_aGraphics[i].pGraphics->Init( this, window_get_xid(m_pWindow), m_nScreen );
#endif
}
return m_aGraphics[i].pGraphics;
@@ -1440,7 +1439,7 @@ void GtkSalFrame::Show( sal_Bool bVisible, sal_Bool bNoActivate )
nUserTime= getDisplay()->GetLastUserEventTime( true );
//nUserTime = gdk_x11_get_server_time(GTK_WIDGET (m_pWindow)->window);
}
- lcl_set_user_time( widget_get_window(GTK_WIDGET(m_pWindow)), nUserTime );
+ lcl_set_user_time(GTK_WINDOW(m_pWindow), nUserTime );
if( ! bNoActivate && (m_nStyle & SAL_FRAME_STYLE_TOOLWINDOW) )
m_bSetFocusOnMap = true;
@@ -2162,7 +2161,7 @@ void GtkSalFrame::StartPresentation( sal_Bool bStart )
#endif
#ifdef ENABLE_DBUS
m_nGSMCookie = dbus_inhibit_gsm(g_get_application_name(), "presentation",
- GDK_WINDOW_XID(widget_get_window(m_pWindow)));
+ widget_get_xid(m_pWindow));
#endif
}
else
@@ -2213,7 +2212,7 @@ void GtkSalFrame::ToTop( sal_uInt16 nFlags )
// sad but true: this can cause an XError, we need to catch that
// to do this we need to synchronize with the XServer
GetGenericData()->ErrorTrapPush();
- XSetInputFocus( getDisplay()->GetDisplay(), GDK_WINDOW_XWINDOW( widget_get_window(m_pWindow) ), RevertToParent, CurrentTime );
+ XSetInputFocus( getDisplay()->GetDisplay(), widget_get_xid(m_pWindow), RevertToParent, CurrentTime );
GetGenericData()->ErrorTrapPop();
}
#endif
@@ -2282,7 +2281,7 @@ void GtkSalFrame::grabPointer( sal_Bool bGrab, sal_Bool bOwnerEvents )
// set the right cursor this way
if( !pEnv || !*pEnv )
XGrabPointer( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW( widget_get_window( m_pWindow ) ),
+ window_get_xid( m_pWindow ),
bOwnerEvents,
PointerMotionMask | ButtonPressMask | ButtonReleaseMask,
GrabModeAsync,
@@ -2463,9 +2462,8 @@ SalBitmap* GtkSalFrame::SnapShot()
return pRet;
#else
X11SalBitmap *pBmp = new X11SalBitmap;
- GdkWindow *pWin = widget_get_window(m_pWindow);
if( pBmp->SnapShot( GDK_DISPLAY_XDISPLAY( getGdkDisplay() ),
- GDK_WINDOW_XID( pWin ) ) )
+ window_get_xid(m_pWindow) ) )
return pBmp;
else
delete pBmp;
@@ -2610,7 +2608,7 @@ void GtkSalFrame::createNewWindow( XLIB_Window aNewParent, bool bXEmbed, int nSc
{
if( m_aGraphics[i].bInUse )
{
- m_aGraphics[i].pGraphics->SetDrawable( GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)), m_nScreen );
+ m_aGraphics[i].pGraphics->SetDrawable( window_get_xid(m_pWindow), m_nScreen );
m_aGraphics[i].pGraphics->SetWindow( m_pWindow );
}
}
@@ -2699,7 +2697,7 @@ bool GtkSalFrame::Dispatch( const XEvent* pEvent )
if( pEvent->xproperty.atom == nDesktopAtom &&
pEvent->xproperty.state == PropertyNewValue )
{
- m_nWorkArea = pAdaptor->getWindowWorkArea( GDK_WINDOW_XWINDOW( widget_get_window(m_pWindow)) );
+ m_nWorkArea = pAdaptor->getWindowWorkArea( window_get_xid(m_pWindow) );
}
}
else if( pEvent->type == ConfigureNotify )
@@ -2727,7 +2725,7 @@ bool GtkSalFrame::Dispatch( const XEvent* pEvent )
int x = 0, y = 0;
XLIB_Window aChild;
XTranslateCoordinates( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW( widget_get_window(m_pWindow) ),
+ window_get_xid(m_pWindow),
getDisplay()->GetRootWindow( getDisplay()->GetDefaultScreenNumber() ),
0, 0,
&x, &y,
@@ -2742,7 +2740,7 @@ bool GtkSalFrame::Dispatch( const XEvent* pEvent )
}
else if( pEvent->type == ClientMessage &&
pEvent->xclient.message_type == getDisplay()->getWMAdaptor()->getAtom( vcl_sal::WMAdaptor::XEMBED ) &&
- pEvent->xclient.window == GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)) &&
+ pEvent->xclient.window == window_get_xid(m_pWindow) &&
m_bWindowIsGtkPlug
)
{
@@ -2771,7 +2769,7 @@ void GtkSalFrame::SetBackgroundBitmap( SalBitmap* pBitmap )
if( m_hBackgroundPixmap )
{
XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
None );
XFreePixmap( getDisplay()->GetDisplay(), m_hBackgroundPixmap );
m_hBackgroundPixmap = None;
@@ -2784,7 +2782,7 @@ void GtkSalFrame::SetBackgroundBitmap( SalBitmap* pBitmap )
{
m_hBackgroundPixmap =
XCreatePixmap( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
aSize.Width(),
aSize.Height(),
getDisplay()->GetVisual(m_nScreen).GetDepth() );
@@ -2800,7 +2798,7 @@ void GtkSalFrame::SetBackgroundBitmap( SalBitmap* pBitmap )
aTwoRect,
getDisplay()->GetCopyGC(m_nScreen) );
XSetWindowBackgroundPixmap( getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW(widget_get_window(m_pWindow)),
+ window_get_xid(m_pWindow),
m_hBackgroundPixmap );
}
}
@@ -3278,7 +3276,7 @@ gboolean GtkSalFrame::signalMap( GtkWidget*, GdkEvent*, gpointer frame )
if( bSetFocus )
{
XSetInputFocus( pThis->getDisplay()->GetDisplay(),
- GDK_WINDOW_XWINDOW( widget_get_window(GTK_WIDGET(pThis->m_pWindow))),
+ window_get_xid(m_pWindow),
RevertToParent, CurrentTime );
}
#else
More information about the Libreoffice-commits
mailing list