18
18
%%%-------------------------------------------------------------------
19
19
%%% File : wx_class_SUITE.erl
20
20
%%% Author : Dan Gudmundsson <dan.gudmundsson@ericsson.com>
23
23
%%% Created : 13 Nov 2008 by Dan Gudmundsson <dan.gudmundsson@ericsson.com>
24
24
%%%-------------------------------------------------------------------
25
25
-module(wx_class_SUITE).
27
-export([all/0, init_per_suite/1, end_per_suite/1,
28
init_per_testcase/2, fin_per_testcase/2, end_per_testcase/2]).
27
-export([all/0, suite/0,groups/0,init_per_group/2,end_per_group/2,
28
init_per_suite/1, end_per_suite/1,
29
init_per_testcase/2, end_per_testcase/2]).
30
31
-compile(export_all).
41
42
init_per_testcase(Func,Config) ->
42
43
wx_test_lib:init_per_testcase(Func,Config).
43
end_per_testcase(Func,Config) ->
44
wx_test_lib:end_per_testcase(Func,Config).
45
fin_per_testcase(Func,Config) -> %% For test_server
44
end_per_testcase(Func,Config) ->
46
45
wx_test_lib:end_per_testcase(Func,Config).
48
47
%% SUITE specification
48
suite() -> [{ct_hooks,[ts_install_cth]}].
51
[calendarCtrl, treeCtrl, notebook, staticBoxSizer,
52
clipboard, helpFrame, htmlWindow, listCtrlSort, listCtrlVirtual,
53
radioBox, systemSettings].
58
init_per_group(_GroupName, Config) ->
61
end_per_group(_GroupName, Config) ->
71
70
Frame = ?mt(wxFrame, wxFrame:new(Wx, 1, "Calendar", [])),
72
71
Panel = wxPanel:new(Frame),
73
72
Sz = wxBoxSizer:new(?wxVERTICAL),
75
74
{YMD={_,_,Day},_} = DateTime = calendar:now_to_datetime(erlang:now()),
76
Cal = ?mt(wxCalendarCtrl, wxCalendarCtrl:new(Panel, ?wxID_ANY,
75
Cal = ?mt(wxCalendarCtrl, wxCalendarCtrl:new(Panel, ?wxID_ANY,
79
78
wxSizer:add(Sz,Cal),
92
91
?m({0,243,0,255}, wxCalendarDateAttr:getBackgroundColour(DateAttr1)),
94
93
?m({YMD, _},wxCalendarCtrl:getDate(Cal)),
96
wxCalendarCtrl:connect(Cal, calendar_weekday_clicked),
97
wxCalendarCtrl:connect(Cal, calendar_day_changed),
98
wxCalendarCtrl:connect(Cal, calendar_month_changed),
95
wxCalendarCtrl:connect(Cal, calendar_weekday_clicked),
96
wxCalendarCtrl:connect(Cal, calendar_day_changed),
97
wxCalendarCtrl:connect(Cal, calendar_month_changed),
99
98
wxCalendarCtrl:connect(Cal, calendar_year_changed),
100
wxCalendarCtrl:connect(Cal, calendar_doubleclicked),
99
wxCalendarCtrl:connect(Cal, calendar_doubleclicked),
101
100
wxCalendarCtrl:connect(Cal, calendar_sel_changed),
103
102
wxWindow:setSizer(Panel,Sz),
104
103
wxSizer:setSizeHints(Sz,Frame),
105
wxWindow:show(Frame),
104
wxWindow:show(Frame),
107
106
wx_test_lib:wx_destroy(Frame,Config).
110
109
treeCtrl(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
111
110
treeCtrl(Config) ->
114
113
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
115
114
Panel = wxPanel:new(Frame, []),
116
115
Tree = ?mt(wxTreeCtrl,wxTreeCtrl:new(Panel, [{style , ?wxTR_HAS_BUTTONS}])),
123
122
?m(ok, wxTreeCtrl:setItemData(Tree, Item2, {data, item2})),
124
123
Item3 = wxTreeCtrl:appendItem(Tree, Root, "Item3", []),
125
124
?m(ok, wxTreeCtrl:setItemData(Tree, Item3, {data, item3})),
127
126
Sizer = wxBoxSizer:new(?wxVERTICAL),
128
127
wxSizer:add(Sizer, Tree, [{flag, ?wxEXPAND}, {proportion, 1}]),
130
129
wxWindow:setSizerAndFit(Panel, Sizer),
131
130
wxFrame:show(Frame),
133
132
?m([], wxTreeCtrl:getItemData(Tree, Root)),
134
133
?m({data,item1}, wxTreeCtrl:getItemData(Tree, Item1)),
135
134
?m({data,item2}, wxTreeCtrl:getItemData(Tree, Item2)),
136
135
?m({data,item3}, wxTreeCtrl:getItemData(Tree, Item3)),
138
137
wxFrame:connect(Tree, command_tree_item_expanded),
139
138
wxFrame:connect(Tree, command_tree_item_collapsed),
140
139
wxFrame:connect(Frame, close_window),
142
141
wxTreeCtrl:editLabel(Tree, Root),
145
144
wx_test_lib:wx_destroy(Frame,Config).
147
146
notebook(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
211
210
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
212
211
Panel = wxPanel:new(Frame, []),
213
212
InclSizer = ?mt(wxStaticBoxSizer,
214
wxStaticBoxSizer:new(?wxVERTICAL, Panel,
213
wxStaticBoxSizer:new(?wxVERTICAL, Panel,
215
214
[{label, "Module inclusion policy"}])),
216
215
Sizer = wxBoxSizer:new(?wxVERTICAL),
217
216
wxSizer:add(Sizer, InclSizer,
218
217
[{border, 2}, {flag, ?wxALL bor ?wxEXPAND}, {proportion, 1}]),
219
wxWindow:setSizerAndFit(Panel, Sizer),
218
wxWindow:setSizerAndFit(Panel, Sizer),
221
220
wxWindow:show(Frame),
222
221
wx_test_lib:wx_destroy(Frame,Config).
264
263
wxClipboard:flush(CB),
265
264
?log("Stopping ~n",[]),
268
267
helpFrame(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
269
268
helpFrame(Config) ->
271
270
MFrame = wx:batch(fun() ->
272
271
MFrame = wxFrame:new(Wx, ?wxID_ANY, "Main Frame"),
273
wxPanel:new(MFrame, [{size, {600,400}}]),
272
wxPanel:new(MFrame, [{size, {600,400}}]),
274
273
wxWindow:show(MFrame),
280
279
{X, Y, W,H} = wxWindow:getScreenRect(MFrame),
281
280
io:format("Pos0: ~p ~p ~p Pos: ~p:~p Size: ~p:~p ~n",
282
281
[X0,Y0, wxWindow:clientToScreen(MFrame, {0,0}), X,Y,W,H]),
284
283
Pos = {X+5, Y+(H div 2)},
285
284
Size = {W-10, (H div 2) - 5},
287
Comp = wxFrame:new(MFrame, ?wxID_ANY, "Completion Window",
286
Comp = wxFrame:new(MFrame, ?wxID_ANY, "Completion Window",
288
287
[{pos, Pos}, {size, Size},
289
288
{style, ?wxFRAME_FLOAT_ON_PARENT}]),
290
289
LB = wxListBox:new(Comp, 42, [{style, ?wxLB_SINGLE},
302
301
{MFrame,HPanel} =
303
302
wx:batch(fun() ->
304
303
MFrame = wxFrame:new(Wx, ?wxID_ANY, "Main Frame"),
305
HPanel = wxHtmlWindow:new(MFrame, [{size, {600,400}}]),
304
HPanel = wxHtmlWindow:new(MFrame, [{size, {600,400}}]),
306
305
wxWindow:show(MFrame),
311
310
WxMod = code:which(wx),
312
311
WxDir = filename:split(filename:dirname(WxMod)) -- ["ebin"],
313
312
Html = filename:join(filename:join(WxDir),filename:join("doc", "html")),
315
314
Index = filename:join(Html, "wx.html"),
317
316
?m(ok, wxHtmlWindow:connect(HPanel, command_html_link_clicked,
335
334
listCtrlSort(Config) ->
337
336
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
339
338
LC = wxListCtrl:new(Frame, [{style, ?wxLC_REPORT bor ?wxLC_SORT_ASCENDING}]),
341
340
%% must be done crashes in wxwidgets otherwise.
342
341
wxListCtrl:insertColumn(LC, 0, "Column"),
345
344
wxListCtrl:insertItem(LC, Int, integer_to_list(Int)),
346
345
%% ItemData Can only be integers currently
347
346
wxListCtrl:setItemData(LC, Int, abs(2500-Int))
350
349
wx:foreach(Add, lists:seq(0,5000)),
351
350
wxWindow:show(Frame),
376
375
wx_test_lib:wx_destroy(Frame,Config).
377
listCtrlVirtual(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
378
listCtrlVirtual(Config) ->
380
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
381
IA = wxListItemAttr:new(),
382
wxListItemAttr:setTextColour(IA, {190, 25, 25}),
383
LC = wxListCtrl:new(Frame,
384
[{style, ?wxLC_REPORT bor ?wxLC_VIRTUAL},
385
{onGetItemText, fun(_This, Item, 0) ->
386
"Row " ++ integer_to_list(Item);
387
(_, Item, 1) when Item rem 5 == 0 ->
391
{onGetItemAttr, fun(_This, Item) when Item rem 3 == 0 ->
394
wx:typeCast(wx:null(), wxListItemAttr)
396
{onGetItemColumnImage, fun(_This, Item, 1) ->
403
IL = wxImageList:new(16,16),
404
wxImageList:add(IL, wxArtProvider:getBitmap("wxART_COPY", [{size, {16,16}}])),
405
wxImageList:add(IL, wxArtProvider:getBitmap("wxART_MISSING_IMAGE", [{size, {16,16}}])),
406
wxImageList:add(IL, wxArtProvider:getBitmap("wxART_TICK_MARK", [{size, {16,16}}])),
407
wxImageList:add(IL, wxArtProvider:getBitmap("wxART_CROSS_MARK", [{size, {16,16}}])),
408
wxListCtrl:assignImageList(LC, IL, ?wxIMAGE_LIST_SMALL),
410
wxListCtrl:insertColumn(LC, 0, "Column 1"),
411
wxListCtrl:insertColumn(LC, 1, "Column 2"),
412
wxListCtrl:setColumnWidth(LC, 0, 200),
413
wxListCtrl:setColumnWidth(LC, 1, 200),
414
wxListCtrl:setItemCount(LC, 1000000),
416
wxWindow:show(Frame),
417
wx_test_lib:wx_destroy(Frame,Config).
379
420
radioBox(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
380
421
radioBox(Config) ->
384
425
TrSortRadioBox = wxRadioBox:new(Frame, ?wxID_ANY, "Sort by:",
385
426
{100, 100},{100, 100}, ["Timestamp"]),
387
428
io:format("TrSortRadioBox ~p ~n", [TrSortRadioBox]),
388
429
%% If I uncomment any of these lines, it will crash
399
440
systemSettings(Config) ->
401
442
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
403
444
?m({_,_,_,_}, wxSystemSettings:getColour(?wxSYS_COLOUR_DESKTOP)),
404
445
?mt(wxFont, wxSystemSettings:getFont(?wxSYS_SYSTEM_FONT)),
405
446
?m(true, is_integer(wxSystemSettings:getMetric(?wxSYS_MOUSE_BUTTONS))),
408
449
wxWindow:show(Frame),
409
450
wx_test_lib:wx_destroy(Frame,Config).
453
textCtrl(TestInfo) when is_atom(TestInfo) -> wx_test_lib:tc_info(TestInfo);
456
Frame = wxFrame:new(Wx, ?wxID_ANY, "Frame"),
458
TC = ?mt(wxTextCtrl, wxTextCtrl:new(Frame, ?wxID_ANY, [{style, ?wxTE_MULTILINE bor ?wxTE_RICH2}])),
459
wxTextCtrl:appendText(TC, "This line is in default color\n"),
460
Attr = ?mt(wxTextAttr, wxTextAttr:new(?wxRED)),
461
wxTextCtrl:setDefaultStyle(TC, Attr),
462
wxTextCtrl:appendText(TC, "This line is in ?wxRED color\n"),
463
wxTextAttr:setTextColour(Attr, ?wxBLACK),
464
wxTextCtrl:setDefaultStyle(TC, Attr),
465
wxTextCtrl:appendText(TC, "This line is in ?wxBLACK color\n"),
466
Default = wxSystemSettings:getColour(?wxSYS_COLOUR_WINDOWTEXT),
467
wxTextAttr:setTextColour(Attr, Default),
468
wxTextCtrl:setDefaultStyle(TC, Attr),
469
wxTextCtrl:appendText(TC, "This line is in default color\n"),
470
wxTextAttr:destroy(Attr),
471
wxWindow:show(Frame),
472
wx_test_lib:wx_destroy(Frame,Config).