Still bit fiddling in wxImage.

SetSize rewritten.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@988 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
1998-11-11 14:19:46 +00:00
parent 0f358732e4
commit fb1585ae85
21 changed files with 900 additions and 704 deletions

View File

@@ -7,9 +7,6 @@ wxTreeCtrl
wxClipboard wxClipboard
-> On the way, but not functional yet. -> On the way, but not functional yet.
wxHelpController
-> Karsten ?
Fix printing of bitmaps Fix printing of bitmaps
-> No idea. -> No idea.

View File

@@ -68,6 +68,8 @@ class wxDialog: public wxPanel
/* /*
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
*/ */
virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO );
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual int ShowModal(void); virtual int ShowModal(void);
virtual void EndModal(int retCode); virtual void EndModal(int retCode);
@@ -83,18 +85,12 @@ class wxDialog: public wxPanel
virtual void Maximize(void) { } virtual void Maximize(void) { }
virtual void Restore(void) { } virtual void Restore(void) { }
private: // implementation
friend wxWindow;
friend wxDC;
friend wxRadioBox;
bool m_modalShowing; bool m_modalShowing;
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;
virtual void ImplementSetPosition();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -64,6 +64,9 @@ public:
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
virtual void SetClientSize( int const width, int const height ); virtual void SetClientSize( int const width, int const height );
virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO );
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
const wxString& name = "statusBar"); const wxString& name = "statusBar");
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
@@ -100,7 +103,6 @@ public:
// implementation // implementation
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates(); void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu); void DoMenuUpdates(wxMenu* menu);

View File

@@ -285,9 +285,6 @@ public:
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize();
virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );

View File

@@ -68,6 +68,8 @@ class wxDialog: public wxPanel
/* /*
void OnCharHook(wxKeyEvent& event); void OnCharHook(wxKeyEvent& event);
*/ */
virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO );
virtual bool Show( bool show ); virtual bool Show( bool show );
virtual int ShowModal(void); virtual int ShowModal(void);
virtual void EndModal(int retCode); virtual void EndModal(int retCode);
@@ -83,18 +85,12 @@ class wxDialog: public wxPanel
virtual void Maximize(void) { } virtual void Maximize(void) { }
virtual void Restore(void) { } virtual void Restore(void) { }
private: // implementation
friend wxWindow;
friend wxDC;
friend wxRadioBox;
bool m_modalShowing; bool m_modalShowing;
wxString m_title; wxString m_title;
wxIcon m_icon; wxIcon m_icon;
virtual void ImplementSetPosition();
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };

View File

@@ -64,6 +64,9 @@ public:
virtual void GetClientSize( int *width, int *height ) const; virtual void GetClientSize( int *width, int *height ) const;
virtual void SetClientSize( int const width, int const height ); virtual void SetClientSize( int const width, int const height );
virtual void SetSize( int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO );
virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0, virtual wxStatusBar* CreateStatusBar(int number=1, long style = wxST_SIZEGRIP, wxWindowID id = 0,
const wxString& name = "statusBar"); const wxString& name = "statusBar");
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id, virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
@@ -100,7 +103,6 @@ public:
// implementation // implementation
virtual void GtkOnSize( int x, int y, int width, int height ); virtual void GtkOnSize( int x, int y, int width, int height );
virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
void DoMenuUpdates(); void DoMenuUpdates();
void DoMenuUpdates(wxMenu* menu); void DoMenuUpdates(wxMenu* menu);

View File

@@ -285,9 +285,6 @@ public:
bool HasVMT(); bool HasVMT();
virtual void ImplementSetSize();
virtual void ImplementSetPosition();
virtual wxPoint GetClientAreaOrigin() const; virtual wxPoint GetClientAreaOrigin() const;
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags ); virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );

View File

