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:
parent
0f358732e4
commit
fb1585ae85
@ -7,9 +7,6 @@ wxTreeCtrl
|
||||
wxClipboard
|
||||
-> On the way, but not functional yet.
|
||||
|
||||
wxHelpController
|
||||
-> Karsten ?
|
||||
|
||||
Fix printing of bitmaps
|
||||
-> No idea.
|
||||
|
||||
|
@ -68,6 +68,8 @@ class wxDialog: public wxPanel
|
||||
/*
|
||||
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 int ShowModal(void);
|
||||
virtual void EndModal(int retCode);
|
||||
@ -83,18 +85,12 @@ class wxDialog: public wxPanel
|
||||
virtual void Maximize(void) { }
|
||||
virtual void Restore(void) { }
|
||||
|
||||
private:
|
||||
// implementation
|
||||
|
||||
friend wxWindow;
|
||||
friend wxDC;
|
||||
friend wxRadioBox;
|
||||
|
||||
bool m_modalShowing;
|
||||
wxString m_title;
|
||||
wxIcon m_icon;
|
||||
|
||||
virtual void ImplementSetPosition();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
};
|
||||
|
@ -64,6 +64,9 @@ public:
|
||||
virtual void GetClientSize( int *width, int *height ) const;
|
||||
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,
|
||||
const wxString& name = "statusBar");
|
||||
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
||||
@ -100,7 +103,6 @@ public:
|
||||
// implementation
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void ImplementSetPosition();
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
void DoMenuUpdates();
|
||||
void DoMenuUpdates(wxMenu* menu);
|
||||
|
@ -285,9 +285,6 @@ public:
|
||||
|
||||
bool HasVMT();
|
||||
|
||||
virtual void ImplementSetSize();
|
||||
virtual void ImplementSetPosition();
|
||||
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
|
||||
|
||||
|
@ -68,6 +68,8 @@ class wxDialog: public wxPanel
|
||||
/*
|
||||
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 int ShowModal(void);
|
||||
virtual void EndModal(int retCode);
|
||||
@ -83,18 +85,12 @@ class wxDialog: public wxPanel
|
||||
virtual void Maximize(void) { }
|
||||
virtual void Restore(void) { }
|
||||
|
||||
private:
|
||||
// implementation
|
||||
|
||||
friend wxWindow;
|
||||
friend wxDC;
|
||||
friend wxRadioBox;
|
||||
|
||||
bool m_modalShowing;
|
||||
wxString m_title;
|
||||
wxIcon m_icon;
|
||||
|
||||
virtual void ImplementSetPosition();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
};
|
||||
|
@ -64,6 +64,9 @@ public:
|
||||
virtual void GetClientSize( int *width, int *height ) const;
|
||||
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,
|
||||
const wxString& name = "statusBar");
|
||||
virtual wxStatusBar *OnCreateStatusBar( int number, long style, wxWindowID id,
|
||||
@ -100,7 +103,6 @@ public:
|
||||
// implementation
|
||||
|
||||
virtual void GtkOnSize( int x, int y, int width, int height );
|
||||
virtual void ImplementSetPosition();
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
void DoMenuUpdates();
|
||||
void DoMenuUpdates(wxMenu* menu);
|
||||
|
@ -285,9 +285,6 @@ public:
|
||||
|
||||
bool HasVMT();
|
||||
|
||||
virtual void ImplementSetSize();
|
||||
virtual void ImplementSetPosition();
|
||||
|
||||
virtual wxPoint GetClientAreaOrigin() const;
|
||||
virtual void AdjustForParentClientOrigin( int& x, int& y, int sizeFlags );
|
||||
|
||||
|
@ -130,6 +130,7 @@ IMPLEMENT_DYNAMIC_CLASS( MyFrame, wxFrame )
|
||||
BEGIN_EVENT_TABLE(MyFrame,wxFrame)
|
||||
EVT_MENU (ID_ABOUT, MyFrame::OnAbout)
|
||||
EVT_MENU (ID_QUIT, MyFrame::OnQuit)
|
||||
EVT_SIZE (MyFrame::OnSize)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
MyFrame::MyFrame(void) :
|
||||
@ -149,7 +150,7 @@ MyFrame::MyFrame(void) :
|
||||
int widths[] = { -1, 100 };
|
||||
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 );
|
||||
}
|
||||
|
||||
@ -163,6 +164,13 @@ void MyFrame::OnAbout( wxCommandEvent &WXUNUSED(event) )
|
||||
(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
|
||||
//-----------------------------------------------------------------------------
|
||||
|
@ -131,8 +131,7 @@ LIB_CPP_SRC=\
|
||||
generic/statusbr.cpp \
|
||||
generic/tabg.cpp \
|
||||
generic/textdlgg.cpp \
|
||||
generic/treectrl.cpp \
|
||||
generic/helpext.cpp
|
||||
generic/treectrl.cpp
|
||||
|
||||
LIB_C_SRC=\
|
||||
common/extended.c \
|
||||
|
@ -413,7 +413,7 @@ wxBitmap::wxBitmap( const wxImage &image )
|
||||
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
|
||||
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
||||
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;
|
||||
|
||||
// Render
|
||||
@ -554,7 +554,7 @@ wxImage wxBitmap::ConvertToImage() const
|
||||
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
|
||||
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
||||
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();
|
||||
|
||||
|
@ -27,15 +27,15 @@ extern wxList wxPendingDelete;
|
||||
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
|
||||
{
|
||||
/*
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
|
||||
|
||||
wxDialog::wxDialog(void)
|
||||
{
|
||||
m_title = "";
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_title = "";
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
wxDialog::wxDialog( wxWindow *parent,
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
}
|
||||
|
||||
bool wxDialog::Create( wxWindow *parent,
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
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 );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
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_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
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)
|
||||
{
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
}
|
||||
|
||||
void wxDialog::SetTitle(const wxString& title )
|
||||
{
|
||||
m_title = title;
|
||||
if (m_title.IsNull()) m_title = "";
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||
m_title = title;
|
||||
if (m_title.IsNull()) m_title = "";
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||
}
|
||||
|
||||
wxString wxDialog::GetTitle(void) const
|
||||
{
|
||||
return (wxString&)m_title;
|
||||
return (wxString&)m_title;
|
||||
}
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (Validate()) TransferDataFromWindow();
|
||||
if (Validate()) TransferDataFromWindow();
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow())
|
||||
{
|
||||
if (IsModal())
|
||||
if ( Validate() && TransferDataFromWindow())
|
||||
{
|
||||
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) )
|
||||
@ -165,66 +165,129 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
|
||||
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);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
closing.DeleteObject(this);
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
closing.DeleteObject(this);
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxDialog::Destroy(void)
|
||||
{
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
if (GetEventHandler()->OnClose() || event.GetForce())
|
||||
{
|
||||
this->Destroy();
|
||||
}
|
||||
if (GetEventHandler()->OnClose() || event.GetForce())
|
||||
{
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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();
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
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 )
|
||||
{
|
||||
if (!show && IsModal())
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
if (!show && IsModal())
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
wxWindow::Show( show );
|
||||
wxWindow::Show( show );
|
||||
|
||||
if (show) InitDialog();
|
||||
if (show) InitDialog();
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxDialog::IsModal(void) const
|
||||
{
|
||||
return m_modalShowing;
|
||||
return m_modalShowing;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal( bool WXUNUSED(flag) )
|
||||
@ -235,58 +298,58 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
|
||||
else
|
||||
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)
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:ShowModal called twice" );
|
||||
return GetReturnCode();
|
||||
}
|
||||
if (IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:ShowModal called twice" );
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
m_modalShowing = TRUE;
|
||||
m_modalShowing = TRUE;
|
||||
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
|
||||
return GetReturnCode();
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
void wxDialog::EndModal( int retCode )
|
||||
{
|
||||
SetReturnCode( retCode );
|
||||
SetReturnCode( retCode );
|
||||
|
||||
if (!IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:EndModal called twice" );
|
||||
return;
|
||||
}
|
||||
if (!IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:EndModal called twice" );
|
||||
return;
|
||||
}
|
||||
|
||||
m_modalShowing = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
|
||||
gtk_main_quit();
|
||||
gtk_main_quit();
|
||||
|
||||
Show( FALSE );
|
||||
Show( FALSE );
|
||||
}
|
||||
|
||||
void wxDialog::InitDialog(void)
|
||||
{
|
||||
wxWindow::InitDialog();
|
||||
wxWindow::InitDialog();
|
||||
}
|
||||
|
||||
void wxDialog::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
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 );
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ extern wxList wxPendingDelete;
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
|
||||
{
|
||||
if (!win->HasVMT()) return;
|
||||
if (!win->HasVMT()) return;
|
||||
|
||||
/*
|
||||
printf( "OnFrameResize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnFrameResize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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 )
|
||||
{
|
||||
/*
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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 )
|
||||
{
|
||||
if (!win->HasVMT()) return FALSE;
|
||||
if (!win->HasVMT()) return FALSE;
|
||||
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
win->m_x = event->x;
|
||||
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)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
|
||||
|
||||
wxFrame::wxFrame()
|
||||
{
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
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;
|
||||
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
if ((size.x != -1) && (size.y != -1))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
if ((pos.x != -1) && (pos.y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
m_widget = gtk_window_new( win_type );
|
||||
if ((size.x != -1) && (size.y != -1))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
if ((pos.x != -1) && (pos.y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title );
|
||||
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_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
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_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
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()
|
||||
{
|
||||
if (m_frameMenuBar) delete m_frameMenuBar;
|
||||
if (m_frameStatusBar) delete m_frameStatusBar;
|
||||
if (m_frameToolBar) delete m_frameToolBar;
|
||||
if (m_frameMenuBar) delete m_frameMenuBar;
|
||||
if (m_frameStatusBar) delete m_frameStatusBar;
|
||||
if (m_frameToolBar) delete m_frameToolBar;
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
}
|
||||
|
||||
bool wxFrame::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
if (show)
|
||||
{
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
m_sizeSet = FALSE;
|
||||
ProcessEvent( event );
|
||||
}
|
||||
return wxWindow::Show( show );
|
||||
if (show)
|
||||
{
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
m_sizeSet = FALSE;
|
||||
ProcessEvent( event );
|
||||
}
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrame::OnCloseWindow( wxCloseEvent &event )
|
||||
{
|
||||
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
|
||||
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
|
||||
}
|
||||
|
||||
bool wxFrame::Destroy()
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
{
|
||||
wxPoint pt(0, 0);
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameMenuBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h + 2;
|
||||
}
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameToolBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h;
|
||||
}
|
||||
return pt;
|
||||
wxPoint pt(0, 0);
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameMenuBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h + 2;
|
||||
}
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameToolBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h;
|
||||
}
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
|
||||
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;
|
||||
|
||||
ImplementSetPosition();
|
||||
Move( x, y );
|
||||
}
|
||||
|
||||
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 );
|
||||
if (height)
|
||||
{
|
||||
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
|
||||
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameToolBar)
|
||||
wxWindow::GetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
int y = 0;
|
||||
m_frameToolBar->GetSize( (int *) NULL, &y );
|
||||
(*height) -= y;
|
||||
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
|
||||
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int y = 0;
|
||||
m_frameToolBar->GetSize( (int *) NULL, &y );
|
||||
(*height) -= y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxFrame::SetClientSize( int const width, int const height )
|
||||
|
@ -119,10 +119,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
|
||||
|
||||
if (m_mdiMenuBar)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetClientSize( &x, &y );
|
||||
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
|
||||
m_mdiMenuBar->m_x = 1;
|
||||
m_mdiMenuBar->m_y = 1;
|
||||
m_mdiMenuBar->m_width = m_width-2;
|
||||
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;
|
||||
if (m_mdiMenuBar)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetClientSize( &x, &y );
|
||||
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
|
||||
m_mdiMenuBar->m_x = 1;
|
||||
m_mdiMenuBar->m_y = 1;
|
||||
m_mdiMenuBar->m_width = m_width-2;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
|
||||
if (child->widget == widget)
|
||||
{
|
||||
if ((child->x == x) && (child->y == y)) return;
|
||||
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
|
@ -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 )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
if (m_resizing) return; // I don't like recursions
|
||||
m_resizing = TRUE;
|
||||
|
||||
int newX = x;
|
||||
int newY = y;
|
||||
int newW = width;
|
||||
int newH = height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
|
||||
{
|
||||
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 (newW == -1) newW = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (newH == -1) newH = 26;
|
||||
}
|
||||
|
||||
AdjustForParentClientOrigin( newX, newY, sizeFlags );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
|
||||
|
||||
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
|
||||
{
|
||||
m_x = newX;
|
||||
m_y = newY;
|
||||
ImplementSetPosition();
|
||||
}
|
||||
// Don't do anything for children of wxNotebook
|
||||
if (m_parent->m_wxwindow == NULL) return;
|
||||
|
||||
if (m_resizing) return; // I don't like recursions
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
|
||||
{
|
||||
m_width = newW;
|
||||
m_height = newH;
|
||||
ImplementSetSize();
|
||||
}
|
||||
m_sizeSet = TRUE;
|
||||
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;
|
||||
}
|
||||
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
ProcessEvent( event );
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
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;
|
||||
|
||||
wxPoint pt( m_parent->GetClientAreaOrigin() );
|
||||
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
|
||||
|
||||
if ((old_width != m_width) || (old_height != m_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 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 )
|
||||
{
|
||||
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
|
||||
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
|
||||
}
|
||||
|
||||
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 (height) (*height) = m_height;
|
||||
if (width) (*width) = m_width;
|
||||
if (height) (*height) = m_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" );
|
||||
|
||||
int xx = m_x;
|
||||
int yy = m_y;
|
||||
|
||||
if (GetParent())
|
||||
{
|
||||
wxPoint pt(GetParent()->GetClientAreaOrigin());
|
||||
xx -= pt.x;
|
||||
yy -= pt.y;
|
||||
}
|
||||
|
||||
if (x) (*x) = xx;
|
||||
if (y) (*y) = yy;
|
||||
if (x) (*x) = m_x;
|
||||
if (y) (*y) = m_y;
|
||||
}
|
||||
|
||||
void wxWindow::ClientToScreen( int *x, int *y )
|
||||
@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
|
||||
{
|
||||
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_h = 0;
|
||||
m_parent->GetSize( &p_w, &p_h );
|
||||
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2;
|
||||
ImplementSetPosition();
|
||||
}
|
||||
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
|
||||
}
|
||||
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()
|
||||
|
@ -413,7 +413,7 @@ wxBitmap::wxBitmap( const wxImage &image )
|
||||
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
|
||||
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
||||
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;
|
||||
|
||||
// Render
|
||||
@ -554,7 +554,7 @@ wxImage wxBitmap::ConvertToImage() const
|
||||
GdkVisual *visual = gdk_window_get_visual( M_BMPDATA->m_pixmap );
|
||||
if (visual == NULL) visual = gdk_window_get_visual( (GdkWindow*) &gdk_root_parent );
|
||||
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();
|
||||
|
||||
|
@ -27,15 +27,15 @@ extern wxList wxPendingDelete;
|
||||
bool gtk_dialog_delete_callback( GtkWidget *WXUNUSED(widget), GdkEvent *WXUNUSED(event), wxDialog *win )
|
||||
{
|
||||
/*
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
EVT_BUTTON (wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON (wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_BUTTON (wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_CLOSE (wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog,wxPanel)
|
||||
|
||||
wxDialog::wxDialog(void)
|
||||
{
|
||||
m_title = "";
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_title = "";
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
wxDialog::wxDialog( wxWindow *parent,
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
m_modalShowing = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
}
|
||||
|
||||
bool wxDialog::Create( wxWindow *parent,
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
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 );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
m_widget = gtk_window_new( GTK_WINDOW_TOPLEVEL );
|
||||
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_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_dialog_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
if ((m_x != -1) || (m_y != -1))
|
||||
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)
|
||||
{
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
}
|
||||
|
||||
void wxDialog::SetTitle(const wxString& title )
|
||||
{
|
||||
m_title = title;
|
||||
if (m_title.IsNull()) m_title = "";
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||
m_title = title;
|
||||
if (m_title.IsNull()) m_title = "";
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), m_title );
|
||||
}
|
||||
|
||||
wxString wxDialog::GetTitle(void) const
|
||||
{
|
||||
return (wxString&)m_title;
|
||||
return (wxString&)m_title;
|
||||
}
|
||||
|
||||
void wxDialog::OnApply( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (Validate()) TransferDataFromWindow();
|
||||
if (Validate()) TransferDataFromWindow();
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
if (IsModal())
|
||||
{
|
||||
EndModal(wxID_CANCEL);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnOK( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow())
|
||||
{
|
||||
if (IsModal())
|
||||
if ( Validate() && TransferDataFromWindow())
|
||||
{
|
||||
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) )
|
||||
@ -165,66 +165,129 @@ void wxDialog::OnPaint( wxPaintEvent& WXUNUSED(event) )
|
||||
|
||||
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);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
closing.DeleteObject(this);
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
closing.DeleteObject(this);
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxDialog::Destroy(void)
|
||||
{
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
{
|
||||
if (GetEventHandler()->OnClose() || event.GetForce())
|
||||
{
|
||||
this->Destroy();
|
||||
}
|
||||
if (GetEventHandler()->OnClose() || event.GetForce())
|
||||
{
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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();
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
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 )
|
||||
{
|
||||
if (!show && IsModal())
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
if (!show && IsModal())
|
||||
{
|
||||
EndModal( wxID_CANCEL );
|
||||
}
|
||||
|
||||
wxWindow::Show( show );
|
||||
wxWindow::Show( show );
|
||||
|
||||
if (show) InitDialog();
|
||||
if (show) InitDialog();
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxDialog::IsModal(void) const
|
||||
{
|
||||
return m_modalShowing;
|
||||
return m_modalShowing;
|
||||
}
|
||||
|
||||
void wxDialog::SetModal( bool WXUNUSED(flag) )
|
||||
@ -235,58 +298,58 @@ void wxDialog::SetModal( bool WXUNUSED(flag) )
|
||||
else
|
||||
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)
|
||||
{
|
||||
if (IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:ShowModal called twice" );
|
||||
return GetReturnCode();
|
||||
}
|
||||
if (IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:ShowModal called twice" );
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
Show( TRUE );
|
||||
Show( TRUE );
|
||||
|
||||
m_modalShowing = TRUE;
|
||||
m_modalShowing = TRUE;
|
||||
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
gtk_grab_add( m_widget );
|
||||
gtk_main();
|
||||
gtk_grab_remove( m_widget );
|
||||
|
||||
return GetReturnCode();
|
||||
return GetReturnCode();
|
||||
}
|
||||
|
||||
void wxDialog::EndModal( int retCode )
|
||||
{
|
||||
SetReturnCode( retCode );
|
||||
SetReturnCode( retCode );
|
||||
|
||||
if (!IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:EndModal called twice" );
|
||||
return;
|
||||
}
|
||||
if (!IsModal())
|
||||
{
|
||||
wxFAIL_MSG( "wxDialog:EndModal called twice" );
|
||||
return;
|
||||
}
|
||||
|
||||
m_modalShowing = FALSE;
|
||||
m_modalShowing = FALSE;
|
||||
|
||||
gtk_main_quit();
|
||||
gtk_main_quit();
|
||||
|
||||
Show( FALSE );
|
||||
Show( FALSE );
|
||||
}
|
||||
|
||||
void wxDialog::InitDialog(void)
|
||||
{
|
||||
wxWindow::InitDialog();
|
||||
wxWindow::InitDialog();
|
||||
}
|
||||
|
||||
void wxDialog::SetIcon( const wxIcon &icon )
|
||||
{
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
m_icon = icon;
|
||||
if (!icon.Ok()) return;
|
||||
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
if (mask) bm = mask->GetBitmap();
|
||||
wxMask *mask = icon.GetMask();
|
||||
GdkBitmap *bm = (GdkBitmap *) NULL;
|
||||
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 );
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ extern wxList wxPendingDelete;
|
||||
|
||||
static void gtk_frame_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxFrame *win )
|
||||
{
|
||||
if (!win->HasVMT()) return;
|
||||
if (!win->HasVMT()) return;
|
||||
|
||||
/*
|
||||
printf( "OnFrameResize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnFrameResize from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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 )
|
||||
{
|
||||
/*
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
printf( ".\n" );
|
||||
printf( "OnDelete from " );
|
||||
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
|
||||
printf( win->GetClassInfo()->GetClassName() );
|
||||
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 )
|
||||
{
|
||||
if (!win->HasVMT()) return FALSE;
|
||||
if (!win->HasVMT()) return FALSE;
|
||||
|
||||
win->m_x = event->x;
|
||||
win->m_y = event->y;
|
||||
win->m_x = event->x;
|
||||
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)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
EVT_SIZE(wxFrame::OnSize)
|
||||
EVT_CLOSE(wxFrame::OnCloseWindow)
|
||||
EVT_IDLE(wxFrame::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxFrame,wxWindow)
|
||||
|
||||
wxFrame::wxFrame()
|
||||
{
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
wxFrame::wxFrame( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
long style, const wxString &name )
|
||||
{
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
wxTopLevelWindows.Insert( this );
|
||||
m_frameMenuBar = (wxMenuBar *) NULL;
|
||||
m_frameStatusBar = (wxStatusBar *) NULL;
|
||||
m_frameToolBar = (wxToolBar *) NULL;
|
||||
m_sizeSet = FALSE;
|
||||
Create( parent, id, title, pos, size, style, name );
|
||||
wxTopLevelWindows.Insert( this );
|
||||
}
|
||||
|
||||
bool wxFrame::Create( wxWindow *parent, wxWindowID id, const wxString &title,
|
||||
const wxPoint &pos, const wxSize &size,
|
||||
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;
|
||||
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
|
||||
GtkWindowType win_type = GTK_WINDOW_TOPLEVEL;
|
||||
if (style & wxSIMPLE_BORDER) win_type = GTK_WINDOW_POPUP;
|
||||
|
||||
m_widget = gtk_window_new( win_type );
|
||||
if ((size.x != -1) && (size.y != -1))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
if ((pos.x != -1) && (pos.y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
m_widget = gtk_window_new( win_type );
|
||||
if ((size.x != -1) && (size.y != -1))
|
||||
gtk_widget_set_usize( m_widget, m_width, m_height );
|
||||
if ((pos.x != -1) && (pos.y != -1))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_widget, GTK_CAN_FOCUS );
|
||||
gtk_window_set_title( GTK_WINDOW(m_widget), title );
|
||||
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_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "delete_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_delete_callback), (gpointer)this );
|
||||
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
GTK_WIDGET_UNSET_FLAGS( m_wxwindow, GTK_CAN_FOCUS );
|
||||
m_wxwindow = gtk_myfixed_new();
|
||||
gtk_widget_show( m_wxwindow );
|
||||
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_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "size_allocate",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_size_callback), (gpointer)this );
|
||||
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
GTK_SIGNAL_FUNC(gtk_frame_configure_callback), (gpointer)this );
|
||||
gtk_signal_connect( GTK_OBJECT(m_widget), "configure_event",
|
||||
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()
|
||||
{
|
||||
if (m_frameMenuBar) delete m_frameMenuBar;
|
||||
if (m_frameStatusBar) delete m_frameStatusBar;
|
||||
if (m_frameToolBar) delete m_frameToolBar;
|
||||
if (m_frameMenuBar) delete m_frameMenuBar;
|
||||
if (m_frameStatusBar) delete m_frameStatusBar;
|
||||
if (m_frameToolBar) delete m_frameToolBar;
|
||||
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
wxTopLevelWindows.DeleteObject( this );
|
||||
if (wxTopLevelWindows.Number() == 0) wxTheApp->ExitMainLoop();
|
||||
}
|
||||
|
||||
bool wxFrame::Show( bool show )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
if (show)
|
||||
{
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
m_sizeSet = FALSE;
|
||||
ProcessEvent( event );
|
||||
}
|
||||
return wxWindow::Show( show );
|
||||
if (show)
|
||||
{
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
m_sizeSet = FALSE;
|
||||
ProcessEvent( event );
|
||||
}
|
||||
return wxWindow::Show( show );
|
||||
}
|
||||
|
||||
void wxFrame::OnCloseWindow( wxCloseEvent &event )
|
||||
{
|
||||
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
|
||||
if (GetEventHandler()->OnClose() || event.GetForce()) this->Destroy();
|
||||
}
|
||||
|
||||
bool wxFrame::Destroy()
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
|
||||
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
|
||||
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxPoint wxFrame::GetClientAreaOrigin() const
|
||||
{
|
||||
wxPoint pt(0, 0);
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameMenuBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h + 2;
|
||||
}
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameToolBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h;
|
||||
}
|
||||
return pt;
|
||||
wxPoint pt(0, 0);
|
||||
if (m_frameMenuBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameMenuBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h + 2;
|
||||
}
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int h = 0;
|
||||
m_frameToolBar->GetSize( (int*)NULL, &h );
|
||||
pt.y += h;
|
||||
}
|
||||
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))
|
||||
gtk_widget_set_uposition( m_widget, m_x, m_y );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
|
||||
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;
|
||||
|
||||
ImplementSetPosition();
|
||||
Move( x, y );
|
||||
}
|
||||
|
||||
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 );
|
||||
if (height)
|
||||
{
|
||||
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
|
||||
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameToolBar)
|
||||
wxWindow::GetClientSize( width, height );
|
||||
if (height)
|
||||
{
|
||||
int y = 0;
|
||||
m_frameToolBar->GetSize( (int *) NULL, &y );
|
||||
(*height) -= y;
|
||||
if (m_frameMenuBar) (*height) -= wxMENU_HEIGHT;
|
||||
if (m_frameStatusBar) (*height) -= wxSTATUS_HEIGHT;
|
||||
if (m_frameToolBar)
|
||||
{
|
||||
int y = 0;
|
||||
m_frameToolBar->GetSize( (int *) NULL, &y );
|
||||
(*height) -= y;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxFrame::SetClientSize( int const width, int const height )
|
||||
|
@ -119,10 +119,12 @@ void wxMDIParentFrame::GtkOnSize( int x, int y, int width, int height )
|
||||
|
||||
if (m_mdiMenuBar)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetClientSize( &x, &y );
|
||||
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
|
||||
m_mdiMenuBar->m_x = 1;
|
||||
m_mdiMenuBar->m_y = 1;
|
||||
m_mdiMenuBar->m_width = m_width-2;
|
||||
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;
|
||||
if (m_mdiMenuBar)
|
||||
{
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
GetClientSize( &x, &y );
|
||||
m_mdiMenuBar->SetSize( 1, 1, x-2, wxMENU_HEIGHT-2, wxSIZE_NO_ADJUSTMENTS );
|
||||
m_mdiMenuBar->m_x = 1;
|
||||
m_mdiMenuBar->m_y = 1;
|
||||
m_mdiMenuBar->m_width = m_width-2;
|
||||
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 );
|
||||
}
|
||||
}
|
||||
|
@ -169,6 +169,8 @@ gtk_myfixed_move (GtkMyFixed *myfixed,
|
||||
|
||||
if (child->widget == widget)
|
||||
{
|
||||
if ((child->x == x) && (child->y == y)) return;
|
||||
|
||||
child->x = x;
|
||||
child->y = y;
|
||||
|
||||
|
@ -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 )
|
||||
{
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
|
||||
if (m_resizing) return; // I don't like recursions
|
||||
m_resizing = TRUE;
|
||||
|
||||
int newX = x;
|
||||
int newY = y;
|
||||
int newW = width;
|
||||
int newH = height;
|
||||
|
||||
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
|
||||
{
|
||||
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 (newW == -1) newW = 80;
|
||||
}
|
||||
|
||||
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
|
||||
{
|
||||
if (newH == -1) newH = 26;
|
||||
}
|
||||
|
||||
AdjustForParentClientOrigin( newX, newY, sizeFlags );
|
||||
wxASSERT_MSG( (m_widget != NULL), "invalid window" );
|
||||
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
|
||||
|
||||
if ((m_x != newX) || (m_y != newY) || (!m_sizeSet))
|
||||
{
|
||||
m_x = newX;
|
||||
m_y = newY;
|
||||
ImplementSetPosition();
|
||||
}
|
||||
// Don't do anything for children of wxNotebook
|
||||
if (m_parent->m_wxwindow == NULL) return;
|
||||
|
||||
if (m_resizing) return; // I don't like recursions
|
||||
m_resizing = TRUE;
|
||||
|
||||
int old_width = m_width;
|
||||
int old_height = m_height;
|
||||
|
||||
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
|
||||
{
|
||||
m_width = newW;
|
||||
m_height = newH;
|
||||
ImplementSetSize();
|
||||
}
|
||||
m_sizeSet = TRUE;
|
||||
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;
|
||||
}
|
||||
|
||||
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
|
||||
event.SetEventObject( this );
|
||||
ProcessEvent( event );
|
||||
if ((sizeFlags & wxSIZE_AUTO_WIDTH) == wxSIZE_AUTO_WIDTH)
|
||||
{
|
||||
if (width == -1) m_width = 80;
|
||||
}
|
||||
|
||||
m_resizing = FALSE;
|
||||
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;
|
||||
|
||||
wxPoint pt( m_parent->GetClientAreaOrigin() );
|
||||
gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
|
||||
|
||||
if ((old_width != m_width) || (old_height != m_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 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 )
|
||||
{
|
||||
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
|
||||
SetSize( x, y, -1, -1, wxSIZE_USE_EXISTING );
|
||||
}
|
||||
|
||||
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 (height) (*height) = m_height;
|
||||
if (width) (*width) = m_width;
|
||||
if (height) (*height) = m_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" );
|
||||
|
||||
int xx = m_x;
|
||||
int yy = m_y;
|
||||
|
||||
if (GetParent())
|
||||
{
|
||||
wxPoint pt(GetParent()->GetClientAreaOrigin());
|
||||
xx -= pt.x;
|
||||
yy -= pt.y;
|
||||
}
|
||||
|
||||
if (x) (*x) = xx;
|
||||
if (y) (*y) = yy;
|
||||
if (x) (*x) = m_x;
|
||||
if (y) (*y) = m_y;
|
||||
}
|
||||
|
||||
void wxWindow::ClientToScreen( int *x, int *y )
|
||||
@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
|
||||
{
|
||||
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_h = 0;
|
||||
m_parent->GetSize( &p_w, &p_h );
|
||||
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2;
|
||||
ImplementSetPosition();
|
||||
}
|
||||
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
|
||||
if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
|
||||
}
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user