inline wxRadioBox( wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = (const wxString *) NULL,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
+ int majorDim = 1, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr )
{
GtkWidget *widget;
gint16 x;
gint16 y;
+ gint16 width;
+ gint16 height;
};
guint gtk_myfixed_get_type (void);
void gtk_myfixed_put (GtkMyFixed *myfixed,
GtkWidget *widget,
gint16 x,
- gint16 y);
+ gint16 y,
+ gint16 width,
+ gint16 height);
+
void gtk_myfixed_move (GtkMyFixed *myfixed,
GtkWidget *widget,
gint16 x,
- gint16 y);
+ gint16 y );
+
+void gtk_myfixed_resize (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 width,
+ gint16 height );
+
+void gtk_myfixed_set_size (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
inline wxRadioBox( wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = (const wxString *) NULL,
- int majorDim = 0, long style = wxRA_HORIZONTAL,
+ int majorDim = 1, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr )
{
GtkWidget *widget;
gint16 x;
gint16 y;
+ gint16 width;
+ gint16 height;
};
guint gtk_myfixed_get_type (void);
void gtk_myfixed_put (GtkMyFixed *myfixed,
GtkWidget *widget,
gint16 x,
- gint16 y);
+ gint16 y,
+ gint16 width,
+ gint16 height);
+
void gtk_myfixed_move (GtkMyFixed *myfixed,
GtkWidget *widget,
gint16 x,
- gint16 y);
+ gint16 y );
+
+void gtk_myfixed_resize (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 width,
+ gint16 height );
+
+void gtk_myfixed_set_size (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height);
#ifdef __cplusplus
}
#endif /* __cplusplus */
--- /dev/null
+Linux
+linux-gnu
+linux
+test.png
--- /dev/null
+include ../../setup/general/makeapp
--- /dev/null
+# WXXT base directory
+WXBASEDIR=@WXBASEDIR@
+
+# set the OS type for compilation
+OS=@OS@
+# compile a library only
+RULE=bin
+
+# define library name
+BIN_TARGET=scroll
+# define library sources
+BIN_SRC=\
+scroll.cpp
+
+#define library objects
+BIN_OBJ=\
+scroll.o
+
+# additional things needed to link
+BIN_LINK=
+
+# additional things needed to compile
+ADD_COMPILE=
+
+# include the definitions now
+include ../../../template.mak
--- /dev/null
+/*
+ * Program: scroll
+ *
+ * Author: Robert Roebling
+ *
+ * Copyright: (C) 1998, Robert Roebling
+ *
+ */
+
+// For compilers that support precompilation, includes "wx/wx.h".
+#include "wx/wxprec.h"
+
+#ifdef __BORLANDC__
+#pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+#include "wx/wx.h"
+#endif
+
+#include "wx/image.h"
+
+// derived classes
+
+class MyFrame;
+class MyApp;
+
+// MyCanvas
+
+class MyCanvas: public wxScrolledWindow
+{
+public:
+ MyCanvas() {};
+ MyCanvas( wxWindow *parent, wxWindowID, const wxPoint &pos, const wxSize &size );
+ ~MyCanvas();
+ void OnPaint( wxPaintEvent &event );
+
+ DECLARE_DYNAMIC_CLASS(MyCanvas)
+ DECLARE_EVENT_TABLE()
+};
+
+// MyFrame
+
+class MyFrame: public wxFrame
+{
+public:
+ MyFrame();
+
+ void OnAbout( wxCommandEvent &event );
+ void OnQuit( wxCommandEvent &event );
+
+ MyCanvas *m_canvas;
+
+ DECLARE_DYNAMIC_CLASS(MyFrame)
+ DECLARE_EVENT_TABLE()
+};
+
+// MyApp
+
+class MyApp: public wxApp
+{
+public:
+ virtual bool OnInit();
+};
+
+// main program
+
+IMPLEMENT_APP(MyApp)
+
+// MyCanvas
+
+IMPLEMENT_DYNAMIC_CLASS(MyCanvas, wxScrolledWindow)
+
+BEGIN_EVENT_TABLE(MyCanvas, wxScrolledWindow)
+ EVT_PAINT(MyCanvas::OnPaint)
+END_EVENT_TABLE()
+
+MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
+ const wxPoint &pos, const wxSize &size )
+ : wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER )
+{
+ (void) new wxButton( this, -1, "wxButton", wxPoint(10,10) );
+
+ (void) new wxTextCtrl( this, -1, "wxTextCtrl", wxPoint(10,50) );
+
+ (void) new wxCheckBox( this, -1, "Disable", wxPoint(10,90) );
+
+ wxString choices[] =
+ {
+ "This",
+ "is one of my",
+ "really",
+ "wonderful",
+ "examples."
+ };
+
+ (void) new wxComboBox( this, -1, "This", wxPoint(10,130), wxDefaultSize, 5, choices );
+
+ (void) new wxRadioBox( this, -1, "This", wxPoint(10,200), wxDefaultSize, 5, choices );
+}
+
+MyCanvas::~MyCanvas()
+{
+}
+
+void MyCanvas::OnPaint( wxPaintEvent &WXUNUSED(event) )
+{
+ wxPaintDC dc( this );
+ PrepareDC( dc );
+
+ dc.DrawText( "Some text", 10, 10 );
+
+ dc.DrawRectangle( 50, 30, 200, 200 );
+}
+
+// MyFrame
+
+const int ID_QUIT = 108;
+const int ID_ABOUT = 109;
+
+IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
+
+BEGIN_EVENT_TABLE(MyFrame,wxFrame)
+ EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
+ EVT_MENU (ID_QUIT, MyFrame::OnQuit)
+END_EVENT_TABLE()
+
+MyFrame::MyFrame()
+ : wxFrame( (wxFrame *)NULL, -1, "wxScrolledWindow sample",
+ wxPoint(20,20), wxSize(470,360) )
+{
+ wxMenu *file_menu = new wxMenu();
+ file_menu->Append( ID_ABOUT, "&About..");
+ file_menu->Append( ID_QUIT, "E&xit\tAlt-X");
+
+ wxMenuBar *menu_bar = new wxMenuBar();
+ menu_bar->Append(file_menu, "&File");
+
+ SetMenuBar( menu_bar );
+
+ CreateStatusBar(2);
+ int widths[] = { -1, 100 };
+ SetStatusWidths( 2, widths );
+
+ m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
+ m_canvas->SetScrollbars( 10, 10, 50, 100 );
+}
+
+void MyFrame::OnQuit( wxCommandEvent &WXUNUSED(event) )
+{
+ Close( TRUE );
+}
+
+void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
+{
+ (void)wxMessageBox( "wxScroll demo\n"
+ "Robert Roebling (c) 1998",
+ "About wxScroll Demo", wxICON_INFORMATION | wxOK );
+}
+
+//-----------------------------------------------------------------------------
+// MyApp
+//-----------------------------------------------------------------------------
+
+bool MyApp::OnInit()
+{
+ wxFrame *frame = new MyFrame();
+ frame->Show( TRUE );
+
+ return TRUE;
+}
+
if (newSize.x == -1)
newSize.x = 100;
if (newSize.y == -1)
- newSize.y = 22;
+ newSize.y = 26;
SetSize( newSize.x, newSize.y );
GtkWidget *list = GTK_COMBO(m_widget)->list;
void wxComboBox::OnSize( wxSizeEvent &event )
{
wxControl::OnSize( event );
+
+ return;
int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
+ child->m_y,
+ child->m_width,
+ child->m_height );
/* we connect to these events for recalculating the client area
space when the toolbar is floating */
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
+ child->m_y,
+ child->m_width,
+ child->m_height );
}
- gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
- child->m_width,
- child->m_height );
-
/* resize on OnInternalIdle */
parent->m_sizeSet = FALSE;
}
m_frameMenuBar->m_y = yy;
m_frameMenuBar->m_width = ww;
m_frameMenuBar->m_height = hh;
-
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameMenuBar->m_widget, xx, yy );
-
-// m_frameMenuBar->m_widget->requisition.width = ww;
-// m_frameMenuBar->m_widget->requisition.height = hh;
- gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh );
-
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameMenuBar->m_widget,
+ xx, yy, ww, hh );
client_area_y_offset += hh;
}
m_frameToolBar->m_y = yy;
/* m_frameToolBar->m_height = hh; don't change the toolbar's height */
m_frameToolBar->m_width = ww;
-
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy );
-
- gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh );
-
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameToolBar->m_widget,
+ xx, yy, ww, hh );
client_area_y_offset += hh;
}
int client_x = m_miniEdge;
int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_wxwindow, client_x, client_y );
-
int client_w = m_width - 2*m_miniEdge;
int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
- gtk_widget_set_usize( m_wxwindow, client_w, client_h );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_wxwindow,
+ client_x, client_y, client_w, client_h );
}
else
{
int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
-
m_frameStatusBar->m_x = xx;
m_frameStatusBar->m_y = yy;
m_frameStatusBar->m_width = ww;
m_frameStatusBar->m_height = hh;
-
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy );
-
-// m_frameStatusBar->m_widget->requisition.width = ww;
-// m_frameStatusBar->m_widget->requisition.height = hh;
- gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
+ m_frameStatusBar->m_widget,
+ xx, yy, ww, hh );
}
/* we actually set the size of a frame here and no-where else */
{
m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
+ m_frameMenuBar->m_widget,
+ m_frameMenuBar->m_x,
+ m_frameMenuBar->m_y,
+ m_frameMenuBar->m_width,
+ m_frameMenuBar->m_height );
if (menuBar->m_windowStyle & wxMB_DOCKABLE)
{
menu_bar->m_y = 0;
menu_bar->m_width = m_width;
menu_bar->m_height = wxMENU_HEIGHT;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), menu_bar->m_widget, 0, 0 );
- gtk_widget_set_usize( menu_bar->m_widget, m_width, wxMENU_HEIGHT );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ menu_bar->m_widget,
+ 0, 0, m_width, wxMENU_HEIGHT );
}
void wxMDIParentFrame::OnInternalIdle()
gtk_widget_hide( m_menuBar->m_widget );
/* insert the invisible menu bar into the _parent_ mdi frame */
- gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget), m_menuBar->m_widget, 0, 0 );
- gtk_widget_set_usize( menu_bar->m_widget, mdi_frame->m_width, wxMENU_HEIGHT );
+ gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget),
+ m_menuBar->m_widget,
+ 0, 0, mdi_frame->m_width, wxMENU_HEIGHT );
}
}
{
GtkWidget *close_button = gtk_button_new_with_label( "x" );
- gtk_myfixed_put( GTK_MYFIXED(m_mainWidget), close_button, 4, 4 );
- gtk_widget_set_usize( close_button, 12, 11 );
+ gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
+ close_button,
+ 4, 4, 12, 11 );
gtk_widget_show( close_button );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), m_x+10, m_y+10+(i*24) );
-
+ gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow),
+ GTK_WIDGET(m_radio),
+ m_x+10, m_y+10+(i*24), 10, 10 );
}
wxSize ls = LayoutItems();
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_widget_set_usize( button, max_len, 20 );
+ gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 );
node = node->Next();
if (!node) break;
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
x += max;
- gtk_widget_set_usize( button, max, 20 );
node = node->Next();
}
void
gtk_myfixed_put (GtkMyFixed *myfixed,
- GtkWidget *widget,
- gint16 x,
- gint16 y)
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height)
{
GtkMyFixedChild *child_info;
child_info->widget = widget;
child_info->x = x;
child_info->y = y;
+ child_info->width = width;
+ child_info->height = height;
gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
}
void
-gtk_myfixed_move (GtkMyFixed *myfixed,
- GtkWidget *widget,
- gint16 x,
- gint16 y)
+gtk_myfixed_move (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y)
{
GtkMyFixedChild *child;
GList *children;
g_return_if_fail (GTK_IS_MYFIXED (myfixed));
g_return_if_fail (widget != NULL);
+ children = myfixed->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (child->widget == widget)
+ {
+ gtk_myfixed_set_size( myfixed, widget, x, y, child->width, child->height );
+ break;
+ }
+ }
+}
+
+void
+gtk_myfixed_resize (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 width,
+ gint16 height)
+{
+ GtkMyFixedChild *child;
+ GList *children;
+
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+ g_return_if_fail (widget != NULL);
+
+ children = myfixed->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (child->widget == widget)
+ {
+ gtk_myfixed_set_size( myfixed, widget, child->x, child->y, width, height );
+ break;
+ }
+ }
+}
+
+void
+gtk_myfixed_set_size (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height)
+{
+ GtkMyFixedChild *child;
+ GList *children;
+ GtkAllocation child_allocation;
+
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+ g_return_if_fail (widget != NULL);
+
children = myfixed->children;
while (children)
{
if (child->widget == widget)
{
- if ((child->x == x) && (child->y == y)) return;
+ if ((child->x == x) &&
+ (child->y == y) &&
+ (child->width == width) &&
+ (child->height == height)) return;
child->x = x;
child->y = y;
+ child->width = width;
+ child->height = height;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
- gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+ {
+ if ((child->width > 1) && (child->height > 1) && (GTK_WIDGET_REALIZED(widget)))
+ {
+ child_allocation.x = child->x;
+ child_allocation.y = child->y;
+ child_allocation.width = child->width;
+ child_allocation.height = child->height;
+ gtk_widget_size_allocate (widget, &child_allocation);
+ }
+ else
+ {
+ gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+ }
+ }
break;
}
myfixed = GTK_MYFIXED (widget);
-/*
- requisition->width = 0;
- requisition->height = 0;
-*/
requisition->width = widget->requisition.width;
requisition->height = widget->requisition.height;
static void
gtk_myfixed_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
GtkMyFixed *myfixed;
gint border;
{
child_allocation.x = child->x;
child_allocation.y = child->y;
- child_allocation.width = child->widget->requisition.width;
- child_allocation.height = child->widget->requisition.height;
+ child_allocation.width = child->width;
+ child_allocation.height = child->height;
gtk_widget_size_allocate (child->widget, &child_allocation);
}
}
static void
gtk_myfixed_paint (GtkWidget *widget,
- GdkRectangle *area)
+ GdkRectangle *area)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MYFIXED (widget));
static void
gtk_myfixed_draw (GtkWidget *widget,
- GdkRectangle *area)
+ GdkRectangle *area)
{
GtkMyFixed *myfixed;
GtkMyFixedChild *child;
static gint
gtk_myfixed_expose (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
GtkMyFixed *myfixed;
GtkMyFixedChild *child;
g_return_if_fail (GTK_IS_MYFIXED (container));
g_return_if_fail (widget != NULL);
- gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0);
+ gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0, 20, 20 );
}
static void
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
-
- gtk_widget_set_usize( child->m_widget,
- child->m_width,
- child->m_height );
+ child->m_y,
+ child->m_width,
+ child->m_height );
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
{
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+ int border = 0;
+
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
{
/* the default button has a border around it */
- int border = 5;
-
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, m_y-border );
-
- gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+ border = 5;
}
- else
- {
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
- if ((old_width != m_width) || (old_height != m_height))
- {
- gtk_widget_set_usize( m_widget, m_width, m_height );
+ /* this is the result of hours of debugging: the following code
+ means that if we have a m_wxwindow and we set the size of
+ m_widget, m_widget (which is a GtkScrolledWindow) does NOT
+ automatically propagate its size down to its m_wxwindow,
+ which is its client area. therefore, we have to tell the
+ client area directly that it has to resize itself.
+ this will lead to that m_widget (GtkScrolledWindow) will
+ calculate how much size it needs for scrollbars etc and
+ it will then call XXX_size_allocate of its child, which
+ is m_wxwindow. m_wxwindow in turn will do the same with its
+ children and so on. problems can arise if this happens
+ before all the children have been realized as some widgets
+ stupidy need to be realized during XXX_size_allocate (e.g.
+ GtkNotebook) and they will segv if called otherwise. this
+ emergency is tested in gtk_myfixed_size_allocate. Normally
+ this shouldn't be needed and only gtk_widget_queue_resize()
+ should be enough to provoke a resize at the next appropriate
+ moment, but this seems to fail, e.g. when a wxNotebook contains
+ a wxSplitterWindow: the splitter window's children won't
+ show up properly resized then. */
+
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow),
+ m_widget,
+ m_x-border,
+ m_y-border,
+ m_width+2*border,
+ m_height+2*border );
- /* this is the result of hours of debugging: the following code
- means that if we have a m_wxwindow and we set the size of
- m_widget, m_widget (which is a GtkScrolledWindow) does NOT
- automatically propagate its size down to its m_wxwindow,
- which is its client area. therefore, we have to tell the
- client area directly that it has to resize itself.
- this will lead to that m_widget (GtkScrolledWindow) will
- calculate how much size it needs for scrollbars etc and
- it will then call XXX_size_allocate of its child, which
- is m_wxwindow. m_wxwindow in turn will do the same with its
- children and so on. problems can arise if this happens
- before all the children have been realized as some widgets
- stupidy need to be realized during XXX_size_allocate (e.g.
- GtkNotebook) and they will segv if called otherwise. this
- emergency is tested in gtk_myfixed_size_allocate. Normally
- this shouldn't be needed and only gtk_widget_queue_resize()
- should be enough to provoke a resize at the next appropriate
- moment, but this seems to fail, e.g. when a wxNotebook contains
- a wxSplitterWindow: the splitter window's children won't
- show up properly resized then. */
-
- if (m_wxwindow)
- {
- GtkAllocation alloc;
- alloc.x = m_x;
- alloc.y = m_y;
- alloc.width = m_width;
- alloc.height = m_height;
- gtk_widget_size_allocate( m_widget, &alloc );
- }
- }
- }
}
m_sizeSet = TRUE;
if (newSize.x == -1)
newSize.x = 100;
if (newSize.y == -1)
- newSize.y = 22;
+ newSize.y = 26;
SetSize( newSize.x, newSize.y );
GtkWidget *list = GTK_COMBO(m_widget)->list;
void wxComboBox::OnSize( wxSizeEvent &event )
{
wxControl::OnSize( event );
+
+ return;
int w = 21;
gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
gtk_myfixed_put( GTK_MYFIXED(frame->m_mainWidget),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
+ child->m_y,
+ child->m_width,
+ child->m_height );
/* we connect to these events for recalculating the client area
space when the toolbar is floating */
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
+ child->m_y,
+ child->m_width,
+ child->m_height );
}
- gtk_widget_set_usize( GTK_WIDGET(child->m_widget),
- child->m_width,
- child->m_height );
-
/* resize on OnInternalIdle */
parent->m_sizeSet = FALSE;
}
m_frameMenuBar->m_y = yy;
m_frameMenuBar->m_width = ww;
m_frameMenuBar->m_height = hh;
-
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameMenuBar->m_widget, xx, yy );
-
-// m_frameMenuBar->m_widget->requisition.width = ww;
-// m_frameMenuBar->m_widget->requisition.height = hh;
- gtk_widget_set_usize( m_frameMenuBar->m_widget, ww, hh );
-
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameMenuBar->m_widget,
+ xx, yy, ww, hh );
client_area_y_offset += hh;
}
m_frameToolBar->m_y = yy;
/* m_frameToolBar->m_height = hh; don't change the toolbar's height */
m_frameToolBar->m_width = ww;
-
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_frameToolBar->m_widget, xx, yy );
-
- gtk_widget_set_usize( m_frameToolBar->m_widget, ww, hh );
-
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_frameToolBar->m_widget,
+ xx, yy, ww, hh );
client_area_y_offset += hh;
}
int client_x = m_miniEdge;
int client_y = client_area_y_offset + m_miniEdge + m_miniTitle;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), m_wxwindow, client_x, client_y );
-
int client_w = m_width - 2*m_miniEdge;
int client_h = m_height - client_area_y_offset- 2*m_miniEdge - m_miniTitle;
- gtk_widget_set_usize( m_wxwindow, client_w, client_h );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ m_wxwindow,
+ client_x, client_y, client_w, client_h );
}
else
{
int yy = m_height - wxSTATUS_HEIGHT - m_miniEdge - client_area_y_offset;
int ww = m_width - 2*m_miniEdge;
int hh = wxSTATUS_HEIGHT;
-
m_frameStatusBar->m_x = xx;
m_frameStatusBar->m_y = yy;
m_frameStatusBar->m_width = ww;
m_frameStatusBar->m_height = hh;
-
- gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_frameStatusBar->m_widget, xx, yy );
-
-// m_frameStatusBar->m_widget->requisition.width = ww;
-// m_frameStatusBar->m_widget->requisition.height = hh;
- gtk_widget_set_usize( m_frameStatusBar->m_widget, ww, hh );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_wxwindow),
+ m_frameStatusBar->m_widget,
+ xx, yy, ww, hh );
}
/* we actually set the size of a frame here and no-where else */
{
m_frameMenuBar->m_parent = this;
gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
- m_frameMenuBar->m_widget, m_frameMenuBar->m_x, m_frameMenuBar->m_y );
+ m_frameMenuBar->m_widget,
+ m_frameMenuBar->m_x,
+ m_frameMenuBar->m_y,
+ m_frameMenuBar->m_width,
+ m_frameMenuBar->m_height );
if (menuBar->m_windowStyle & wxMB_DOCKABLE)
{
menu_bar->m_y = 0;
menu_bar->m_width = m_width;
menu_bar->m_height = wxMENU_HEIGHT;
- gtk_myfixed_move( GTK_MYFIXED(m_mainWidget), menu_bar->m_widget, 0, 0 );
- gtk_widget_set_usize( menu_bar->m_widget, m_width, wxMENU_HEIGHT );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_mainWidget),
+ menu_bar->m_widget,
+ 0, 0, m_width, wxMENU_HEIGHT );
}
void wxMDIParentFrame::OnInternalIdle()
gtk_widget_hide( m_menuBar->m_widget );
/* insert the invisible menu bar into the _parent_ mdi frame */
- gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget), m_menuBar->m_widget, 0, 0 );
- gtk_widget_set_usize( menu_bar->m_widget, mdi_frame->m_width, wxMENU_HEIGHT );
+ gtk_myfixed_put( GTK_MYFIXED(mdi_frame->m_mainWidget),
+ m_menuBar->m_widget,
+ 0, 0, mdi_frame->m_width, wxMENU_HEIGHT );
}
}
{
GtkWidget *close_button = gtk_button_new_with_label( "x" );
- gtk_myfixed_put( GTK_MYFIXED(m_mainWidget), close_button, 4, 4 );
- gtk_widget_set_usize( close_button, 12, 11 );
+ gtk_myfixed_put( GTK_MYFIXED(m_mainWidget),
+ close_button,
+ 4, 4, 12, 11 );
gtk_widget_show( close_button );
gtk_signal_connect( GTK_OBJECT(m_radio), "clicked",
GTK_SIGNAL_FUNC(gtk_radiobutton_clicked_callback), (gpointer*)this );
- gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow), GTK_WIDGET(m_radio), m_x+10, m_y+10+(i*24) );
-
+ gtk_myfixed_put( GTK_MYFIXED(m_parent->m_wxwindow),
+ GTK_WIDGET(m_radio),
+ m_x+10, m_y+10+(i*24), 10, 10 );
}
wxSize ls = LayoutItems();
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_widget_set_usize( button, max_len, 20 );
+ gtk_myfixed_resize( GTK_MYFIXED(m_parent->m_wxwindow), button, max_len, 20 );
node = node->Next();
if (!node) break;
{
GtkWidget *button = GTK_WIDGET( node->Data() );
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y );
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow), button, m_x+x, m_y+y, max, 20 );
x += max;
- gtk_widget_set_usize( button, max, 20 );
node = node->Next();
}
void
gtk_myfixed_put (GtkMyFixed *myfixed,
- GtkWidget *widget,
- gint16 x,
- gint16 y)
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height)
{
GtkMyFixedChild *child_info;
child_info->widget = widget;
child_info->x = x;
child_info->y = y;
+ child_info->width = width;
+ child_info->height = height;
gtk_widget_set_parent (widget, GTK_WIDGET (myfixed));
}
void
-gtk_myfixed_move (GtkMyFixed *myfixed,
- GtkWidget *widget,
- gint16 x,
- gint16 y)
+gtk_myfixed_move (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y)
{
GtkMyFixedChild *child;
GList *children;
g_return_if_fail (GTK_IS_MYFIXED (myfixed));
g_return_if_fail (widget != NULL);
+ children = myfixed->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (child->widget == widget)
+ {
+ gtk_myfixed_set_size( myfixed, widget, x, y, child->width, child->height );
+ break;
+ }
+ }
+}
+
+void
+gtk_myfixed_resize (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 width,
+ gint16 height)
+{
+ GtkMyFixedChild *child;
+ GList *children;
+
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+ g_return_if_fail (widget != NULL);
+
+ children = myfixed->children;
+ while (children)
+ {
+ child = children->data;
+ children = children->next;
+
+ if (child->widget == widget)
+ {
+ gtk_myfixed_set_size( myfixed, widget, child->x, child->y, width, height );
+ break;
+ }
+ }
+}
+
+void
+gtk_myfixed_set_size (GtkMyFixed *myfixed,
+ GtkWidget *widget,
+ gint16 x,
+ gint16 y,
+ gint16 width,
+ gint16 height)
+{
+ GtkMyFixedChild *child;
+ GList *children;
+ GtkAllocation child_allocation;
+
+ g_return_if_fail (myfixed != NULL);
+ g_return_if_fail (GTK_IS_MYFIXED (myfixed));
+ g_return_if_fail (widget != NULL);
+
children = myfixed->children;
while (children)
{
if (child->widget == widget)
{
- if ((child->x == x) && (child->y == y)) return;
+ if ((child->x == x) &&
+ (child->y == y) &&
+ (child->width == width) &&
+ (child->height == height)) return;
child->x = x;
child->y = y;
+ child->width = width;
+ child->height = height;
if (GTK_WIDGET_VISIBLE (widget) && GTK_WIDGET_VISIBLE (myfixed))
- gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+ {
+ if ((child->width > 1) && (child->height > 1) && (GTK_WIDGET_REALIZED(widget)))
+ {
+ child_allocation.x = child->x;
+ child_allocation.y = child->y;
+ child_allocation.width = child->width;
+ child_allocation.height = child->height;
+ gtk_widget_size_allocate (widget, &child_allocation);
+ }
+ else
+ {
+ gtk_widget_queue_resize (GTK_WIDGET (myfixed));
+ }
+ }
break;
}
myfixed = GTK_MYFIXED (widget);
-/*
- requisition->width = 0;
- requisition->height = 0;
-*/
requisition->width = widget->requisition.width;
requisition->height = widget->requisition.height;
static void
gtk_myfixed_size_allocate (GtkWidget *widget,
- GtkAllocation *allocation)
+ GtkAllocation *allocation)
{
GtkMyFixed *myfixed;
gint border;
{
child_allocation.x = child->x;
child_allocation.y = child->y;
- child_allocation.width = child->widget->requisition.width;
- child_allocation.height = child->widget->requisition.height;
+ child_allocation.width = child->width;
+ child_allocation.height = child->height;
gtk_widget_size_allocate (child->widget, &child_allocation);
}
}
static void
gtk_myfixed_paint (GtkWidget *widget,
- GdkRectangle *area)
+ GdkRectangle *area)
{
g_return_if_fail (widget != NULL);
g_return_if_fail (GTK_IS_MYFIXED (widget));
static void
gtk_myfixed_draw (GtkWidget *widget,
- GdkRectangle *area)
+ GdkRectangle *area)
{
GtkMyFixed *myfixed;
GtkMyFixedChild *child;
static gint
gtk_myfixed_expose (GtkWidget *widget,
- GdkEventExpose *event)
+ GdkEventExpose *event)
{
GtkMyFixed *myfixed;
GtkMyFixedChild *child;
g_return_if_fail (GTK_IS_MYFIXED (container));
g_return_if_fail (widget != NULL);
- gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0);
+ gtk_myfixed_put (GTK_MYFIXED (container), widget, 0, 0, 20, 20 );
}
static void
gtk_myfixed_put( GTK_MYFIXED(parent->m_wxwindow),
GTK_WIDGET(child->m_widget),
child->m_x,
- child->m_y );
-
- gtk_widget_set_usize( child->m_widget,
- child->m_width,
- child->m_height );
+ child->m_y,
+ child->m_width,
+ child->m_height );
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
{
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_maxWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_maxHeight;
+ int border = 0;
+
if (GTK_WIDGET_HAS_DEFAULT(m_widget))
{
/* the default button has a border around it */
- int border = 5;
-
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x-border, m_y-border );
-
- gtk_widget_set_usize( m_widget, m_width+2*border, m_height+2*border );
+ border = 5;
}
- else
- {
- gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
- if ((old_width != m_width) || (old_height != m_height))
- {
- gtk_widget_set_usize( m_widget, m_width, m_height );
+ /* this is the result of hours of debugging: the following code
+ means that if we have a m_wxwindow and we set the size of
+ m_widget, m_widget (which is a GtkScrolledWindow) does NOT
+ automatically propagate its size down to its m_wxwindow,
+ which is its client area. therefore, we have to tell the
+ client area directly that it has to resize itself.
+ this will lead to that m_widget (GtkScrolledWindow) will
+ calculate how much size it needs for scrollbars etc and
+ it will then call XXX_size_allocate of its child, which
+ is m_wxwindow. m_wxwindow in turn will do the same with its
+ children and so on. problems can arise if this happens
+ before all the children have been realized as some widgets
+ stupidy need to be realized during XXX_size_allocate (e.g.
+ GtkNotebook) and they will segv if called otherwise. this
+ emergency is tested in gtk_myfixed_size_allocate. Normally
+ this shouldn't be needed and only gtk_widget_queue_resize()
+ should be enough to provoke a resize at the next appropriate
+ moment, but this seems to fail, e.g. when a wxNotebook contains
+ a wxSplitterWindow: the splitter window's children won't
+ show up properly resized then. */
+
+ gtk_myfixed_set_size( GTK_MYFIXED(m_parent->m_wxwindow),
+ m_widget,
+ m_x-border,
+ m_y-border,
+ m_width+2*border,
+ m_height+2*border );
- /* this is the result of hours of debugging: the following code
- means that if we have a m_wxwindow and we set the size of
- m_widget, m_widget (which is a GtkScrolledWindow) does NOT
- automatically propagate its size down to its m_wxwindow,
- which is its client area. therefore, we have to tell the
- client area directly that it has to resize itself.
- this will lead to that m_widget (GtkScrolledWindow) will
- calculate how much size it needs for scrollbars etc and
- it will then call XXX_size_allocate of its child, which
- is m_wxwindow. m_wxwindow in turn will do the same with its
- children and so on. problems can arise if this happens
- before all the children have been realized as some widgets
- stupidy need to be realized during XXX_size_allocate (e.g.
- GtkNotebook) and they will segv if called otherwise. this
- emergency is tested in gtk_myfixed_size_allocate. Normally
- this shouldn't be needed and only gtk_widget_queue_resize()
- should be enough to provoke a resize at the next appropriate
- moment, but this seems to fail, e.g. when a wxNotebook contains
- a wxSplitterWindow: the splitter window's children won't
- show up properly resized then. */
-
- if (m_wxwindow)
- {
- GtkAllocation alloc;
- alloc.x = m_x;
- alloc.y = m_y;
- alloc.width = m_width;
- alloc.height = m_height;
- gtk_widget_size_allocate( m_widget, &alloc );
- }
- }
- }
}
m_sizeSet = TRUE;