GTK's dnd is broken, not mine
Added notebook::removepage (not tested) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1030 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,6 +20,16 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/cursor.h"
|
#include "wx/cursor.h"
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// conditional compilation
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if (GTK_MINOR_VERSION == 1)
|
||||||
|
#if (GTK_MICRO_VERSION >= 3)
|
||||||
|
#define NEW_GTK_DND_CODE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@@ -122,6 +122,8 @@ public:
|
|||||||
|
|
||||||
// operations
|
// operations
|
||||||
// ----------
|
// ----------
|
||||||
|
// remove one page from the notebook but do not destroy it
|
||||||
|
bool RemovePage(int nPage);
|
||||||
// remove one page from the notebook
|
// remove one page from the notebook
|
||||||
bool DeletePage(int nPage);
|
bool DeletePage(int nPage);
|
||||||
// remove all pages
|
// remove all pages
|
||||||
|
@@ -20,6 +20,16 @@
|
|||||||
#include "wx/string.h"
|
#include "wx/string.h"
|
||||||
#include "wx/cursor.h"
|
#include "wx/cursor.h"
|
||||||
|
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
// conditional compilation
|
||||||
|
//-------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if (GTK_MINOR_VERSION == 1)
|
||||||
|
#if (GTK_MICRO_VERSION >= 3)
|
||||||
|
#define NEW_GTK_DND_CODE
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
// classes
|
// classes
|
||||||
//-------------------------------------------------------------------------
|
//-------------------------------------------------------------------------
|
||||||
|
@@ -122,6 +122,8 @@ public:
|
|||||||
|
|
||||||
// operations
|
// operations
|
||||||
// ----------
|
// ----------
|
||||||
|
// remove one page from the notebook but do not destroy it
|
||||||
|
bool RemovePage(int nPage);
|
||||||
// remove one page from the notebook
|
// remove one page from the notebook
|
||||||
bool DeletePage(int nPage);
|
bool DeletePage(int nPage);
|
||||||
// remove all pages
|
// remove all pages
|
||||||
|
@@ -182,6 +182,7 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
|||||||
m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL);
|
m_ctrlFile = new wxListBox(this, -1, pos, size, 1, &strFile, wxLB_HSCROLL);
|
||||||
m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL);
|
m_ctrlText = new wxListBox(this, -1, pos, size, 1, &strText, wxLB_HSCROLL);
|
||||||
|
|
||||||
|
/*
|
||||||
m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size,
|
m_ctrlLog = new wxTextCtrl(this, -1, "", pos, size,
|
||||||
wxTE_MULTILINE | wxTE_READONLY |
|
wxTE_MULTILINE | wxTE_READONLY |
|
||||||
wxSUNKEN_BORDER| wxHSCROLL);
|
wxSUNKEN_BORDER| wxHSCROLL);
|
||||||
@@ -189,6 +190,10 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
|||||||
// redirect log messages to the text window (don't forget to delete it!)
|
// redirect log messages to the text window (don't forget to delete it!)
|
||||||
m_pLog = new wxLogTextCtrl(m_ctrlLog);
|
m_pLog = new wxLogTextCtrl(m_ctrlLog);
|
||||||
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
|
m_pLogPrev = wxLog::SetActiveTarget(m_pLog);
|
||||||
|
*/
|
||||||
|
|
||||||
|
wxStaticText *m_testLabel = new wxStaticText( this, -1, "Hallo", pos, size );
|
||||||
|
m_testLabel->SetDropTarget( new wxTextDropTarget() );
|
||||||
|
|
||||||
// associate drop targets with 2 text controls
|
// associate drop targets with 2 text controls
|
||||||
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
|
m_ctrlFile->SetDropTarget(new DnDFile(m_ctrlFile));
|
||||||
@@ -212,14 +217,24 @@ DnDFrame::DnDFrame(wxFrame *frame, char *title, int x, int y, int w, int h)
|
|||||||
c->height.PercentOf(this, wxHeight, 40);
|
c->height.PercentOf(this, wxHeight, 40);
|
||||||
m_ctrlText->SetConstraints(c);
|
m_ctrlText->SetConstraints(c);
|
||||||
|
|
||||||
|
/*
|
||||||
// Lower text control
|
// Lower text control
|
||||||
c = new wxLayoutConstraints;
|
c = new wxLayoutConstraints;
|
||||||
c->left.SameAs (this, wxLeft);
|
c->left.SameAs (this, wxLeft);
|
||||||
c->right.SameAs (this, wxRight);
|
c->right.SameAs (this, wxRight);
|
||||||
c->height.PercentOf(this, wxHeight, 40);
|
c->height.PercentOf(this, wxHeight, 40);
|
||||||
c->top.SameAs(m_ctrlText, wxBottom);
|
c->top.SameAs(m_ctrlText, wxBottom);
|
||||||
|
|
||||||
m_ctrlLog->SetConstraints(c);
|
m_ctrlLog->SetConstraints(c);
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Lower label control
|
||||||
|
c = new wxLayoutConstraints;
|
||||||
|
c->left.SameAs (this, wxLeft);
|
||||||
|
c->right.SameAs (this, wxRight);
|
||||||
|
c->height.PercentOf(this, wxHeight, 40);
|
||||||
|
c->top.SameAs(m_ctrlText, wxBottom);
|
||||||
|
m_testLabel->SetConstraints(c);
|
||||||
|
|
||||||
|
|
||||||
SetAutoLayout(TRUE);
|
SetAutoLayout(TRUE);
|
||||||
}
|
}
|
||||||
@@ -284,7 +299,7 @@ void DnDFrame::OnHelp(wxCommandEvent& /* event */)
|
|||||||
|
|
||||||
void DnDFrame::OnLogClear(wxCommandEvent& /* event */ )
|
void DnDFrame::OnLogClear(wxCommandEvent& /* event */ )
|
||||||
{
|
{
|
||||||
m_ctrlLog->Clear();
|
// m_ctrlLog->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DnDFrame::OnClose()
|
bool DnDFrame::OnClose()
|
||||||
|
@@ -27,13 +27,6 @@
|
|||||||
|
|
||||||
extern bool g_blockEventsOnDrag;
|
extern bool g_blockEventsOnDrag;
|
||||||
|
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION == 1)
|
|
||||||
#if (GTK_MICRO_VERSION >= 3)
|
|
||||||
#define NEW_GTK_DND_CODE
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEW_GTK_DND_CODE
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
|
||||||
#include "gtk/gtkdnd.h"
|
#include "gtk/gtkdnd.h"
|
||||||
|
@@ -486,19 +486,38 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
|
|||||||
GList *child = m_list->children;
|
GList *child = m_list->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
GtkBin *item = GTK_BIN( child->data );
|
||||||
|
m_dropTarget->UnregisterWidget( item->child );
|
||||||
|
#else
|
||||||
m_dropTarget->UnregisterWidget( GTK_WIDGET( child->data ) );
|
m_dropTarget->UnregisterWidget( GTK_WIDGET( child->data ) );
|
||||||
|
#endif
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::SetDropTarget( dropTarget );
|
#ifndef NEW_GTK_DND_CODE
|
||||||
|
if (m_dropTarget) m_dropTarget->UnregisterWidget( m_list );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (m_dropTarget) delete m_dropTarget;
|
||||||
|
m_dropTarget = dropTarget;
|
||||||
|
|
||||||
|
#ifndef NEW_GTK_DND_CODE
|
||||||
|
if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget );
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_dropTarget)
|
if (m_dropTarget)
|
||||||
{
|
{
|
||||||
GList *child = m_list->children;
|
GList *child = m_list->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
GtkBin *item = GTK_BIN( child->data );
|
||||||
|
m_dropTarget->RegisterWidget( item->child );
|
||||||
|
#else
|
||||||
m_dropTarget->RegisterWidget( GTK_WIDGET( child->data ) );
|
m_dropTarget->RegisterWidget( GTK_WIDGET( child->data ) );
|
||||||
|
#endif
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -370,12 +370,32 @@ bool wxNotebook::DeletePage( int page )
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT( child );
|
wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
|
||||||
|
|
||||||
delete nb_page->m_client;
|
delete nb_page->m_client;
|
||||||
|
|
||||||
// Amazingly, this is not necessary
|
m_pages.DeleteObject( nb_page );
|
||||||
// gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::RemovePage( int page )
|
||||||
|
{
|
||||||
|
wxNotebookPage* nb_page = GetNotebookPage(page);
|
||||||
|
if (!nb_page) return FALSE;
|
||||||
|
|
||||||
|
int page_num = 0;
|
||||||
|
GList *child = GTK_NOTEBOOK(m_widget)->children;
|
||||||
|
while (child)
|
||||||
|
{
|
||||||
|
if (nb_page->m_page == (GtkNotebookPage*)child->data) break;
|
||||||
|
page_num++;
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
|
||||||
|
|
||||||
|
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
|
||||||
|
|
||||||
m_pages.DeleteObject( nb_page );
|
m_pages.DeleteObject( nb_page );
|
||||||
|
|
||||||
|
@@ -27,13 +27,6 @@
|
|||||||
|
|
||||||
extern bool g_blockEventsOnDrag;
|
extern bool g_blockEventsOnDrag;
|
||||||
|
|
||||||
|
|
||||||
#if (GTK_MINOR_VERSION == 1)
|
|
||||||
#if (GTK_MICRO_VERSION >= 3)
|
|
||||||
#define NEW_GTK_DND_CODE
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef NEW_GTK_DND_CODE
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
|
||||||
#include "gtk/gtkdnd.h"
|
#include "gtk/gtkdnd.h"
|
||||||
|
@@ -486,19 +486,38 @@ void wxListBox::SetDropTarget( wxDropTarget *dropTarget )
|
|||||||
GList *child = m_list->children;
|
GList *child = m_list->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
GtkBin *item = GTK_BIN( child->data );
|
||||||
|
m_dropTarget->UnregisterWidget( item->child );
|
||||||
|
#else
|
||||||
m_dropTarget->UnregisterWidget( GTK_WIDGET( child->data ) );
|
m_dropTarget->UnregisterWidget( GTK_WIDGET( child->data ) );
|
||||||
|
#endif
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxWindow::SetDropTarget( dropTarget );
|
#ifndef NEW_GTK_DND_CODE
|
||||||
|
if (m_dropTarget) m_dropTarget->UnregisterWidget( m_list );
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (m_dropTarget) delete m_dropTarget;
|
||||||
|
m_dropTarget = dropTarget;
|
||||||
|
|
||||||
|
#ifndef NEW_GTK_DND_CODE
|
||||||
|
if (m_dropTarget) m_dropTarget->RegisterWidget( dnd_widget );
|
||||||
|
#endif
|
||||||
|
|
||||||
if (m_dropTarget)
|
if (m_dropTarget)
|
||||||
{
|
{
|
||||||
GList *child = m_list->children;
|
GList *child = m_list->children;
|
||||||
while (child)
|
while (child)
|
||||||
{
|
{
|
||||||
|
#ifdef NEW_GTK_DND_CODE
|
||||||
|
GtkBin *item = GTK_BIN( child->data );
|
||||||
|
m_dropTarget->RegisterWidget( item->child );
|
||||||
|
#else
|
||||||
m_dropTarget->RegisterWidget( GTK_WIDGET( child->data ) );
|
m_dropTarget->RegisterWidget( GTK_WIDGET( child->data ) );
|
||||||
|
#endif
|
||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -370,12 +370,32 @@ bool wxNotebook::DeletePage( int page )
|
|||||||
child = child->next;
|
child = child->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxASSERT( child );
|
wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
|
||||||
|
|
||||||
delete nb_page->m_client;
|
delete nb_page->m_client;
|
||||||
|
|
||||||
// Amazingly, this is not necessary
|
m_pages.DeleteObject( nb_page );
|
||||||
// gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxNotebook::RemovePage( int page )
|
||||||
|
{
|
||||||
|
wxNotebookPage* nb_page = GetNotebookPage(page);
|
||||||
|
if (!nb_page) return FALSE;
|
||||||
|
|
||||||
|
int page_num = 0;
|
||||||
|
GList *child = GTK_NOTEBOOK(m_widget)->children;
|
||||||
|
while (child)
|
||||||
|
{
|
||||||
|
if (nb_page->m_page == (GtkNotebookPage*)child->data) break;
|
||||||
|
page_num++;
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxCHECK_MSG( child != NULL, FALSE, "illegal notebook index" );
|
||||||
|
|
||||||
|
gtk_notebook_remove_page( GTK_NOTEBOOK(m_widget), page_num );
|
||||||
|
|
||||||
m_pages.DeleteObject( nb_page );
|
m_pages.DeleteObject( nb_page );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user