]> git.saurik.com Git - wxWidgets.git/commitdiff
A few resize bugs removed
authorRobert Roebling <robert@roebling.de>
Tue, 26 Jan 1999 11:35:26 +0000 (11:35 +0000)
committerRobert Roebling <robert@roebling.de>
Tue, 26 Jan 1999 11:35:26 +0000 (11:35 +0000)
  combo box now emits EVT_TEXT
  position of pop-up menu can now be set

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1481 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

samples/dnd/dnd.cpp
src/gtk/combobox.cpp
src/gtk/dialog.cpp
src/gtk/frame.cpp
src/gtk/textctrl.cpp
src/gtk/window.cpp
src/gtk1/combobox.cpp
src/gtk1/dialog.cpp
src/gtk1/frame.cpp
src/gtk1/textctrl.cpp
src/gtk1/window.cpp

index abc81422cae2b25c02c9aacda20a96c257ff9666..208f397e25c5f6885a69e86b221f4e985e5a78ba 100644 (file)
@@ -308,10 +308,12 @@ void DnDFrame::OnLeftDown(wxMouseEvent &WXUNUSED(event) )
   if ( !m_strText.IsEmpty() ) 
   {
     // start drag operation
+#ifdef __WXMSW__
     wxTextDataObject textData(m_strText);
     wxDropSource dragSource( textData, this );
-
-//    wxDropSource dragSource( new wxTextDataObject (m_strText), this );
+#else
+    wxDropSource dragSource( new wxTextDataObject (m_strText), this );
+#endif
     const char *pc;
 
     switch ( dragSource.DoDragDrop(TRUE) ) 
index 499e2153d96960791bf4d8d81a069568e20fd5cb..be2d6b281db3ab146cb8edccce60b7deab6c0b83 100644 (file)
@@ -50,6 +50,20 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
     combo->GetEventHandler()->ProcessEvent(event);
 }
 
+//-----------------------------------------------------------------------------
+//  "changed"
+//-----------------------------------------------------------------------------
+
+static void 
+gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
+{
+    wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->m_windowId );
+    event.SetString( copystring(combo->GetValue()) );
+    event.SetEventObject( combo );
+    combo->GetEventHandler()->ProcessEvent( event );
+    delete[] event.GetString();
+}
+
 //-----------------------------------------------------------------------------
 // wxComboBox
 //-----------------------------------------------------------------------------
@@ -115,6 +129,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     gtk_widget_realize( GTK_COMBO(m_widget)->entry );
     gtk_widget_realize( GTK_COMBO(m_widget)->button );
   
+    gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed",
+      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+      
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
 
index f370b07580e22b0d01d5cb8b173194a193b1299f..e1da79d411c3d39a48b47fa8d2a5a3bfeb4f6ae0 100644 (file)
@@ -263,8 +263,8 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh
   
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     gtk_widget_set_usize( m_widget, m_width, m_height );
 
@@ -350,8 +350,8 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
   
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     if ((m_x != -1) || (m_y != -1))
     {
index d21f976cc87937f1706ab32714ca248e90d1bb9b..9d83f91591398b845f71493305b907862d282c40 100644 (file)
@@ -299,8 +299,8 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     if ((m_x != -1) || (m_y != -1))
     {
@@ -310,7 +310,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_width != old_width) || (m_height != old_height))
     {
-        gtk_widget_set_usize( m_widget, m_width, m_height );
+       gtk_widget_set_usize( m_widget, m_width, m_height );
     }
 
     wxSizeEvent event( wxSize(m_width,m_height), GetId() );
@@ -393,8 +393,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
 
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     gtk_widget_set_usize( m_widget, m_width, m_height );
 
index 61c406c6fb4f8918bbc89cf602d87d1b22405424..ff00fd75a47f5aefe1a7f7b51d7aaad1bc2503b2 100644 (file)
@@ -42,10 +42,10 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
     win->CalculateScrollbar();
 
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId );
-    wxString val( win->GetValue() );
-    if (!val.IsNull()) event.m_commandString = WXSTRINGCAST val;
+    event.SetString( copystring(win->GetValue()) );
     event.SetEventObject( win );
     win->GetEventHandler()->ProcessEvent( event );
+    delete[] event.GetString();
 }
 
 //-----------------------------------------------------------------------------
