resize mdi and notebook client

bitmap resizing (used in imagelist)
draw spline bug


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 1998-07-13 23:30:59 +00:00
parent d29d303b1c
commit 33d0b396b2
18 changed files with 193 additions and 36 deletions

View File

@ -594,6 +594,7 @@ class wxListCtrl: public wxControl
bool GetItemPosition( long item, wxPoint& pos ) const; // not supported in wxGLC
bool SetItemPosition( long item, const wxPoint& pos ); // not supported in wxGLC
int GetItemCount(void);
void SetItemSpacing( int spacing, bool isSmall = FALSE );
int GetItemSpacing( bool isSmall );
int GetSelectedItemCount(void);
// wxColour GetTextColour(void) const; // wxGLC has colours for every Item (see wxListItem)

View File

@ -222,6 +222,7 @@ class wxWindow: public wxEvtHandler
bool m_hasScrolling;
bool m_hasVMT;
bool m_sizeSet;
bool m_resizing;
public: // Layout section

View File

@ -222,6 +222,7 @@ class wxWindow: public wxEvtHandler
bool m_hasScrolling;
bool m_hasVMT;
bool m_sizeSet;
bool m_resizing;
public: // Layout section

View File

@ -180,7 +180,7 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h ) :
m_combo = new wxComboBox( panel, ID_COMBO, "This", wxPoint(10,10), wxSize(120,-1), 9, choices );
m_notebook->AddPage(panel, "wxComboBox");
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(0,20), wxSize(120,100), wxTE_MULTILINE );
wxTextCtrl *text = new wxTextCtrl( m_notebook, ID_TEXT, "Write text here.", wxPoint(10,10), wxSize(120,100), wxTE_MULTILINE );
m_notebook->AddPage( text, "wxTextCtrl" );
}

View File

@ -206,7 +206,7 @@ void MyCanvas::OnDraw(wxDC& dc)
points[0].x = 200; points[0].y = 300;
points[1].x = 100; points[1].y = 400;
points[2].x = 300; points[2].y = 400;
dc.DrawPolygon(3, points);
}
@ -271,6 +271,7 @@ void MyFrame::OnSize(wxSizeEvent& event)
BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
EVT_MENU(MDI_CHILD_QUIT, MyChild::OnQuit)
EVT_SIZE( MyChild::OnSize)
END_EVENT_TABLE()
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
@ -286,7 +287,15 @@ MyChild::~MyChild(void)
my_children.DeleteObject(this);
}
void MyChild::OnQuit(wxCommandEvent& event)
void MyChild::OnSize(wxSizeEvent& WXUNUSED(event))
{
int x = 0;
int y = 0;
GetClientSize( &x, &y );
if (canvas) canvas->SetSize( x, y );
}
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}

View File

@ -77,6 +77,7 @@ class MyChild: public wxMDIChildFrame
MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size, const long style);
~MyChild(void);
bool OnClose(void);
void OnSize(wxSizeEvent& event);
void OnActivate(wxActivateEvent& event);
void OnQuit(wxCommandEvent& event);

View File

@ -1314,12 +1314,12 @@ void wxListMainWindow::DrawImage( int index, wxPaintDC *dc, int x, int y )
{
if ((m_mode & wxLC_ICON) && (m_normal_image_list))
{
m_normal_image_list->Draw( index, *dc, x, y );
m_normal_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT );
return;
};
if ((m_mode & wxLC_SMALL_ICON) && (m_small_image_list))
{
m_small_image_list->Draw( index, *dc, x, y );
m_small_image_list->Draw( index, *dc, x, y, wxIMAGELIST_DRAW_TRANSPARENT );
};
};
@ -2212,6 +2212,11 @@ int wxListCtrl::GetItemCount(void)
return m_mainWin->GetItemCount();
};
void wxListCtrl::SetItemSpacing( int spacing, bool isSmall )
{
m_mainWin->SetItemSpacing( spacing, isSmall );
};
int wxListCtrl::GetItemSpacing( bool isSmall )
{
return m_mainWin->GetItemSpacing( isSmall );

View File

@ -278,8 +278,6 @@ void wxBitmap::Resize( int height, int width )
{
if (!Ok()) return;
return;
#ifdef USE_GDK_IMLIB
if (M_BMPDATA->m_bitmap) return; // not supported for bitmaps

View File

@ -136,11 +136,17 @@ void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
wxList list;
list.DeleteContents(TRUE);
list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list);
wxNode *node = list.First();
while (node)
{
wxPoint *p = (wxPoint*)node->Data();
delete p;
node = node->Next();
};
};
void wxDC::DrawSpline( wxList *points )

