Still bit fiddling in wxImage.

SetSize rewritten.


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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -181,8 +181,7 @@ bool wxDialog::OnClose(void)
bool wxDialog::Destroy(void) bool wxDialog::Destroy(void)
{ {
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
@@ -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 != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
}
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); int x,y;
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
bool wxDialog::Show( bool show ) bool wxDialog::Show( bool show )

View File

@@ -196,8 +196,7 @@ bool wxFrame::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
@@ -220,20 +219,81 @@ wxPoint wxFrame::GetClientAreaOrigin() const
return pt; 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 != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
}
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; int x,y;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::GetClientSize( int *width, int *height ) const

View File

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

View File

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

View File

@@ -1315,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 ) void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// Don't do anything for children of wxNotebook
if (m_parent->m_wxwindow == NULL) return;
if (m_resizing) return; // I don't like recursions if (m_resizing) return; // I don't like recursions
m_resizing = TRUE; m_resizing = TRUE;
int newX = x; int old_width = m_width;
int newY = y; int old_height = m_height;
int newW = width;
int newH = height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{ {
if (newX == -1) newX = m_x; if (x != -1) m_x = x;
if (newY == -1) newY = m_y; if (y != -1) m_y = y;
if (newW == -1) newW = m_width; if (width != -1) m_width = width;
if (newH == -1) newH = m_height; 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 ((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 ((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)) wxPoint pt( m_parent->GetClientAreaOrigin() );
{ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
m_x = newX;
m_y = newY; if ((old_width != m_width) || (old_height != m_height))
ImplementSetPosition(); 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; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); 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" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
int xx = m_x; if (x) (*x) = m_x;
int yy = m_y; if (y) (*y) = m_y;
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
if (x) (*x) = xx;
if (y) (*y) = yy;
} }
void wxWindow::ClientToScreen( int *x, int *y ) void wxWindow::ClientToScreen( int *x, int *y )
@@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) int x = m_x;
{ int y = m_y;
if (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) if (m_parent)
{ {
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
ImplementSetPosition();
} }
else
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
} }
Move( x, y );
} }
void wxWindow::Fit() void wxWindow::Fit()

View File

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

View File

@@ -181,8 +181,7 @@ bool wxDialog::OnClose(void)
bool wxDialog::Destroy(void) bool wxDialog::Destroy(void)
{ {
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
@@ -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 != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
}
void wxDialog::Centre( int direction ) void wxDialog::Centre( int direction )
{ {
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); int x,y;
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
bool wxDialog::Show( bool show ) bool wxDialog::Show( bool show )

View File

@@ -196,8 +196,7 @@ bool wxFrame::Destroy()
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this)) wxPendingDelete.Append(this);
wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
@@ -220,20 +219,81 @@ wxPoint wxFrame::GetClientAreaOrigin() const
return pt; 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 != -1) || (m_y != -1))
{
if ((m_x != old_x) || (m_y != old_y))
gtk_widget_set_uposition( m_widget, m_x, m_y ); gtk_widget_set_uposition( m_widget, m_x, m_y );
} }
if ((m_width != old_width) || (m_height != old_height))
{
gtk_widget_set_usize( m_widget, m_width, m_height );
}
m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
}
void wxFrame::Centre( int direction ) void wxFrame::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid frame" ); wxASSERT_MSG( (m_widget != NULL), "invalid frame" );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (gdk_screen_width () - m_width) / 2; int x,y;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (gdk_screen_height () - m_height) / 2;
ImplementSetPosition(); if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
Move( x, y );
} }
void wxFrame::GetClientSize( int *width, int *height ) const void wxFrame::GetClientSize( int *width, int *height ) const

View File

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

View File

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

View File

@@ -1315,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 ) void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
wxASSERT_MSG( (m_parent != NULL), "wxWindow::SetSize requires parent.\n" );
// Don't do anything for children of wxNotebook
if (m_parent->m_wxwindow == NULL) return;
if (m_resizing) return; // I don't like recursions if (m_resizing) return; // I don't like recursions
m_resizing = TRUE; m_resizing = TRUE;
int newX = x; int old_width = m_width;
int newY = y; int old_height = m_height;
int newW = width;
int newH = height;
if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING) if ((sizeFlags & wxSIZE_USE_EXISTING) == wxSIZE_USE_EXISTING)
{ {
if (newX == -1) newX = m_x; if (x != -1) m_x = x;
if (newY == -1) newY = m_y; if (y != -1) m_y = y;
if (newW == -1) newW = m_width; if (width != -1) m_width = width;
if (newH == -1) newH = m_height; 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 ((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 ((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)) wxPoint pt( m_parent->GetClientAreaOrigin() );
{ gtk_myfixed_move( GTK_MYFIXED(m_parent->m_wxwindow), m_widget, m_x+pt.x, m_y+pt.y );
m_x = newX;
m_y = newY; if ((old_width != m_width) || (old_height != m_height))
ImplementSetPosition(); 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; m_sizeSet = TRUE;
wxSizeEvent event( wxSize(m_width,m_height), GetId() ); 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" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
int xx = m_x; if (x) (*x) = m_x;
int yy = m_y; if (y) (*y) = m_y;
if (GetParent())
{
wxPoint pt(GetParent()->GetClientAreaOrigin());
xx -= pt.x;
yy -= pt.y;
}
if (x) (*x) = xx;
if (y) (*y) = yy;
} }
void wxWindow::ClientToScreen( int *x, int *y ) void wxWindow::ClientToScreen( int *x, int *y )
@@ -1616,24 +1588,24 @@ void wxWindow::Centre( int direction )
{ {
wxASSERT_MSG( (m_widget != NULL), "invalid window" ); wxASSERT_MSG( (m_widget != NULL), "invalid window" );
if (IS_KIND_OF(this,wxDialog) || IS_KIND_OF(this,wxFrame)) int x = m_x;
{ int y = m_y;
if (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) if (m_parent)
{ {
int p_w = 0; int p_w = 0;
int p_h = 0; int p_h = 0;
m_parent->GetSize( &p_w, &p_h ); m_parent->GetSize( &p_w, &p_h );
if (direction & wxHORIZONTAL == wxHORIZONTAL) m_x = (p_w - m_width) / 2; if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (p_w - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) m_y = (p_h - m_height) / 2; if (direction & wxVERTICAL == wxVERTICAL) y = (p_h - m_height) / 2;
ImplementSetPosition();
} }
else
{
if (direction & wxHORIZONTAL == wxHORIZONTAL) x = (gdk_screen_width () - m_width) / 2;
if (direction & wxVERTICAL == wxVERTICAL) y = (gdk_screen_height () - m_height) / 2;
} }
Move( x, y );
} }
void wxWindow::Fit() void wxWindow::Fit()