some minor changes in controls/image, timings added to listtest
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5865 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -632,11 +632,11 @@ MyPanel::MyPanel( wxFrame *frame, int x, int y, int w, int h )
|
||||
|
||||
(void)new wxBitmapButton(panel, -1, bitmap, wxPoint(100, 20));
|
||||
|
||||
#if 0
|
||||
#if 1
|
||||
// test for masked bitmap display
|
||||
bitmap = wxBitmap("test2.bmp", wxBITMAP_TYPE_BMP);
|
||||
bitmap.SetMask(new wxMask(bitmap, *wxBLUE));
|
||||
(void)new wxBitmapButton(panel, -1, bitmap, wxPoint(300, 120));
|
||||
(void)new wxStaticBitmap /* wxBitmapButton */ (panel, -1, bitmap, wxPoint(300, 120));
|
||||
#endif
|
||||
|
||||
wxBitmap bmp1(wxTheApp->GetStdIcon(wxICON_INFORMATION)),
|
||||
|
@@ -59,7 +59,8 @@ enum ScreenToShow
|
||||
Show_Text,
|
||||
Show_Lines,
|
||||
Show_Polygons,
|
||||
Show_Mask
|
||||
Show_Mask,
|
||||
Show_Ops
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -145,6 +146,7 @@ protected:
|
||||
void DrawTestLines( int x, int y, int width, wxDC &dc );
|
||||
void DrawText(wxDC& dc);
|
||||
void DrawImages(wxDC& dc);
|
||||
void DrawWithLogicalOps(wxDC& dc);
|
||||
void DrawDefault(wxDC& dc);
|
||||
|
||||
private:
|
||||
@@ -172,7 +174,8 @@ enum
|
||||
File_ShowLines,
|
||||
File_ShowPolygons,
|
||||
File_ShowMask,
|
||||
MenuShow_Last = File_ShowMask,
|
||||
File_ShowOps,
|
||||
MenuShow_Last = File_ShowOps,
|
||||
|
||||
MenuOption_First,
|
||||
|
||||
@@ -556,7 +559,6 @@ void MyCanvas::DrawTestLines( int x, int y, int width, wxDC &dc )
|
||||
dash1[0] = 0xFF;
|
||||
ud.SetDashes( 1, dash1 );
|
||||
dc.DrawLine( x+20, y+170, 100, y+170 );
|
||||
|
||||
}
|
||||
|
||||
void MyCanvas::DrawDefault(wxDC& dc)
|
||||
@@ -628,7 +630,6 @@ void MyCanvas::DrawDefault(wxDC& dc)
|
||||
bitmap = image.ConvertToBitmap();
|
||||
dc.DrawBitmap( bitmap, 50, 170 );
|
||||
|
||||
|
||||
// test the rectangle outline drawing - there should be one pixel between
|
||||
// the rect and the lines
|
||||
dc.SetPen(*wxWHITE_PEN);
|
||||
@@ -715,14 +716,12 @@ void MyCanvas::DrawText(wxDC& dc)
|
||||
dc.DrawRectangle( 100, 40, 4, height );
|
||||
}
|
||||
|
||||
void MyCanvas::DrawImages(wxDC& dc)
|
||||
static const struct
|
||||
{
|
||||
static const struct
|
||||
{
|
||||
const wxChar *name;
|
||||
int rop;
|
||||
} rasterOperations[] =
|
||||
{
|
||||
} rasterOperations[] =
|
||||
{
|
||||
{ "wxAND", wxAND },
|
||||
{ "wxAND_INVERT", wxAND_INVERT },
|
||||
{ "wxAND_REVERSE", wxAND_REVERSE },
|
||||
@@ -738,8 +737,10 @@ void MyCanvas::DrawImages(wxDC& dc)
|
||||
{ "wxSET", wxSET },
|
||||
{ "wxSRC_INVERT", wxSRC_INVERT },
|
||||
{ "wxXOR", wxXOR },
|
||||
};
|
||||
};
|
||||
|
||||
void MyCanvas::DrawImages(wxDC& dc)
|
||||
{
|
||||
dc.DrawText("original image", 0, 0);
|
||||
dc.DrawBitmap(gs_bmpNoMask, 0, 20, 0);
|
||||
dc.DrawText("with colour mask", 0, 100);
|
||||
@@ -764,6 +765,27 @@ void MyCanvas::DrawImages(wxDC& dc)
|
||||
}
|
||||
}
|
||||
|
||||
void MyCanvas::DrawWithLogicalOps(wxDC& dc)
|
||||
{
|
||||
static const wxCoord w = 60;
|
||||
static const wxCoord h = 60;
|
||||
|
||||
// reuse the text colour here
|
||||
dc.SetPen(wxPen(m_owner->m_colourForeground, 1, wxSOLID));
|
||||
|
||||
for ( size_t n = 0; n < WXSIZEOF(rasterOperations); n++ )
|
||||
{
|
||||
wxCoord x = 20 + 150*(n%4),
|
||||
y = 20 + 100*(n/4);
|
||||
|
||||
dc.DrawText(rasterOperations[n].name, x, y - 20);
|
||||
dc.SetLogicalFunction(rasterOperations[n].rop);
|
||||
//dc.DrawRectangle(x, y, w, h);
|
||||
dc.DrawLine(x, y, x + w, y + h);
|
||||
dc.DrawLine(x + w, y, x, y + h);
|
||||
}
|
||||
}
|
||||
|
||||
void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
@@ -804,6 +826,10 @@ void MyCanvas::OnPaint(wxPaintEvent &WXUNUSED(event))
|
||||
case Show_Mask:
|
||||
DrawImages(dc);
|
||||
break;
|
||||
|
||||
case Show_Ops:
|
||||
DrawWithLogicalOps(dc);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -850,6 +876,7 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
||||
menuFile->Append(File_ShowLines, "&Lines screen\tF3");
|
||||
menuFile->Append(File_ShowPolygons, "&Polygons screen\tF4");
|
||||
menuFile->Append(File_ShowMask, "wx&Mask screen\tF5");
|
||||
menuFile->Append(File_ShowOps, "&ROP screen\tF6");
|
||||
menuFile->AppendSeparator();
|
||||
menuFile->Append(File_About, "&About...\tCtrl-A", "Show about dialog");
|
||||
menuFile->AppendSeparator();
|
||||
|
@@ -1,2 +1,2 @@
|
||||
test.png
|
||||
|
||||
saved.xpm
|
||||
|
@@ -100,9 +100,11 @@ END_EVENT_TABLE()
|
||||
|
||||
MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
const wxPoint &pos, const wxSize &size )
|
||||
: wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER ),
|
||||
m_bmpSmileXpm((const char **) smile_xpm),
|
||||
m_iconSmileXpm((const char **) smile_xpm)
|
||||
: wxScrolledWindow( parent, id, pos, size, wxSUNKEN_BORDER )
|
||||
#if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
|
||||
, m_bmpSmileXpm((const char **) smile_xpm)
|
||||
, m_iconSmileXpm((const char **) smile_xpm)
|
||||
#endif
|
||||
{
|
||||
my_horse_png = (wxBitmap*) NULL;
|
||||
my_horse_jpeg = (wxBitmap*) NULL;
|
||||
@@ -168,6 +170,9 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
wxLogError("Can't load PCX image");
|
||||
else
|
||||
my_horse_pcx = new wxBitmap( image.ConvertToBitmap() );
|
||||
|
||||
image.LoadFile( dir + wxString("test.pcx") );
|
||||
my_square = new wxBitmap( image.ConvertToBitmap() );
|
||||
#endif
|
||||
|
||||
if ( !image.LoadFile( dir + wxString("horse.bmp"), wxBITMAP_TYPE_BMP ) )
|
||||
@@ -189,17 +194,16 @@ MyCanvas::MyCanvas( wxWindow *parent, wxWindowID id,
|
||||
my_horse_tiff = new wxBitmap( image.ConvertToBitmap() );
|
||||
#endif
|
||||
|
||||
image.LoadFile( dir + wxString("test.pcx") );
|
||||
my_square = new wxBitmap( image.ConvertToBitmap() );
|
||||
|
||||
CreateAntiAliasedBitmap();
|
||||
|
||||
my_smile_xbm = new wxBitmap( (const char*)smile_bits, smile_width,
|
||||
smile_height, 1 );
|
||||
|
||||
#if !defined(__WINDOWS__) || wxUSE_XPM_IN_MSW
|
||||
// demonstrates XPM automatically using the mask when saving
|
||||
if ( m_bmpSmileXpm.Ok() )
|
||||
m_bmpSmileXpm.SaveFile("saved.xpm", wxBITMAP_TYPE_XPM);
|
||||
#endif
|
||||
}
|
||||
|
||||
MyCanvas::~MyCanvas()
|
||||
@@ -398,7 +402,7 @@ MyFrame::MyFrame()
|
||||
wxPoint(20,20), wxSize(470,360) )
|
||||
{
|
||||
wxMenu *file_menu = new wxMenu();
|
||||
file_menu->Append( ID_ABOUT, "&About..");
|
||||
file_menu->Append( ID_ABOUT, "&About...");
|
||||
file_menu->Append( ID_QUIT, "E&xit");
|
||||
|
||||
wxMenuBar *menu_bar = new wxMenuBar();
|
||||
|
@@ -30,6 +30,7 @@
|
||||
#endif
|
||||
|
||||
#include "wx/listctrl.h"
|
||||
#include "wx/timer.h" // for wxStopWatch
|
||||
#include "listtest.h"
|
||||
|
||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||
@@ -132,12 +133,12 @@ bool MyApp::OnInit(void)
|
||||
// Make a menubar
|
||||
wxMenu *file_menu = new wxMenu;
|
||||
|
||||
file_menu->Append(LIST_LIST_VIEW, "&List view");
|
||||
file_menu->Append(LIST_REPORT_VIEW, "&Report view");
|
||||
file_menu->Append(LIST_ICON_VIEW, "&Icon view");
|
||||
file_menu->Append(LIST_ICON_TEXT_VIEW, "Icon view with &text");
|
||||
file_menu->Append(LIST_SMALL_ICON_VIEW, "&Small icon view");
|
||||
file_menu->Append(LIST_SMALL_ICON_TEXT_VIEW, "Small icon &view with text");
|
||||
file_menu->Append(LIST_LIST_VIEW, "&List view\tF1");
|
||||
file_menu->Append(LIST_REPORT_VIEW, "&Report view\tF2");
|
||||
file_menu->Append(LIST_ICON_VIEW, "&Icon view\tF3");
|
||||
file_menu->Append(LIST_ICON_TEXT_VIEW, "Icon view with &text\tF4");
|
||||
file_menu->Append(LIST_SMALL_ICON_VIEW, "&Small icon view\tF5");
|
||||
file_menu->Append(LIST_SMALL_ICON_TEXT_VIEW, "Small icon &view with text\tF6");
|
||||
file_menu->Append(LIST_DESELECT_ALL, "&Deselect All");
|
||||
file_menu->Append(LIST_SELECT_ALL, "S&elect All");
|
||||
file_menu->AppendSeparator();
|
||||
@@ -149,7 +150,7 @@ bool MyApp::OnInit(void)
|
||||
file_menu->Append(BUSY_OFF, "&Busy cursor off");
|
||||
file_menu->AppendSeparator();
|
||||
file_menu->Append(LIST_ABOUT, "&About");
|
||||
file_menu->Append(LIST_QUIT, "E&xit");
|
||||
file_menu->Append(LIST_QUIT, "E&xit\tAlt-X");
|
||||
wxMenuBar *menu_bar = new wxMenuBar;
|
||||
menu_bar->Append(file_menu, "&File");
|
||||
frame->SetMenuBar(menu_bar);
|
||||
@@ -274,20 +275,30 @@ void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
|
||||
m_listCtrl->InsertColumn(1, "Column 2"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
m_listCtrl->InsertColumn(2, "One More Column (2)"); // , wxLIST_FORMAT_LEFT, 140);
|
||||
|
||||
for ( int i = 0; i < 300; i++ )
|
||||
// to speed up inserting we hide the control temporarily
|
||||
m_listCtrl->Hide();
|
||||
|
||||
wxStopWatch sw;
|
||||
|
||||
wxString buf;
|
||||
static const int NUM_ITEMS = 3000;
|
||||
for ( int i = 0; i < NUM_ITEMS; i++ )
|
||||
{
|
||||
wxChar buf[50];
|
||||
wxSprintf(buf, _T("This is item %d"), i);
|
||||
buf.Printf(_T("This is item %d"), i);
|
||||
long tmp = m_listCtrl->InsertItem(i, buf, 0);
|
||||
m_listCtrl->SetItemData(tmp, i);
|
||||
|
||||
wxSprintf(buf, _T("Col 1, item %d"), i);
|
||||
buf.Printf(_T("Col 1, item %d"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 1, buf);
|
||||
|
||||
wxSprintf(buf, _T("Item %d in column 2"), i);
|
||||
buf.Printf(_T("Item %d in column 2"), i);
|
||||
tmp = m_listCtrl->SetItem(i, 2, buf);
|
||||
}
|
||||
|
||||
m_logWindow->WriteText(wxString::Format(_T("%d items inserted in %ldms\n"),
|
||||
NUM_ITEMS, sw.Time()));
|
||||
m_listCtrl->Show();
|
||||
|
||||
// we leave all mask fields to 0 and only change the colour
|
||||
wxListItem item;
|
||||
item.m_itemId = 0;
|
||||
@@ -371,18 +382,24 @@ void MyFrame::OnSmallIconTextView(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
void MyFrame::OnSort(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
wxStopWatch sw;
|
||||
|
||||
m_listCtrl->SortItems(MyCompareFunction, 0);
|
||||
|
||||
m_logWindow->WriteText(wxString::Format(_T("Sorting %d items took %ld ms\n"),
|
||||
m_listCtrl->GetItemCount(),
|
||||
sw.Time()));
|
||||
}
|
||||
|
||||
void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
(void)wxGetElapsedTime(TRUE);
|
||||
wxStopWatch sw;
|
||||
|
||||
int nItems = m_listCtrl->GetItemCount();
|
||||
m_listCtrl->DeleteAllItems();
|
||||
|
||||
wxLogMessage("Deleting %d items took %ld ms",
|
||||
nItems, wxGetElapsedTime());
|
||||
m_logWindow->WriteText(wxString::Format(_T("Deleting %d items took %ld ms\n"),
|
||||
m_listCtrl->GetItemCount(),
|
||||
sw.Time()));
|
||||
}
|
||||
|
||||
// MyListCtrl
|
||||
|
Reference in New Issue
Block a user