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
This commit is contained in:
@@ -52,7 +52,6 @@ class wxButton: public wxControl
|
|||||||
long style = 0, const wxString &name = wxButtonNameStr );
|
long style = 0, const wxString &name = wxButtonNameStr );
|
||||||
void SetDefault(void);
|
void SetDefault(void);
|
||||||
void SetLabel( const wxString &label );
|
void SetLabel( const wxString &label );
|
||||||
wxString GetLabel(void) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GTKBUTTONH__
|
#endif // __GTKBUTTONH__
|
||||||
|
@@ -235,12 +235,14 @@ class wxDropSource: public wxObject
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
friend void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source );
|
||||||
|
|
||||||
void RegisterWindow(void);
|
void RegisterWindow(void);
|
||||||
void UnregisterWindow(void);
|
void UnregisterWindow(void);
|
||||||
|
|
||||||
GtkWidget *m_widget;
|
GtkWidget *m_widget;
|
||||||
wxWindow *m_window;
|
wxWindow *m_window;
|
||||||
|
DragResult m_retValue;
|
||||||
wxDataObject *m_data;
|
wxDataObject *m_data;
|
||||||
|
|
||||||
wxCursor m_defaultCursor;
|
wxCursor m_defaultCursor;
|
||||||
|
@@ -52,7 +52,6 @@ class wxButton: public wxControl
|
|||||||
long style = 0, const wxString &name = wxButtonNameStr );
|
long style = 0, const wxString &name = wxButtonNameStr );
|
||||||
void SetDefault(void);
|
void SetDefault(void);
|
||||||
void SetLabel( const wxString &label );
|
void SetLabel( const wxString &label );
|
||||||
wxString GetLabel(void) const;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GTKBUTTONH__
|
#endif // __GTKBUTTONH__
|
||||||
|
@@ -235,12 +235,14 @@ class wxDropSource: public wxObject
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
friend void gtk_drag_callback( GtkWidget *widget, GdkEvent *event, wxDropSource *source );
|
||||||
|
|
||||||
void RegisterWindow(void);
|
void RegisterWindow(void);
|
||||||
void UnregisterWindow(void);
|
void UnregisterWindow(void);
|
||||||
|
|
||||||
GtkWidget *m_widget;
|
GtkWidget *m_widget;
|
||||||
wxWindow *m_window;
|
wxWindow *m_window;
|
||||||
|
DragResult m_retValue;
|
||||||
wxDataObject *m_data;
|
wxDataObject *m_data;
|
||||||
|
|
||||||
wxCursor m_defaultCursor;
|
wxCursor m_defaultCursor;
|
||||||
|
@@ -1 +1,2 @@
|
|||||||
Linux
|
Linux
|
||||||
|
linux
|
||||||
|
@@ -89,9 +89,8 @@ void wxButton::SetDefault(void)
|
|||||||
void wxButton::SetLabel( const wxString &label )
|
void wxButton::SetLabel( const wxString &label )
|
||||||
{
|
{
|
||||||
wxControl::SetLabel( 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();
|
|
||||||
};
|
|
||||||
|
@@ -122,11 +122,17 @@ int wxChoice::FindString( const wxString &string ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = NULL;
|
GtkLabel *label = NULL;
|
||||||
if (bin->child) label = GTK_LABEL(bin->child);
|
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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
if (string == label->label) return count;
|
if (string == label->label) return count;
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: string not found" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,6 +153,9 @@ int wxChoice::GetSelection(void)
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: no selection" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -162,18 +171,27 @@ wxString wxChoice::GetString( int n ) const
|
|||||||
{
|
{
|
||||||
GtkLabel *label = NULL;
|
GtkLabel *label = NULL;
|
||||||
if (bin->child) label = GTK_LABEL(bin->child);
|
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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: string not found" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString wxChoice::GetStringSelection(void) const
|
wxString wxChoice::GetStringSelection(void) const
|
||||||
{
|
{
|
||||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
|
|
||||||
|
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||||
|
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -93,6 +93,7 @@ wxColour::wxColour( const wxString &colourName )
|
|||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxColour: couldn't find colour" );
|
||||||
delete m_refData;
|
delete m_refData;
|
||||||
m_refData = NULL;
|
m_refData = NULL;
|
||||||
};
|
};
|
||||||
@@ -134,6 +135,7 @@ wxColour& wxColour::operator = ( const wxString& colourName )
|
|||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxColour: couldn't find colour" );
|
||||||
delete m_refData;
|
delete m_refData;
|
||||||
m_refData = NULL;
|
m_refData = NULL;
|
||||||
};
|
};
|
||||||
|
@@ -156,7 +156,7 @@ void wxComboBox::Delete( int n )
|
|||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG(_("wxComboBox::Delete wrong index"));
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_clientData.DeleteNode( node );
|
m_clientData.DeleteNode( node );
|
||||||
@@ -176,6 +176,9 @@ int wxComboBox::FindString( const wxString &item )
|
|||||||
count++;
|
count++;
|
||||||
child = child->next;
|
child = child->next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -183,6 +186,9 @@ char* wxComboBox::GetClientData( int n )
|
|||||||
{
|
{
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (node) return (char*)node->Data();
|
if (node) return (char*)node->Data();
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -190,6 +196,8 @@ void wxComboBox::SetClientData( int n, char * clientData )
|
|||||||
{
|
{
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (node) node->SetData( (wxObject*) clientData );
|
if (node) node->SetData( (wxObject*) clientData );
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
};
|
};
|
||||||
|
|
||||||
int wxComboBox::GetSelection(void) const
|
int wxComboBox::GetSelection(void) const
|
||||||
@@ -208,6 +216,9 @@ int wxComboBox::GetSelection(void) const
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -222,6 +233,9 @@ wxString wxComboBox::GetString( int n ) const
|
|||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -236,6 +250,9 @@ wxString wxComboBox::GetStringSelection(void) const
|
|||||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||||
return tmp;
|
return tmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ void wxControl::SetLabel( const wxString &label )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_label = "";
|
||||||
m_label << *pc;
|
m_label << *pc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -279,16 +279,62 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[],
|
void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
||||||
long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) )
|
long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
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),
|
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset,
|
||||||
long WXUNUSED(yoffset), int WXUNUSED(fillStyle) )
|
long yoffset, int WXUNUSED(fillStyle))
|
||||||
{
|
{
|
||||||
|
int n = lines->Number();
|
||||||
|
|
||||||
if (!Ok()) return;
|
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 wxPaintDC::DrawRectangle( long x, long y, long width, long height )
|
||||||
|
@@ -107,6 +107,7 @@ wxDialog::~wxDialog(void)
|
|||||||
void wxDialog::SetTitle(const wxString& title )
|
void wxDialog::SetTitle(const wxString& title )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
|
if (m_title.IsNull()) m_title = "";
|
||||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,7 +220,12 @@ void wxDialog::EndModal( int retCode )
|
|||||||
{
|
{
|
||||||
SetReturnCode( retCode );
|
SetReturnCode( retCode );
|
||||||
|
|
||||||
if (!m_modalShowing) return;
|
if (!m_modalShowing)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "wxDialog: called EndModal twice" );
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
m_modalShowing = FALSE;
|
m_modalShowing = FALSE;
|
||||||
|
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
@@ -144,10 +144,12 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// drag request
|
// 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" );
|
printf( "Data requested for dropping.\n" );
|
||||||
|
|
||||||
|
wxDataObject *data = source->m_data;
|
||||||
|
|
||||||
uint size = data->GetDataSize();
|
uint size = data->GetDataSize();
|
||||||
char *ptr = new char[size];
|
char *ptr = new char[size];
|
||||||
data->GetDataHere( ptr );
|
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 );
|
gtk_widget_dnd_data_set( widget, event, ptr, size );
|
||||||
|
|
||||||
delete ptr;
|
delete ptr;
|
||||||
|
|
||||||
|
source->m_retValue = wxDropSource::Copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDropSource::wxDropSource( wxWindow *win )
|
wxDropSource::wxDropSource( wxWindow *win )
|
||||||
@@ -166,6 +170,7 @@ wxDropSource::wxDropSource( wxWindow *win )
|
|||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
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_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||||
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||||
@@ -178,6 +183,7 @@ wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
|
|||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
|
m_retValue = Cancel;
|
||||||
|
|
||||||
m_data = &data;
|
m_data = &data;
|
||||||
|
|
||||||
@@ -202,6 +208,8 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
if (gdk_dnd.dnd_grabbed) return None;
|
if (gdk_dnd.dnd_grabbed) return None;
|
||||||
if (gdk_dnd.drag_really) return None;
|
if (gdk_dnd.drag_really) return None;
|
||||||
|
|
||||||
|
wxASSERT_MSG( data, "wxDragSource: no data" );
|
||||||
|
|
||||||
if (!m_data) return None;
|
if (!m_data) return None;
|
||||||
if (m_data->GetDataSize() == 0) return None;
|
if (m_data->GetDataSize() == 0) return None;
|
||||||
|
|
||||||
@@ -255,7 +263,7 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
|
|
||||||
UnregisterWindow();
|
UnregisterWindow();
|
||||||
|
|
||||||
return Copy;
|
return m_retValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wxDropSource::RegisterWindow(void)
|
void wxDropSource::RegisterWindow(void)
|
||||||
@@ -283,7 +291,7 @@ void wxDropSource::RegisterWindow(void)
|
|||||||
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
|
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
|
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)
|
void wxDropSource::UnregisterWindow(void)
|
||||||
@@ -292,5 +300,5 @@ void wxDropSource::UnregisterWindow(void)
|
|||||||
|
|
||||||
gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
|
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 );
|
||||||
};
|
};
|
||||||
|
@@ -184,7 +184,7 @@ int wxNotebook::GetSelection() const
|
|||||||
node = node->Next();
|
node = node->Next();
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?"));
|
wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" );
|
||||||
|
|
||||||
return page->m_id;
|
return page->m_id;
|
||||||
};
|
};
|
||||||
@@ -230,7 +230,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
|
|||||||
node = node->Next();
|
node = node->Next();
|
||||||
};
|
};
|
||||||
|
|
||||||
wxLogDebug( _("Notebook page %d not found!"), page );
|
wxLogDebug( "Notebook page %d not found!", page );
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
@@ -89,9 +89,8 @@ void wxButton::SetDefault(void)
|
|||||||
void wxButton::SetLabel( const wxString &label )
|
void wxButton::SetLabel( const wxString &label )
|
||||||
{
|
{
|
||||||
wxControl::SetLabel( 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();
|
|
||||||
};
|
|
||||||
|
@@ -122,11 +122,17 @@ int wxChoice::FindString( const wxString &string ) const
|
|||||||
GtkBin *bin = GTK_BIN( child->data );
|
GtkBin *bin = GTK_BIN( child->data );
|
||||||
GtkLabel *label = NULL;
|
GtkLabel *label = NULL;
|
||||||
if (bin->child) label = GTK_LABEL(bin->child);
|
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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
if (string == label->label) return count;
|
if (string == label->label) return count;
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: string not found" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -147,6 +153,9 @@ int wxChoice::GetSelection(void)
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: no selection" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -162,18 +171,27 @@ wxString wxChoice::GetString( int n ) const
|
|||||||
{
|
{
|
||||||
GtkLabel *label = NULL;
|
GtkLabel *label = NULL;
|
||||||
if (bin->child) label = GTK_LABEL(bin->child);
|
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 (!label) label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
child = child->next;
|
child = child->next;
|
||||||
count++;
|
count++;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxChoice: string not found" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
wxString wxChoice::GetStringSelection(void) const
|
wxString wxChoice::GetStringSelection(void) const
|
||||||
{
|
{
|
||||||
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
GtkLabel *label = GTK_LABEL( GTK_BUTTON(m_widget)->child );
|
||||||
|
|
||||||
|
wxASSERT_MSG( label != NULL , "wxChoice: invalid label" );
|
||||||
|
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -93,6 +93,7 @@ wxColour::wxColour( const wxString &colourName )
|
|||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxColour: couldn't find colour" );
|
||||||
delete m_refData;
|
delete m_refData;
|
||||||
m_refData = NULL;
|
m_refData = NULL;
|
||||||
};
|
};
|
||||||
@@ -134,6 +135,7 @@ wxColour& wxColour::operator = ( const wxString& colourName )
|
|||||||
m_refData = new wxColourRefData();
|
m_refData = new wxColourRefData();
|
||||||
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
if (!gdk_color_parse( colourName, &M_COLDATA->m_color ))
|
||||||
{
|
{
|
||||||
|
wxFAIL_MSG( "wxColour: couldn't find colour" );
|
||||||
delete m_refData;
|
delete m_refData;
|
||||||
m_refData = NULL;
|
m_refData = NULL;
|
||||||
};
|
};
|
||||||
|
@@ -156,7 +156,7 @@ void wxComboBox::Delete( int n )
|
|||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (!node)
|
if (!node)
|
||||||
{
|
{
|
||||||
wxFAIL_MSG(_("wxComboBox::Delete wrong index"));
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_clientData.DeleteNode( node );
|
m_clientData.DeleteNode( node );
|
||||||
@@ -176,6 +176,9 @@ int wxComboBox::FindString( const wxString &item )
|
|||||||
count++;
|
count++;
|
||||||
child = child->next;
|
child = child->next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: string not found" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -183,6 +186,9 @@ char* wxComboBox::GetClientData( int n )
|
|||||||
{
|
{
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (node) return (char*)node->Data();
|
if (node) return (char*)node->Data();
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -190,6 +196,8 @@ void wxComboBox::SetClientData( int n, char * clientData )
|
|||||||
{
|
{
|
||||||
wxNode *node = m_clientData.Nth( n );
|
wxNode *node = m_clientData.Nth( n );
|
||||||
if (node) node->SetData( (wxObject*) clientData );
|
if (node) node->SetData( (wxObject*) clientData );
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
};
|
};
|
||||||
|
|
||||||
int wxComboBox::GetSelection(void) const
|
int wxComboBox::GetSelection(void) const
|
||||||
@@ -208,6 +216,9 @@ int wxComboBox::GetSelection(void) const
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -222,6 +233,9 @@ wxString wxComboBox::GetString( int n ) const
|
|||||||
GtkLabel *label = GTK_LABEL( bin->child );
|
GtkLabel *label = GTK_LABEL( bin->child );
|
||||||
return label->label;
|
return label->label;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: wrong index" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -236,6 +250,9 @@ wxString wxComboBox::GetStringSelection(void) const
|
|||||||
wxString tmp = GTK_LABEL( bin->child )->label;
|
wxString tmp = GTK_LABEL( bin->child )->label;
|
||||||
return tmp;
|
return tmp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
wxFAIL_MSG( "wxComboBox: no selection" );
|
||||||
|
|
||||||
return "";
|
return "";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -47,6 +47,7 @@ void wxControl::SetLabel( const wxString &label )
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_label = "";
|
||||||
m_label << *pc;
|
m_label << *pc;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -279,16 +279,62 @@ void wxPaintDC::DrawLines( wxList *points, long xoffset, long yoffset )
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
void wxPaintDC::DrawPolygon( int WXUNUSED(n), wxPoint WXUNUSED(points)[],
|
void wxPaintDC::DrawPolygon( int n, wxPoint points[],
|
||||||
long WXUNUSED(xoffset), long WXUNUSED(yoffset), int WXUNUSED(fillStyle) )
|
long xoffset, long yoffset, int WXUNUSED(fillStyle) )
|
||||||
{
|
{
|
||||||
if (!Ok()) return;
|
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),
|
void wxPaintDC::DrawPolygon( wxList *lines, long xoffset,
|
||||||
long WXUNUSED(yoffset), int WXUNUSED(fillStyle) )
|
long yoffset, int WXUNUSED(fillStyle))
|
||||||
{
|
{
|
||||||
|
int n = lines->Number();
|
||||||
|
|
||||||
if (!Ok()) return;
|
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 wxPaintDC::DrawRectangle( long x, long y, long width, long height )
|
||||||
|
@@ -107,6 +107,7 @@ wxDialog::~wxDialog(void)
|
|||||||
void wxDialog::SetTitle(const wxString& title )
|
void wxDialog::SetTitle(const wxString& title )
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
|
if (m_title.IsNull()) m_title = "";
|
||||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,7 +220,12 @@ void wxDialog::EndModal( int retCode )
|
|||||||
{
|
{
|
||||||
SetReturnCode( retCode );
|
SetReturnCode( retCode );
|
||||||
|
|
||||||
if (!m_modalShowing) return;
|
if (!m_modalShowing)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( "wxDialog: called EndModal twice" );
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
m_modalShowing = FALSE;
|
m_modalShowing = FALSE;
|
||||||
|
|
||||||
gtk_main_quit();
|
gtk_main_quit();
|
||||||
|
@@ -144,10 +144,12 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// drag request
|
// 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" );
|
printf( "Data requested for dropping.\n" );
|
||||||
|
|
||||||
|
wxDataObject *data = source->m_data;
|
||||||
|
|
||||||
uint size = data->GetDataSize();
|
uint size = data->GetDataSize();
|
||||||
char *ptr = new char[size];
|
char *ptr = new char[size];
|
||||||
data->GetDataHere( ptr );
|
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 );
|
gtk_widget_dnd_data_set( widget, event, ptr, size );
|
||||||
|
|
||||||
delete ptr;
|
delete ptr;
|
||||||
|
|
||||||
|
source->m_retValue = wxDropSource::Copy;
|
||||||
};
|
};
|
||||||
|
|
||||||
wxDropSource::wxDropSource( wxWindow *win )
|
wxDropSource::wxDropSource( wxWindow *win )
|
||||||
@@ -166,6 +170,7 @@ wxDropSource::wxDropSource( wxWindow *win )
|
|||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
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_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||||
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||||
@@ -178,6 +183,7 @@ wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
|
|||||||
m_window = win;
|
m_window = win;
|
||||||
m_widget = win->m_widget;
|
m_widget = win->m_widget;
|
||||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||||
|
m_retValue = Cancel;
|
||||||
|
|
||||||
m_data = &data;
|
m_data = &data;
|
||||||
|
|
||||||
@@ -202,6 +208,8 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
if (gdk_dnd.dnd_grabbed) return None;
|
if (gdk_dnd.dnd_grabbed) return None;
|
||||||
if (gdk_dnd.drag_really) return None;
|
if (gdk_dnd.drag_really) return None;
|
||||||
|
|
||||||
|
wxASSERT_MSG( data, "wxDragSource: no data" );
|
||||||
|
|
||||||
if (!m_data) return None;
|
if (!m_data) return None;
|
||||||
if (m_data->GetDataSize() == 0) return None;
|
if (m_data->GetDataSize() == 0) return None;
|
||||||
|
|
||||||
@@ -255,7 +263,7 @@ wxDropSource::DragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
|||||||
|
|
||||||
UnregisterWindow();
|
UnregisterWindow();
|
||||||
|
|
||||||
return Copy;
|
return m_retValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
void wxDropSource::RegisterWindow(void)
|
void wxDropSource::RegisterWindow(void)
|
||||||
@@ -283,7 +291,7 @@ void wxDropSource::RegisterWindow(void)
|
|||||||
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
|
gtk_widget_dnd_drag_set( m_widget, TRUE, &str, 1 );
|
||||||
|
|
||||||
gtk_signal_connect( GTK_OBJECT(m_widget), "drag_request_event",
|
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)
|
void wxDropSource::UnregisterWindow(void)
|
||||||
@@ -292,5 +300,5 @@ void wxDropSource::UnregisterWindow(void)
|
|||||||
|
|
||||||
gtk_widget_dnd_drag_set( m_widget, FALSE, NULL, 0 );
|
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 );
|
||||||
};
|
};
|
||||||
|
@@ -184,7 +184,7 @@ int wxNotebook::GetSelection() const
|
|||||||
node = node->Next();
|
node = node->Next();
|
||||||
};
|
};
|
||||||
|
|
||||||
wxCHECK_MSG( node != NULL, -1, _("wxNotebook: no selection?"));
|
wxCHECK_MSG( node != NULL, -1, "wxNotebook: no selection?" );
|
||||||
|
|
||||||
return page->m_id;
|
return page->m_id;
|
||||||
};
|
};
|
||||||
@@ -230,7 +230,7 @@ wxNotebookPage* wxNotebook::GetNotebookPage(int page) const
|
|||||||
node = node->Next();
|
node = node->Next();
|
||||||
};
|
};
|
||||||
|
|
||||||
wxLogDebug( _("Notebook page %d not found!"), page );
|
wxLogDebug( "Notebook page %d not found!", page );
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user