@@ -130,6 +130,7 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
BEGIN_EVENT_TABLE(MyFrame,wxFrame) BEGIN_EVENT_TABLE(MyFrame,wxFrame)
EVT_MENU (ID_ABOUT, MyFrame::OnAbout) EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
EVT_MENU (ID_QUIT, MyFrame::OnQuit) EVT_MENU (ID_QUIT, MyFrame::OnQuit)
EVT_SIZE (MyFrame::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
MyFrame::MyFrame(void) : MyFrame::MyFrame(void) :
@@ -149,7 +150,7 @@ MyFrame::MyFrame(void) :
int widths[] = { -1, 100 }; int widths[] = { -1, 100 };
SetStatusWidths( 2, widths ); SetStatusWidths( 2, widths );
m_canvas = new MyCanvas( this, -1, wxPoint(2,62), wxSize(300-4,120-4) ); m_canvas = new MyCanvas( this, -1, wxPoint(0,0), wxSize(10,10) );
m_canvas->SetScrollbars( 10, 10, 50, 50 ); m_canvas->SetScrollbars( 10, 10, 50, 50 );
} }
@@ -163,6 +164,13 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
(void) wxMessageBox( "wxImage demo\nRobert Roebling (c) 1998", "About wxImage Demo", wxOK ); (void) wxMessageBox( "wxImage demo\nRobert Roebling (c) 1998", "About wxImage Demo", wxOK );
} }
void MyFrame::OnSize( wxSizeEvent &WXUNUSED(event) )
{
int w,h;
GetClientSize( &w, &h );
m_canvas->SetSize( w, h );
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// MyApp // MyApp
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View File

@@ -131,8 +131,7 @@ LIB_CPP_SRC=\
generic/statusbr.cpp \ generic/statusbr.cpp \
generic/tabg.cpp \ generic/tabg.cpp \
generic/textdlgg.cpp \ generic/textdlgg.cpp \
generic/treectrl.cpp \ generic/treectrl.cpp
generic/helpext.cpp
LIB_C_SRC=\ LIB_C_SRC=\
common/extended.c \ common/extended.c \

View File

@@ -413,7 +413,7 @@ wxBitmap::wxBitmap( const wxImage &image )
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask == 0xfc00)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp < 8) bpp = 8; if (bpp < 8) bpp = 8;
// Render // Render
@@ -554,7 +554,7 @@ wxImage wxBitmap::ConvertToImage() const
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask == 0xfc00)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
GdkColormap *cmap = gtk_widget_get_default_colormap(); GdkColormap *cmap = gtk_widget_get_default_colormap();

View File

@@ -27,15 +27,15 @@ extern wxList wxPendingDelete;
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{ {
/* /*
printf( "OnDelete from " ); printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->Close(); win->Close();
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -43,119 +43,119 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxDialog,wxPanel) BEGIN_EVENT_TABLE(wxDialog,wxPanel)
EVT_BUTTON (wxID_OK, wxDialog::OnOK) EVT_BUTTON (wxID_OK, wxDialog::OnOK)
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply) EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
EVT_CLOSE (wxDialog::OnCloseWindow) EVT_CLOSE (wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
wxDialog::wxDialog(void) wxDialog::wxDialog(void)
{ {
m_title = ""; m_title = "";
m_modalShowing = FALSE; m_modalShowing = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
wxDialog::wxDialog( wxWindow *parent, wxDialog::wxDialog( wxWindow *parent,
wxWindowID id, const wxString &title, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_modalShowing = FALSE; m_modalShowing = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
} }
bool wxDialog::Create( wxWindow *parent, bool wxDialog::Create( wxWindow *parent,
wxWindowID id, const wxString &title, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL); gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL);
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
SetTitle( title ); SetTitle( title );
if ((m_x != -1) || (m_y != -1)) if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;
} }
wxDialog::~wxDialog(void) wxDialog::~wxDialog(void)
{ {
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
void wxDialog::SetTitle(const wxString& title ) void wxDialog::SetTitle(const wxString& title )
{ {
m_title = title; m_title = title;
if (m_title.IsNull()) m_title = ""; if (m_title.IsNull()) m_title = "";
gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
} }
wxString wxDialog::GetTitle(void) const wxString wxDialog::GetTitle(void) const
{ {
return (wxString&)m_title; return (wxString&)m_title;
} }
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
{ {
if (Validate()) TransferDataFromWindow(); if (Validate()) TransferDataFromWindow();
} }
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
{ {
if (IsModal()) if (IsModal())
{ {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
else else
{ {
SetReturnCode(wxID_CANCEL); SetReturnCode(wxID_CANCEL);
this->Show(FALSE); this->Show(FALSE);
} }
} }
void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
{ {
if ( Validate() && TransferDataFromWindow()) if ( Validate() && TransferDataFromWindow())
{
if (IsModal())
{ {
EndModal(wxID_OK); if (IsModal())
{
EndModal(wxID_OK);
}
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
} }
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
}
} }
void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
@@ -165,66 +165,129 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
bool wxDialog::OnClose(void) bool wxDialog::OnClose(void)
{ {
static wxList closing; static wxList closing;
if (closing.Member(this)) return FALSE; // no loops if (closing.Member(this)) return FALSE; // no loops
closing.Append(this); closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this ); cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); GetEventHandler()->ProcessEvent(cancelEvent);
closing.DeleteObject(this); closing.DeleteObject(this);
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void) bool wxDialog::Destroy(void)
{ {
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) if (GetEventHandler()->OnClose() || event.GetForce())
{ {
this->Destroy(); this->Destroy();
} }
} }
void wxDialog::ImplementSetPosition(void) void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != -1) || (m_y != -1)) wxASSERT_MSG( (m_widget != NULL), "invalid window" );
gtk_widget_set_uposition( m_widget, m_x, m_y );
// Don't do anything for children of wxMDIChildFrame
if (!m_wxwindow) return;
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int old_x = m_x;
int old_y = m_y;
int old_width = m_width;
int old_height = m_height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y );
}
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); int x,y;
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
bool wxDialog::Show( bool show ) bool wxDialog::Show( bool show )
{ {
if (!show && IsModal()) if (!show && IsModal())
{ {
EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL );
} }
wxWindow::Show( show ); wxWindow::Show( show );
if (show) InitDialog(); if (show) InitDialog();
return TRUE; return TRUE;
} }
bool wxDialog::IsModal(void) const bool wxDialog::IsModal(void) const
{ {
return m_modalShowing; return m_modalShowing;
} }
void wxDialog::SetModal( bool WXUNUSED(flag) ) void wxDialog::SetModal( bool WXUNUSED(flag) )
@@ -235,58 +298,58 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
else else
if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL;
*/ */
wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); wxFAIL_MSG( "wxDialog:SetModal obsolete now" );
} }
int wxDialog::ShowModal(void) int wxDialog::ShowModal(void)
{ {
if (IsModal()) if (IsModal())
{ {
wxFAIL_MSG( "wxDialog:ShowModal called twice" ); wxFAIL_MSG( "wxDialog:ShowModal called twice" );
return GetReturnCode();
}
Show( TRUE );
m_modalShowing = TRUE;
gtk_grab_add( m_widget );
gtk_main();
gtk_grab_remove( m_widget );
return GetReturnCode(); return GetReturnCode();
}
Show( TRUE );
m_modalShowing = TRUE;
gtk_grab_add( m_widget );
gtk_main();
gtk_grab_remove( m_widget );
return GetReturnCode();
} }
void wxDialog::EndModal( int retCode ) void wxDialog::EndModal( int retCode )
{ {
SetReturnCode( retCode ); SetReturnCode( retCode );
if (!IsModal()) if (!IsModal())
{ {
wxFAIL_MSG( "wxDialog:EndModal called twice" ); wxFAIL_MSG( "wxDialog:EndModal called twice" );
return; return;
} }
m_modalShowing = FALSE; m_modalShowing = FALSE;
gtk_main_quit(); gtk_main_quit();
Show( FALSE ); Show( FALSE );
} }
void wxDialog::InitDialog(void) void wxDialog::InitDialog(void)
{ {
wxWindow::InitDialog(); wxWindow::InitDialog();
} }
void wxDialog::SetIcon( const wxIcon &icon ) void wxDialog::SetIcon( const wxIcon &icon )
{ {
m_icon = icon; m_icon = icon;
if (!icon.Ok()) return; if (!icon.Ok()) return;
wxMask *mask = icon.GetMask(); wxMask *mask = icon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL; GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap(); if (mask) bm = mask->GetBitmap();
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
} }

