LCOV - code coverage report
Current view: top level - vcl/inc/unx/gtk - gtkgdi.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 2 4 50.0 %
Date: 2015-06-13 12:38:46 Functions: 2 4 50.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2             : /*
       3             :  * This file is part of the LibreOffice project.
       4             :  *
       5             :  * This Source Code Form is subject to the terms of the Mozilla Public
       6             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       7             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       8             :  *
       9             :  * This file incorporates work covered by the following license notice:
      10             :  *
      11             :  *   Licensed to the Apache Software Foundation (ASF) under one or more
      12             :  *   contributor license agreements. See the NOTICE file distributed
      13             :  *   with this work for additional information regarding copyright
      14             :  *   ownership. The ASF licenses this file to you under the Apache
      15             :  *   License, Version 2.0 (the "License"); you may not use this file
      16             :  *   except in compliance with the License. You may obtain a copy of
      17             :  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
      18             :  */
      19             : 
      20             : #ifndef INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
      21             : #define INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
      22             : 
      23             : #include <prex.h>
      24             : #include <gtk/gtk.h>
      25             : #include <gdk/gdkx.h>
      26             : #include <gdk/gdkkeysyms.h>
      27             : #include <postx.h>
      28             : 
      29             : #include <unx/gtk/gtkframe.hxx>
      30             : 
      31             : #if GTK_CHECK_VERSION(3,0,0)
      32             : 
      33             : #include <headless/svpgdi.hxx>
      34             : #include "textrender.hxx"
      35             : 
      36             : class GtkSalGraphics : public SvpSalGraphics
      37             : {
      38             :     GtkSalFrame *mpFrame;
      39             : public:
      40             :     GtkSalGraphics( GtkSalFrame *pFrame, GtkWidget *pWindow );
      41             :     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart,
      42             :                                                const Rectangle& rControlRegion,
      43             :                                                ControlState nState, const ImplControlValue& aValue,
      44             :                                                const OUString& rCaption ) SAL_OVERRIDE;
      45             :     virtual bool        IsNativeControlSupported( ControlType nType, ControlPart nPart ) SAL_OVERRIDE;
      46             :     virtual bool        getNativeControlRegion( ControlType nType, ControlPart nPart,
      47             :                                                     const Rectangle& rControlRegion,
      48             :                                                     ControlState nState,
      49             :                                                     const ImplControlValue& aValue,
      50             :                                                     const OUString& rCaption,
      51             :                                                     Rectangle &rNativeBoundingRegion,
      52             :                                                     Rectangle &rNativeContentRegion ) SAL_OVERRIDE;
      53             :     virtual bool        SupportsCairo() const SAL_OVERRIDE;
      54             :     virtual cairo::SurfaceSharedPtr CreateSurface(const cairo::CairoSurfaceSharedPtr& rSurface) const SAL_OVERRIDE;
      55             :     virtual cairo::SurfaceSharedPtr CreateSurface(const OutputDevice& rRefDevice, int x, int y, int width, int height) const SAL_OVERRIDE;
      56             :     void WidgetQueueDraw() const;
      57             : 
      58             :     void updateSettings( AllSettings& rSettings );
      59             :     static void refreshFontconfig( GtkSettings *pSettings );
      60             :     static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
      61             : 
      62             :     cairo_t* getCairoContext() const;
      63             : 
      64             :     void clipRegion(cairo_t* cr);
      65             : 
      66             : private:
      67             :     GtkWidget       *mpWindow;
      68             :     static GtkStyleContext *mpButtonStyle;
      69             :     static GtkStyleContext *mpEntryStyle;
      70             :     static GtkStyleContext *mpTextViewStyle;
      71             :     static GtkStyleContext *mpVScrollbarStyle;
      72             :     static GtkStyleContext *mpHScrollbarStyle;
      73             :     static GtkStyleContext *mpToolbarStyle;
      74             :     static GtkStyleContext *mpToolButtonStyle;
      75             :     static GtkStyleContext *mpToolbarSeperatorStyle;
      76             :     static GtkStyleContext *mpCheckButtonStyle;
      77             :     static GtkStyleContext *mpMenuBarStyle;
      78             :     static GtkStyleContext *mpMenuBarItemStyle;
      79             :     static GtkStyleContext *mpMenuStyle;
      80             :     static GtkStyleContext *mpMenuItemStyle;
      81             :     static GtkStyleContext *mpSpinStyle;
      82             :     static GtkStyleContext *mpComboboxStyle;
      83             :     static GtkStyleContext *mpComboboxButtonStyle;
      84             :     static GtkStyleContext *mpListboxStyle;
      85             :     static GtkStyleContext *mpListboxButtonStyle;
      86             :     static GtkStyleContext *mpNoteBookStyle;
      87             :     static GtkStyleContext *mpFrameInStyle;
      88             :     static GtkStyleContext *mpFrameOutStyle;
      89             :     static GtkStyleContext *mpFixedHoriLineStyle;
      90             :     static GtkStyleContext *mpFixedVertLineStyle;
      91             :     static GtkStyleContext *mpTreeHeaderButtonStyle;
      92             :     static GtkStyleContext *mpProgressBarStyle;
      93             : 
      94             :     static Rectangle NWGetScrollButtonRect( ControlPart nPart, Rectangle aAreaRect );
      95             :     static Rectangle NWGetSpinButtonRect( ControlPart nPart, Rectangle aAreaRect);
      96             :     static Rectangle NWGetComboBoxButtonRect( ControlType nType, ControlPart nPart, Rectangle aAreaRect );
      97             : 
      98             :     static void PaintScrollbar(GtkStyleContext *context,
      99             :                         cairo_t *cr,
     100             :                         const Rectangle& rControlRectangle,
     101             :                         ControlType nType,
     102             :                         ControlPart nPart,
     103             :                         const ImplControlValue& aValue );
     104             :     static void PaintOneSpinButton( GtkStyleContext *context,
     105             :                              cairo_t *cr,
     106             :                              ControlType nType,
     107             :                              ControlPart nPart,
     108             :                              Rectangle aAreaRect,
     109             :                              ControlState nState );
     110             :     static void PaintSpinButton(GtkStyleContext *context,
     111             :                          cairo_t *cr,
     112             :                          const Rectangle& rControlRectangle,
     113             :                          ControlType nType,
     114             :                          ControlPart nPart,
     115             :                          const ImplControlValue& aValue);
     116             :     static void PaintCombobox(GtkStateFlags flags,
     117             :                         cairo_t *cr,
     118             :                         const Rectangle& rControlRectangle,
     119             :                         ControlType nType,
     120             :                         ControlPart nPart,
     121             :                         const ImplControlValue& aValue);
     122             :     static void PaintCheckOrRadio(GtkStyleContext *context,
     123             :                            cairo_t *cr,
     124             :                            const Rectangle& rControlRectangle,
     125             :                            ControlType nType);
     126             : 
     127             :     static bool style_loaded;
     128             : };
     129             : 
     130             : #else
     131             : #include <unx/salgdi.h>
     132             : 
     133             : class GdkX11Pixmap;
     134             : class GtkSalGraphics : public X11SalGraphics
     135             : {
     136             :     GtkWidget           *m_pWindow;
     137             :     vcl::Region               m_aClipRegion;
     138             : 
     139             : public:
     140             :                         GtkSalGraphics( GtkSalFrame *, GtkWidget *window );
     141             :                         GtkSalGraphics( GtkSalFrame *, GtkWidget *window, SalX11Screen nXScreen );
     142             :     virtual             ~GtkSalGraphics();
     143             : 
     144         177 :     inline GtkWidget*  GetGtkWidget() const { return m_pWindow; }
     145           0 :     inline GdkWindow*  GetGdkWindow() const { return m_pWindow->window; }
     146         177 :     inline GtkSalFrame* GetGtkFrame() const { return static_cast<GtkSalFrame*>(m_pFrame); }
     147           0 :     void SetWindow( GtkWidget* window ) { m_pWindow = window; }
     148             : 
     149             :     // will be set when UI theme was changed
     150             :     static  bool        bThemeChanged;
     151             :     static  bool        bNeedPixmapPaint;
     152             :     static  bool        bNeedTwoPasses;
     153             : 
     154             :     // native widget methods
     155             :     virtual bool        IsNativeControlSupported( ControlType nType, ControlPart nPart ) SAL_OVERRIDE;
     156             :     virtual bool        hitTestNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
     157             :                                               const Point& aPos, bool& rIsInside ) SAL_OVERRIDE;
     158             :     virtual bool        drawNativeControl( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion,
     159             :                                            ControlState nState, const ImplControlValue& aValue,
     160             :                                            const OUString& rCaption ) SAL_OVERRIDE;
     161             :     virtual bool        getNativeControlRegion( ControlType nType, ControlPart nPart, const Rectangle& rControlRegion, ControlState nState,
     162             :                                                 const ImplControlValue& aValue, const OUString& rCaption,
     163             :                                                 Rectangle &rNativeBoundingRegion, Rectangle &rNativeContentRegion ) SAL_OVERRIDE;
     164             : 
     165             :     //helper methods for frame's UpdateSettings
     166             :     void updateSettings( AllSettings& rSettings );
     167             :     static void refreshFontconfig( GtkSettings *pSettings );
     168             :     static void signalSettingsNotify( GObject*, GParamSpec *pSpec, gpointer );
     169             : 
     170             :     virtual bool            setClipRegion( const vcl::Region& ) SAL_OVERRIDE;
     171             :     virtual void            ResetClipRegion() SAL_OVERRIDE;
     172             : 
     173             :     // some themes set the background pixmap of our window EVERY time
     174             :     // a control is painted; but presentation effects need
     175             :     // the background set to None; workaround: set the background
     176             :     // before copyBits
     177             :     virtual void            copyBits( const SalTwoRect& rPosAry,
     178             :                                       SalGraphics* pSrcGraphics ) SAL_OVERRIDE;
     179             : 
     180             : protected:
     181             :     typedef std::list< Rectangle > clipList;
     182             : 
     183             :     GdkX11Pixmap* NWGetPixmapFromScreen( Rectangle srcRect, int nBgColor = 0 );
     184             :     bool NWRenderPixmapToScreen( GdkX11Pixmap* pPixmap, GdkX11Pixmap* pMask, Rectangle dstRect );
     185             : 
     186             :     bool DoDrawNativeControl( GdkDrawable* pDrawable,
     187             :                            ControlType nType,
     188             :                            ControlPart nPart,
     189             :                            const Rectangle& aCtrlRect,
     190             :                            const clipList& aClip,
     191             :                            ControlState nState,
     192             :                            const ImplControlValue& aValue,
     193             :                            const OUString& rCaption );
     194             : 
     195             :     bool NWPaintGTKArrow( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     196             :                            const Rectangle& rControlRectangle,
     197             :                            const clipList& rClipList,
     198             :                            ControlState nState, const ImplControlValue& aValue,
     199             :                            const OUString& rCaption );
     200             :     bool NWPaintGTKListHeader( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     201             :                            const Rectangle& rControlRectangle,
     202             :                            const clipList& rClipList,
     203             :                            ControlState nState, const ImplControlValue& aValue,
     204             :                            const OUString& rCaption );
     205             :     bool NWPaintGTKFixedLine( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     206             :                            const Rectangle& rControlRectangle,
     207             :                            const clipList& rClipList,
     208             :                            ControlState nState, const ImplControlValue& aValue,
     209             :                            const OUString& rCaption );
     210             :     bool NWPaintGTKFrame( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     211             :                            const Rectangle& rControlRectangle,
     212             :                            const clipList& rClipList,
     213             :                            ControlState nState, const ImplControlValue& aValue,
     214             :                            const OUString& rCaption );
     215             :     bool NWPaintGTKWindowBackground( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     216             :                            const Rectangle& rControlRectangle,
     217             :                            const clipList& rClipList,
     218             :                            ControlState nState, const ImplControlValue& aValue,
     219             :                            const OUString& rCaption );
     220             :     bool NWPaintGTKButtonReal( GtkWidget* button, GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     221             :                            const Rectangle& rControlRectangle,
     222             :                            const clipList& rClipList,
     223             :                            ControlState nState, const ImplControlValue& aValue,
     224             :                            const OUString& rCaption );
     225             :     bool NWPaintGTKButton( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     226             :                            const Rectangle& rControlRectangle,
     227             :                            const clipList& rClipList,
     228             :                            ControlState nState, const ImplControlValue& aValue,
     229             :                            const OUString& rCaption );
     230             :     bool NWPaintGTKRadio( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     231             :                           const Rectangle& rControlRectangle,
     232             :                           const clipList& rClipList,
     233             :                           ControlState nState, const ImplControlValue& aValue,
     234             :                           const OUString& rCaption );
     235             :     bool NWPaintGTKCheck( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     236             :                           const Rectangle& rControlRectangle,
     237             :                           const clipList& rClipList,
     238             :                           ControlState nState, const ImplControlValue& aValue,
     239             :                           const OUString& rCaption );
     240             :     bool NWPaintGTKScrollbar( ControlType nType, ControlPart nPart,
     241             :                               const Rectangle& rControlRectangle,
     242             :                               const clipList& rClipList,
     243             :                               ControlState nState, const ImplControlValue& aValue,
     244             :                               const OUString& rCaption );
     245             :     bool NWPaintGTKEditBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     246             :                             const Rectangle& rControlRectangle,
     247             :                             const clipList& rClipList,
     248             :                             ControlState nState, const ImplControlValue& aValue,
     249             :                             const OUString& rCaption );
     250             :     bool NWPaintGTKSpinBox( ControlType nType, ControlPart nPart,
     251             :                             const Rectangle& rControlRectangle,
     252             :                             const clipList& rClipList,
     253             :                             ControlState nState, const ImplControlValue& aValue,
     254             :                             const OUString& rCaption );
     255             :     bool NWPaintGTKComboBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     256             :                              const Rectangle& rControlRectangle,
     257             :                              const clipList& rClipList,
     258             :                              ControlState nState, const ImplControlValue& aValue,
     259             :                              const OUString& rCaption );
     260             :     bool NWPaintGTKTabItem( ControlType nType, ControlPart nPart,
     261             :                             const Rectangle& rControlRectangle,
     262             :                             const clipList& rClipList,
     263             :                             ControlState nState, const ImplControlValue& aValue,
     264             :                             const OUString& rCaption );
     265             :     bool NWPaintGTKListBox( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     266             :                             const Rectangle& rControlRectangle,
     267             :                             const clipList& rClipList,
     268             :                             ControlState nState, const ImplControlValue& aValue,
     269             :                             const OUString& rCaption );
     270             : 
     271             :     bool NWPaintGTKToolbar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     272             :                             const Rectangle& rControlRectangle,
     273             :                             const clipList& rClipList,
     274             :                             ControlState nState, const ImplControlValue& aValue,
     275             :                             const OUString& rCaption );
     276             :     bool NWPaintGTKMenubar( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     277             :                             const Rectangle& rControlRectangle,
     278             :                             const clipList& rClipList,
     279             :                             ControlState nState, const ImplControlValue& aValue,
     280             :                             const OUString& rCaption );
     281             :     bool NWPaintGTKPopupMenu( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     282             :                               const Rectangle& rControlRectangle,
     283             :                               const clipList& rClipList,
     284             :                               ControlState nState, const ImplControlValue& aValue,
     285             :                               const OUString& rCaption );
     286             :     bool NWPaintGTKTooltip( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     287             :                             const Rectangle& rControlRectangle,
     288             :                             const clipList& rClipList,
     289             :                             ControlState nState, const ImplControlValue& aValue,
     290             :                             const OUString& rCaption );
     291             :     bool NWPaintGTKProgress( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     292             :                             const Rectangle& rControlRectangle,
     293             :                             const clipList& rClipList,
     294             :                             ControlState nState, const ImplControlValue& aValue,
     295             :                             const OUString& rCaption );
     296             :     bool NWPaintGTKSlider( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     297             :                            const Rectangle& rControlRectangle,
     298             :                            const clipList& rClipList,
     299             :                            ControlState nState, const ImplControlValue& aValue,
     300             :                            const OUString& rCaption );
     301             :     bool NWPaintGTKListNode( GdkDrawable* gdkDrawable, ControlType nType, ControlPart nPart,
     302             :                             const Rectangle& rControlRectangle,
     303             :                             const clipList& rClipList,
     304             :                             ControlState nState, const ImplControlValue& aValue,
     305             :                             const OUString& rCaption );
     306             : };
     307             : 
     308             : #endif // !gtk3
     309             : 
     310             : #endif // INCLUDED_VCL_INC_UNX_GTK_GTKGDI_HXX
     311             : 
     312             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11