Added test for wxTreeCtrl::GetChildrenCount()
Fixed Reparent (added heaps of debug code for this) Small mods to glcanvas git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3799 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -133,7 +133,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
|
||||
toolBar->AddTool(wxID_PASTE, *(toolBarBitmaps[5]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Paste");
|
||||
currentX += width + 5;
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Print");
|
||||
toolBar->AddTool(wxID_PRINT, *(toolBarBitmaps[6]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Reparent the button");
|
||||
currentX += width + 5;
|
||||
toolBar->AddSeparator();
|
||||
toolBar->AddTool(wxID_HELP, *(toolBarBitmaps[7]), wxNullBitmap, FALSE, currentX, -1, (wxObject *) NULL, "Help");
|
||||
@@ -155,6 +155,7 @@ bool MyApp::InitToolbar(wxToolBar* toolBar)
|
||||
BEGIN_EVENT_TABLE(MyMiniFrame, wxMiniFrame)
|
||||
EVT_CLOSE ( MyMiniFrame::OnCloseWindow)
|
||||
EVT_BUTTON (ID_REPARENT, MyMiniFrame::OnReparent)
|
||||
EVT_MENU (wxID_PRINT, MyMiniFrame::OnReparent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyMiniFrame::MyMiniFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
|
||||
@@ -180,6 +181,7 @@ void MyMiniFrame::OnReparent(wxCommandEvent& WXUNUSED(event))
|
||||
BEGIN_EVENT_TABLE(MyMainFrame, wxFrame)
|
||||
EVT_CLOSE ( MyMainFrame::OnCloseWindow)
|
||||
EVT_BUTTON (ID_REPARENT, MyMainFrame::OnReparent)
|
||||
EVT_MENU (wxID_PRINT, MyMainFrame::OnReparent)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyMainFrame::MyMainFrame(wxFrame* parent, wxWindowID id, const wxString& title, const wxPoint& pos,
|
||||
|
@@ -72,6 +72,8 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
EVT_MENU(TreeTest_Unselect, MyFrame::OnUnselect)
|
||||
#endif // NO_MULTIPLE_SELECTION
|
||||
EVT_MENU(TreeTest_Rename, MyFrame::OnRename)
|
||||
EVT_MENU(TreeTest_Count, MyFrame::OnCount)
|
||||
EVT_MENU(TreeTest_CountRec, MyFrame::OnCountRec)
|
||||
EVT_MENU(TreeTest_Sort, MyFrame::OnSort)
|
||||
EVT_MENU(TreeTest_SortRev, MyFrame::OnSortRev)
|
||||
EVT_MENU(TreeTest_Bold, MyFrame::OnSetBold)
|
||||
@@ -155,6 +157,9 @@ MyFrame::MyFrame(const wxString& title, int x, int y, int w, int h)
|
||||
tree_menu->Append(TreeTest_DeleteChildren, "Delete &children");
|
||||
tree_menu->Append(TreeTest_DeleteAll, "Delete &all items");
|
||||
tree_menu->AppendSeparator();
|
||||
tree_menu->Append(TreeTest_Count, "Count children of current item");
|
||||
tree_menu->Append(TreeTest_CountRec, "Recursively count children of current item");
|
||||
tree_menu->AppendSeparator();
|
||||
tree_menu->Append(TreeTest_Sort, "Sort children of current item");
|
||||
tree_menu->Append(TreeTest_SortRev, "Sort in reversed order");
|
||||
tree_menu->AppendSeparator();
|
||||
@@ -272,6 +277,28 @@ void MyFrame::OnRename(wxCommandEvent& WXUNUSED(event))
|
||||
(void)m_treeCtrl->EditLabel(item);
|
||||
}
|
||||
|
||||
void MyFrame::OnCount(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxTreeItemId item = m_treeCtrl->GetSelection();
|
||||
|
||||
CHECK_ITEM( item );
|
||||
|
||||
int i = m_treeCtrl->GetChildrenCount( item, FALSE );
|
||||
|
||||
wxLogMessage(_T("%d children"), i);
|
||||
}
|
||||
|
||||
void MyFrame::OnCountRec(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxTreeItemId item = m_treeCtrl->GetSelection();
|
||||
|
||||
CHECK_ITEM( item );
|
||||
|
||||
int i = m_treeCtrl->GetChildrenCount( item );
|
||||
|
||||
wxLogMessage(_T("%d children"), i);
|
||||
}
|
||||
|
||||
void MyFrame::DoSort(bool reverse)
|
||||
{
|
||||
wxTreeItemId item = m_treeCtrl->GetSelection();
|
||||
|
@@ -130,6 +130,9 @@ public:
|
||||
|
||||
void OnEnsureVisible(wxCommandEvent& event);
|
||||
|
||||
void OnCount(wxCommandEvent& event);
|
||||
void OnCountRec(wxCommandEvent& event);
|
||||
|
||||
void OnRename(wxCommandEvent& event);
|
||||
void OnSort(wxCommandEvent& event) { DoSort(); }
|
||||
void OnSortRev(wxCommandEvent& event) { DoSort(TRUE); }
|
||||
@@ -161,6 +164,8 @@ enum
|
||||
TreeTest_About,
|
||||
TreeTest_Dump,
|
||||
TreeTest_DumpSelected,
|
||||
TreeTest_Count,
|
||||
TreeTest_CountRec,
|
||||
TreeTest_Sort,
|
||||
TreeTest_SortRev,
|
||||
TreeTest_Bold,
|
||||
|
@@ -270,6 +270,8 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
|
||||
|
||||
static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
|
||||
{
|
||||
wxASSERT( GTK_IS_WIDGET(child->m_widget) );
|
||||
|
||||
if (!parent->m_insertInClientArea)
|
||||
{
|
||||
/* these are outside the client area */
|
||||
|
@@ -695,6 +695,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
/* security checks */
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
myfixed->children = g_list_remove_link (myfixed->children, children);
|
||||
g_list_free (children);
|
||||
g_free (child);
|
||||
@@ -702,6 +705,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
if (was_visible && GTK_WIDGET_VISIBLE (container))
|
||||
gtk_widget_queue_resize (GTK_WIDGET (container));
|
||||
|
||||
/* security checks */
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -2564,20 +2564,32 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase )
|
||||
wxWindow *oldParent = m_parent,
|
||||
*newParent = (wxWindow *)newParentBase;
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
if ( !wxWindowBase::Reparent(newParent) )
|
||||
return FALSE;
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
/* prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_ref( m_widget );
|
||||
|
||||
if (oldParent)
|
||||
{
|
||||
gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
|
||||
}
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
if (newParent)
|
||||
{
|
||||
/* insert GTK representation */
|
||||
(*(newParent->m_insertCallback))(newParent, this);
|
||||
}
|
||||
|
||||
/* reverse: prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_unref( m_widget );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -270,6 +270,8 @@ gtk_frame_realized_callback( GtkWidget *widget, wxFrame *win )
|
||||
|
||||
static void wxInsertChildInFrame( wxFrame* parent, wxWindow* child )
|
||||
{
|
||||
wxASSERT( GTK_IS_WIDGET(child->m_widget) );
|
||||
|
||||
if (!parent->m_insertInClientArea)
|
||||
{
|
||||
/* these are outside the client area */
|
||||
|
@@ -695,6 +695,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
|
||||
gtk_widget_unparent (widget);
|
||||
|
||||
/* security checks */
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
myfixed->children = g_list_remove_link (myfixed->children, children);
|
||||
g_list_free (children);
|
||||
g_free (child);
|
||||
@@ -702,6 +705,9 @@ gtk_myfixed_remove (GtkContainer *container,
|
||||
if (was_visible && GTK_WIDGET_VISIBLE (container))
|
||||
gtk_widget_queue_resize (GTK_WIDGET (container));
|
||||
|
||||
/* security checks */
|
||||
g_return_if_fail (GTK_IS_WIDGET (widget));
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
@@ -2564,20 +2564,32 @@ bool wxWindow::Reparent( wxWindowBase *newParentBase )
|
||||
wxWindow *oldParent = m_parent,
|
||||
*newParent = (wxWindow *)newParentBase;
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
if ( !wxWindowBase::Reparent(newParent) )
|
||||
return FALSE;
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
/* prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_ref( m_widget );
|
||||
|
||||
if (oldParent)
|
||||
{
|
||||
gtk_container_remove( GTK_CONTAINER(oldParent->m_wxwindow), m_widget );
|
||||
}
|
||||
|
||||
wxASSERT( GTK_IS_WIDGET(m_widget) );
|
||||
|
||||
if (newParent)
|
||||
{
|
||||
/* insert GTK representation */
|
||||
(*(newParent->m_insertCallback))(newParent, this);
|
||||
}
|
||||
|
||||
/* reverse: prevent GTK from deleting the widget arbitrarily */
|
||||
gtk_widget_unref( m_widget );
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
@@ -242,8 +242,6 @@ bool wxGLCanvas::Create( wxWindow *parent,
|
||||
XFree( g_vi );
|
||||
g_vi = (XVisualInfo*) NULL;
|
||||
|
||||
// gdk_window_set_back_pixmap( m_glWidget->window, None, 0 );
|
||||
|
||||
/* we pretend to have a m_wxwindow so that PostCreation hooks
|
||||
up the events for expose and draw */
|
||||
m_wxwindow = m_glWidget;
|
||||
@@ -269,10 +267,10 @@ void wxGLCanvas::OnSize(wxSizeEvent& WXUNUSED(event))
|
||||
{
|
||||
int width, height;
|
||||
GetClientSize( &width, &height );
|
||||
|
||||
if (m_glContext && GTK_WIDGET_REALIZED(m_glWidget) )
|
||||
{
|
||||
SetCurrent();
|
||||
// gdk_window_set_back_pixmap( gtk_widget_get_parent_window(m_glWidget), None, 0 );
|
||||
|
||||
glViewport(0, 0, (GLint)width, (GLint)height );
|
||||
glMatrixMode(GL_PROJECTION);
|
||||
|
@@ -54,10 +54,7 @@ class wxGLCanvas;
|
||||
|
||||
class wxGLContext: public wxObject
|
||||
{
|
||||
DECLARE_CLASS(wxGLContext)
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
wxGLContext( bool isRGB, wxWindow *win, const wxPalette& palette = wxNullPalette );
|
||||
wxGLContext(
|
||||
bool WXUNUSED(isRGB), wxWindow *win,
|
||||
@@ -79,13 +76,15 @@ class wxGLContext: public wxObject
|
||||
inline GtkWidget* GetWidget() const { return m_widget; }
|
||||
inline GLXContext GetContext() const { return m_glContext; }
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
GLXContext m_glContext;
|
||||
|
||||
GtkWidget *m_widget;
|
||||
wxPalette m_palette;
|
||||
wxWindow* m_window;
|
||||
|
||||
private:
|
||||
DECLARE_CLASS(wxGLContext)
|
||||
};
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
@@ -94,9 +93,7 @@ class wxGLContext: public wxObject
|
||||
|
||||
class wxGLCanvas: public wxScrolledWindow
|
||||
{
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
|
||||
public:
|
||||
public:
|
||||
wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
@@ -137,7 +134,9 @@ class wxGLCanvas: public wxScrolledWindow
|
||||
wxGLContext *m_glContext;
|
||||
GtkWidget *m_glWidget;
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
private:
|
||||
DECLARE_EVENT_TABLE()
|
||||
DECLARE_CLASS(wxGLCanvas)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user