View File

@@ -41,16 +41,16 @@ extern wxList wxPendingDelete;
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
/* /*
printf( "OnFrameResize from " ); printf( "OnFrameResize from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -60,15 +60,15 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win ) static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
{ {
/* /*
printf( "OnDelete from " ); printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->Close(); win->Close();
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -77,12 +77,12 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
{ {
if (!win->HasVMT()) return FALSE; if (!win->HasVMT()) return FALSE;
win->m_x = event->x; win->m_x = event->x;
win->m_y = event->y; win->m_y = event->y;
return FALSE; return FALSE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -90,168 +90,228 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_SIZE(wxFrame::OnSize) EVT_SIZE(wxFrame::OnSize)
EVT_CLOSE(wxFrame::OnCloseWindow) EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_IDLE(wxFrame::OnIdle) EVT_IDLE(wxFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
wxFrame::wxFrame() wxFrame::wxFrame()
{ {
m_frameMenuBar = (wxMenuBar *) NULL; m_frameMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_frameMenuBar = (wxMenuBar *) NULL; m_frameMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_title = title; m_title = title;
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
m_widget = gtk_window_new( win_type ); m_widget = gtk_window_new( win_type );
if ((size.x != -1) && (size.y != -1)) if ((size.x != -1) && (size.y != -1))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if ((pos.x != -1) && (pos.y != -1)) if ((pos.x != -1) && (pos.y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
gtk_window_set_title( GTK_WINDOW(m_widget), title ); gtk_window_set_title( GTK_WINDOW(m_widget), title );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL ); gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;
} }
wxFrame::~wxFrame() wxFrame::~wxFrame()
{ {
if (m_frameMenuBar) delete m_frameMenuBar; if (m_frameMenuBar) delete m_frameMenuBar;
if (m_frameStatusBar) delete m_frameStatusBar; if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar; if (m_frameToolBar) delete m_frameToolBar;
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
bool wxFrame::Show( bool show ) bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (show) if (show)
{ {
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); wxSizeEvent event( wxSize(m_width,m_height), GetId() );
m_sizeSet = FALSE; m_sizeSet = FALSE;
ProcessEvent( event ); ProcessEvent( event );
} }
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
void wxFrame::OnCloseWindow( wxCloseEvent &event ) void wxFrame::OnCloseWindow( wxCloseEvent &event )
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
} }
bool wxFrame::Destroy() bool wxFrame::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
wxPoint wxFrame::GetClientAreaOrigin() const wxPoint wxFrame::GetClientAreaOrigin() const
{ {
wxPoint pt(0, 0); wxPoint pt(0, 0);
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
int h = 0; int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h ); m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2; pt.y += h + 2;
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
int h = 0; int h = 0;
m_frameToolBar->GetSize( (int*)NULL, &h ); m_frameToolBar->GetSize( (int*)NULL, &h );
pt.y += h; pt.y += h;
} }
return pt; return pt;
} }
void wxFrame::ImplementSetPosition(void) void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != -1) || (m_y != -1)) wxASSERT_MSG( (m_widget != NULL), "invalid window" );
gtk_widget_set_uposition( m_widget, m_x, m_y );
// Don't do anything for children of wxMDIChildFrame
if (!m_wxwindow) return;
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int old_x = m_x;
int old_y = m_y;
int old_width = m_width;
int old_height = m_height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y );
}
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; int x,y;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::GetClientSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxWindow::GetClientSize( width, height ); wxWindow::GetClientSize( width, height );
if (height) if (height)
{
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
if (m_frameToolBar)
{ {
int y = 0; if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
m_frameToolBar->GetSize( (int *) NULL, &y ); if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
(*height) -= y; if (m_frameToolBar)
{
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
(*height) -= y;
}
} }
}
} }
void wxFrame::SetClientSize( int const width, int const height ) void wxFrame::SetClientSize( int const width, int const height )

View File

@@ -119,10 +119,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
int x = 0; m_mdiMenuBar->m_x = 1;
int y = 0; m_mdiMenuBar->m_y = 1;
GetClientSize( &x, &y ); m_mdiMenuBar->m_width = m_width-2;
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS ); m_mdiMenuBar->m_height = wxMENU_HEIGHT-2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
} }
} }
@@ -132,10 +134,12 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
m_mdiMenuBar = menu_bar; m_mdiMenuBar = menu_bar;
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
int x = 0; m_mdiMenuBar->m_x = 1;
int y = 0; m_mdiMenuBar->m_y = 1;
GetClientSize( &x, &y ); m_mdiMenuBar->m_width = m_width-2;
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS ); m_mdiMenuBar->m_height = wxMENU_HEIGHT-2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }

View File

@@ -169,6 +169,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
if (child->widget == widget) if (child->widget == widget)
{ {
if ((child->x == x) && (child->y == y)) return;
child->x = x; child->x = x;
child->y = y; child->y = y;

View File

@@ -1315,99 +1315,81 @@ void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
} }
} }
void wxWindow::ImplementSetSize()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
gtk_widget_set_usize( m_widget, m_width, m_height );
}
void wxWindow::ImplementSetPosition()
{
if (!m_parent)
{
wxFAIL_MSG( "wxWindow::SetSize error.\n" );
return;
}
if ((m_parent) && (m_parent->m_wxwindow))
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
// Don't do anything for children of wxNotebook and wxMDIChildFrame
}
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
if (m_resizing) return; // I don't like recursions // Don't do anything for children of wxNotebook
m_resizing = TRUE; if (m_parent->m_wxwindow == NULL) return;
int newX = x; if (m_resizing) return; // I don't like recursions
int newY = y; m_resizing = TRUE;
int newW = width;
int newH = height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) int old_width = m_width;
{ int old_height = m_height;
if (newX == -1) newX = m_x;
if (newY == -1) newY = m_y;
if (newW == -1) newW = m_width;
if (newH == -1) newH = m_height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{ {
if (newW == -1) newW = 80; if (x != -1) m_x = x;
} if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{ {
if (newH == -1) newH = 26; if (width == -1) m_width = 80;
} }
AdjustForParentClientOrigin( newX, newY, sizeFlags ); if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet)) if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
{ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
m_x = newX; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
m_y = newY; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
ImplementSetPosition();
}
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet)) wxPoint pt( m_parent->GetClientAreaOrigin() );
{ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
m_width = newW;
m_height = newH;
ImplementSetSize();
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); if ((old_width != m_width) || (old_height != m_height))
event.SetEventObject( this ); gtk_widget_set_usize( m_widget, m_width, m_height );
ProcessEvent( event );
m_resizing = FALSE; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxWindow::SetSize( int width, int height ) void wxWindow::SetSize( int width, int height )
{ {
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
} }
void wxWindow::Move( int x, int y ) void wxWindow::Move( int x, int y )
{ {
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
} }
void wxWindow::GetSize( int *width, int *height ) const void wxWindow::GetSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (width) (*width) = m_width; if (width) (*width) = m_width;
if (height) (*height) = m_height; if (height) (*height) = m_height;
} }
void wxWindow::SetClientSize( int width, int height ) void wxWindow::SetClientSize( int width, int height )
@@ -1536,18 +1518,8 @@ void wxWindow::GetPosition( int *x, int *y ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
int xx = m_x; if (x) (*x) = m_x;
int yy = m_y; if (y) (*y) = 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 ) void wxWindow::ClientToScreen( int *x, int *y )
@@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) int x = m_x;
int y = m_y;
if (m_parent)
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition();
}
else
{
if (m_parent)
{
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
ImplementSetPosition();
}
} }
else
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
}
Move( x, y );
} }
void wxWindow::Fit() void wxWindow::Fit()

View File

@@ -413,7 +413,7 @@ wxBitmap::wxBitmap( const wxImage &image )
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask == 0xfc00)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
if (bpp < 8) bpp = 8; if (bpp < 8) bpp = 8;
// Render // Render
@@ -554,7 +554,7 @@ wxImage wxBitmap::ConvertToImage() const
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap ); GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent ); if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
int bpp = visual->depth; int bpp = visual->depth;
if ((bpp == 16) && (visual->red_mask == 0xfc00)) bpp = 15; if ((bpp == 16) && (visual->red_mask != 0xf800)) bpp = 15;
GdkColormap *cmap = gtk_widget_get_default_colormap(); GdkColormap *cmap = gtk_widget_get_default_colormap();

View File

@@ -27,15 +27,15 @@ extern wxList wxPendingDelete;
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win ) bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
{ {
/* /*
printf( "OnDelete from " ); printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->Close(); win->Close();
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -43,119 +43,119 @@ bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxDialog,wxPanel) BEGIN_EVENT_TABLE(wxDialog,wxPanel)
EVT_BUTTON (wxID_OK, wxDialog::OnOK) EVT_BUTTON (wxID_OK, wxDialog::OnOK)
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply) EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
EVT_CLOSE (wxDialog::OnCloseWindow) EVT_CLOSE (wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
wxDialog::wxDialog(void) wxDialog::wxDialog(void)
{ {
m_title = ""; m_title = "";
m_modalShowing = FALSE; m_modalShowing = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
wxDialog::wxDialog( wxWindow *parent, wxDialog::wxDialog( wxWindow *parent,
wxWindowID id, const wxString &title, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_modalShowing = FALSE; m_modalShowing = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
} }
bool wxDialog::Create( wxWindow *parent, bool wxDialog::Create( wxWindow *parent,
wxWindowID id, const wxString &title, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL ); m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL); gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL);
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
SetTitle( title ); SetTitle( title );
if ((m_x != -1) || (m_y != -1)) if ((m_x != -1) || (m_y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;
} }
wxDialog::~wxDialog(void) wxDialog::~wxDialog(void)
{ {
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
void wxDialog::SetTitle(const wxString& title ) void wxDialog::SetTitle(const wxString& title )
{ {
m_title = title; m_title = title;
if (m_title.IsNull()) m_title = ""; if (m_title.IsNull()) m_title = "";
gtk_window_set_title( GTK_WINDOW(m_widget), m_title ); gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
} }
wxString wxDialog::GetTitle(void) const wxString wxDialog::GetTitle(void) const
{ {
return (wxString&)m_title; return (wxString&)m_title;
} }
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
{ {
if (Validate()) TransferDataFromWindow(); if (Validate()) TransferDataFromWindow();
} }
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
{ {
if (IsModal()) if (IsModal())
{ {
EndModal(wxID_CANCEL); EndModal(wxID_CANCEL);
} }
else else
{ {
SetReturnCode(wxID_CANCEL); SetReturnCode(wxID_CANCEL);
this->Show(FALSE); this->Show(FALSE);
} }
} }
void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) ) void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
{ {
if ( Validate() && TransferDataFromWindow()) if ( Validate() && TransferDataFromWindow())
{
if (IsModal())
{ {
EndModal(wxID_OK); if (IsModal())
{
EndModal(wxID_OK);
}
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
} }
else
{
SetReturnCode(wxID_OK);
this->Show(FALSE);
}
}
} }
void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) ) void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
@@ -165,66 +165,129 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
bool wxDialog::OnClose(void) bool wxDialog::OnClose(void)
{ {
static wxList closing; static wxList closing;
if (closing.Member(this)) return FALSE; // no loops if (closing.Member(this)) return FALSE; // no loops
closing.Append(this); closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this ); cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); GetEventHandler()->ProcessEvent(cancelEvent);
closing.DeleteObject(this); closing.DeleteObject(this);
return FALSE; return FALSE;
} }
bool wxDialog::Destroy(void) bool wxDialog::Destroy(void)
{ {
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) if (GetEventHandler()->OnClose() || event.GetForce())
{ {
this->Destroy(); this->Destroy();
} }
} }
void wxDialog::ImplementSetPosition(void) void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != -1) || (m_y != -1)) wxASSERT_MSG( (m_widget != NULL), "invalid window" );
gtk_widget_set_uposition( m_widget, m_x, m_y );
// Don't do anything for children of wxMDIChildFrame
if (!m_wxwindow) return;
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int old_x = m_x;
int old_y = m_y;
int old_width = m_width;
int old_height = m_height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y );
}
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); int x,y;
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
bool wxDialog::Show( bool show ) bool wxDialog::Show( bool show )
{ {
if (!show && IsModal()) if (!show && IsModal())
{ {
EndModal( wxID_CANCEL ); EndModal( wxID_CANCEL );
} }
wxWindow::Show( show ); wxWindow::Show( show );
if (show) InitDialog(); if (show) InitDialog();
return TRUE; return TRUE;
} }
bool wxDialog::IsModal(void) const bool wxDialog::IsModal(void) const
{ {
return m_modalShowing; return m_modalShowing;
} }
void wxDialog::SetModal( bool WXUNUSED(flag) ) void wxDialog::SetModal( bool WXUNUSED(flag) )
@@ -235,58 +298,58 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
else else
if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL; if (m_windowStyle & wxDIALOG_MODAL) m_windowStyle -= wxDIALOG_MODAL;
*/ */
wxFAIL_MSG( "wxDialog:SetModal obsolete now" ); wxFAIL_MSG( "wxDialog:SetModal obsolete now" );
} }
int wxDialog::ShowModal(void) int wxDialog::ShowModal(void)
{ {
if (IsModal()) if (IsModal())
{ {
wxFAIL_MSG( "wxDialog:ShowModal called twice" ); wxFAIL_MSG( "wxDialog:ShowModal called twice" );
return GetReturnCode();
}
Show( TRUE );
m_modalShowing = TRUE;
gtk_grab_add( m_widget );
gtk_main();
gtk_grab_remove( m_widget );
return GetReturnCode(); return GetReturnCode();
}
Show( TRUE );
m_modalShowing = TRUE;
gtk_grab_add( m_widget );
gtk_main();
gtk_grab_remove( m_widget );
return GetReturnCode();
} }
void wxDialog::EndModal( int retCode ) void wxDialog::EndModal( int retCode )
{ {
SetReturnCode( retCode ); SetReturnCode( retCode );
if (!IsModal()) if (!IsModal())
{ {
wxFAIL_MSG( "wxDialog:EndModal called twice" ); wxFAIL_MSG( "wxDialog:EndModal called twice" );
return; return;
} }
m_modalShowing = FALSE; m_modalShowing = FALSE;
gtk_main_quit(); gtk_main_quit();
Show( FALSE ); Show( FALSE );
} }
void wxDialog::InitDialog(void) void wxDialog::InitDialog(void)
{ {
wxWindow::InitDialog(); wxWindow::InitDialog();
} }
void wxDialog::SetIcon( const wxIcon &icon ) void wxDialog::SetIcon( const wxIcon &icon )
{ {
m_icon = icon; m_icon = icon;
if (!icon.Ok()) return; if (!icon.Ok()) return;
wxMask *mask = icon.GetMask(); wxMask *mask = icon.GetMask();
GdkBitmap *bm = (GdkBitmap *) NULL; GdkBitmap *bm = (GdkBitmap *) NULL;
if (mask) bm = mask->GetBitmap(); if (mask) bm = mask->GetBitmap();
gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm ); gdk_window_set_icon( m_widget->window, (GdkWindow *) NULL, icon.GetPixmap(), bm );
} }

