Page Menu
Home
Wildfire Games
Search
Configure Global Search
Log In
Paste
P168
#5574 test script
Active
Public
Actions
Authored by
s0600204
on Sep 4 2019, 10:24 PM.
Edit Paste
Archive Paste
View Raw File
Subscribe
Mute Notifications
Award Token
Flag For Later
Tags
None
Subscribers
None
// wxwidgets test program, for #5574
//
// On linux:
// gcc -o wxtest ./wxtest.cpp -lstdc++ `wx-config --cxxflags --libs`
#include
<vector>
#include
<wx/wx.h>
enum
{
ID_ViewerAnimationStr
=
1
,
ID_ViewerAnimationChar
,
ID_ViewerAnimationWStr
,
ID_ViewerAnimationWChar
,
};
class
MyApp
:
public
wxApp
{
public
:
virtual
bool
OnInit
();
};
class
MyFrame
:
public
wxFrame
{
public
:
MyFrame
(
const
wxString
&
title
,
const
wxPoint
&
pos
,
const
wxSize
&
size
);
private
:
wxPanel
*
m_ViewerPanel
;
void
OnSelectAnim
(
wxCommandEvent
&
event
);
wxDECLARE_EVENT_TABLE
();
};
BEGIN_EVENT_TABLE
(
MyFrame
,
wxFrame
)
EVT_CHOICE
(
ID_ViewerAnimationStr
,
MyFrame
::
OnSelectAnim
)
EVT_CHOICE
(
ID_ViewerAnimationChar
,
MyFrame
::
OnSelectAnim
)
EVT_CHOICE
(
ID_ViewerAnimationWStr
,
MyFrame
::
OnSelectAnim
)
EVT_CHOICE
(
ID_ViewerAnimationWChar
,
MyFrame
::
OnSelectAnim
)
END_EVENT_TABLE
()
wxIMPLEMENT_APP
(
MyApp
);
bool
MyApp
::
OnInit
()
{
MyFrame
*
frame
=
new
MyFrame
(
"string type imports"
,
wxPoint
(
250
,
250
),
wxSize
(
450
,
340
));
frame
->
Show
(
true
);
return
true
;
}
MyFrame
::
MyFrame
(
const
wxString
&
title
,
const
wxPoint
&
pos
,
const
wxSize
&
size
)
:
wxFrame
(
NULL
,
wxID_ANY
,
title
,
pos
,
size
)
{
m_ViewerPanel
=
new
wxPanel
(
this
,
wxID_ANY
);
wxSizer
*
viewerAnimSizer
=
new
wxStaticBoxSizer
(
wxVERTICAL
,
m_ViewerPanel
,
_
(
"Animation"
));
// std::string
{
wxArrayString
animChoices
;
std
::
vector
<
std
::
string
>
anims
=
{
"apple"
,
"banana"
,
"carrot"
};
for
(
std
::
string
a
:
anims
)
animChoices
.
Add
(
wxString
(
a
));
wxChoice
*
viewerAnimSelector
=
new
wxChoice
(
m_ViewerPanel
,
ID_ViewerAnimationStr
,
wxDefaultPosition
,
wxDefaultSize
,
animChoices
);
viewerAnimSelector
->
SetSelection
(
0
);
viewerAnimSizer
->
Add
(
viewerAnimSelector
,
wxSizerFlags
().
Expand
());
}
// char
{
wxArrayString
animChoices
;
std
::
vector
<
std
::
string
>
anims
=
{
"doughnut"
,
"egg"
,
"fudge"
};
for
(
std
::
string
a
:
anims
)
animChoices
.
Add
(
wxString
(
a
.
c_str
()));
wxChoice
*
viewerAnimSelector
=
new
wxChoice
(
m_ViewerPanel
,
ID_ViewerAnimationChar
,
wxDefaultPosition
,
wxDefaultSize
,
animChoices
);
viewerAnimSelector
->
SetSelection
(
0
);
viewerAnimSizer
->
Add
(
viewerAnimSelector
,
wxSizerFlags
().
Expand
());
}
// std::wstring
{
wxArrayString
animChoices
;
std
::
vector
<
std
::
wstring
>
anims
=
{
L
"grapefuit"
,
L
"horseradish"
,
L
"icecream"
};
for
(
std
::
wstring
a
:
anims
)
animChoices
.
Add
(
wxString
(
a
));
wxChoice
*
viewerAnimSelector
=
new
wxChoice
(
m_ViewerPanel
,
ID_ViewerAnimationWStr
,
wxDefaultPosition
,
wxDefaultSize
,
animChoices
);
viewerAnimSelector
->
SetSelection
(
0
);
viewerAnimSizer
->
Add
(
viewerAnimSelector
,
wxSizerFlags
().
Expand
());
}
// wchar
{
wxArrayString
animChoices
;
std
::
vector
<
std
::
wstring
>
anims
=
{
L
"jam"
,
L
"kitkat"
,
L
"loaf"
};
for
(
std
::
wstring
a
:
anims
)
animChoices
.
Add
(
wxString
(
a
.
c_str
()));
wxChoice
*
viewerAnimSelector
=
new
wxChoice
(
m_ViewerPanel
,
ID_ViewerAnimationChar
,
wxDefaultPosition
,
wxDefaultSize
,
animChoices
);
viewerAnimSelector
->
SetSelection
(
0
);
viewerAnimSizer
->
Add
(
viewerAnimSelector
,
wxSizerFlags
().
Expand
());
}
m_ViewerPanel
->
SetSizer
(
viewerAnimSizer
);
}
void
MyFrame
::
OnSelectAnim
(
wxCommandEvent
&
event
)
{
wxMessageBox
(
event
.
GetString
(),
"Selected Value"
,
wxOK
|
wxICON_INFORMATION
);
}
Event Timeline
s0600204
created this paste.
Sep 4 2019, 10:24 PM
s0600204
created this object with visibility "
s0600204
".
s0600204
created this object with edit policy "
s0600204
".
s0600204
edited the content of this paste.
(Show Details)
Sep 5 2019, 12:31 AM
s0600204
changed the visibility from "
s0600204
" to "
Contributors
(Project)".
s0600204
edited the content of this paste.
(Show Details)
Sep 5 2019, 2:52 AM
s0600204
changed the visibility from "
Contributors
(Project)" to "All Users".
Sep 5 2019, 3:02 AM
s0600204
changed the visibility from "All Users" to "Public (No Login Required)".
Sep 5 2019, 3:11 AM
Log In to Comment