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

Generated by: LCOV version 1.10