]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/window.cpp
#ifdef'd out some parts for non-supported systems.
[wxWidgets.git] / src / gtk / window.cpp
index 9457a59a57cbf194b81e2d8ad35269a29d8f0b1f..515eb483cc4740858aa3b7afe2233d68883579d6 100644 (file)
@@ -29,7 +29,6 @@
 #include "wx/notebook.h"
 #include "wx/statusbr.h"
 #include <wx/intl.h>
-//#include "wx/treectrl.h"
 #include "gdk/gdkkeysyms.h"
 #include <math.h>
 #include "wx/gtk/win_gtk.h"
@@ -272,9 +271,10 @@ gint gtk_window_key_press_callback( GtkWidget *WXUNUSED(widget), GdkEventKey *gd
 //-----------------------------------------------------------------------------
 // button_press
 
-gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
-{ 
-  if (widget->window != gdk_event->window) return TRUE;
+gint gtk_window_button_press_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win )
+{
+  if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
+  
   if (g_blockEventsOnDrag) return TRUE;
 
   if (win->m_wxwindow)
@@ -353,10 +353,9 @@ gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton *gdk_ev
 //-----------------------------------------------------------------------------
 // button_release
 
-gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_event, wxWindow *win )
+gint gtk_window_button_release_callback( GtkWidget *WXUNUSED(widget), GdkEventButton *gdk_event, wxWindow *win )
 { 
-  if (widget->window != gdk_event->window) return TRUE;
-
+  if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
   if (g_blockEventsOnDrag) return TRUE;
 
   if (!win->HasVMT()) return TRUE;
@@ -397,10 +396,9 @@ gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButton *gdk_
 //-----------------------------------------------------------------------------
 // motion_notify
 
-gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion *gdk_event, wxWindow *win )
+gint gtk_window_motion_notify_callback( GtkWidget *WXUNUSED(widget), GdkEventMotion *gdk_event, wxWindow *win )
 { 
-  if (widget->window != gdk_event->window) return TRUE;
-
+  if (!win->IsOwnGtkWindow( gdk_event->window )) return TRUE;
   if (g_blockEventsOnDrag) return TRUE;
 
   if (!win->HasVMT()) return TRUE;
@@ -748,8 +746,6 @@ wxWindow::wxWindow()
   m_oldVerticalPos = 0.0;
   m_isShown = FALSE;
   m_isEnabled = TRUE;
-  m_drawingOffsetX = 0;
-  m_drawingOffsetY = 0;
   m_pDropTarget = NULL;
   m_resizing = FALSE;
 }
@@ -929,8 +925,6 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
   m_windowSizer = NULL;
   m_sizerParent = NULL;
   m_autoLayout = FALSE;
-  m_drawingOffsetX = 0;
-  m_drawingOffsetY = 0;
   m_pDropTarget = NULL;
   m_resizing = FALSE;
   m_windowValidator = NULL;
@@ -1010,7 +1004,12 @@ void wxWindow::PostCreation(void)
 */
   
   if (m_widget && m_parent) gtk_widget_realize( m_widget );
-  if (m_wxwindow) gtk_widget_realize( m_wxwindow );
+  
+  if (m_wxwindow)
+  {
+    gtk_widget_realize( m_wxwindow );
+    gdk_gc_set_exposures( m_wxwindow->style->fg_gc[0], TRUE );
+  }
   
   SetCursor( wxSTANDARD_CURSOR );
   
@@ -1049,7 +1048,7 @@ bool wxWindow::DestroyChildren(void)
       if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) 
       {
         delete child;
-  if (GetChildren()->Member(child)) delete node;
+        if (GetChildren()->Member(child)) delete node;
       }
     }
   }
@@ -1077,7 +1076,7 @@ void wxWindow::ImplementSetPosition(void)
   
   if (!m_parent)
   {
-    printf( _("wxWindow::SetSize error.\n") );
+    wxFAIL_MSG( _("wxWindow::SetSize error.\n") );
     return;
   }
   
@@ -1395,6 +1394,31 @@ void wxWindow::Enable( bool enable )
   if (m_wxwindow) gtk_widget_set_sensitive( m_wxwindow, enable );
 }
 
