diff options
author | Ruslan Kabatsayev <b7.10110111@gmail.com> | 2012-07-07 21:19:39 +0400 |
---|---|---|
committer | Michael Meeks <michael.meeks@suse.com> | 2012-07-10 16:23:33 +0100 |
commit | 27dfb08d09803055a76ece27dfda47cbc79eb251 (patch) | |
tree | 2a08569ef8ad7663b9c4ccf632686fd0651261fe /vcl | |
parent | 1c67fc8015d88a383f2138c4d03d692314d6f579 (diff) |
Implement support for listview headers native render, add GTK implementation
Change-Id: Ief59396e772512b8696e03af86535754b3697d13
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/inc/unx/gtk/gtkgdi.hxx | 5 | ||||
-rw-r--r-- | vcl/inc/vcl/salnativewidgets.hxx | 2 | ||||
-rw-r--r-- | vcl/unx/gtk/gdi/salnativewidgets-gtk.cxx | 64 |
3 files changed, 69 insertions, 2 deletions
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 ); } } |