long style = 0, const wxString &name = wxButtonNameStr );
void SetDefault(void);
void SetLabel( const wxString &label );
- wxString GetLabel(void) const;
};
#endif // __GTKBUTTONH__
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;
long style = 0, const wxString &name = wxButtonNameStr );
void SetDefault(void);
void SetLabel( const wxString &label );
- wxString GetLabel(void) const;
};
#endif // __GTKBUTTONH__
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;
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();
-};
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;
};
child = child->next;
count++;
};
+
+ wxFAIL_MSG( "wxChoice: no selection" );
+
return -1;
};
{
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;
};
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;
};
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;
};
wxNode *node = m_clientData.Nth( n );
if (!node)
{
- wxFAIL_MSG(_("wxComboBox::Delete wrong index"));
+ wxFAIL_MSG( "wxComboBox: wrong index" );
}
else
m_clientData.DeleteNode( node );
count++;
child = child->next;
};
+
+ wxFAIL_MSG( "wxComboBox: string not found" );
+
return -1;
};
{
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
+
return NULL;
};
{
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
};
int wxComboBox::GetSelection(void) const
child = child->next;
};
};
+
+ wxFAIL_MSG( "wxComboBox: no selection" );
+
return -1;
};
GtkLabel *label = GTK_LABEL( bin->child );
return label->label;
};
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
+
return "";
};
wxString tmp = GTK_LABEL( bin->child )->label;
return tmp;
};
+
+ wxFAIL_MSG( "wxComboBox: no selection" );
+
return "";
};
#endif
}
+ m_label = "";
m_label << *pc;
}
};
};
};
-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 )
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 );
};
{
SetReturnCode( retCode );
- if (!m_modalShowing) return;
+ if (!m_modalShowing)
+ {
+ wxFAIL_MSG( "wxDialog: called EndModal twice" );
+ return;
+ };
+
m_modalShowing = FALSE;
gtk_main_quit();
//-----------------------------------------------------------------------------
// 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 );
gtk_widget_dnd_data_set( widget, event, ptr, size );
delete ptr;
+
+ source->m_retValue = wxDropSource::Copy;
};
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 );
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_retValue = Cancel;
m_data = &data;
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;
UnregisterWindow();
- return Copy;
+ return m_retValue;
};
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)
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 );
};
node = node->Next();
};
- wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?"));
+ wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" );
return page->m_id;
};
node = node->Next();
};
- wxLogDebug( _("Notebook page %d not found!"), page );
+ wxLogDebug( "Notebook page %d not found!", page );
return NULL;
};
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();
-};
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;
};
child = child->next;
count++;
};
+
+ wxFAIL_MSG( "wxChoice: no selection" );
+
return -1;
};
{
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;
};
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;
};
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;
};
wxNode *node = m_clientData.Nth( n );
if (!node)
{
- wxFAIL_MSG(_("wxComboBox::Delete wrong index"));
+ wxFAIL_MSG( "wxComboBox: wrong index" );
}
else
m_clientData.DeleteNode( node );
count++;
child = child->next;
};
+
+ wxFAIL_MSG( "wxComboBox: string not found" );
+
return -1;
};
{
wxNode *node = m_clientData.Nth( n );
if (node) return (char*)node->Data();
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
+
return NULL;
};
{
wxNode *node = m_clientData.Nth( n );
if (node) node->SetData( (wxObject*) clientData );
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
};
int wxComboBox::GetSelection(void) const
child = child->next;
};
};
+
+ wxFAIL_MSG( "wxComboBox: no selection" );
+
return -1;
};
GtkLabel *label = GTK_LABEL( bin->child );
return label->label;
};
+
+ wxFAIL_MSG( "wxComboBox: wrong index" );
+
return "";
};
wxString tmp = GTK_LABEL( bin->child )->label;
return tmp;
};
+
+ wxFAIL_MSG( "wxComboBox: no selection" );
+
return "";
};
#endif
}
+ m_label = "";
m_label << *pc;
}
};
};
};
-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 )
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 );
};
{
SetReturnCode( retCode );
- if (!m_modalShowing) return;
+ if (!m_modalShowing)
+ {
+ wxFAIL_MSG( "wxDialog: called EndModal twice" );
+ return;
+ };
+
m_modalShowing = FALSE;
gtk_main_quit();
//-----------------------------------------------------------------------------
// 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 );
gtk_widget_dnd_data_set( widget, event, ptr, size );
delete ptr;
+
+ source->m_retValue = wxDropSource::Copy;
};
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 );
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_retValue = Cancel;
m_data = &data;
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;
UnregisterWindow();
- return Copy;
+ return m_retValue;
};
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)
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 );
};
node = node->Next();
};
- wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?"));
+ wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" );
return page->m_id;
};
node = node->Next();
};
- wxLogDebug( _("Notebook page %d not found!"), page );
+ wxLogDebug( "Notebook page %d not found!", page );
return NULL;
};