index 936b4a76a283f53f4859a94017a050a75455cc08..54cc47720830926909de5b80e3aae3731190ce2f 100644 (file)
@@ -631,6 +631,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
             node = node->Next();
         }
     }
+    
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
 
     event.SetEventObject( win );
 
@@ -736,6 +740,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
         }
     }
 
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     event.SetEventObject( win );
 
     if (win->GetEventHandler()->ProcessEvent( event ))
@@ -841,6 +849,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
         }
     }
 
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     event.SetEventObject( win );
 
     if (win->GetEventHandler()->ProcessEvent( event ))
@@ -966,6 +978,10 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
     event.m_x = (long)x;
     event.m_y = (long)y;
     
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     if (win->GetEventHandler()->ProcessEvent( event ))
        gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
 
@@ -1014,6 +1030,10 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
     event.m_x = (long)x;
     event.m_y = (long)y;
     
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     if (win->GetEventHandler()->ProcessEvent( event ))
         gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
 
@@ -2635,21 +2655,35 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
     }
 }
 
-bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
+static gint gs_pop_x = 0;
+static gint gs_pop_y = 0;
+
+static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win )
+{
+    win->ClientToScreen( &gs_pop_x, &gs_pop_y );
+    *x = gs_pop_x;
+    *y = gs_pop_y;
+}
+
+bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
 {
     wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
     wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" );
 
     SetInvokingWindow( menu, this );
+    
+    gs_pop_x = x;
+    gs_pop_y = y;
+    
     gtk_menu_popup(
                   GTK_MENU(menu->m_menu),
-                  (GtkWidget *)NULL,          // parent menu shell
-                  (GtkWidget *)NULL,          // parent menu item
-                  (GtkMenuPositionFunc)NULL,
-                  NULL,                       // client data
-                  0,                          // button used to activate it
-                  0//gs_timeLastClick            // the time of activation
+                  (GtkWidget *) NULL,          // parent menu shell
+                  (GtkWidget *) NULL,          // parent menu item
+                  (GtkMenuPositionFunc) pop_pos_callback,
+                  (gpointer) this,             // client data
+                  0,                           // button used to activate it
+                  0 //gs_timeLastClick         // the time of activation
                 );
     return TRUE;
 }
index 499e2153d96960791bf4d8d81a069568e20fd5cb..be2d6b281db3ab146cb8edccce60b7deab6c0b83 100644 (file)
@@ -50,6 +50,20 @@ static void gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox
     combo->GetEventHandler()->ProcessEvent(event);
 }
 
+//-----------------------------------------------------------------------------
+//  "changed"
+//-----------------------------------------------------------------------------
+
+static void 
+gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
+{
+    wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->m_windowId );
+    event.SetString( copystring(combo->GetValue()) );
+    event.SetEventObject( combo );
+    combo->GetEventHandler()->ProcessEvent( event );
+    delete[] event.GetString();
+}
+
 //-----------------------------------------------------------------------------
 // wxComboBox
 //-----------------------------------------------------------------------------
@@ -115,6 +129,9 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
     gtk_widget_realize( GTK_COMBO(m_widget)->entry );
     gtk_widget_realize( GTK_COMBO(m_widget)->button );
   
+    gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed",
+      GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
+      
     SetBackgroundColour( parent->GetBackgroundColour() );
     SetForegroundColour( parent->GetForegroundColour() );
 
index f370b07580e22b0d01d5cb8b173194a193b1299f..e1da79d411c3d39a48b47fa8d2a5a3bfeb4f6ae0 100644 (file)
@@ -263,8 +263,8 @@ void wxDialog::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int heigh
   
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     gtk_widget_set_usize( m_widget, m_width, m_height );
 
@@ -350,8 +350,8 @@ void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
   
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     if ((m_x != -1) || (m_y != -1))
     {
index d21f976cc87937f1706ab32714ca248e90d1bb9b..9d83f91591398b845f71493305b907862d282c40 100644 (file)
@@ -299,8 +299,8 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     if ((m_x != -1) || (m_y != -1))
     {
@@ -310,7 +310,7 @@ void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
 
     if ((m_width != old_width) || (m_height != old_height))
     {
-        gtk_widget_set_usize( m_widget, m_width, m_height );
+       gtk_widget_set_usize( m_widget, m_width, m_height );
     }
 
     wxSizeEvent event( wxSize(m_width,m_height), GetId() );
@@ -393,8 +393,8 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
 
     if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
     if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
-    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
-    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
+    if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
+    if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
 
     gtk_widget_set_usize( m_widget, m_width, m_height );
 
index 61c406c6fb4f8918bbc89cf602d87d1b22405424..ff00fd75a47f5aefe1a7f7b51d7aaad1bc2503b2 100644 (file)
@@ -42,10 +42,10 @@ gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxTextCtrl *win )
     win->CalculateScrollbar();
 
     wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, win->m_windowId );
