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
-> On the way, but not functional yet.
wxHelpController
-> Karsten ?
Fix printing of bitmaps
-> No idea.

View File

@ -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:
friend wxWindow;
friend wxDC;
friend wxRadioBox;
// implementation
bool m_modalShowing;
wxString m_title;
wxIcon m_icon;
virtual void ImplementSetPosition();
DECLARE_EVENT_TABLE()
};

View File

@ -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);

View File

@ -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 );

View File

@ -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:
friend wxWindow;
friend wxDC;
friend wxRadioBox;
// implementation
bool m_modalShowing;
wxString m_title;
wxIcon m_icon;
virtual void ImplementSetPosition();
DECLARE_EVENT_TABLE()
};

View File

@ -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);

View File

@ -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 );

View File

@ -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
//-----------------------------------------------------------------------------

View File

@ -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 \

View File

@ -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();

View File

@ -181,8 +181,7 @@ bool wxDialog::OnClose(void)
bool wxDialog::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
}
@ -195,17 +194,81 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
}
}
void wxDialog::ImplementSetPosition(void)
void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
{
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 )

View File

@ -196,8 +196,7 @@ bool wxFrame::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
}
@ -220,20 +219,81 @@ wxPoint wxFrame::GetClientAreaOrigin() const
return pt;
}
void wxFrame::ImplementSetPosition(void)
void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
{
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" );
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;
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

View File

@ -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 );
}
}

View File

@ -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;

View File

@ -1315,74 +1315,56 @@ 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" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// 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 newX = x;
int newY = y;
int newW = width;
int newH = height;
int old_width = m_width;
int old_height = m_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 (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 (newW == -1) newW = 80;
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (newH == -1) newH = 26;
if (height == -1) m_height = 26;
}
AdjustForParentClientOrigin( newX, newY, sizeFlags );
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 != newX) || (m_y != newY) || (!m_sizeSet))
{
m_x = newX;
m_y = newY;
ImplementSetPosition();
}
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 );
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{
m_width = newW;
m_height = newH;
ImplementSetSize();
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
@ -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))
{
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
{
int x = m_x;
int y = m_y;
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()

View File

@ -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();

View File

@ -181,8 +181,7 @@ bool wxDialog::OnClose(void)
bool wxDialog::Destroy(void)
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
}
@ -195,17 +194,81 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
}
}
void wxDialog::ImplementSetPosition(void)
void wxDialog::SetSize( int x, int y, int width, int height, int sizeFlags )
{
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 )

View File

@ -196,8 +196,7 @@ bool wxFrame::Destroy()
{
wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
return TRUE;
}
@ -220,20 +219,81 @@ wxPoint wxFrame::GetClientAreaOrigin() const
return pt;
}
void wxFrame::ImplementSetPosition(void)
void wxFrame::SetSize( int x, int y, int width, int height, int sizeFlags )
{
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" );
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;
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

View File

@ -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 );
}
}

View File

@ -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;

View File

@ -1315,74 +1315,56 @@ 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" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// 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 newX = x;
int newY = y;
int newW = width;
int newH = height;
int old_width = m_width;
int old_height = m_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 (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 (newW == -1) newW = 80;
if (width == -1) m_width = 80;
}
if ((sizeFlags & wxSIZE_AUTO_HEIGHT) == wxSIZE_AUTO_HEIGHT)
{
if (newH == -1) newH = 26;
if (height == -1) m_height = 26;
}
AdjustForParentClientOrigin( newX, newY, sizeFlags );
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 != newX) || (m_y != newY) || (!m_sizeSet))
{
m_x = newX;
m_y = newY;
ImplementSetPosition();
}
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 );
if ((m_width != newW) || (m_height != newH) || (!m_sizeSet))
{
m_width = newW;
m_height = newH;
ImplementSetSize();
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
@ -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))
{
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
{
int x = m_x;
int y = m_y;
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()