View File

@ -18,6 +18,21 @@
// wxMDIParentFrame
//-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
return;
};
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
};
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
wxMDIParentFrame::wxMDIParentFrame(void)
@ -113,10 +128,10 @@ wxMDIChildFrame::wxMDIChildFrame(void)
wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame *parent,
wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
const wxPoint& WXUNUSED(pos), const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, title, pos, size, style, name );
Create( parent, id, title, wxDefaultPosition, size, style, name );
};
wxMDIChildFrame::~wxMDIChildFrame(void)
@ -125,11 +140,11 @@ wxMDIChildFrame::~wxMDIChildFrame(void)
bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
const wxPoint& WXUNUSED(pos), const wxSize& size,
long style, const wxString& name )
{
m_title = title;
return wxPanel::Create( parent->GetClientWindow(), id, pos, size, style, name );
return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
};
void wxMDIChildFrame::SetMenuBar( wxMenuBar *WXUNUSED(menu_bar) )
@ -191,6 +206,9 @@ void wxMDIClientWindow::AddChild( wxWindow *child )
GtkWidget *label_widget;
label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), child->m_widget, label_widget );
};

View File

@ -69,6 +69,40 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
notebook->ProcessEvent(event);
}
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
return;
};
/*
printf( "OnResize from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( " .\n" );
printf( " Old: X: %d Y: %d ", win->m_x, win->m_y );
printf( " W: %d H: %d ", win->m_width, win->m_height );
printf( " .\n" );
printf( " New: X: %d Y: %d ", alloc->x, alloc->y );
printf( " W: %d H: %d ", alloc->width, alloc->height );
printf( " .\n" );
*/
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
/*
printf( " Res: X: %d Y: %d ", win->m_x, win->m_y );
printf( " W: %d H: %d ", win->m_width, win->m_height );
printf( " .\n" );
*/
};
//-----------------------------------------------------------------------------
// wxNotebook
//-----------------------------------------------------------------------------
@ -370,7 +404,6 @@ void wxNotebook::AddChild( wxWindow *win )
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
page->m_id = GetPageCount();
@ -384,7 +417,10 @@ void wxNotebook::AddChild( wxWindow *win )
(GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
page->m_parent = GTK_NOTEBOOK(m_widget);
gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
@ -404,12 +440,12 @@ void wxNotebook::OnSize(wxSizeEvent& event)
// @@@@ the numbers I substract here are completely arbitrary, instead we
// should somehow calculate the size of the page from the size of the
// notebook
page->SetSize(event.GetSize().GetX() - 5,
/* page->SetSize(event.GetSize().GetX() - 5,
event.GetSize().GetY() - 30);
if ( page->GetAutoLayout() )
page->Layout();
*/
node = node->Next();
};
}

View File

