LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/vcl/unx/gtk/window - gtkobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 93 0.0 %
Date: 2013-07-09 Functions: 0 17 0.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             : 
      21             : #ifdef AIX
      22             : #define _LINUX_SOURCE_COMPAT
      23             : #include <sys/timer.h>
      24             : #undef _LINUX_SOURCE_COMPAT
      25             : #endif
      26             : 
      27             : #include <unx/gtk/gtkobject.hxx>
      28             : #include <unx/gtk/gtkframe.hxx>
      29             : #include <unx/gtk/gtkdata.hxx>
      30             : #include <unx/gtk/gtkinst.hxx>
      31             : #include <unx/gtk/gtkgdi.hxx>
      32             : 
      33           0 : GtkSalObject::GtkSalObject( GtkSalFrame* pParent, sal_Bool bShow )
      34             :         : m_pSocket( NULL ),
      35           0 :           m_pRegion( NULL )
      36             : {
      37           0 :     if( pParent )
      38             :     {
      39             :         // our plug window
      40           0 :         m_pSocket = gtk_drawing_area_new();
      41           0 :         Show( bShow );
      42             :         // insert into container
      43             :         gtk_fixed_put( pParent->getFixedContainer(),
      44             :                        m_pSocket,
      45           0 :                        0, 0 );
      46             :         // realize so we can get a window id
      47           0 :         gtk_widget_realize( m_pSocket );
      48             : 
      49             :         // make it transparent; some plugins may not insert
      50             :         // their own window here but use the socket window itself
      51           0 :         gtk_widget_set_app_paintable( m_pSocket, TRUE );
      52             : 
      53             :         // system data
      54           0 :         SalDisplay* pDisp = GetGenericData()->GetSalDisplay();
      55           0 :         m_aSystemData.nSize         = sizeof( SystemChildData );
      56           0 :         m_aSystemData.pDisplay      = pDisp->GetDisplay();
      57           0 :         m_aSystemData.aWindow       = GDK_WINDOW_XWINDOW(widget_get_window(m_pSocket));
      58           0 :         m_aSystemData.pSalFrame     = NULL;
      59           0 :         m_aSystemData.pWidget       = m_pSocket;
      60           0 :         m_aSystemData.pVisual       = pDisp->GetVisual(pParent->getXScreenNumber()).GetVisual();
      61           0 :         m_aSystemData.nScreen       = pParent->getXScreenNumber().getXScreen();
      62           0 :         m_aSystemData.nDepth        = pDisp->GetVisual(pParent->getXScreenNumber()).GetDepth();
      63           0 :         m_aSystemData.aColormap     = pDisp->GetColormap(pParent->getXScreenNumber()).GetXColormap();
      64           0 :         m_aSystemData.pAppContext   = NULL;
      65           0 :         m_aSystemData.aShellWindow  = GDK_WINDOW_XWINDOW(widget_get_window(GTK_WIDGET(pParent->getWindow())));
      66           0 :         m_aSystemData.pShellWidget  = GTK_WIDGET(pParent->getWindow());
      67             : 
      68           0 :         g_signal_connect( G_OBJECT(m_pSocket), "button-press-event", G_CALLBACK(signalButton), this );
      69           0 :         g_signal_connect( G_OBJECT(m_pSocket), "button-release-event", G_CALLBACK(signalButton), this );
      70           0 :         g_signal_connect( G_OBJECT(m_pSocket), "focus-in-event", G_CALLBACK(signalFocus), this );
      71           0 :         g_signal_connect( G_OBJECT(m_pSocket), "focus-out-event", G_CALLBACK(signalFocus), this );
      72           0 :         g_signal_connect( G_OBJECT(m_pSocket), "destroy", G_CALLBACK(signalDestroy), this );
      73             : 
      74             :         // #i59255# necessary due to sync effects with java child windows
      75           0 :         pParent->Sync();
      76             :     }
      77           0 : }
      78             : 
      79           0 : GtkSalObject::~GtkSalObject()
      80             : {
      81           0 :     if( m_pRegion )
      82             :     {
      83             : #if GTK_CHECK_VERSION(3,0,0)
      84             :         cairo_region_destroy( m_pRegion );
      85             : #else
      86           0 :         gdk_region_destroy( m_pRegion );
      87             : #endif
      88             :     }
      89           0 :     if( m_pSocket )
      90             :     {
      91             :         // remove socket from parent frame's fixed container
      92           0 :         gtk_container_remove( GTK_CONTAINER(gtk_widget_get_parent(m_pSocket)),
      93           0 :                               m_pSocket );
      94             :         // get rid of the socket
      95             :         // actually the gtk_container_remove should let the ref count
      96             :         // of the socket sink to 0 and destroy it (see signalDestroy)
      97             :         // this is just a sanity check
      98           0 :         if( m_pSocket )
      99           0 :             gtk_widget_destroy( m_pSocket );
     100             :     }
     101           0 : }
     102             : 
     103           0 : void GtkSalObject::ResetClipRegion()
     104             : {
     105           0 :     if( m_pSocket )
     106           0 :         gdk_window_shape_combine_region( widget_get_window(m_pSocket), NULL, 0, 0 );
     107           0 : }
     108             : 
     109           0 : sal_uInt16 GtkSalObject::GetClipRegionType()
     110             : {
     111           0 :     return SAL_OBJECT_CLIP_INCLUDERECTS;
     112             : }
     113             : 
     114           0 : void GtkSalObject::BeginSetClipRegion( sal_uLong )
     115             : {
     116             : #if GTK_CHECK_VERSION(3,0,0)
     117             :     if( m_pRegion )
     118             :         cairo_region_destroy( m_pRegion );
     119             :     m_pRegion = cairo_region_create();
     120             : #else
     121           0 :     if( m_pRegion )
     122           0 :         gdk_region_destroy( m_pRegion );
     123           0 :     m_pRegion = gdk_region_new();
     124             : #endif
     125           0 : }
     126             : 
     127           0 : void GtkSalObject::UnionClipRegion( long nX, long nY, long nWidth, long nHeight )
     128             : {
     129             :     GdkRectangle aRect;
     130           0 :     aRect.x         = nX;
     131           0 :     aRect.y         = nY;
     132           0 :     aRect.width     = nWidth;
     133           0 :     aRect.height    = nHeight;
     134             : 
     135             : #if GTK_CHECK_VERSION(3,0,0)
     136             :     cairo_region_union_rectangle( m_pRegion, &aRect );
     137             : #else
     138           0 :     gdk_region_union_with_rect( m_pRegion, &aRect );
     139             : #endif
     140           0 : }
     141             : 
     142           0 : void GtkSalObject::EndSetClipRegion()
     143             : {
     144           0 :     if( m_pSocket )
     145           0 :         gdk_window_shape_combine_region( widget_get_window(m_pSocket), m_pRegion, 0, 0 );
     146           0 : }
     147             : 
     148           0 : void GtkSalObject::SetPosSize( long nX, long nY, long nWidth, long nHeight )
     149             : {
     150           0 :     if( m_pSocket )
     151             :     {
     152           0 :         GtkFixed* pContainer = GTK_FIXED(gtk_widget_get_parent(m_pSocket));
     153           0 :         gtk_fixed_move( pContainer, m_pSocket, nX, nY );
     154           0 :         gtk_widget_set_size_request( m_pSocket, nWidth, nHeight );
     155           0 :         gtk_container_resize_children( GTK_CONTAINER(pContainer) );
     156             :     }
     157           0 : }
     158             : 
     159           0 : void GtkSalObject::Show( sal_Bool bVisible )
     160             : {
     161           0 :     if( m_pSocket )
     162             :     {
     163           0 :         if( bVisible )
     164           0 :             gtk_widget_show( m_pSocket );
     165             :         else
     166           0 :             gtk_widget_hide( m_pSocket );
     167             :     }
     168           0 : }
     169             : 
     170           0 : const SystemEnvData* GtkSalObject::GetSystemData() const
     171             : {
     172           0 :     return &m_aSystemData;
     173             : }
     174             : 
     175           0 : gboolean GtkSalObject::signalButton( GtkWidget*, GdkEventButton* pEvent, gpointer object )
     176             : {
     177           0 :     GtkSalObject* pThis = (GtkSalObject*)object;
     178             : 
     179           0 :     if( pEvent->type == GDK_BUTTON_PRESS )
     180             :     {
     181           0 :         pThis->CallCallback( SALOBJ_EVENT_TOTOP, NULL );
     182             :     }
     183             : 
     184           0 :     return FALSE;
     185             : }
     186             : 
     187           0 : gboolean GtkSalObject::signalFocus( GtkWidget*, GdkEventFocus* pEvent, gpointer object )
     188             : {
     189           0 :     GtkSalObject* pThis = (GtkSalObject*)object;
     190             : 
     191           0 :     pThis->CallCallback( pEvent->in ? SALOBJ_EVENT_GETFOCUS : SALOBJ_EVENT_LOSEFOCUS, NULL );
     192             : 
     193           0 :     return FALSE;
     194             : }
     195             : 
     196           0 : void GtkSalObject::signalDestroy( GtkWidget* pObj, gpointer object )
     197             : {
     198           0 :     GtkSalObject* pThis = (GtkSalObject*)object;
     199           0 :     if( pObj == pThis->m_pSocket )
     200             :     {
     201           0 :         pThis->m_pSocket = NULL;
     202             :     }
     203           0 : }
     204             : 
     205           0 : void GtkSalObject::SetForwardKey( sal_Bool bEnable )
     206             : {
     207           0 :     if( bEnable )
     208           0 :         gtk_widget_add_events( GTK_WIDGET( m_pSocket ), GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE );
     209             :     else
     210           0 :         gtk_widget_set_events( GTK_WIDGET( m_pSocket ), ~(GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE) & gtk_widget_get_events( GTK_WIDGET( m_pSocket ) ) );
     211           0 : }
     212             : 
     213             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10