added wxGetMultiChoice() (which refuses to work for some reason - will fix

a.s.a.p.)


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8676 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2000-11-03 20:52:17 +00:00
parent 53ccf1c0ba
commit d6c9c1b71e
7 changed files with 689 additions and 182 deletions

View File

@@ -35,7 +35,7 @@
// what to test (in alphabetic order)?
//#define TEST_ARRAYS
#define TEST_ARRAYS
//#define TEST_CMDLINE
//#define TEST_DATETIME
//#define TEST_DIR
@@ -3117,11 +3117,57 @@ static void PrintArray(const char* name, const wxArrayString& array)
}
}
static int StringLenCompare(const wxString& first, const wxString& second)
static void PrintArray(const char* name, const wxArrayInt& array)
{
printf("Dump of the array '%s'\n", name);
size_t nCount = array.GetCount();
for ( size_t n = 0; n < nCount; n++ )
{
printf("\t%s[%u] = %d\n", name, n, array[n]);
}
}
int wxCMPFUNC_CONV StringLenCompare(const wxString& first,
const wxString& second)
{
return first.length() - second.length();
}
int wxCMPFUNC_CONV IntCompare(int *first,
int *second)
{
return *first - *second;
}
int wxCMPFUNC_CONV IntRevCompare(int *first,
int *second)
{
return *second - *first;
}
static void TestArrayOfInts()
{
puts("*** Testing wxArrayInt ***\n");
wxArrayInt a;
a.Add(1);
a.Add(17);
a.Add(5);
a.Add(3);
puts("Initially:");
PrintArray("a", a);
puts("After sort:");
a.Sort(IntCompare);
PrintArray("a", a);
puts("After reverse sort:");
a.Sort(IntRevCompare);
PrintArray("a", a);
}
#include "wx/dynarray.h"
WX_DECLARE_OBJARRAY(Bar, ArrayBars);
@@ -3581,6 +3627,8 @@ int main(int argc, char **argv)
#endif // TEST_STRINGS
#ifdef TEST_ARRAYS
if ( 0 )
{
wxArrayString a1;
a1.Add("tiger");
a1.Add("cat");
@@ -3624,6 +3672,8 @@ int main(int argc, char **argv)
PrintArray("a1", a1);
TestArrayOfObjects();
}
TestArrayOfInts();
#endif // TEST_ARRAYS
#ifdef TEST_DIR

View File

@@ -60,6 +60,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU(DIALOGS_PASSWORD_ENTRY, MyFrame::PasswordEntry)
EVT_MENU(DIALOGS_NUM_ENTRY, MyFrame::NumericEntry)
EVT_MENU(DIALOGS_SINGLE_CHOICE, MyFrame::SingleChoice)
EVT_MENU(DIALOGS_MULTI_CHOICE, MyFrame::MultiChoice)
EVT_MENU(DIALOGS_FILE_OPEN, MyFrame::FileOpen)
EVT_MENU(DIALOGS_FILE_OPEN2, MyFrame::FileOpen2)
EVT_MENU(DIALOGS_FILES_OPEN, MyFrame::FilesOpen)
@@ -127,6 +128,7 @@ bool MyApp::OnInit()
file_menu->Append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P");
file_menu->Append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N");
file_menu->Append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C");
file_menu->Append(DIALOGS_MULTI_CHOICE, "M&ultiple choice\tCtrl-U");
file_menu->AppendSeparator();
file_menu->Append(DIALOGS_TIP, "&Tip of the day\tCtrl-T");
file_menu->AppendSeparator();
@@ -349,6 +351,30 @@ void MyFrame::SingleChoice(wxCommandEvent& WXUNUSED(event) )
}
}
void MyFrame::MultiChoice(wxCommandEvent& WXUNUSED(event) )
{
const wxString choices[] = { "One", "Two", "Three", "Four", "Five" } ;
int n = 5;
wxArrayInt selections;
size_t count = wxGetMultipleChoices(selections,
"This is a small sample\n"
"A multi-choice convenience dialog",
"Please select a value",
n, (const wxString *)choices,
this);
if ( count )
{
wxLogMessage("You selected %u items:", count);
for ( size_t n = 0; n < count; n++ )
{
wxLogMessage("\t%u: %u (%s)", n, selections[n],
choices[selections[n]].c_str());
}
}
//else: cancelled or nothing selected
}
void MyFrame::FileOpen(wxCommandEvent& WXUNUSED(event) )
{
wxFileDialog dialog(this, "Testing open file dialog", "", "", "*.txt", 0);

View File

@@ -61,6 +61,7 @@ public:
void LogDialog(wxCommandEvent& event);
void MessageBox(wxCommandEvent& event);
void SingleChoice(wxCommandEvent& event);
void MultiChoice(wxCommandEvent& event);
void TextEntry(wxCommandEvent& event);
void PasswordEntry(wxCommandEvent& event);
void NumericEntry(wxCommandEvent& event);
@@ -110,6 +111,7 @@ enum
DIALOGS_CHOOSE_FONT_GENERIC,
DIALOGS_MESSAGE_BOX,
DIALOGS_SINGLE_CHOICE,
DIALOGS_MULTI_CHOICE,
DIALOGS_TEXT_ENTRY,
DIALOGS_PASSWORD_ENTRY,
DIALOGS_FILE_OPEN,

View File

@@ -67,6 +67,16 @@ public:
MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
// event handlers (these functions should _not_ be virtual)
void OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
dc.DrawRectangle(20, 20, 100, 100);
dc.SetPen(*wxRED_PEN);
dc.SetDeviceOrigin(20, 20);
dc.SetClippingRegion(0, 0, 100, 100);
dc.DrawLine(0, 0, 1000, 1000);
}
void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event);
@@ -95,6 +105,7 @@ enum
// handlers) which process them. It can be also done at run-time, but for the
// simple menu events like this the static method is much simpler.
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_PAINT(MyFrame::OnPaint)
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
EVT_MENU(Minimal_About, MyFrame::OnAbout)
END_EVENT_TABLE()