1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 24 #ifndef _VCL_GTKGDI_HXX 25 #define _VCL_GTKGDI_HXX 26 27 #include <tools/prex.h> 28 #include <gtk/gtk.h> 29 #include <gdk/gdkx.h> 30 #include <tools/postx.h> 31 32 #include <unx/salgdi.h> 33 34 class GtkSalGraphics : public X11SalGraphics 35 { 36 GtkWidget *m_pWindow; 37 Region m_aClipRegion; 38 39 public: GtkSalGraphics(GtkWidget * window)40 GtkSalGraphics( GtkWidget *window ) 41 : m_pWindow( window ), 42 m_aClipRegion(true) 43 {} 44 virtual ~GtkSalGraphics(); 45 GetGdkWindow() const46 inline GdkWindow* GetGdkWindow() const { return m_pWindow ? gtk_widget_get_window( m_pWindow ) : NULL; } GetGtkFrame() const47 inline GtkSalFrame* GetGtkFrame() const { return static_cast<GtkSalFrame*>(m_pFrame); } SetWindow(GtkWidget * window)48 void SetWindow( GtkWidget* window ) { m_pWindow = window; } 49 50 51 // will be set when UI theme was changed 52 static sal_Bool bThemeChanged; 53 static sal_Bool bNeedPixmapPaint; 54 static sal_Bool bGlobalNeedPixmapPaint; 55 static sal_Bool bToolbarGripWorkaround; 56 static sal_Bool bNeedButtonStyleAsEditBackgroundWorkaround; 57 58 // native widget methods 59 virtual sal_Bool IsNativeControlSupported( ControlType nType, ControlPart nPart ); 60 virtual sal_Bool hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 61 const Point& aPos, sal_Bool& rIsInside ); 62 virtual sal_Bool drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 63 ControlState nState, const ImplControlValue& aValue, 64 const rtl::OUString& rCaption ); 65 virtual sal_Bool drawNativeControlText( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, 66 ControlState nState, const ImplControlValue& aValue, 67 const rtl::OUString& rCaption ); 68 virtual sal_Bool getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState, 69 const ImplControlValue& aValue, const rtl::OUString& rCaption, 70 Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ); 71 72 //helper methods for frame's UpdateSettings 73 void updateSettings( AllSettings& rSettings ); 74 75 virtual bool setClipRegion( const Region& ); 76 virtual void ResetClipRegion(); 77 78 // some themes set the background pixmap of our window EVERY time 79 // a control is painted; but presentation effects need 80 // the background set to None; workaround: set the background 81 // before copyBits 82 virtual void copyBits( const SalTwoRect& rPosAry, 83 SalGraphics* pSrcGraphics ); 84 85 protected: 86 typedef std::list< Rectangle > clipList; 87 88 GdkPixmap* NWGetPixmapFromScreen( Rectangle srcRect ); 89 sal_Bool NWRenderPixmapToScreen( GdkPixmap* pPixmap, Rectangle dstRect ); 90 91 sal_Bool NWPaintGTKButton( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 92 const Rectangle& rControlRectangle, 93 const clipList& rClipList, 94 ControlState nState, const ImplControlValue& aValue, 95 const OUString& rCaption ); 96 sal_Bool NWPaintGTKRadio( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 97 const Rectangle& rControlRectangle, 98 const clipList& rClipList, 99 ControlState nState, const ImplControlValue& aValue, 100 const OUString& rCaption ); 101 sal_Bool NWPaintGTKCheck( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 102 const Rectangle& rControlRectangle, 103 const clipList& rClipList, 104 ControlState nState, const ImplControlValue& aValue, 105 const OUString& rCaption ); 106 sal_Bool NWPaintGTKScrollbar( ControlType nType, ControlPart nPart, 107 const Rectangle& rControlRectangle, 108 const clipList& rClipList, 109 ControlState nState, const ImplControlValue& aValue, 110 const OUString& rCaption ); 111 sal_Bool NWPaintGTKEditBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 112 const Rectangle& rControlRectangle, 113 const clipList& rClipList, 114 ControlState nState, const ImplControlValue& aValue, 115 const OUString& rCaption ); 116 sal_Bool NWPaintGTKSpinBox( ControlType nType, ControlPart nPart, 117 const Rectangle& rControlRectangle, 118 const clipList& rClipList, 119 ControlState nState, const ImplControlValue& aValue, 120 const OUString& rCaption ); 121 sal_Bool NWPaintGTKComboBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 122 const Rectangle& rControlRectangle, 123 const clipList& rClipList, 124 ControlState nState, const ImplControlValue& aValue, 125 const OUString& rCaption ); 126 sal_Bool NWPaintGTKTabItem( ControlType nType, ControlPart nPart, 127 const Rectangle& rControlRectangle, 128 const clipList& rClipList, 129 ControlState nState, const ImplControlValue& aValue, 130 const OUString& rCaption ); 131 sal_Bool NWPaintGTKListBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 132 const Rectangle& rControlRectangle, 133 const clipList& rClipList, 134 ControlState nState, const ImplControlValue& aValue, 135 const OUString& rCaption ); 136 137 sal_Bool NWPaintGTKToolbar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 138 const Rectangle& rControlRectangle, 139 const clipList& rClipList, 140 ControlState nState, const ImplControlValue& aValue, 141 const OUString& rCaption ); 142 sal_Bool NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 143 const Rectangle& rControlRectangle, 144 const clipList& rClipList, 145 ControlState nState, const ImplControlValue& aValue, 146 const OUString& rCaption ); 147 sal_Bool NWPaintGTKPopupMenu( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 148 const Rectangle& rControlRectangle, 149 const clipList& rClipList, 150 ControlState nState, const ImplControlValue& aValue, 151 const OUString& rCaption ); 152 sal_Bool NWPaintGTKTooltip( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 153 const Rectangle& rControlRectangle, 154 const clipList& rClipList, 155 ControlState nState, const ImplControlValue& aValue, 156 const OUString& rCaption ); 157 sal_Bool NWPaintGTKProgress( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 158 const Rectangle& rControlRectangle, 159 const clipList& rClipList, 160 ControlState nState, const ImplControlValue& aValue, 161 const OUString& rCaption ); 162 sal_Bool NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 163 const Rectangle& rControlRectangle, 164 const clipList& rClipList, 165 ControlState nState, const ImplControlValue& aValue, 166 const OUString& rCaption ); 167 sal_Bool NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart, 168 const Rectangle& rControlRectangle, 169 const clipList& rClipList, 170 ControlState nState, const ImplControlValue& aValue, 171 const OUString& rCaption ); 172 }; 173 174 #endif // _VCL_GTKGDI_HXX 175