-    wxString val( win->GetValue() );
-    if (!val.IsNull()) event.m_commandString = WXSTRINGCAST val;
+    event.SetString( copystring(win->GetValue()) );
     event.SetEventObject( win );
     win->GetEventHandler()->ProcessEvent( event );
+    delete[] event.GetString();
 }
 
 //-----------------------------------------------------------------------------
index 936b4a76a283f53f4859a94017a050a75455cc08..54cc47720830926909de5b80e3aae3731190ce2f 100644 (file)
@@ -631,6 +631,10 @@ static gint gtk_window_button_press_callback( GtkWidget *widget, GdkEventButton
             node = node->Next();
         }
     }
+    
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
 
     event.SetEventObject( win );
 
@@ -736,6 +740,10 @@ static gint gtk_window_button_release_callback( GtkWidget *widget, GdkEventButto
         }
     }
 
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     event.SetEventObject( win );
 
     if (win->GetEventHandler()->ProcessEvent( event ))
@@ -841,6 +849,10 @@ static gint gtk_window_motion_notify_callback( GtkWidget *widget, GdkEventMotion
         }
     }
 
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     event.SetEventObject( win );
 
     if (win->GetEventHandler()->ProcessEvent( event ))
@@ -966,6 +978,10 @@ static gint gtk_window_enter_callback( GtkWidget *widget, GdkEventCrossing *gdk_
     event.m_x = (long)x;
     event.m_y = (long)y;
     
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     if (win->GetEventHandler()->ProcessEvent( event ))
        gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "enter_notify_event" );
 
@@ -1014,6 +1030,10 @@ static gint gtk_window_leave_callback( GtkWidget *widget, GdkEventCrossing *gdk_
     event.m_x = (long)x;
     event.m_y = (long)y;
     
+    wxPoint pt(win->GetClientAreaOrigin());
+    event.m_x -= pt.x;
+    event.m_y -= pt.y;
+
     if (win->GetEventHandler()->ProcessEvent( event ))
         gtk_signal_emit_stop_by_name( GTK_OBJECT(widget), "leave_notify_event" );
 
@@ -2635,21 +2655,35 @@ static void SetInvokingWindow( wxMenu *menu, wxWindow *win )
     }
 }
 
-bool wxWindow::PopupMenu( wxMenu *menu, int WXUNUSED(x), int WXUNUSED(y) )
+static gint gs_pop_x = 0;
+static gint gs_pop_y = 0;
+
+static void pop_pos_callback( GtkMenu *menu, gint *x, gint *y, wxWindow *win )
+{
+    win->ClientToScreen( &gs_pop_x, &gs_pop_y );
+    *x = gs_pop_x;
+    *y = gs_pop_y;
+}
+
+bool wxWindow::PopupMenu( wxMenu *menu, int x, int y )
 {
     wxCHECK_MSG( m_widget != NULL, FALSE, "invalid window" );
 
     wxCHECK_MSG( menu != NULL, FALSE, "invalid popup-menu" );
 
     SetInvokingWindow( menu, this );
+    
+    gs_pop_x = x;
+    gs_pop_y = y;
+    
     gtk_menu_popup(
                   GTK_MENU(menu->m_menu),
-                  (GtkWidget *)NULL,          // parent menu shell
-                  (GtkWidget *)NULL,          // parent menu item
-                  (GtkMenuPositionFunc)NULL,
-                  NULL,                       // client data
-                  0,                          // button used to activate it
-                  0//gs_timeLastClick            // the time of activation
+                  (GtkWidget *) NULL,          // parent menu shell
+                  (GtkWidget *) NULL,          // parent menu item
+                  (GtkMenuPositionFunc) pop_pos_callback,
+                  (gpointer) this,             // client data
+                  0,                           // button used to activate it
+                  0 //gs_timeLastClick         // the time of activation
                 );
     return TRUE;
 }