summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuslan Kabatsayev <b7.10110111@gmail.com>2012-07-07 21:19:39 +0400
committerMichael Meeks <michael.meeks@suse.com>2012-07-10 16:23:33 +0100
commit27dfb08d09803055a76ece27dfda47cbc79eb251 (patch)
tree2a08569ef8ad7663b9c4ccf632686fd0651261fe
parent1c67fc8015d88a383f2138c4d03d692314d6f579 (diff)
Implement support for listview headers native render, add GTK implementation
Change-Id: Ief59396e772512b8696e03af86535754b3697d13
-rw-r--r--svtools/source/control/headbar.cxx76
-rw-r--r--vcl/inc/unx/gtk/gtkgdi.hxx5
-rw-r--r--vcl/inc/vcl/salnativewidgets.hxx2
-rw-r--r--vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx64
4 files changed, 123 insertions, 24 deletions
diff --git a/svtools/source/control/headbar.cxx b/svtools/source/control/headbar.cxx
index 30343f68280e..3f004e3a5ac8 100644
--- a/svtools/source/control/headbar.cxx
+++ b/svtools/source/control/headbar.cxx
@@ -34,6 +34,7 @@
#include <vcl/svapp.hxx>
#include <vcl/help.hxx>
#include <vcl/image.hxx>
+#include <vcl/salnativewidgets.hxx>
#include <com/sun/star/accessibility/XAccessible.hpp>
// =======================================================================
@@ -320,6 +321,11 @@ void HeaderBar::ImplDrawItem( OutputDevice* pDev,
const Rectangle* pRect,
sal_uLong )
{
+ Window *const pWin = (pDev->GetOutDevType()==OUTDEV_WINDOW) ? (Window*) pDev : NULL;
+ ImplControlValue aControlValue(0);
+ Rectangle aCtrlRegion;
+ ControlState nState(0);
+
Rectangle aRect = rItemRect;
// Wenn kein Platz, dann brauchen wir auch nichts ausgeben
@@ -346,35 +352,61 @@ void HeaderBar::ImplDrawItem( OutputDevice* pDev,
HeaderBarItemBits nBits = pItem->mnBits;
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- // Border muss nicht gemalt werden
- aRect.Top() += mnBorderOff1;
- aRect.Bottom() -= mnBorderOff2;
+ if( pWin && pWin->IsNativeControlSupported(CTRL_WINDOW_BACKGROUND, PART_ENTIRE_CONTROL) )
+ {
+ aCtrlRegion=aRect;
+ pWin->DrawNativeControl( CTRL_WINDOW_BACKGROUND, PART_ENTIRE_CONTROL,
+ aCtrlRegion, nState, aControlValue,
+ rtl::OUString() );
- // Hintergrund loeschen
- if ( !pRect || bDrag )
+ }
+ else
{
- if ( bDrag )
+ // Border muss nicht gemalt werden
+ aRect.Top() += mnBorderOff1;
+ aRect.Bottom() -= mnBorderOff2;
+
+ // Hintergrund loeschen
+ if ( !pRect || bDrag )
{
- pDev->SetLineColor();
- pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
- pDev->DrawRect( aRect );
+ if ( bDrag )
+ {
+ pDev->SetLineColor();
+ pDev->SetFillColor( rStyleSettings.GetCheckedColor() );
+ pDev->DrawRect( aRect );
+ }
+ else
+ pDev->DrawWallpaper( aRect, GetBackground() );
}
- else
- pDev->DrawWallpaper( aRect, GetBackground() );
}
- // Trennlinie malen
- pDev->SetLineColor( rStyleSettings.GetDarkShadowColor() );
- pDev->DrawLine( Point( aRect.Right(), aRect.Top() ),
- Point( aRect.Right(), aRect.Bottom() ) );
-
- // ButtonStyle malen
- // avoid 3D borders
Color aSelectionTextColor( COL_TRANSPARENT );
- if( bHigh )
- DrawSelectionBackground( aRect, 1, sal_True, sal_False, sal_False, &aSelectionTextColor );
- else if ( !mbButtonStyle || (nBits & HIB_FLAT) )
- DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False, &aSelectionTextColor );
+
+ if( pWin && pWin->IsNativeControlSupported(CTRL_LISTHEADER, PART_BUTTON) )
+ {
+ aCtrlRegion=aRect;
+ aControlValue.setTristateVal(BUTTONVALUE_ON);
+ nState|=CTRL_STATE_ENABLED;
+ if(bHigh)
+ nState|=CTRL_STATE_PRESSED;
+ pWin->DrawNativeControl( CTRL_LISTHEADER, PART_BUTTON,
+ aCtrlRegion, nState, aControlValue,
+ rtl::OUString() );
+ }
+ else
+ {
+ // Trennlinie malen
+ pDev->SetLineColor( rStyleSettings.GetDarkShadowColor() );
+ pDev->DrawLine( Point( aRect.Right(), aRect.Top() ),
+ Point( aRect.Right(), aRect.Bottom() ) );
+
+ // ButtonStyle malen
+ // avoid 3D borders
+ if( bHigh )
+ DrawSelectionBackground( aRect, 1, sal_True, sal_False, sal_False, &aSelectionTextColor );
+ else if ( !mbButtonStyle || (nBits & HIB_FLAT) )
+ DrawSelectionBackground( aRect, 0, sal_True, sal_False, sal_False, &aSelectionTextColor );
+ }
// Wenn kein Platz, dann brauchen wir auch nichts ausgeben
if ( aRect.GetWidth() < 1 )
diff --git a/vcl/inc/unx/gtk/gtkgdi.hxx b/vcl/inc/unx/gtk/gtkgdi.hxx
index a8d658431d00..ab03d1864bd3 100644
--- a/vcl/inc/unx/gtk/gtkgdi.hxx
+++ b/vcl/inc/unx/gtk/gtkgdi.hxx
@@ -165,6 +165,11 @@ protected:
GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect );
sal_Bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect );
+ sal_Bool NWPaintGTKListHeader( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
+ const Rectangle& rControlRectangle,
+ const clipList& rClipList,
+ ControlState nState, const ImplControlValue& aValue,
+ const OUString& rCaption );
sal_Bool NWPaintGTKFixedLine( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
const Rectangle& rControlRectangle,
const clipList& rClipList,
diff --git a/vcl/inc/vcl/salnativewidgets.hxx b/vcl/inc/vcl/salnativewidgets.hxx
index a3c9bab78e42..02857a11b3ff 100644
--- a/vcl/inc/vcl/salnativewidgets.hxx
+++ b/vcl/inc/vcl/salnativewidgets.hxx
@@ -142,6 +142,8 @@ typedef sal_uInt32 ControlType;
// nets between elements of listviews
// with nodes
#define CTRL_LISTNET 171
+// for list headers
+#define CTRL_LISTHEADER 172
/* Control Parts:
diff --git a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
index 96b702bd1241..31067512a0c7 100644
--- a/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
+++ b/vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx
@@ -639,6 +639,11 @@ sal_Bool GtkSalGraphics::IsNativeControlSupported( ControlType nType, ControlPar
if(nPart == PART_SEPARATOR_VERT || nPart == PART_SEPARATOR_HORZ)
return true;
break;
+
+ case CTRL_LISTHEADER:
+ if(nPart == PART_BUTTON)
+ return true;
+ break;
}
return false;
@@ -929,11 +934,14 @@ sal_Bool GtkSalGraphics::drawNativeControl( ControlType nType,
{
returnVal = NWPaintGTKFixedLine( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
}
-
- if(nType==CTRL_FRAME)
+ else if(nType==CTRL_FRAME)
{
returnVal = NWPaintGTKFrame( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption);
}
+ else if(nType==CTRL_LISTHEADER)
+ {
+ returnVal = NWPaintGTKListHeader( gdkDrawable, nType, nPart, aCtrlRect, aClip, nState, aValue, rCaption );
+ }
if( pixmap )
{
@@ -1195,6 +1203,47 @@ sal_Bool GtkSalGraphics::getNativeControlRegion( ControlType nType,
/************************************************************************
* Individual control drawing functions
************************************************************************/
+sal_Bool GtkSalGraphics::NWPaintGTKListHeader(
+ GdkDrawable* gdkDrawable,
+ ControlType, ControlPart,
+ const Rectangle& rControlRectangle,
+ const clipList& rClipList,
+ ControlState nState, const ImplControlValue&,
+ const OUString& )
+{
+ GtkStateType stateType;
+ GtkShadowType shadowType;
+ NWEnsureGTKTreeView( m_nXScreen );
+ GtkWidget* &treeview(gWidgetData[m_nXScreen].gTreeView);
+ GtkTreeViewColumn* column=gtk_tree_view_get_column(GTK_TREE_VIEW(treeview),0);
+ GtkWidget* button=gtk_tree_view_column_get_widget(column);
+ while(button && !GTK_IS_BUTTON(button))
+ button=gtk_widget_get_parent(button);
+ if(!button)
+ // Shouldn't ever happen
+ return false;
+ gtk_widget_realize(button);
+ NWConvertVCLStateToGTKState( nState, &stateType, &shadowType );
+ NWSetWidgetState( button, nState, stateType );
+
+ GdkRectangle clipRect;
+ for( clipList::const_iterator it = rClipList.begin(); it != rClipList.end(); ++it )
+ {
+ clipRect.x = it->Left();
+ clipRect.y = it->Top();
+ clipRect.width = it->GetWidth();
+ clipRect.height = it->GetHeight();
+
+ gtk_paint_box(button->style,gdkDrawable,stateType,shadowType,&clipRect,
+ button,"button",
+ rControlRectangle.Left()-1,
+ rControlRectangle.Top(),
+ rControlRectangle.GetWidth()+1,
+ rControlRectangle.GetHeight());
+ }
+ return true;
+}
+
sal_Bool GtkSalGraphics::NWPaintGTKFixedLine(
GdkDrawable* gdkDrawable,
ControlType, ControlPart nPart,
@@ -4338,6 +4387,17 @@ static void NWEnsureGTKTreeView( SalX11Screen nScreen )
if( !gWidgetData[nScreen].gTreeView )
{
gWidgetData[nScreen].gTreeView = gtk_tree_view_new ();
+
+ // Columns will be used for tree header rendering
+ GtkCellRenderer* renderer=gtk_cell_renderer_text_new();
+ GtkTreeViewColumn* column=gtk_tree_view_column_new_with_attributes("",renderer,"text",0,NULL);
+ gtk_tree_view_column_set_widget(column,gtk_label_new(""));
+ gtk_tree_view_append_column(GTK_TREE_VIEW(gWidgetData[nScreen].gTreeView), column);
+
+ // Add one more column so that some engines like clearlooks did render separators between columns
+ column=gtk_tree_view_column_new_with_attributes("",renderer,"text",0,NULL);
+ gtk_tree_view_append_column(GTK_TREE_VIEW(gWidgetData[nScreen].gTreeView), column);
+
NWAddWidgetToCacheWindow( gWidgetData[nScreen].gTreeView, nScreen );
}
}