summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2015-05-15 17:19:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2015-05-15 17:21:00 +0100
commit186eefd7e2020c65db32dacc3a9389573e7cddeb (patch)
tree448573811b4160ede37c8cba2553f31e27002399
parent18331ddcc8cb65183967d9763a6a02cb5dea72e9 (diff)
gtk3: render native menubar and menubaritems
this needs the addition of a new MenuBarHighlightTextColor which defaults to MenuHighlightTextColor on other platforms Change-Id: Id0550294f1778229cbbe154857ba16c629dc5a87
-rw-r--r--include/vcl/settings.hxx3
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx1
-rw-r--r--vcl/osx/salframe.cxx1
-rw-r--r--vcl/source/app/settings.cxx16
-rw-r--r--vcl/source/window/menu.cxx16
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx1
-rw-r--r--vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx72
-rw-r--r--vcl/unx/kde/salnativewidgets-kde.cxx1
-rw-r--r--vcl/unx/kde4/KDESalFrame.cxx1
-rw-r--r--vcl/win/source/window/salframe.cxx1
10 files changed, 87 insertions, 26 deletions
diff --git a/include/vcl/settings.hxx b/include/vcl/settings.hxx
index 445bb5ad32e6..c60aa6400ba0 100644
--- a/include/vcl/settings.hxx
+++ b/include/vcl/settings.hxx
@@ -328,6 +328,9 @@ public:
void SetMenuBarRolloverTextColor( const Color& rColor );
const Color& GetMenuBarRolloverTextColor() const;
+ void SetMenuBarHighlightTextColor( const Color& rColor );
+ const Color& GetMenuBarHighlightTextColor() const;
+
void SetMenuHighlightColor( const Color& rColor );
const Color& GetMenuHighlightColor() const;
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index 0403b599db55..656c1ac93f05 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -73,6 +73,7 @@ private:
static GtkStyleContext *mpToolbarSeperatorStyle;
static GtkStyleContext *mpCheckButtonStyle;
static GtkStyleContext *mpMenuBarStyle;
+ static GtkStyleContext *mpMenuBarItemStyle;
static GtkStyleContext *mpMenuStyle;
static GtkStyleContext *mpMenuItemStyle;
static GtkStyleContext *mpSpinStyle;
diff --git a/vcl/osx/salframe.cxx b/vcl/osx/salframe.cxx
index af1327f3d568..98b49e803ca8 100644
--- a/vcl/osx/salframe.cxx
+++ b/vcl/osx/salframe.cxx
@@ -1199,6 +1199,7 @@ void AquaSalFrame::UpdateSettings( AllSettings& rSettings )
aStyleSettings.SetMenuTextColor( aMenuTextColor );
aStyleSettings.SetMenuBarTextColor( aMenuTextColor );
aStyleSettings.SetMenuBarRolloverTextColor( aMenuTextColor );
+ aStyleSettings.SetMenuBarHighlightTextColor(aStyleSettings.GetMenuHighlightTextColor());
aStyleSettings.SetCursorBlinkTime( 500 );
diff --git a/vcl/source/app/settings.cxx b/vcl/source/app/settings.cxx
index 5d593369e771..ff49e02df2a0 100644
--- a/vcl/source/app/settings.cxx
+++ b/vcl/source/app/settings.cxx
@@ -125,6 +125,7 @@ struct ImplStyleData
Color maMenuTextColor;
Color maMenuBarTextColor;
Color maMenuBarRolloverTextColor;
+ Color maMenuBarHighlightTextColor;
Color maMonoColor;
Color maRadioCheckTextColor;
Color maShadowColor;
@@ -600,6 +601,7 @@ ImplStyleData::ImplStyleData( const ImplStyleData& rData ) :
maMenuTextColor( rData.maMenuTextColor ),
maMenuBarTextColor( rData.maMenuBarTextColor ),
maMenuBarRolloverTextColor( rData.maMenuBarRolloverTextColor ),
+ maMenuBarHighlightTextColor( rData.maMenuBarHighlightTextColor ),
maMonoColor( rData.maMonoColor ),
maRadioCheckTextColor( rData.maRadioCheckTextColor ),
maShadowColor( rData.maShadowColor ),
@@ -734,6 +736,7 @@ void ImplStyleData::SetStandardStyles()
maMenuTextColor = Color( COL_BLACK );
maMenuBarTextColor = Color( COL_BLACK );
maMenuBarRolloverTextColor = Color( COL_WHITE );
+ maMenuBarHighlightTextColor = Color( COL_BLUE );
maMenuHighlightColor = Color( COL_BLUE );
maMenuHighlightTextColor = Color( COL_WHITE );
maHighlightColor = Color( COL_BLUE );
@@ -1271,6 +1274,19 @@ StyleSettings::GetMenuBarRolloverTextColor() const
}
void
+StyleSettings::SetMenuBarHighlightTextColor( const Color& rColor )
+{
+ CopyData();
+ mxData->maMenuBarHighlightTextColor = rColor;
+}
+
+const Color&
+StyleSettings::GetMenuBarHighlightTextColor() const
+{
+ return mxData->maMenuBarHighlightTextColor;
+}
+
+void
StyleSettings::SetMenuHighlightColor( const Color& rColor )
{
CopyData();
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 7c9900323884..d43c3cf04fb8 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -1857,10 +1857,18 @@ void Menu::ImplPaint(vcl::Window* pWin, sal_uInt16 nBorder, long nStartY, MenuIt
{
if ( pThisItemOnly )
{
- if (IsMenuBar()&& bRollover )
- pWin->SetTextColor( rSettings.GetMenuBarRolloverTextColor() );
- else if ( bHighlighted )
- pWin->SetTextColor( rSettings.GetMenuHighlightTextColor() );
+ if (IsMenuBar())
+ {
+ if (bRollover)
+ pWin->SetTextColor(rSettings.GetMenuBarRolloverTextColor());
+ else if (bHighlighted)
+ pWin->SetTextColor(rSettings.GetMenuBarHighlightTextColor());
+ }
+ else
+ {
+ if (bHighlighted)
+ pWin->SetTextColor(rSettings.GetMenuHighlightTextColor());
+ }
}
Point aPos( aTopLeft );
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 20feb225733f..b29c13a4f123 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -4018,6 +4018,7 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
aTextColor = aStyleSet.GetPersonaMenuBarTextColor().get_value_or( getColor( pMenubarStyle->fg[GTK_STATE_NORMAL] ) );
aStyleSet.SetMenuBarTextColor( aTextColor );
aStyleSet.SetMenuBarRolloverTextColor( aTextColor );
+ aStyleSet.SetMenuBarHighlightTextColor(aStyleSet.GetMenuHighlightTextColor());
#if OSL_DEBUG_LEVEL > 1
std::fprintf( stderr, "==\n" );
diff --git a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
index aa0681ba49b7..ed0a3599b87b 100644
--- a/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk3/gdi/gtk3salnativewidgets-gtk.cxx
@@ -29,6 +29,7 @@ GtkStyleContext* GtkSalGraphics::mpToolButtonStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpToolbarSeperatorStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpCheckButtonStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuBarStyle = NULL;
+GtkStyleContext* GtkSalGraphics::mpMenuBarItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpMenuItemStyle = NULL;
GtkStyleContext* GtkSalGraphics::mpSpinStyle = NULL;
@@ -796,6 +797,20 @@ void GtkSalGraphics::PaintCheckOrRadio(GtkStyleContext *context,
# define CHECKED GTK_STATE_FLAG_ACTIVE
#endif
+static GtkWidget* gCacheWindow;
+static GtkWidget* gDumbContainer;
+static GtkWidget* gSpinBox;
+static GtkWidget* gEntryBox;
+static GtkWidget* gComboBox;
+static GtkWidget* gComboBoxButtonWidget;
+static GtkWidget* gComboBoxEntryWidget;
+static GtkWidget* gListBox;
+static GtkWidget* gListBoxButtonWidget;
+static GtkWidget* gFrameIn;
+static GtkWidget* gFrameOut;
+static GtkWidget* gMenuBarWidget;
+static GtkWidget* gMenuItemMenuBarWidget;
+
bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
ControlState nState, const ImplControlValue& rValue,
const OUString& )
@@ -946,6 +961,22 @@ bool GtkSalGraphics::drawNativeControl( ControlType nType, ControlPart nPart, co
context = mpFrameInStyle;
break;
}
+ case CTRL_MENUBAR:
+ if (nPart == PART_MENU_ITEM)
+ {
+ context = mpMenuBarItemStyle;
+ styleClass = GTK_STYLE_CLASS_MENUBAR;
+
+ flags = (!(nState & ControlState::ENABLED)) ? GTK_STATE_FLAG_INSENSITIVE : GTK_STATE_FLAG_NORMAL;
+ if (nState & ControlState::SELECTED)
+ flags = (GtkStateFlags) (flags | GTK_STATE_FLAG_PRELIGHT);
+ }
+ else
+ {
+ context = gtk_widget_get_style_context(gMenuBarWidget);
+ styleClass = GTK_STYLE_CLASS_BACKGROUND;
+ }
+ break;
default:
return false;
}
@@ -1096,18 +1127,6 @@ Rectangle AdjustRectForTextBordersPadding(GtkStyleContext* pStyle, long nContent
return aEditRect;
}
-static GtkWidget* gCacheWindow;
-static GtkWidget* gDumbContainer;
-static GtkWidget* gSpinBox;
-static GtkWidget* gEntryBox;
-static GtkWidget* gComboBox;
-static GtkWidget* gComboBoxButtonWidget;
-static GtkWidget* gComboBoxEntryWidget;
-static GtkWidget* gListBox;
-static GtkWidget* gListBoxButtonWidget;
-static GtkWidget* gFrameIn;
-static GtkWidget* gFrameOut;
-
bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState,
const ImplControlValue& rValue, const OUString&,
Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion )
@@ -1182,6 +1201,10 @@ bool GtkSalGraphics::getNativeControlRegion( ControlType nType, ControlPart nPar
if (!aEditRect.GetHeight())
aEditRect.Bottom() = aEditRect.Top() + 1;
}
+ if( (nType == CTRL_MENUBAR) && (nPart == PART_ENTIRE_CONTROL) )
+ {
+ aEditRect = GetWidgetSize(rControlRegion, gMenuBarWidget);
+ }
else if ( (nType==CTRL_SPINBOX) &&
((nPart==PART_BUTTON_UP) || (nPart==PART_BUTTON_DOWN) ||
(nPart==PART_SUB_EDIT)) )
@@ -1391,11 +1414,15 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
aStyleSet.SetMenuBarColor( aBackColor );
aStyleSet.SetMenuBarRolloverColor( aBackColor );
- gtk_style_context_get_color( mpMenuBarStyle, GTK_STATE_FLAG_NORMAL, &text_color );
+ gtk_style_context_get_color( mpMenuBarItemStyle, GTK_STATE_FLAG_NORMAL, &text_color );
aTextColor = aStyleSet.GetPersonaMenuBarTextColor().get_value_or( getColor( text_color ) );
aStyleSet.SetMenuBarTextColor( aTextColor );
aStyleSet.SetMenuBarRolloverTextColor( aTextColor );
+ gtk_style_context_get_color( mpMenuBarItemStyle, GTK_STATE_FLAG_PRELIGHT, &text_color );
+ aTextColor = aStyleSet.GetPersonaMenuBarTextColor().get_value_or( getColor( text_color ) );
+ aStyleSet.SetMenuBarHighlightTextColor( aTextColor );
+
// menu items
gtk_style_context_get_color( mpMenuStyle, GTK_STATE_FLAG_NORMAL, &color );
aTextColor = getColor( color );
@@ -1418,12 +1445,10 @@ void GtkSalGraphics::updateSettings( AllSettings& rSettings )
gtk_style_context_get_background_color( mpMenuItemStyle, GTK_STATE_FLAG_PRELIGHT, &background_color );
::Color aHighlightColor = getColor( background_color );
+ aStyleSet.SetMenuHighlightColor( aHighlightColor );
gtk_style_context_get_color( mpMenuItemStyle, GTK_STATE_FLAG_PRELIGHT, &color );
::Color aHighlightTextColor = getColor( color );
- if( aHighlightColor == aHighlightTextColor )
- aHighlightTextColor = (aHighlightColor.GetLuminance() < 128) ? ::Color( COL_WHITE ) : ::Color( COL_BLACK );
- aStyleSet.SetMenuHighlightColor( aHighlightColor );
aStyleSet.SetMenuHighlightTextColor( aHighlightTextColor );
// hyperlink colors
@@ -1718,10 +1743,10 @@ bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPart nP
return true;
break;
-// case CTRL_MENUBAR:
-// if(nPart==PART_ENTIRE_CONTROL || nPart==PART_MENU_ITEM)
-// return true;
-// break;
+ case CTRL_MENUBAR:
+ if (nPart==PART_ENTIRE_CONTROL || nPart==PART_MENU_ITEM)
+ return true;
+ break;
case CTRL_MENU_POPUP:
if (nPart==PART_ENTIRE_CONTROL
@@ -1893,8 +1918,11 @@ GtkSalGraphics::GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow )
gtk_widget_path_free(path);
/* Menu bar */
- getStyleContext(&mpMenuBarStyle, gtk_menu_bar_new());
- gtk_style_context_add_class(mpMenuBarStyle, GTK_STYLE_CLASS_MENU);
+ gMenuBarWidget = gtk_menu_bar_new();
+ gMenuItemMenuBarWidget = gtk_menu_item_new_with_label( "b" );
+ gtk_menu_shell_append(GTK_MENU_SHELL(gMenuBarWidget), gMenuItemMenuBarWidget);
+ getStyleContext(&mpMenuBarStyle, gMenuBarWidget);
+ mpMenuBarItemStyle = gtk_widget_get_style_context(gMenuItemMenuBarWidget);
/* Spinbutton */
gSpinBox = gtk_spin_button_new(NULL, 0, 0);
diff --git a/vcl/unx/kde/salnativewidgets-kde.cxx b/vcl/unx/kde/salnativewidgets-kde.cxx
index 627a15597a64..e014e78f3136 100644
--- a/vcl/unx/kde/salnativewidgets-kde.cxx
+++ b/vcl/unx/kde/salnativewidgets-kde.cxx
@@ -2018,6 +2018,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
aStyleSettings.SetMenuBarRolloverColor( aMenuBack );
aStyleSettings.SetMenuBarRolloverTextColor( aMenuFore );
}
+ aStyleSettings.SetMenuBarHighlightTextColor(aStyleSettings.GetMenuHighlightTextColor());
// Font
aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() );
diff --git a/vcl/unx/kde4/KDESalFrame.cxx b/vcl/unx/kde4/KDESalFrame.cxx
index fa18109c222a..51f6cf59b363 100644
--- a/vcl/unx/kde4/KDESalFrame.cxx
+++ b/vcl/unx/kde4/KDESalFrame.cxx
@@ -323,6 +323,7 @@ void KDESalFrame::UpdateSettings( AllSettings& rSettings )
style.SetMenuBarRolloverColor( aMenuBack );
style.SetMenuBarRolloverTextColor( aMenuFore );
}
+ style.SetMenuBarHighlightTextColor(style.GetMenuHighlightTextColor());
// Font
aFont = toFont( pMenuBar->font(), rSettings.GetUILanguageTag().getLocale() );
diff --git a/vcl/win/source/window/salframe.cxx b/vcl/win/source/window/salframe.cxx
index fae12e695f06..79f4e6ee0dd6 100644
--- a/vcl/win/source/window/salframe.cxx
+++ b/vcl/win/source/window/salframe.cxx
@@ -2723,6 +2723,7 @@ void WinSalFrame::UpdateSettings( AllSettings& rSettings )
aStyleSettings.SetMenuBarTextColor( ImplWinColorToSal( GetSysColor( COLOR_MENUTEXT ) ) );
aStyleSettings.SetMenuBarRolloverTextColor( ImplWinColorToSal( GetSysColor( COLOR_HIGHLIGHTTEXT ) ) );
}
+ aStyleSettings.SetMenuBarHighlightTextColor(aStyleSettings.GetMenuHighlightTextColor());
aStyleSettings.SetActiveColor( ImplWinColorToSal( GetSysColor( COLOR_ACTIVECAPTION ) ) );
aStyleSettings.SetActiveTextColor( ImplWinColorToSal( GetSysColor( COLOR_CAPTIONTEXT ) ) );
aStyleSettings.SetDeactiveColor( ImplWinColorToSal( GetSysColor( COLOR_INACTIVECAPTION ) ) );