WinCE friendly wxCheckListBox sample.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37737 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
c5491b21d9
commit
1914bb8e12
@ -46,8 +46,7 @@ class CheckListBoxFrame : public wxFrame
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
CheckListBoxFrame(wxFrame *frame, const wxChar *title,
|
CheckListBoxFrame(wxFrame *frame, const wxChar *title);
|
||||||
int x, int y, int w, int h);
|
|
||||||
virtual ~CheckListBoxFrame(){};
|
virtual ~CheckListBoxFrame(){};
|
||||||
|
|
||||||
// notifications
|
// notifications
|
||||||
@ -83,19 +82,20 @@ private:
|
|||||||
|
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
Menu_About = 100,
|
Menu_About = wxID_ABOUT,
|
||||||
Menu_Quit,
|
Menu_Quit = wxID_EXIT,
|
||||||
|
|
||||||
Menu_CheckFirst,
|
Menu_CheckFirst = wxID_HIGHEST,
|
||||||
Menu_UncheckFirst,
|
Menu_UncheckFirst,
|
||||||
Menu_ToggleFirst,
|
Menu_ToggleFirst,
|
||||||
Menu_Selection,
|
Menu_Selection,
|
||||||
Menu_AddItems,
|
Menu_AddItems,
|
||||||
|
|
||||||
Control_First = 1000,
|
Control_First,
|
||||||
Control_Listbox,
|
Control_Listbox,
|
||||||
Btn_Up,
|
|
||||||
Btn_Down
|
Btn_Up = wxID_UP,
|
||||||
|
Btn_Down = wxID_DOWN
|
||||||
};
|
};
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(CheckListBoxFrame, wxFrame)
|
BEGIN_EVENT_TABLE(CheckListBoxFrame, wxFrame)
|
||||||
@ -124,8 +124,7 @@ bool CheckListBoxApp::OnInit(void)
|
|||||||
CheckListBoxFrame *pFrame = new CheckListBoxFrame
|
CheckListBoxFrame *pFrame = new CheckListBoxFrame
|
||||||
(
|
(
|
||||||
NULL,
|
NULL,
|
||||||
_T("wxWidgets Checklistbox Sample"),
|
_T("wxWidgets Checklistbox Sample")
|
||||||
50, 50, 480, 320
|
|
||||||
);
|
);
|
||||||
SetTopWindow(pFrame);
|
SetTopWindow(pFrame);
|
||||||
|
|
||||||
@ -134,16 +133,14 @@ bool CheckListBoxApp::OnInit(void)
|
|||||||
|
|
||||||
// main frame constructor
|
// main frame constructor
|
||||||
CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
||||||
const wxChar *title,
|
const wxChar *title)
|
||||||
int x, int y, int w, int h)
|
: wxFrame(frame, wxID_ANY, title)
|
||||||
: wxFrame(frame, wxID_ANY, title, wxPoint(x, y), wxSize(w, h))
|
|
||||||
{
|
{
|
||||||
#if wxUSE_STATUSBAR
|
#if wxUSE_STATUSBAR
|
||||||
// create the status line
|
// create the status line
|
||||||
const int widths[] = { -1, 60 };
|
const int widths[] = { -1, 60 };
|
||||||
CreateStatusBar(2);
|
CreateStatusBar(2);
|
||||||
SetStatusWidths(2, widths);
|
SetStatusWidths(2, widths);
|
||||||
wxLogStatus(this, _T("no selection"));
|
|
||||||
#endif // wxUSE_STATUSBAR
|
#endif // wxUSE_STATUSBAR
|
||||||
|
|
||||||
// Make a menubar
|
// Make a menubar
|
||||||
@ -161,7 +158,7 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
|||||||
menuList->Append(Menu_UncheckFirst, _T("Uncheck the first item\tCtrl-U"));
|
menuList->Append(Menu_UncheckFirst, _T("Uncheck the first item\tCtrl-U"));
|
||||||
menuList->Append(Menu_ToggleFirst, _T("Toggle the first item\tCtrl-T"));
|
menuList->Append(Menu_ToggleFirst, _T("Toggle the first item\tCtrl-T"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
menuList->AppendCheckItem(Menu_AddItems, _T("Add more items\tCtrl-A"));
|
menuList->Append(Menu_AddItems, _T("Add more items\tCtrl-A"));
|
||||||
menuList->AppendSeparator();
|
menuList->AppendSeparator();
|
||||||
menuList->AppendCheckItem(Menu_Selection, _T("Multiple selection\tCtrl-M"));
|
menuList->AppendCheckItem(Menu_Selection, _T("Multiple selection\tCtrl-M"));
|
||||||
|
|
||||||
@ -172,14 +169,13 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
|||||||
SetMenuBar(menu_bar);
|
SetMenuBar(menu_bar);
|
||||||
|
|
||||||
// make a panel with some controls
|
// make a panel with some controls
|
||||||
m_panel = new wxPanel(this, wxID_ANY, wxPoint(0, 0),
|
m_panel = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||||
wxSize(400, 200), wxTAB_TRAVERSAL);
|
|
||||||
|
|
||||||
CreateCheckListbox();
|
CreateCheckListbox();
|
||||||
|
|
||||||
// create buttons for moving the items around
|
// create buttons for moving the items around
|
||||||
wxButton *button1 = new wxButton(m_panel, Btn_Up, _T(" &Up "), wxPoint(420, 90));
|
wxButton *button1 = new wxButton(m_panel, Btn_Up);
|
||||||
wxButton *button2 = new wxButton(m_panel, Btn_Down, _T("&Down"), wxPoint(420, 120));
|
wxButton *button2 = new wxButton(m_panel, Btn_Down);
|
||||||
|
|
||||||
|
|
||||||
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
|
wxBoxSizer *mainsizer = new wxBoxSizer( wxVERTICAL );
|
||||||
@ -197,8 +193,10 @@ CheckListBoxFrame::CheckListBoxFrame(wxFrame *frame,
|
|||||||
m_panel->SetAutoLayout( true );
|
m_panel->SetAutoLayout( true );
|
||||||
m_panel->SetSizer( mainsizer );
|
m_panel->SetSizer( mainsizer );
|
||||||
|
|
||||||
|
#ifndef __WXWINCE__
|
||||||
// don't allow frame to get smaller than what the sizers tell ye
|
// don't allow frame to get smaller than what the sizers tell ye
|
||||||
mainsizer->SetSizeHints( this );
|
mainsizer->SetSizeHints( this );
|
||||||
|
#endif
|
||||||
|
|
||||||
Show(true);
|
Show(true);
|
||||||
}
|
}
|
||||||
@ -369,7 +367,7 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
|||||||
{
|
{
|
||||||
selection = m_pListBox->GetSelection();
|
selection = m_pListBox->GetSelection();
|
||||||
}
|
}
|
||||||
if ( selection != -1 )
|
if ( selection != wxNOT_FOUND )
|
||||||
{
|
{
|
||||||
wxString label = m_pListBox->GetString(selection);
|
wxString label = m_pListBox->GetString(selection);
|
||||||
|
|
||||||
@ -393,6 +391,7 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
|||||||
int selectionNew = up ? positionNew : positionNew - 1;
|
int selectionNew = up ? positionNew : positionNew - 1;
|
||||||
m_pListBox->Check(selectionNew, wasChecked);
|
m_pListBox->Check(selectionNew, wasChecked);
|
||||||
m_pListBox->SetSelection(selectionNew);
|
m_pListBox->SetSelection(selectionNew);
|
||||||
|
m_pListBox->SetFocus();
|
||||||
|
|
||||||
AdjustColour(selection);
|
AdjustColour(selection);
|
||||||
AdjustColour(selectionNew);
|
AdjustColour(selectionNew);
|
||||||
@ -407,7 +406,7 @@ void CheckListBoxFrame::OnButtonMove(bool up)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// not implemented in ports other than (native) MSW yet
|
// not implemented in ports other than (native) MSW yet
|
||||||
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
|
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) && !defined(__WXWINCE__)
|
||||||
void CheckListBoxFrame::AdjustColour(size_t index)
|
void CheckListBoxFrame::AdjustColour(size_t index)
|
||||||
{
|
{
|
||||||
// even items have grey backround, odd ones - white
|
// even items have grey backround, odd ones - white
|
||||||
|
Loading…
Reference in New Issue
Block a user