+int wxWindow::GetCharHeight(void) const
+{
+  GdkFont *font = m_font.GetInternalFont( 1.0 );
+  return font->ascent + font->descent;
+}
+
+int wxWindow::GetCharWidth(void) const
+{
+  GdkFont *font = m_font.GetInternalFont( 1.0 );
+  return gdk_string_width( font, "H" );
+}
+
+void wxWindow::GetTextExtent( const wxString& string, int *x, int *y,
+  int *descent, int *externalLeading, const wxFont *theFont, bool WXUNUSED(use16) ) const
+{
+  wxFont fontToUse = m_font;
+  if (theFont) fontToUse = *theFont;
+  
+  GdkFont *font = fontToUse.GetInternalFont( 1.0 );
+  if (x) (*y) = gdk_string_width( font, string );
+  if (y) (*y) = font->ascent + font->descent;
+  if (descent) (*descent) = font->descent;
+  if (externalLeading) (*externalLeading) = 0;  // ??
+}
+
 void wxWindow::MakeModal( bool modal )
 {
   return;
@@ -1518,11 +1542,6 @@ int wxWindow::GetReturnCode(void)
   return m_retCode;
 }
 
-wxWindow *wxWindow::GetParent(void)
-{
-  return m_parent;
-}
-
 void wxWindow::Raise(void)
 {
   if (m_widget) gdk_window_raise( m_widget->window );
@@ -1627,19 +1646,13 @@ void wxWindow::Refresh( bool eraseBackground, const wxRect *rect )
   {
     if (m_wxwindow)
     {
-      wxClientDC dc(this);
-      PrepareDC(dc);
-      long x = 0;
-      long y = 0;
-      dc.GetInternalDeviceOrigin( &x, &y );
-      
       int w = 0;
       int h = 0;
       GetClientSize( &w, &h );
       
       GdkRectangle gdk_rect;
-      gdk_rect.x = x;
-      gdk_rect.y = y;
+      gdk_rect.x = 0;
+      gdk_rect.y = 0;
       gdk_rect.width = w;
       gdk_rect.height = h;
       gtk_widget_draw( m_wxwindow, &gdk_rect );
@@ -1812,6 +1825,12 @@ GtkWidget* wxWindow::GetConnectWidget(void)
   return connect_widget;
 }
   
+bool wxWindow::IsOwnGtkWindow( GdkWindow *window )
+{
+  if (m_wxwindow) return (window == m_wxwindow->window);
+  return (window == m_widget->window);
+}
+
 void wxWindow::SetFont( const wxFont &font )
 {
   m_font = font;
@@ -1969,23 +1988,9 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
   if (m_wxwindow->window)
   {
     if (orient == wxHORIZONTAL)
-    {
-/*
-      m_drawingOffsetX = -16000;
-  
-      gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
-*/  
       gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
-    }
     else
-    { 
-/*
-      m_drawingOffsetY = -16000;
-  
-      gtk_myfixed_set_offset( GTK_MYFIXED(m_wxwindow), m_drawingOffsetX, m_drawingOffsetY );
-*/      
       gtk_signal_emit_by_name( GTK_OBJECT(m_vAdjust), "changed" );
-    }
       
     gtk_widget_set_usize( m_widget, m_width, m_height );
   }
@@ -2054,6 +2059,7 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
 {
   if (!m_wxwindow) return;
   
+/*
   bool refresh = FALSE;
     
   if ((m_drawingOffsetX == 0) && (m_drawingOffsetY == 0))
@@ -2074,9 +2080,9 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
   
   if (refresh) Refresh();
   
-/*
     The code here is very nifty, but it doesn't work with
     overlapping windows...
+*/
 
     int cw = 0;
     int ch = 0;
@@ -2107,13 +2113,6 @@ void wxWindow::ScrollWindow( int dx, int dy, const wxRect* WXUNUSED(rect) )
     if (dx != 0) rect.height = ch; else rect.height = abs(dy);
   
     Refresh( TRUE, &rect );
-*/
-}
-
-void wxWindow::GetDrawingOffset( long *x, long *y )
-{
-  if (x) *x = m_drawingOffsetX;
-  if (y) *y = m_drawingOffsetY;
 }
 
 //-------------------------------------------------------------------------------------