View File

@@ -41,16 +41,16 @@ extern wxList wxPendingDelete;
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win ) static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
{ {
if (!win->HasVMT()) return; if (!win->HasVMT()) return;
/* /*
printf( "OnFrameResize from " ); printf( "OnFrameResize from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height ); win->GtkOnSize( alloc->x, alloc->y, alloc->width, alloc->height );
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -60,15 +60,15 @@ static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation*
static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win ) static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxFrame *win )
{ {
/* /*
printf( "OnDelete from " ); printf( "OnDelete from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName()) if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() ); printf( win->GetClassInfo()->GetClassName() );
printf( ".\n" ); printf( ".\n" );
*/ */
win->Close(); win->Close();
return TRUE; return TRUE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -77,12 +77,12 @@ static gint gtk_frame_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WX
static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win ) static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventConfigure *event, wxFrame *win )
{ {
if (!win->HasVMT()) return FALSE; if (!win->HasVMT()) return FALSE;
win->m_x = event->x; win->m_x = event->x;
win->m_y = event->y; win->m_y = event->y;
return FALSE; return FALSE;
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -90,168 +90,228 @@ static gint gtk_frame_configure_callback( GtkWidget *WXUNUSED(widget), GdkEventC
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrame, wxWindow) BEGIN_EVENT_TABLE(wxFrame, wxWindow)
EVT_SIZE(wxFrame::OnSize) EVT_SIZE(wxFrame::OnSize)
EVT_CLOSE(wxFrame::OnCloseWindow) EVT_CLOSE(wxFrame::OnCloseWindow)
EVT_IDLE(wxFrame::OnIdle) EVT_IDLE(wxFrame::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
wxFrame::wxFrame() wxFrame::wxFrame()
{ {
m_frameMenuBar = (wxMenuBar *) NULL; m_frameMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title, wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_frameMenuBar = (wxMenuBar *) NULL; m_frameMenuBar = (wxMenuBar *) NULL;
m_frameStatusBar = (wxStatusBar *) NULL; m_frameStatusBar = (wxStatusBar *) NULL;
m_frameToolBar = (wxToolBar *) NULL; m_frameToolBar = (wxToolBar *) NULL;
m_sizeSet = FALSE; m_sizeSet = FALSE;
Create( parent, id, title, pos, size, style, name ); Create( parent, id, title, pos, size, style, name );
wxTopLevelWindows.Insert( this ); wxTopLevelWindows.Insert( this );
} }
bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title, bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
const wxPoint &pos, const wxSize &size, const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) long style, const wxString &name )
{ {
m_needParent = FALSE; m_needParent = FALSE;
PreCreation( parent, id, pos, size, style, name ); PreCreation( parent, id, pos, size, style, name );
m_title = title; m_title = title;
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL; GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP; if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
m_widget = gtk_window_new( win_type ); m_widget = gtk_window_new( win_type );
if ((size.x != -1) && (size.y != -1)) if ((size.x != -1) && (size.y != -1))
gtk_widget_set_usize( m_widget, m_width, m_height ); gtk_widget_set_usize( m_widget, m_width, m_height );
if ((pos.x != -1) && (pos.y != -1)) if ((pos.x != -1) && (pos.y != -1))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
gtk_window_set_title( GTK_WINDOW(m_widget), title ); gtk_window_set_title( GTK_WINDOW(m_widget), title );
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL ); gtk_widget_set( m_widget, "GtkWindow::allow_shrink", TRUE, NULL );
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event", gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
m_wxwindow = gtk_myfixed_new(); m_wxwindow = gtk_myfixed_new();
gtk_widget_show( m_wxwindow ); gtk_widget_show( m_wxwindow );
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS ); GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow ); gtk_container_add( GTK_CONTAINER(m_widget), m_wxwindow );
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate", gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event", gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this ); GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
if (m_parent) m_parent->AddChild( this ); if (m_parent) m_parent->AddChild( this );
PostCreation(); PostCreation();
return TRUE; return TRUE;
} }
wxFrame::~wxFrame() wxFrame::~wxFrame()
{ {
if (m_frameMenuBar) delete m_frameMenuBar; if (m_frameMenuBar) delete m_frameMenuBar;
if (m_frameStatusBar) delete m_frameStatusBar; if (m_frameStatusBar) delete m_frameStatusBar;
if (m_frameToolBar) delete m_frameToolBar; if (m_frameToolBar) delete m_frameToolBar;
wxTopLevelWindows.DeleteObject( this ); wxTopLevelWindows.DeleteObject( this );
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop(); if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
} }
bool wxFrame::Show( bool show ) bool wxFrame::Show( bool show )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (show) if (show)
{ {
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); wxSizeEvent event( wxSize(m_width,m_height), GetId() );
m_sizeSet = FALSE; m_sizeSet = FALSE;
ProcessEvent( event ); ProcessEvent( event );
} }
return wxWindow::Show( show ); return wxWindow::Show( show );
} }
void wxFrame::OnCloseWindow( wxCloseEvent &event ) void wxFrame::OnCloseWindow( wxCloseEvent &event )
{ {
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy(); if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
} }
bool wxFrame::Destroy() bool wxFrame::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
wxPoint wxFrame::GetClientAreaOrigin() const wxPoint wxFrame::GetClientAreaOrigin() const
{ {
wxPoint pt(0, 0); wxPoint pt(0, 0);
if (m_frameMenuBar) if (m_frameMenuBar)
{ {
int h = 0; int h = 0;
m_frameMenuBar->GetSize( (int*)NULL, &h ); m_frameMenuBar->GetSize( (int*)NULL, &h );
pt.y += h + 2; pt.y += h + 2;
} }
if (m_frameToolBar) if (m_frameToolBar)
{ {
int h = 0; int h = 0;
m_frameToolBar->GetSize( (int*)NULL, &h ); m_frameToolBar->GetSize( (int*)NULL, &h );
pt.y += h; pt.y += h;
} }
return pt; return pt;
} }
void wxFrame::ImplementSetPosition(void) void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
if ((m_x != -1) || (m_y != -1)) wxASSERT_MSG( (m_widget != NULL), "invalid window" );
gtk_widget_set_uposition( m_widget, m_x, m_y );
// Don't do anything for children of wxMDIChildFrame
if (!m_wxwindow) return;
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int old_x = m_x;
int old_y = m_y;
int old_width = m_width;
int old_height = m_height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{
if (x != -1) m_x = x;
if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
if ((m_x != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y );
}
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; int x,y;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::GetClientSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
wxWindow::GetClientSize( width, height ); wxWindow::GetClientSize( width, height );
if (height) if (height)
{
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
if (m_frameToolBar)
{ {
int y = 0; if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
m_frameToolBar->GetSize( (int *) NULL, &y ); if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
(*height) -= y; if (m_frameToolBar)
{
int y = 0;
m_frameToolBar->GetSize( (int *) NULL, &y );
(*height) -= y;
}
} }
}
} }
void wxFrame::SetClientSize( int const width, int const height ) void wxFrame::SetClientSize( int const width, int const height )