@ -108,7 +108,9 @@ void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect,
//-----------------------------------------------------------------------------
// size
// I don't any longer intercept GTK's internal resize events (except frames)
// I don't any longer intercept GTK's internal resize events, except
// for frames and from within MDI and tabbed windows (client area
// size determined internally by GTK, not wxWin).
/*
void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
@ -730,6 +732,7 @@ wxWindow::wxWindow()
m_drawingOffsetX = 0;
m_drawingOffsetY = 0;
m_pDropTarget = NULL;
m_resizing = FALSE;
};
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@ -913,6 +916,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_drawingOffsetX = 0;
m_drawingOffsetY = 0;
m_pDropTarget = NULL;
m_resizing = FALSE;
}
void wxWindow::PostCreation(void)
@ -1059,6 +1063,9 @@ void wxWindow::ImplementSetPosition(void)
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int newX = x;
int newY = y;
int newW = width;
@ -1099,6 +1106,8 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
};
void wxWindow::SetSize( int width, int height )
@ -1113,8 +1122,8 @@ void wxWindow::Move( int x, int y )
void wxWindow::GetSize( int *width, int *height ) const
{
(*width) = m_width;
(*height) = m_height;
if (width) (*width) = m_width;
if (height) (*height) = m_height;
};
void wxWindow::SetClientSize( int width, int height )
@ -1423,6 +1432,8 @@ void wxWindow::AddChild( wxWindow *child )
};
};
// wxNotebooks are very special, so they have their own AddChild
if (IsKindOf(CLASSINFO(wxNotebook)))
{
wxNotebook *tab = (wxNotebook*)this;
@ -1828,7 +1839,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
m_vAdjust->page_increment = (float)(wxMax(fthumb-2,0));
m_vAdjust->page_size = fthumb;
};
if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)

View File

@ -278,8 +278,6 @@ void wxBitmap::Resize( int height, int width )
{
if (!Ok()) return;
return;
#ifdef USE_GDK_IMLIB
if (M_BMPDATA->m_bitmap) return; // not supported for bitmaps

View File

@ -136,11 +136,17 @@ void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
wxList list;
list.DeleteContents(TRUE);
list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list);
wxNode *node = list.First();
while (node)
{
wxPoint *p = (wxPoint*)node->Data();
delete p;
node = node->Next();
};
};
void wxDC::DrawSpline( wxList *points )

View File

@ -18,6 +18,21 @@
// wxMDIParentFrame
//-----------------------------------------------------------------------------
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
return;
};
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
};
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMDIParentFrame,wxFrame)
wxMDIParentFrame::wxMDIParentFrame(void)
@ -113,10 +128,10 @@ wxMDIChildFrame::wxMDIChildFrame(void)
wxMDIChildFrame::wxMDIChildFrame( wxMDIParentFrame *parent,
wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
const wxPoint& WXUNUSED(pos), const wxSize& size,
long style, const wxString& name )
{
Create( parent, id, title, pos, size, style, name );
Create( parent, id, title, wxDefaultPosition, size, style, name );
};
wxMDIChildFrame::~wxMDIChildFrame(void)
@ -125,11 +140,11 @@ wxMDIChildFrame::~wxMDIChildFrame(void)
bool wxMDIChildFrame::Create( wxMDIParentFrame *parent,
wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
const wxPoint& WXUNUSED(pos), const wxSize& size,
long style, const wxString& name )
{
m_title = title;
return wxPanel::Create( parent->GetClientWindow(), id, pos, size, style, name );
return wxPanel::Create( parent->GetClientWindow(), id, wxDefaultPosition, size, style, name );
};
void wxMDIChildFrame::SetMenuBar( wxMenuBar *WXUNUSED(menu_bar) )
@ -191,6 +206,9 @@ void wxMDIClientWindow::AddChild( wxWindow *child )
GtkWidget *label_widget;
label_widget = gtk_label_new( s );
gtk_misc_set_alignment( GTK_MISC(label_widget), 0.0, 0.5 );
gtk_signal_connect( GTK_OBJECT(child->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)child );
gtk_notebook_append_page( GTK_NOTEBOOK(m_widget), child->m_widget, label_widget );
};

View File

@ -69,6 +69,40 @@ static void gtk_notebook_page_change_callback(GtkNotebook *WXUNUSED(widget),
notebook->ProcessEvent(event);
}
static void gtk_page_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
{
if ((win->m_x == alloc->x) &&
(win->m_y == alloc->y) &&
(win->m_width == alloc->width) &&
(win->m_height == alloc->height))
{
return;
};
/*
printf( "OnResize from " );
if (win->GetClassInfo() && win->GetClassInfo()->GetClassName())
printf( win->GetClassInfo()->GetClassName() );
printf( " .\n" );
printf( " Old: X: %d Y: %d ", win->m_x, win->m_y );
printf( " W: %d H: %d ", win->m_width, win->m_height );
printf( " .\n" );
printf( " New: X: %d Y: %d ", alloc->x, alloc->y );
printf( " W: %d H: %d ", alloc->width, alloc->height );
printf( " .\n" );
*/
win->SetSize( alloc->x, alloc->y, alloc->width, alloc->height );
/*
printf( " Res: X: %d Y: %d ", win->m_x, win->m_y );
printf( " W: %d H: %d ", win->m_width, win->m_height );
printf( " .\n" );
*/
};
//-----------------------------------------------------------------------------
// wxNotebook
//-----------------------------------------------------------------------------
@ -370,7 +404,6 @@ void wxNotebook::AddChild( wxWindow *win )
m_children.Append(win);
wxNotebookPage *page = new wxNotebookPage();
page->m_id = GetPageCount();
@ -384,7 +417,10 @@ void wxNotebook::AddChild( wxWindow *win )
(GtkNotebookPage*) (g_list_last(GTK_NOTEBOOK(m_widget)->children)->data);
page->m_parent = GTK_NOTEBOOK(m_widget);
gtk_signal_connect( GTK_OBJECT(win->m_widget), "size_allocate",
GTK_SIGNAL_FUNC(gtk_page_size_callback), (gpointer)win );
if (!page->m_page)
{
wxLogFatalError( "Notebook page creation error" );
@ -404,12 +440,12 @@ void wxNotebook::OnSize(wxSizeEvent& event)
// @@@@ the numbers I substract here are completely arbitrary, instead we
// should somehow calculate the size of the page from the size of the
// notebook
page->SetSize(event.GetSize().GetX() - 5,
/* page->SetSize(event.GetSize().GetX() - 5,
event.GetSize().GetY() - 30);
if ( page->GetAutoLayout() )
page->Layout();
*/
node = node->Next();
};
}

