projects
/
wxWidgets.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix for potential crash when conversion fails
[wxWidgets.git]
/
samples
/
widgets
/
combobox.cpp
diff --git
a/samples/widgets/combobox.cpp
b/samples/widgets/combobox.cpp
index 9f7046a89bd62212c1b4583981aa91f80328bff6..2ac76337af76d209f2b99a49c6627040a3dc7e33 100644
(file)
--- a/
samples/widgets/combobox.cpp
+++ b/
samples/widgets/combobox.cpp
@@
-52,7
+52,7
@@
// control ids
enum
{
// control ids
enum
{
- ComboPage_Reset =
100
,
+ ComboPage_Reset =
wxID_HIGHEST
,
ComboPage_CurText,
ComboPage_InsertionPointText,
ComboPage_Insert,
ComboPage_CurText,
ComboPage_InsertionPointText,
ComboPage_Insert,
@@
-85,9
+85,13
@@
enum
class ComboboxWidgetsPage : public WidgetsPage
{
public:
class ComboboxWidgetsPage : public WidgetsPage
{
public:
- ComboboxWidgetsPage(
wxBookCtrlBase
*book, wxImageList *imaglist);
+ ComboboxWidgetsPage(
WidgetsBookCtrl
*book, wxImageList *imaglist);
virtual wxControl *GetWidget() const { return m_combobox; }
virtual wxControl *GetWidget() const { return m_combobox; }
+ virtual void RecreateWidget() { CreateCombo(); }
+
+ // lazy creation of the content
+ virtual void CreateContent();
protected:
// event handlers
protected:
// event handlers
@@
-191,11
+195,19
@@
END_EVENT_TABLE()
// implementation
// ============================================================================
// implementation
// ============================================================================
-IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"));
+#if defined(__WXUNIVERSAL__)
+ #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+ #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(ComboboxWidgetsPage, _T("Combobox"),
+ FAMILY_CTRLS | WITH_ITEMS_CTRLS | COMBO_CTRLS
+ );
-ComboboxWidgetsPage::ComboboxWidgetsPage(
wxBookCtrlBase
*book,
+ComboboxWidgetsPage::ComboboxWidgetsPage(
WidgetsBookCtrl
*book,
wxImageList *imaglist)
wxImageList *imaglist)
- : WidgetsPage(book)
+ : WidgetsPage(book
, imaglist, combobox_xpm
)
{
// init everything
m_chkSort =
{
// init everything
m_chkSort =
@@
-203,9
+215,10
@@
ComboboxWidgetsPage::ComboboxWidgetsPage(wxBookCtrlBase *book,
m_combobox = (wxComboBox *)NULL;
m_sizerCombo = (wxSizer *)NULL;
m_combobox = (wxComboBox *)NULL;
m_sizerCombo = (wxSizer *)NULL;
+}
- imaglist->Add(wxBitmap(combobox_xpm));
-
+void ComboboxWidgetsPage::CreateContent()
+{
/*
What we create here is a frame having 3 panes: style pane is the
leftmost one, in the middle the pane with buttons allowing to perform
/*
What we create here is a frame having 3 panes: style pane is the
leftmost one, in the middle the pane with buttons allowing to perform
@@
-334,7
+347,7
@@
void ComboboxWidgetsPage::Reset()
void ComboboxWidgetsPage::CreateCombo()
{
void ComboboxWidgetsPage::CreateCombo()
{
- int flags =
0
;
+ int flags =
ms_defaultFlags
;
if ( m_chkSort->GetValue() )
flags |= wxCB_SORT;
if ( m_chkSort->GetValue() )
flags |= wxCB_SORT;
@@
-362,8
+375,8
@@
void ComboboxWidgetsPage::CreateCombo()
wxArrayString items;
if ( m_combobox )
{
wxArrayString items;
if ( m_combobox )
{
- int count = m_combobox->GetCount();
- for ( int n = 0; n < count; n++ )
+
unsigned
int count = m_combobox->GetCount();
+ for (
unsigned
int n = 0; n < count; n++ )
{
items.Add(m_combobox->GetString(n));
}
{
items.Add(m_combobox->GetString(n));
}
@@
-377,8
+390,8
@@
void ComboboxWidgetsPage::CreateCombo()
0, NULL,
flags);
0, NULL,
flags);
-
size_
t count = items.GetCount();
- for (
size_
t n = 0; n < count; n++ )
+
unsigned in
t count = items.GetCount();
+ for (
unsigned in
t n = 0; n < count; n++ )
{
m_combobox->Append(items[n]);
}
{
m_combobox->Append(items[n]);
}
@@
-401,7
+414,7
@@
void ComboboxWidgetsPage::OnButtonReset(wxCommandEvent& WXUNUSED(event))
void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
{
int sel = m_combobox->GetSelection();
void ComboboxWidgetsPage::OnButtonChange(wxCommandEvent& WXUNUSED(event))
{
int sel = m_combobox->GetSelection();
- if ( sel !=
-1
)
+ if ( sel !=
wxNOT_FOUND
)
{
#ifndef __WXGTK__
m_combobox->SetString(sel, m_textChange->GetValue());
{
#ifndef __WXGTK__
m_combobox->SetString(sel, m_textChange->GetValue());
@@
-415,7
+428,7
@@
void ComboboxWidgetsPage::OnButtonDelete(wxCommandEvent& WXUNUSED(event))
{
unsigned long n;
if ( !m_textDelete->GetValue().ToULong(&n) ||
{
unsigned long n;
if ( !m_textDelete->GetValue().ToULong(&n) ||
- (n >=
(unsigned)
m_combobox->GetCount()) )
+ (n >= m_combobox->GetCount()) )
{
return;
}
{
return;
}
@@
-426,7
+439,7
@@
void ComboboxWidgetsPage::OnButtonDelete(wxCommandEvent& WXUNUSED(event))
void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
{
int sel = m_combobox->GetSelection();
void ComboboxWidgetsPage::OnButtonDeleteSel(wxCommandEvent& WXUNUSED(event))
{
int sel = m_combobox->GetSelection();
- if ( sel !=
-1
)
+ if ( sel !=
wxNOT_FOUND
)
{
m_combobox->Delete(sel);
}
{
m_combobox->Delete(sel);
}
@@
-524,7
+537,7
@@
void ComboboxWidgetsPage::OnUpdateUIDeleteButton(wxUpdateUIEvent& event)
void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
{
if (m_combobox)
void ComboboxWidgetsPage::OnUpdateUIDeleteSelButton(wxUpdateUIEvent& event)
{
if (m_combobox)
- event.Enable(m_combobox->GetSelection() !=
-1
);
+ event.Enable(m_combobox->GetSelection() !=
wxNOT_FOUND
);
}
void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)
}
void ComboboxWidgetsPage::OnUpdateUIClearButton(wxUpdateUIEvent& event)