View File

@@ -119,10 +119,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
int x = 0; m_mdiMenuBar->m_x = 1;
int y = 0; m_mdiMenuBar->m_y = 1;
GetClientSize( &x, &y ); m_mdiMenuBar->m_width = m_width-2;
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS ); m_mdiMenuBar->m_height = wxMENU_HEIGHT-2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
} }
} }
@@ -132,10 +134,12 @@ void wxMDIParentFrame::SetMDIMenuBar( wxMenuBar *menu_bar )
m_mdiMenuBar = menu_bar; m_mdiMenuBar = menu_bar;
if (m_mdiMenuBar) if (m_mdiMenuBar)
{ {
int x = 0; m_mdiMenuBar->m_x = 1;
int y = 0; m_mdiMenuBar->m_y = 1;
GetClientSize( &x, &y ); m_mdiMenuBar->m_width = m_width-2;
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS ); m_mdiMenuBar->m_height = wxMENU_HEIGHT-2;
gtk_myfixed_move( GTK_MYFIXED(m_wxwindow), m_mdiMenuBar->m_widget, 1, 1 );
gtk_widget_set_usize( m_mdiMenuBar->m_widget, m_width-2, wxMENU_HEIGHT-2 );
m_mdiMenuBar->Show( TRUE ); m_mdiMenuBar->Show( TRUE );
} }
} }