View File

@ -108,7 +108,9 @@ void gtk_window_draw_callback( GtkWidget *WXUNUSED(widget), GdkRectangle *rect,
//-----------------------------------------------------------------------------
// size
// I don't any longer intercept GTK's internal resize events (except frames)
// I don't any longer intercept GTK's internal resize events, except
// for frames and from within MDI and tabbed windows (client area
// size determined internally by GTK, not wxWin).
/*
void gtk_window_size_callback( GtkWidget *WXUNUSED(widget), GtkAllocation* alloc, wxWindow *win )
@ -730,6 +732,7 @@ wxWindow::wxWindow()
m_drawingOffsetX = 0;
m_drawingOffsetY = 0;
m_pDropTarget = NULL;
m_resizing = FALSE;
};
wxWindow::wxWindow( wxWindow *parent, wxWindowID id,
@ -913,6 +916,7 @@ void wxWindow::PreCreation( wxWindow *parent, wxWindowID id,
m_drawingOffsetX = 0;
m_drawingOffsetY = 0;
m_pDropTarget = NULL;
m_resizing = FALSE;
}
void wxWindow::PostCreation(void)
@ -1059,6 +1063,9 @@ void wxWindow::ImplementSetPosition(void)
void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
{
if (m_resizing) return; // I don't like recursions
m_resizing = TRUE;
int newX = x;
int newY = y;
int newW = width;
@ -1099,6 +1106,8 @@ void wxWindow::SetSize( int x, int y, int width, int height, int sizeFlags )
wxSizeEvent event( wxSize(m_width,m_height), GetId() );
event.SetEventObject( this );
ProcessEvent( event );
m_resizing = FALSE;
};
void wxWindow::SetSize( int width, int height )
@ -1113,8 +1122,8 @@ void wxWindow::Move( int x, int y )
void wxWindow::GetSize( int *width, int *height ) const
{
(*width) = m_width;
(*height) = m_height;
if (width) (*width) = m_width;
if (height) (*height) = m_height;
};
void wxWindow::SetClientSize( int width, int height )
@ -1423,6 +1432,8 @@ void wxWindow::AddChild( wxWindow *child )
};
};
// wxNotebooks are very special, so they have their own AddChild
if (IsKindOf(CLASSINFO(wxNotebook)))
{
wxNotebook *tab = (wxNotebook*)this;
@ -1828,7 +1839,7 @@ void wxWindow::SetScrollbar( int orient, int pos, int thumbVisible,
m_vAdjust->page_increment = (float)(wxMax(fthumb-2,0));
m_vAdjust->page_size = fthumb;
};
if (m_wxwindow->window)
{
if (orient == wxHORIZONTAL)

View File

@ -222,7 +222,8 @@ wxFileCtrl::wxFileCtrl( wxWindow *win, const wxWindowID id, const wxString &dirN
const long style, const wxString &name ) :
wxListCtrl( win, id, pos, size, style, name )
{
wxImageList *imageList = new wxImageList();
SetItemSpacing( 20 );
wxImageList *imageList = new wxImageList( 18, 18 );
imageList->Add( wxBitmap( folder_xpm ) );
imageList->Add( wxBitmap( txt_xpm ) );
imageList->Add( wxBitmap( list_xpm ) );