From b6af8d80dcdd9d7ef9cca3aaaaf8fe4db343d7ae Mon Sep 17 00:00:00 2001 From: Robert Roebling Date: Sat, 8 Aug 1998 13:11:54 +0000 Subject: [PATCH] Added wxDC:DrawPolygone Corrected wxBitmap::SetLabel Added wxASSERT here and there wxDropSource:DoDrop() now returns Cancel when supposed to git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@476 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/button.h | 1 - include/wx/gtk/dnd.h | 4 ++- include/wx/gtk1/button.h | 1 - include/wx/gtk1/dnd.h | 4 ++- src/.cvsignore | 1 + src/gtk/button.cpp | 7 ++--- src/gtk/choice.cpp | 18 ++++++++++++ src/gtk/colour.cpp | 2 ++ src/gtk/combobox.cpp | 19 +++++++++++- src/gtk/control.cpp | 1 + src/gtk/dcclient.cpp | 62 ++++++++++++++++++++++++++++++++++------ src/gtk/dialog.cpp | 8 +++++- src/gtk/dnd.cpp | 18 ++++++++---- src/gtk/notebook.cpp | 4 +-- src/gtk1/button.cpp | 7 ++--- src/gtk1/choice.cpp | 18 ++++++++++++ src/gtk1/colour.cpp | 2 ++ src/gtk1/combobox.cpp | 19 +++++++++++- src/gtk1/control.cpp | 1 + src/gtk1/dcclient.cpp | 62 ++++++++++++++++++++++++++++++++++------ src/gtk1/dialog.cpp | 8 +++++- src/gtk1/dnd.cpp | 18 ++++++++---- src/gtk1/notebook.cpp | 4 +-- 23 files changed, 243 insertions(+), 46 deletions(-) diff --git a/include/wx/gtk/button.h b/include/wx/gtk/button.h index 6932755578..c423cc21fb 100644 --- a/include/wx/gtk/button.h +++ b/include/wx/gtk/button.h @@ -52,7 +52,6 @@ class wxButton: public wxControl long style = 0, const wxString &name = wxButtonNameStr ); void SetDefault(void); void SetLabel( const wxString &label ); - wxString GetLabel(void) const; }; #endif // __GTKBUTTONH__ diff --git a/include/wx/gtk/dnd.h b/include/wx/gtk/dnd.h index 2c2a0f5338..1ca1e33671 100644 --- a/include/wx/gtk/dnd.h +++ b/include/wx/gtk/dnd.h @@ -235,12 +235,14 @@ class wxDropSource: public wxObject protected: + friend void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ); + void RegisterWindow(void); void UnregisterWindow(void); GtkWidget *m_widget; wxWindow *m_window; - + DragResult m_retValue; wxDataObject *m_data; wxCursor m_defaultCursor; diff --git a/include/wx/gtk1/button.h b/include/wx/gtk1/button.h index 6932755578..c423cc21fb 100644 --- a/include/wx/gtk1/button.h +++ b/include/wx/gtk1/button.h @@ -52,7 +52,6 @@ class wxButton: public wxControl long style = 0, const wxString &name = wxButtonNameStr ); void SetDefault(void); void SetLabel( const wxString &label ); - wxString GetLabel(void) const; }; #endif // __GTKBUTTONH__ diff --git a/include/wx/gtk1/dnd.h b/include/wx/gtk1/dnd.h index 2c2a0f5338..1ca1e33671 100644 --- a/include/wx/gtk1/dnd.h +++ b/include/wx/gtk1/dnd.h @@ -235,12 +235,14 @@ class wxDropSource: public wxObject protected: + friend void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ); + void RegisterWindow(void); void UnregisterWindow(void); GtkWidget *m_widget; wxWindow *m_window; - + DragResult m_retValue; wxDataObject *m_data; wxCursor m_defaultCursor; diff --git a/src/.cvsignore b/src/.cvsignore index 9b075671ea..ab1b8840ad 100644 --- a/src/.cvsignore +++ b/src/.cvsignore @@ -1 +1,2 @@ Linux +linux diff --git a/src/gtk/button.cpp b/src/gtk/button.cpp index 9e64e2579e..7205e098c5 100644 --- a/src/gtk/button.cpp +++ b/src/gtk/button.cpp @@ -89,9 +89,8 @@ void wxButton::SetDefault(void) void wxButton::SetLabel( const wxString &label ) { wxControl::SetLabel( label ); + GtkBin *bin = GTK_BIN( m_widget ); + GtkLabel *g_label = GTK_LABEL( bin->child ); + gtk_label_set( g_label, GetLabel() ); }; -wxString wxButton::GetLabel(void) const -{ - return wxControl::GetLabel(); -}; diff --git a/src/gtk/choice.cpp b/src/gtk/choice.cpp index 09af84d007..039b4fda7f 100644 --- a/src/gtk/choice.cpp +++ b/src/gtk/choice.cpp @@ -122,11 +122,17 @@ int wxChoice::FindString( const wxString &string ) const GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = NULL; if (bin->child) label = GTK_LABEL(bin->child); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); if (string == label->label) return count; child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: string not found" ); + return -1; }; @@ -147,6 +153,9 @@ int wxChoice::GetSelection(void) child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: no selection" ); + return -1; }; @@ -162,18 +171,27 @@ wxString wxChoice::GetString( int n ) const { GtkLabel *label = NULL; if (bin->child) label = GTK_LABEL(bin->child); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); return label->label; }; child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: string not found" ); + return ""; }; wxString wxChoice::GetStringSelection(void) const { GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + return label->label; }; diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index b0efc2dcc2..90bd8e158a 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -93,6 +93,7 @@ wxColour::wxColour( const wxString &colourName ) m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) { + wxFAIL_MSG( "wxColour: couldn't find colour" ); delete m_refData; m_refData = NULL; }; @@ -134,6 +135,7 @@ wxColour& wxColour::operator = ( const wxString& colourName ) m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) { + wxFAIL_MSG( "wxColour: couldn't find colour" ); delete m_refData; m_refData = NULL; }; diff --git a/src/gtk/combobox.cpp b/src/gtk/combobox.cpp index 9965d5b5a7..6f0acae137 100644 --- a/src/gtk/combobox.cpp +++ b/src/gtk/combobox.cpp @@ -156,7 +156,7 @@ void wxComboBox::Delete( int n ) wxNode *node = m_clientData.Nth( n ); if (!node) { - wxFAIL_MSG(_("wxComboBox::Delete wrong index")); + wxFAIL_MSG( "wxComboBox: wrong index" ); } else m_clientData.DeleteNode( node ); @@ -176,6 +176,9 @@ int wxComboBox::FindString( const wxString &item ) count++; child = child->next; }; + + wxFAIL_MSG( "wxComboBox: string not found" ); + return -1; }; @@ -183,6 +186,9 @@ char* wxComboBox::GetClientData( int n ) { wxNode *node = m_clientData.Nth( n ); if (node) return (char*)node->Data(); + + wxFAIL_MSG( "wxComboBox: wrong index" ); + return NULL; }; @@ -190,6 +196,8 @@ void wxComboBox::SetClientData( int n, char * clientData ) { wxNode *node = m_clientData.Nth( n ); if (node) node->SetData( (wxObject*) clientData ); + + wxFAIL_MSG( "wxComboBox: wrong index" ); }; int wxComboBox::GetSelection(void) const @@ -208,6 +216,9 @@ int wxComboBox::GetSelection(void) const child = child->next; }; }; + + wxFAIL_MSG( "wxComboBox: no selection" ); + return -1; }; @@ -222,6 +233,9 @@ wxString wxComboBox::GetString( int n ) const GtkLabel *label = GTK_LABEL( bin->child ); return label->label; }; + + wxFAIL_MSG( "wxComboBox: wrong index" ); + return ""; }; @@ -236,6 +250,9 @@ wxString wxComboBox::GetStringSelection(void) const wxString tmp = GTK_LABEL( bin->child )->label; return tmp; }; + + wxFAIL_MSG( "wxComboBox: no selection" ); + return ""; }; diff --git a/src/gtk/control.cpp b/src/gtk/control.cpp index 3c7f89d95b..fb7fd4d3af 100644 --- a/src/gtk/control.cpp +++ b/src/gtk/control.cpp @@ -47,6 +47,7 @@ void wxControl::SetLabel( const wxString &label ) #endif } + m_label = ""; m_label << *pc; } }; diff --git a/src/gtk/dcclient.cpp b/src/gtk/dcclient.cpp index 520eaa7036..468db590bc 100644 --- a/src/gtk/dcclient.cpp +++ b/src/gtk/dcclient.cpp @@ -279,16 +279,62 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset ) }; }; -void wxPaintDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[], - long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; +void wxPaintDC::DrawPolygon( int n, wxPoint points[], + long xoffset, long yoffset, int WXUNUSED(fillStyle) ) + { + if (!Ok()) return; + if (!n) return; // Nothing to draw + GdkPoint *gdkpoints = new GdkPoint[n+1]; + int i; + for (i = 0 ; i < n ; i++) + { + gdkpoints[i].x = XLOG2DEV(points[i].x + xoffset); + gdkpoints[i].y = YLOG2DEV(points[i].y + yoffset); + } + if (m_brush.GetStyle() != wxTRANSPARENT) + gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n); + // To do: Fillstyle + if (m_pen.GetStyle() != wxTRANSPARENT) + for (i = 0 ; i < n ; i++) + gdk_draw_line( m_window, m_penGC, + gdkpoints[i%n].x, + gdkpoints[i%n].y, + gdkpoints[(i+1)%n].x, + gdkpoints[(i+1)%n].y); + delete[] gdkpoints; }; -void wxPaintDC::DrawPolygon( wxList *WXUNUSED(lines), long WXUNUSED(xoffset), - long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; +void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, + long yoffset, int WXUNUSED(fillStyle)) + { + int n = lines->Number(); + + if (!Ok()) return; + GdkPoint *gdkpoints = new GdkPoint[n]; + wxNode *node = lines->First(); + int cnt=0; + while (node) + { + wxPoint *p = (wxPoint *) node->Data(); + gdkpoints[cnt].x = XLOG2DEV(p->x + xoffset); + gdkpoints[cnt].y = YLOG2DEV(p->y + yoffset); + node = node->Next(); + cnt++; + } + if (m_brush.GetStyle() != wxTRANSPARENT) + gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n); + // To do: Fillstyle + if (m_pen.GetStyle() != wxTRANSPARENT) + { + int i; + for (i = 0 ; i < n ; i++) + gdk_draw_line( m_window, m_penGC, + gdkpoints[i%n].x, + gdkpoints[i%n].y, + gdkpoints[(i+1)%n].x, + gdkpoints[(i+1)%n].y); + } + delete[] gdkpoints; }; void wxPaintDC::DrawRectangle( long x, long y, long width, long height ) diff --git a/src/gtk/dialog.cpp b/src/gtk/dialog.cpp index 6411ba1930..4c394a33e5 100644 --- a/src/gtk/dialog.cpp +++ b/src/gtk/dialog.cpp @@ -107,6 +107,7 @@ wxDialog::~wxDialog(void) void wxDialog::SetTitle(const wxString& title ) { m_title = title; + if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); }; @@ -219,7 +220,12 @@ void wxDialog::EndModal( int retCode ) { SetReturnCode( retCode ); - if (!m_modalShowing) return; + if (!m_modalShowing) + { + wxFAIL_MSG( "wxDialog: called EndModal twice" ); + return; + }; + m_modalShowing = FALSE; gtk_main_quit(); diff --git a/src/gtk/dnd.cpp b/src/gtk/dnd.cpp index 9a3b2b08ea..ce49947151 100644 --- a/src/gtk/dnd.cpp +++ b/src/gtk/dnd.cpp @@ -144,10 +144,12 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const //----------------------------------------------------------------------------- // drag request -void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) +void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ) { printf( "Data requested for dropping.\n" ); + wxDataObject *data = source->m_data; + uint size = data->GetDataSize(); char *ptr = new char[size]; data->GetDataHere( ptr ); @@ -155,6 +157,8 @@ void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) gtk_widget_dnd_data_set( widget, event, ptr, size ); delete ptr; + + source->m_retValue = wxDropSource::Copy; }; wxDropSource::wxDropSource( wxWindow *win ) @@ -165,7 +169,8 @@ wxDropSource::wxDropSource( wxWindow *win ) m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; - m_data = NULL; + m_data = NULL; + m_retValue = Cancel; m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); m_goaheadCursor = wxCursor( wxCURSOR_HAND ); @@ -178,6 +183,7 @@ wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) m_window = win; m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; + m_retValue = Cancel; m_data = &data; @@ -202,6 +208,8 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) if (gdk_dnd.dnd_grabbed) return None; if (gdk_dnd.drag_really) return None; + wxASSERT_MSG( data, "wxDragSource: no data" ); + if (!m_data) return None; if (m_data->GetDataSize() == 0) return None; @@ -255,7 +263,7 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) UnregisterWindow(); - return Copy; + return m_retValue; }; void wxDropSource::RegisterWindow(void) @@ -283,7 +291,7 @@ void wxDropSource::RegisterWindow(void) gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 ); gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", - GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data ); + GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this ); }; void wxDropSource::UnregisterWindow(void) @@ -292,5 +300,5 @@ void wxDropSource::UnregisterWindow(void) gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); - gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data ); + gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); }; diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp index 356a1a4c8f..da307dfb3e 100644 --- a/src/gtk/notebook.cpp +++ b/src/gtk/notebook.cpp @@ -184,7 +184,7 @@ int wxNotebook::GetSelection() const node = node->Next(); }; - wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?")); + wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" ); return page->m_id; }; @@ -230,7 +230,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const node = node->Next(); }; - wxLogDebug( _("Notebook page %d not found!"), page ); + wxLogDebug( "Notebook page %d not found!", page ); return NULL; }; diff --git a/src/gtk1/button.cpp b/src/gtk1/button.cpp index 9e64e2579e..7205e098c5 100644 --- a/src/gtk1/button.cpp +++ b/src/gtk1/button.cpp @@ -89,9 +89,8 @@ void wxButton::SetDefault(void) void wxButton::SetLabel( const wxString &label ) { wxControl::SetLabel( label ); + GtkBin *bin = GTK_BIN( m_widget ); + GtkLabel *g_label = GTK_LABEL( bin->child ); + gtk_label_set( g_label, GetLabel() ); }; -wxString wxButton::GetLabel(void) const -{ - return wxControl::GetLabel(); -}; diff --git a/src/gtk1/choice.cpp b/src/gtk1/choice.cpp index 09af84d007..039b4fda7f 100644 --- a/src/gtk1/choice.cpp +++ b/src/gtk1/choice.cpp @@ -122,11 +122,17 @@ int wxChoice::FindString( const wxString &string ) const GtkBin *bin = GTK_BIN( child->data ); GtkLabel *label = NULL; if (bin->child) label = GTK_LABEL(bin->child); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); if (string == label->label) return count; child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: string not found" ); + return -1; }; @@ -147,6 +153,9 @@ int wxChoice::GetSelection(void) child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: no selection" ); + return -1; }; @@ -162,18 +171,27 @@ wxString wxChoice::GetString( int n ) const { GtkLabel *label = NULL; if (bin->child) label = GTK_LABEL(bin->child); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + if (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); return label->label; }; child = child->next; count++; }; + + wxFAIL_MSG( "wxChoice: string not found" ); + return ""; }; wxString wxChoice::GetStringSelection(void) const { GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child ); + + wxASSERT_MSG( label != NULL , "wxChoice: invalid label" ); + return label->label; }; diff --git a/src/gtk1/colour.cpp b/src/gtk1/colour.cpp index b0efc2dcc2..90bd8e158a 100644 --- a/src/gtk1/colour.cpp +++ b/src/gtk1/colour.cpp @@ -93,6 +93,7 @@ wxColour::wxColour( const wxString &colourName ) m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) { + wxFAIL_MSG( "wxColour: couldn't find colour" ); delete m_refData; m_refData = NULL; }; @@ -134,6 +135,7 @@ wxColour& wxColour::operator = ( const wxString& colourName ) m_refData = new wxColourRefData(); if (!gdk_color_parse( colourName, &M_COLDATA->m_color )) { + wxFAIL_MSG( "wxColour: couldn't find colour" ); delete m_refData; m_refData = NULL; }; diff --git a/src/gtk1/combobox.cpp b/src/gtk1/combobox.cpp index 9965d5b5a7..6f0acae137 100644 --- a/src/gtk1/combobox.cpp +++ b/src/gtk1/combobox.cpp @@ -156,7 +156,7 @@ void wxComboBox::Delete( int n ) wxNode *node = m_clientData.Nth( n ); if (!node) { - wxFAIL_MSG(_("wxComboBox::Delete wrong index")); + wxFAIL_MSG( "wxComboBox: wrong index" ); } else m_clientData.DeleteNode( node ); @@ -176,6 +176,9 @@ int wxComboBox::FindString( const wxString &item ) count++; child = child->next; }; + + wxFAIL_MSG( "wxComboBox: string not found" ); + return -1; }; @@ -183,6 +186,9 @@ char* wxComboBox::GetClientData( int n ) { wxNode *node = m_clientData.Nth( n ); if (node) return (char*)node->Data(); + + wxFAIL_MSG( "wxComboBox: wrong index" ); + return NULL; }; @@ -190,6 +196,8 @@ void wxComboBox::SetClientData( int n, char * clientData ) { wxNode *node = m_clientData.Nth( n ); if (node) node->SetData( (wxObject*) clientData ); + + wxFAIL_MSG( "wxComboBox: wrong index" ); }; int wxComboBox::GetSelection(void) const @@ -208,6 +216,9 @@ int wxComboBox::GetSelection(void) const child = child->next; }; }; + + wxFAIL_MSG( "wxComboBox: no selection" ); + return -1; }; @@ -222,6 +233,9 @@ wxString wxComboBox::GetString( int n ) const GtkLabel *label = GTK_LABEL( bin->child ); return label->label; }; + + wxFAIL_MSG( "wxComboBox: wrong index" ); + return ""; }; @@ -236,6 +250,9 @@ wxString wxComboBox::GetStringSelection(void) const wxString tmp = GTK_LABEL( bin->child )->label; return tmp; }; + + wxFAIL_MSG( "wxComboBox: no selection" ); + return ""; }; diff --git a/src/gtk1/control.cpp b/src/gtk1/control.cpp index 3c7f89d95b..fb7fd4d3af 100644 --- a/src/gtk1/control.cpp +++ b/src/gtk1/control.cpp @@ -47,6 +47,7 @@ void wxControl::SetLabel( const wxString &label ) #endif } + m_label = ""; m_label << *pc; } }; diff --git a/src/gtk1/dcclient.cpp b/src/gtk1/dcclient.cpp index 520eaa7036..468db590bc 100644 --- a/src/gtk1/dcclient.cpp +++ b/src/gtk1/dcclient.cpp @@ -279,16 +279,62 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset ) }; }; -void wxPaintDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[], - long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; +void wxPaintDC::DrawPolygon( int n, wxPoint points[], + long xoffset, long yoffset, int WXUNUSED(fillStyle) ) + { + if (!Ok()) return; + if (!n) return; // Nothing to draw + GdkPoint *gdkpoints = new GdkPoint[n+1]; + int i; + for (i = 0 ; i < n ; i++) + { + gdkpoints[i].x = XLOG2DEV(points[i].x + xoffset); + gdkpoints[i].y = YLOG2DEV(points[i].y + yoffset); + } + if (m_brush.GetStyle() != wxTRANSPARENT) + gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n); + // To do: Fillstyle + if (m_pen.GetStyle() != wxTRANSPARENT) + for (i = 0 ; i < n ; i++) + gdk_draw_line( m_window, m_penGC, + gdkpoints[i%n].x, + gdkpoints[i%n].y, + gdkpoints[(i+1)%n].x, + gdkpoints[(i+1)%n].y); + delete[] gdkpoints; }; -void wxPaintDC::DrawPolygon( wxList *WXUNUSED(lines), long WXUNUSED(xoffset), - long WXUNUSED(yoffset), int WXUNUSED(fillStyle) ) -{ - if (!Ok()) return; +void wxPaintDC::DrawPolygon( wxList *lines, long xoffset, + long yoffset, int WXUNUSED(fillStyle)) + { + int n = lines->Number(); + + if (!Ok()) return; + GdkPoint *gdkpoints = new GdkPoint[n]; + wxNode *node = lines->First(); + int cnt=0; + while (node) + { + wxPoint *p = (wxPoint *) node->Data(); + gdkpoints[cnt].x = XLOG2DEV(p->x + xoffset); + gdkpoints[cnt].y = YLOG2DEV(p->y + yoffset); + node = node->Next(); + cnt++; + } + if (m_brush.GetStyle() != wxTRANSPARENT) + gdk_draw_polygon (m_window, m_brushGC, TRUE, gdkpoints, n); + // To do: Fillstyle + if (m_pen.GetStyle() != wxTRANSPARENT) + { + int i; + for (i = 0 ; i < n ; i++) + gdk_draw_line( m_window, m_penGC, + gdkpoints[i%n].x, + gdkpoints[i%n].y, + gdkpoints[(i+1)%n].x, + gdkpoints[(i+1)%n].y); + } + delete[] gdkpoints; }; void wxPaintDC::DrawRectangle( long x, long y, long width, long height ) diff --git a/src/gtk1/dialog.cpp b/src/gtk1/dialog.cpp index 6411ba1930..4c394a33e5 100644 --- a/src/gtk1/dialog.cpp +++ b/src/gtk1/dialog.cpp @@ -107,6 +107,7 @@ wxDialog::~wxDialog(void) void wxDialog::SetTitle(const wxString& title ) { m_title = title; + if (m_title.IsNull()) m_title = ""; gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); }; @@ -219,7 +220,12 @@ void wxDialog::EndModal( int retCode ) { SetReturnCode( retCode ); - if (!m_modalShowing) return; + if (!m_modalShowing) + { + wxFAIL_MSG( "wxDialog: called EndModal twice" ); + return; + }; + m_modalShowing = FALSE; gtk_main_quit(); diff --git a/src/gtk1/dnd.cpp b/src/gtk1/dnd.cpp index 9a3b2b08ea..ce49947151 100644 --- a/src/gtk1/dnd.cpp +++ b/src/gtk1/dnd.cpp @@ -144,10 +144,12 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const //----------------------------------------------------------------------------- // drag request -void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) +void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source ) { printf( "Data requested for dropping.\n" ); + wxDataObject *data = source->m_data; + uint size = data->GetDataSize(); char *ptr = new char[size]; data->GetDataHere( ptr ); @@ -155,6 +157,8 @@ void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDataObject *data ) gtk_widget_dnd_data_set( widget, event, ptr, size ); delete ptr; + + source->m_retValue = wxDropSource::Copy; }; wxDropSource::wxDropSource( wxWindow *win ) @@ -165,7 +169,8 @@ wxDropSource::wxDropSource( wxWindow *win ) m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; - m_data = NULL; + m_data = NULL; + m_retValue = Cancel; m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); m_goaheadCursor = wxCursor( wxCURSOR_HAND ); @@ -178,6 +183,7 @@ wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) m_window = win; m_widget = win->m_widget; if (win->m_wxwindow) m_widget = win->m_wxwindow; + m_retValue = Cancel; m_data = &data; @@ -202,6 +208,8 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) if (gdk_dnd.dnd_grabbed) return None; if (gdk_dnd.drag_really) return None; + wxASSERT_MSG( data, "wxDragSource: no data" ); + if (!m_data) return None; if (m_data->GetDataSize() == 0) return None; @@ -255,7 +263,7 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) UnregisterWindow(); - return Copy; + return m_retValue; }; void wxDropSource::RegisterWindow(void) @@ -283,7 +291,7 @@ void wxDropSource::RegisterWindow(void) gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 ); gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event", - GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)m_data ); + GTK_SIGNAL_FUNC(gtk_drag_callback), (gpointer)this ); }; void wxDropSource::UnregisterWindow(void) @@ -292,5 +300,5 @@ void wxDropSource::UnregisterWindow(void) gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 ); - gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)m_data ); + gtk_signal_disconnect_by_data( GTK_OBJECT(m_widget), (gpointer)this ); }; diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp index 356a1a4c8f..da307dfb3e 100644 --- a/src/gtk1/notebook.cpp +++ b/src/gtk1/notebook.cpp @@ -184,7 +184,7 @@ int wxNotebook::GetSelection() const node = node->Next(); }; - wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?")); + wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" ); return page->m_id; }; @@ -230,7 +230,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const node = node->Next(); }; - wxLogDebug( _("Notebook page %d not found!"), page ); + wxLogDebug( "Notebook page %d not found!", page ); return NULL; }; -- 2.45.2