View File

@@ -169,6 +169,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
if (child->widget == widget) if (child->widget == widget)
{ {
if ((child->x == x) && (child->y == y)) return;
child->x = x; child->x = x;
child->y = y; child->y = y;

View File

@@ -1315,99 +1315,81 @@ void wxWindow::AdjustForParentClientOrigin( int& x, int& y, int sizeFlags )
} }
} }
void wxWindow::ImplementSetSize()
{
if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
gtk_widget_set_usize( m_widget, m_width, m_height );
}
void wxWindow::ImplementSetPosition()
{
if (!m_parent)
{
wxFAIL_MSG( "wxWindow::SetSize error.\n" );
return;
}
if ((m_parent) && (m_parent->m_wxwindow))
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x, m_y );
// Don't do anything for children of wxNotebook and wxMDIChildFrame
}
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags ) void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
if (m_resizing) return; // I don't like recursions // Don't do anything for children of wxNotebook
m_resizing = TRUE; if (m_parent->m_wxwindow == NULL) return;
int newX = x; if (m_resizing) return; // I don't like recursions
int newY = y; m_resizing = TRUE;
int newW = width;
int newH = height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) int old_width = m_width;
{ int old_height = m_height;
if (newX == -1) newX = m_x;
if (newY == -1) newY = m_y;
if (newW == -1) newW = m_width;
if (newH == -1) newH = m_height;
}
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH) if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{ {
if (newW == -1) newW = 80; if (x != -1) m_x = x;
} if (y != -1) m_y = y;
if (width != -1) m_width = width;
if (height != -1) m_height = height;
}
else
{
m_x = x;
m_y = y;
m_width = width;
m_height = height;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT) if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
{ {
if (newH == -1) newH = 26; if (width == -1) m_width = 80;
} }
AdjustForParentClientOrigin( newX, newY, sizeFlags ); if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (height == -1) m_height = 26;
}
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet)) if ((m_minWidth != -1) && (m_width < m_minWidth)) m_width = m_minWidth;
{ if ((m_minHeight != -1) && (m_height < m_minHeight)) m_height = m_minHeight;
m_x = newX; if ((m_maxWidth != -1) && (m_width > m_maxWidth)) m_width = m_minWidth;
m_y = newY; if ((m_maxHeight != -1) && (m_height > m_maxHeight)) m_height = m_minHeight;
ImplementSetPosition();
}
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet)) wxPoint pt( m_parent->GetClientAreaOrigin() );
{ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
m_width = newW;
m_height = newH;
ImplementSetSize();
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); if ((old_width != m_width) || (old_height != m_height))
event.SetEventObject( this ); gtk_widget_set_usize( m_widget, m_width, m_height );
ProcessEvent( event );
m_resizing = FALSE; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
} }
void wxWindow::SetSize( int width, int height ) void wxWindow::SetSize( int width, int height )
{ {
SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING ); SetSize( -1, -1, width, height, wxSIZE_USE_EXISTING );
} }
void wxWindow::Move( int x, int y ) void wxWindow::Move( int x, int y )
{ {
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING ); SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
} }
void wxWindow::GetSize( int *width, int *height ) const void wxWindow::GetSize( int *width, int *height ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (width) (*width) = m_width; if (width) (*width) = m_width;
if (height) (*height) = m_height; if (height) (*height) = m_height;
} }
void wxWindow::SetClientSize( int width, int height ) void wxWindow::SetClientSize( int width, int height )
@@ -1536,18 +1518,8 @@ void wxWindow::GetPosition( int *x, int *y ) const
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
int xx = m_x; if (x) (*x) = m_x;
int yy = m_y; if (y) (*y) = 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 ) void wxWindow::ClientToScreen( int *x, int *y )
@@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) int x = m_x;
int y = m_y;
if (m_parent)
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition();
}
else
{
if (m_parent)
{
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
ImplementSetPosition();
}
} }
else
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
}
Move( x, y );
} }
void wxWindow::Fit() void wxWindow::Fit()