#include "wx/msgdlg.h"
#include "wx/dcclient.h"
#include "wx/dnd.h"
-#include "wx/mdi.h"
#include "wx/menu.h"
-#include "wx/notebook.h"
#include "wx/statusbr.h"
#include "wx/intl.h"
-#include "wx/gtk/win_gtk.h"
#include "gdk/gdkprivate.h"
#include "gdk/gdkkeysyms.h"
int x = 0;
int y = 0;
gdk_window_get_pointer( widget->window, &x, &y, (GdkModifierType *) NULL );
- win->GetDropTarget()->m_size = event->data_numbytes;
- win->GetDropTarget()->Drop( event, x, y );
+
+ printf( "Drop data is of type %s.\n", event->data_type );
+
+ win->GetDropTarget()->OnDrop( x, y, (const void*)event->data, (size_t)event->data_numbytes );
}
/*
*/
}
+//-----------------------------------------------------------------------------
+// InsertChild for wxWindow.
+//-----------------------------------------------------------------------------
+
+// Callback for wxWindow. This very strange beast has to be used because
+// C++ has no virtual methods in a constructor. We have to emulate a
+// virtual function here as wxNotebook requires a different way to insert
+// a child in it. I had opted for creating a wxNotebookPage window class
+// which would have made this superflouus (such in the MDI window system),
+// but no-one is listening to me...
+
+static void wxInsertChildInWindow( wxWindow* parent, wxWindow* child )
+{
+ gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
+ GTK_WIDGET(child->m_widget),
+ child->m_x,
+ child->m_y );
+
+ gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
+ child->m_width,
+ child->m_height );
+}
+
//-----------------------------------------------------------------------------
// wxWindow
//-----------------------------------------------------------------------------
m_resizing = FALSE;
m_scrollGC = (GdkGC*) NULL;
m_widgetStyle = (GtkStyle*) NULL;
+ m_insertCallback = wxInsertChildInWindow;
}
+wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size,
+ long style, const wxString &name )
+{
+ m_insertCallback = wxInsertChildInWindow;
+ Create( parent, id, pos, size, style, name );
+}
+
bool wxWindow::Create( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name )
m_isEnabled = TRUE;
m_needParent = TRUE;
- m_cursor = (wxCursor *) NULL;
-
PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_scrolled_window_new( (GtkAdjustment *) NULL, (GtkAdjustment *) NULL );
gtk_signal_emit_by_name( GTK_OBJECT(m_hAdjust), "changed" );
gtk_widget_show( m_wxwindow );
+
+ if (m_parent) m_parent->AddChild( this );
+ (m_parent->m_insertCallback)( m_parent, this );
+
PostCreation();
Show( TRUE );
{
if (m_needParent && (parent == NULL))
wxFatalError( "Need complete parent.", name );
-
+
m_widget = (GtkWidget *) NULL;
m_hasVMT = FALSE;
m_parent = parent;
m_children.DeleteContents( FALSE );
- m_x = (int)pos.x;
- m_y = (int)pos.y;
+
m_width = size.x;
if (m_width == -1) m_width = 20;
m_height = size.y;
if (m_height == -1) m_height = 20;
+
+ m_x = (int)pos.x;
+ m_y = (int)pos.y;
+
+ if (!m_needParent) // some reasonable defaults
+ {
+ if (m_x == -1)
+ {
+ m_x = (gdk_screen_width () - m_width) / 2;
+ if (m_x < 10) m_x = 10;
+ }
+ if (m_y == -1)
+ {
+ m_y = (gdk_screen_height () - m_height) / 2;
+ if (m_y < 10) m_y = 10;
+ }
+ }
+
m_minWidth = -1;
m_minHeight = -1;
m_maxWidth = -1;
void wxWindow::PostCreation()
{
- if (m_parent) m_parent->AddChild( this );
-
if (m_wxwindow)
{
gtk_signal_connect( GTK_OBJECT(m_wxwindow), "expose_event",
// are we to set fonts here ?
}
+wxPoint wxWindow::GetClientAreaOrigin() const
+{
+ return wxPoint(0,0);
+}
+
+void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
+{
+ if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent())
+ {
+ wxPoint pt(GetParent()->GetClientAreaOrigin());
+ x += pt.x;
+ y += pt.y;
+ }
+}
+
void wxWindow::ImplementSetSize()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
void wxWindow::ImplementSetPosition()
{
- if (IS_KIND_OF(this,wxFrame) || IS_KIND_OF(this,wxDialog))
- {
- if ((m_x != -1) || (m_y != -1))
- gtk_widget_set_uposition( m_widget, m_x, m_y );
- return;
- }
-
if (!m_parent)
{
wxFAIL_MSG( "wxWindow::SetSize error.\n" );
if (newH == -1) newH = 26;
}
+ AdjustForParentClientOrigin( newX, newY, sizeFlags );
+
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
{
m_x = newX;
m_y = newY;
ImplementSetPosition();
}
+
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{
m_width = newW;
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- if (x) (*x) = m_x;
- if (y) (*y) = m_y;
+ int xx = m_x;
+ int yy = m_y;
+
+ if (GetParent())
+ {
+ wxPoint pt(GetParent()->GetClientAreaOrigin());
+ xx -= pt.x;
+ yy -= pt.y;
+ }
+
+ if (x) (*x) = xx;
+ if (y) (*y) = yy;
}
void wxWindow::ClientToScreen( int *x, int *y )
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x += pt.x;
+ org_y += pt.y;
+
if (x) *x += org_x;
if (y) *y += org_y;
}
}
}
+ wxPoint pt(GetClientAreaOrigin());
+ org_x -= pt.x;
+ org_y -= pt.y;
+
if (x) *x -= org_x;
if (y) *y -= org_y;
}
void wxWindow::AddChild( wxWindow *child )
{
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
- wxASSERT_MSG( (m_wxwindow != NULL), "window need client area" );
wxASSERT_MSG( (child != NULL), "invalid child" );
- wxASSERT_MSG( (child->m_widget != NULL), "invalid child" );
-
- // Addchild is (often) called before the program
- // has left the parents constructor so that no
- // virtual tables work yet. The approach below
- // practically imitates virtual tables, i.e. it
- // implements a different AddChild() behaviour
- // for wxFrame, wxDialog, wxWindow and
- // wxMDIParentFrame.
-
- // wxFrame and wxDialog as children aren't placed into the parents
-
- if (( IS_KIND_OF(child,wxFrame) || IS_KIND_OF(child,wxDialog) ) &&
- (!IS_KIND_OF(child,wxMDIChildFrame)))
- {
- m_children.Append( child );
-
- if ((child->m_x != -1) && (child->m_y != -1))
- gtk_widget_set_uposition( child->m_widget, child->m_x, child->m_y );
-
- return;
- }
-
- // In the case of an wxMDIChildFrame descendant, we use the
- // client windows's AddChild()
-
- if (IS_KIND_OF(this,wxMDIParentFrame))
- {
- if (IS_KIND_OF(child,wxMDIChildFrame))
- {
- wxMDIClientWindow *client = ((wxMDIParentFrame*)this)->GetClientWindow();
- if (client)
- {
- client->AddChild( child );
- return;
- }
- }
- }
-
- // wxNotebook is very special, so it has a private AddChild()
-
- if (IS_KIND_OF(this,wxNotebook))
- {
- wxNotebook *tab = (wxNotebook*)this;
- tab->AddChild( child );
- return;
- }
-
- // wxFrame has a private AddChild
-
- if (IS_KIND_OF(this,wxFrame) && !IS_KIND_OF(this,wxMDIChildFrame))
- {
- wxFrame *frame = (wxFrame*)this;
- frame->AddChild( child );
- return;
- }
-
- // All the rest
m_children.Append( child );
- if (m_wxwindow) gtk_myfixed_put( GTK_MYFIXED(m_wxwindow), child->m_widget,
- child->m_x, child->m_y );
-
- gtk_widget_set_usize( child->m_widget, child->m_width, child->m_height );
}
wxList *wxWindow::GetChildren()
void wxWindow::RemoveChild( wxWindow *child )
{
- if (GetChildren())
- GetChildren()->DeleteObject( child );
+ if (GetChildren()) GetChildren()->DeleteObject( child );
child->m_parent = (wxWindow *) NULL;
}