Added scrolling of widgets and sample
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2343 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -48,7 +48,7 @@ class wxRadioBox: public wxControl
|
||||
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 )
|
||||
{
|
||||
|
@@ -55,6 +55,8 @@ struct _GtkMyFixedChild
|
||||
GtkWidget *widget;
|
||||
gint16 x;
|
||||
gint16 y;
|
||||
gint16 width;
|
||||
gint16 height;
|
||||
};
|
||||
|
||||
guint gtk_myfixed_get_type (void);
|
||||
@@ -66,11 +68,26 @@ void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
|
||||
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 */
|
||||
|
@@ -48,7 +48,7 @@ class wxRadioBox: public wxControl
|
||||
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 )
|
||||
{
|
||||
|
@@ -55,6 +55,8 @@ struct _GtkMyFixedChild
|
||||
GtkWidget *widget;
|
||||
gint16 x;
|
||||
gint16 y;
|
||||
gint16 width;
|
||||
gint16 height;
|
||||
};
|
||||
|
||||
guint gtk_myfixed_get_type (void);
|
||||
@@ -66,11 +68,26 @@ void gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
|
||||
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 */
|
||||
|
4
samples/scroll/.cvsignore
Normal file
4
samples/scroll/.cvsignore
Normal file
@@ -0,0 +1,4 @@
|
||||
Linux
|
||||
linux-gnu
|
||||
linux
|
||||
test.png
|
1
samples/scroll/Makefile
Normal file
1
samples/scroll/Makefile
Normal file
@@ -0,0 +1 @@
|
||||
include ../../setup/general/makeapp
|
26
samples/scroll/Makefile.in
Normal file
26
samples/scroll/Makefile.in
Normal file
@@ -0,0 +1,26 @@
|
||||
# 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
|
172
samples/scroll/scroll.cpp
Normal file
172
samples/scroll/scroll.cpp
Normal file
@@ -0,0 +1,172 @@
|
||||
/*
|
||||
* 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;
|
||||
}
|
||||
|
@@ -110,7 +110,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
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;
|
||||
@@ -583,6 +583,8 @@ void wxComboBox::OnChar( wxKeyEvent &event )
|
||||
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 );
|
||||
|
@@ -267,7 +267,9 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
|
||||
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 */
|
||||
@@ -290,13 +292,11 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
|
||||
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;
|
||||
}
|
||||
@@ -665,13 +665,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -693,21 +689,19 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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
|
||||
{
|
||||
@@ -721,17 +715,13 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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 */
|
||||
@@ -851,7 +841,11 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@@ -96,8 +96,9 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
|
||||
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()
|
||||
@@ -297,8 +298,9 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -289,8 +289,9 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
|
||||
{
|
||||
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 );
|
||||
|
||||
|
@@ -108,8 +108,9 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
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();
|
||||
@@ -194,7 +195,7 @@ wxSize wxRadioBox::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;
|
||||
@@ -230,9 +231,8 @@ wxSize wxRadioBox::LayoutItems()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@@ -202,9 +202,11 @@ gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
|
||||
|
||||
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;
|
||||
|
||||
@@ -216,6 +218,8 @@ gtk_myfixed_put (GtkMyFixed *myfixed,
|
||||
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));
|
||||
|
||||
@@ -232,10 +236,10 @@ gtk_myfixed_put (GtkMyFixed *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;
|
||||
@@ -244,6 +248,63 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
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)
|
||||
{
|
||||
@@ -252,13 +313,31 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -385,10 +464,6 @@ gtk_myfixed_size_request (GtkWidget *widget,
|
||||
|
||||
myfixed = GTK_MYFIXED (widget);
|
||||
|
||||
/*
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
*/
|
||||
requisition->width = widget->requisition.width;
|
||||
requisition->height = widget->requisition.height;
|
||||
|
||||
@@ -407,7 +482,7 @@ gtk_myfixed_size_request (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
gint border;
|
||||
@@ -457,8 +532,8 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -466,7 +541,7 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
|
||||
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));
|
||||
@@ -480,7 +555,7 @@ gtk_myfixed_paint (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
gtk_myfixed_draw (GtkWidget *widget,
|
||||
GdkRectangle *area)
|
||||
GdkRectangle *area)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
GtkMyFixedChild *child;
|
||||
@@ -509,7 +584,7 @@ gtk_myfixed_draw (GtkWidget *widget,
|
||||
|
||||
static gint
|
||||
gtk_myfixed_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
GtkMyFixedChild *child;
|
||||
@@ -550,7 +625,7 @@ gtk_myfixed_add (GtkContainer *container,
|
||||
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
|
||||
|
@@ -1444,11 +1444,9 @@ 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( child->m_widget,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
|
||||
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
|
||||
{
|
||||
@@ -2037,55 +2035,42 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
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;
|
||||
|
@@ -110,7 +110,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
|
||||
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;
|
||||
@@ -583,6 +583,8 @@ void wxComboBox::OnChar( wxKeyEvent &event )
|
||||
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 );
|
||||
|
@@ -267,7 +267,9 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
|
||||
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 */
|
||||
@@ -290,13 +292,11 @@ static void wxInsertChildInFrame( wxWindow* parent, wxWindow* child )
|
||||
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;
|
||||
}
|
||||
@@ -665,13 +665,9 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -693,21 +689,19 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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
|
||||
{
|
||||
@@ -721,17 +715,13 @@ void wxFrame::GtkOnSize( int WXUNUSED(x), int WXUNUSED(y), int width, int height
|
||||
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 */
|
||||
@@ -851,7 +841,11 @@ void wxFrame::SetMenuBar( wxMenuBar *menuBar )
|
||||
{
|
||||
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)
|
||||
{
|
||||
|
@@ -96,8 +96,9 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
|
||||
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()
|
||||
@@ -297,8 +298,9 @@ void wxMDIChildFrame::SetMenuBar( wxMenuBar *menu_bar )
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -289,8 +289,9 @@ bool wxMiniFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title
|
||||
{
|
||||
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 );
|
||||
|
||||
|
@@ -108,8 +108,9 @@ bool wxRadioBox::Create( wxWindow *parent, wxWindowID id, const wxString& title,
|
||||
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();
|
||||
@@ -194,7 +195,7 @@ wxSize wxRadioBox::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;
|
||||
@@ -230,9 +231,8 @@ wxSize wxRadioBox::LayoutItems()
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
@@ -202,9 +202,11 @@ gtk_myfixed_set_shadow_type (GtkMyFixed *myfixed,
|
||||
|
||||
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;
|
||||
|
||||
@@ -216,6 +218,8 @@ gtk_myfixed_put (GtkMyFixed *myfixed,
|
||||
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));
|
||||
|
||||
@@ -232,10 +236,10 @@ gtk_myfixed_put (GtkMyFixed *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;
|
||||
@@ -244,6 +248,63 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
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)
|
||||
{
|
||||
@@ -252,13 +313,31 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
|
||||
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;
|
||||
}
|
||||
@@ -385,10 +464,6 @@ gtk_myfixed_size_request (GtkWidget *widget,
|
||||
|
||||
myfixed = GTK_MYFIXED (widget);
|
||||
|
||||
/*
|
||||
requisition->width = 0;
|
||||
requisition->height = 0;
|
||||
*/
|
||||
requisition->width = widget->requisition.width;
|
||||
requisition->height = widget->requisition.height;
|
||||
|
||||
@@ -407,7 +482,7 @@ gtk_myfixed_size_request (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
GtkAllocation *allocation)
|
||||
GtkAllocation *allocation)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
gint border;
|
||||
@@ -457,8 +532,8 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -466,7 +541,7 @@ gtk_myfixed_size_allocate (GtkWidget *widget,
|
||||
|
||||
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));
|
||||
@@ -480,7 +555,7 @@ gtk_myfixed_paint (GtkWidget *widget,
|
||||
|
||||
static void
|
||||
gtk_myfixed_draw (GtkWidget *widget,
|
||||
GdkRectangle *area)
|
||||
GdkRectangle *area)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
GtkMyFixedChild *child;
|
||||
@@ -509,7 +584,7 @@ gtk_myfixed_draw (GtkWidget *widget,
|
||||
|
||||
static gint
|
||||
gtk_myfixed_expose (GtkWidget *widget,
|
||||
GdkEventExpose *event)
|
||||
GdkEventExpose *event)
|
||||
{
|
||||
GtkMyFixed *myfixed;
|
||||
GtkMyFixedChild *child;
|
||||
@@ -550,7 +625,7 @@ gtk_myfixed_add (GtkContainer *container,
|
||||
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
|
||||
|
@@ -1444,11 +1444,9 @@ 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( child->m_widget,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
child->m_y,
|
||||
child->m_width,
|
||||
child->m_height );
|
||||
|
||||
if (parent->m_windowStyle & wxTAB_TRAVERSAL)
|
||||
{
|
||||
@@ -2037,55 +2035,42 @@ void wxWindow::DoSetSize( int x, int y, int width, int height, int sizeFlags )
|
||||
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;
|
||||
|
Reference in New Issue
Block a user