wxErlang

wxCommandEvent.erl

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
%      /¯  /¯\ |\/| |\/|  /\  |\ | |¯\    |_¯ \ / |_¯ |\ | ¯|¯                 
%\ W X \_, \_/ |  | |  | /¯¯\ | \| |_/    |__  V  |__ | \|  |  . E  R  L                 
%%——————————————————————————————————————————————————————————————————————
%%
%%   Copyright Ericsson AB 2008-2013. All Rights Reserved.
%%
%%——————————————————————————————————————————————
%% Whitespace Beautified by ScriptCulture © 2018
%% Sit Back · Feet Up · Learn wxErlang
%% For use as a reference only
%% www.scriptculture.com
%% Not check-summed 
%% wx 1.8 —————————————————————————————————————— 
%%
%% Licensed under the Apache License, 
%% Version 2.0 (the "License"); you may 
%% not use this file except in compliance 
%% with the License. You may obtain a copy 
%% of the License at:
%%
%%     http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by 
%% applicable law or agreed to in writing, software
%% distributed under the License is distributed 
%% on an "AS IS" BASIS, WITHOUT WARRANTIES 
%% OR CONDITIONS OF ANY KIND, either 
%% express or implied. See the 
%% License for the specific 
%% language governing 
%% permissions and
%% limitations 
%% under the 
%% License.
%%%%%%%
%%%%
%%%%%
%%
%% @doc See external documentation: <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxcommandevent.html">wxCommandEvent</a>.
%% <dl><dt>Use {@link wxEvtHandler:connect/3.} with EventType:</dt>
%% <dd><em>command_button_clicked</em>, <em>command_checkbox_clicked</em>, <em>command_choice_selected</em>, <em>command_listbox_selected</em>, <em>command_listbox_doubleclicked</em>, 
%% <dd><em>command_text_updated</em>, <em>command_text_enter</em>, <em>command_menu_selected</em>, <em>command_slider_updated</em>, <em>command_radiobox_selected</em>, <em>command_radiobutton_selected</em>, 
%% <dd><em>command_scrollbar_updated</em>, <em>command_vlbox_selected</em>, <em>command_combobox_selected</em>, <em>command_tool_rclicked</em>, <em>command_tool_enter</em>, <em>command_checklistbox_toggled</em>, 
%% <dd><em>command_togglebutton_clicked</em>, <em>command_left_click</em>, <em>command_left_dclick</em>, <em>command_right_click</em>, <em>command_set_focus</em>, <em>command_kill_focus</em>, <em>command_enter</em></dd></dl>
%% See also the message variant {@link wxEvtHandler:wxCommand(). #wxCommand{}} event record type.
%%
%% <p>This class is derived (and can use functions) from:
%% <br />{@link wxEvent}
%% </p>
%% @type wxCommandEvent().  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%   
%%   OVERVIEW
%%   ––––––––
%%   This event class contains information about command events, 
%%   which originate from a variety of simple controls.
%%
%%   More complex controls, such as wxTreeCtrl, 
%%   have separate command event classes.
%%   
%%   
%%   EVENT TABLE MACROS
%%   
%%   To process a menu command event, 
%%   use these event handler macros to direct input to member functions that take a wxCommandEvent argument.
%%   
%%
%%         EVT_COMMAND(id, event, func)             Process a command, supplying the window identifier, 
%%                                                  command event identifier, and member function.
%%                                                  
%%         EVT_COMMAND_RANGE(id1, id2, event, func) Process a command for a range of window identifiers, 
%%                                                  supplying the minimum and maximum window identifiers, 
%%                                                  command event identifier, and member function.
%%                                                  
%%         EVT_BUTTON(id, func)                     Process a wxEVT_COMMAND_BUTTON_CLICKED command, 
%%                                                  which is generated by a wxButton control.
%%                                                  
%%         EVT_CHECKBOX(id, func)                   Process a wxEVT_COMMAND_CHECKBOX_CLICKED command, 
%%                                                  which is generated by a wxCheckBox control.
%%                                                  
%%         EVT_CHOICE(id, func)                     Process a wxEVT_COMMAND_CHOICE_SELECTED command, 
%%                                                  which is generated by a wxChoice control.
%%                                                  
%%         EVT_COMBOBOX(id, func)                   Process a wxEVT_COMMAND_COMBOBOX_SELECTED command, 
%%                                                  which is generated by a wxComboBox control.
%%                                                  
%%         EVT_LISTBOX(id, func)                    Process a wxEVT_COMMAND_LISTBOX_SELECTED command, 
%%                                                  which is generated by a wxListBox control.
%%                                                  
%%         EVT_LISTBOX_DCLICK(id, func)             Process a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED command, 
%%                                                  which is generated by a wxListBox control.
%%                                                  
%%         EVT_MENU(id, func)                       Process a wxEVT_COMMAND_MENU_SELECTED command, 
%%                                                  which is generated by a menu item.
%%                                                  
%%         EVT_MENU_RANGE(id1, id2, func)           Process a wxEVT_COMMAND_MENU_RANGE command, 
%%                                                  which is generated by a range of menu items.
%%                                                  
%%         EVT_CONTEXT_MENU(func)                   Process the event generated when the user has 
%%                                                  requested a popup menu to appear by pressing a special 
%%                                                  keyboard key (under Windows) or by right clicking the mouse.
%%                                                  
%%         EVT_RADIOBOX(id, func)                   Process a wxEVT_COMMAND_RADIOBOX_SELECTED command, 
%%                                                  which is generated by a wxRadioBox control.
%%                                                  
%%         EVT_RADIOBUTTON(id, func)                Process a wxEVT_COMMAND_RADIOBUTTON_SELECTED command, 
%%                                                  which is generated by a wxRadioButton control.
%%                                                  
%%         EVT_SCROLLBAR(id, func)                  Process a wxEVT_COMMAND_SCROLLBAR_UPDATED command, 
%%                                                  which is generated by a wxScrollBar control. 
%%                                                  This is provided for compatibility only; more specific 
%%                                                  scrollbar event macros should be used instead (see wxScrollEvent).
%%                                                  
%%         EVT_SLIDER(id, func)                     Process a wxEVT_COMMAND_SLIDER_UPDATED command, 
%%                                                  which is generated by a wxSlider control.
%%                                                  
%%         EVT_TEXT(id, func)                       Process a wxEVT_COMMAND_TEXT_UPDATED command, 
%%                                                  which is generated by a wxTextCtrl control.
%%                                                  
%%         EVT_TEXT_ENTER(id, func)                 Process a wxEVT_COMMAND_TEXT_ENTER command, 
%%                                                  which is generated by a wxTextCtrl control. 
%%                                                  
%%                                                  Note that you must use wxTE_PROCESS_ENTER flag 
%%                                                  when creating the control if you want it to generate such events.
%%                                                  
%%         EVT_TEXT_MAXLEN(id, func)                Process a wxEVT_COMMAND_TEXT_MAXLEN command, 
%%                                                  which is generated by a wxTextCtrl control when the user 
%%                                                  tries to enter more characters into it than the 
%%                                                  limit previously set with SetMaxLength.
%%                                                  
%%         EVT_TOGGLEBUTTON(id, func)               Process a wxEVT_COMMAND_TOGGLEBUTTON_CLICKED event.
%%                                                  
%%         EVT_TOOL(id, func)                       Process a wxEVT_COMMAND_TOOL_CLICKED event 
%%                                                  (a synonym for wxEVT_COMMAND_MENU_SELECTED). Pass the id of the tool.
%%                                                  
%%         EVT_TOOL_RANGE(id1, id2, func)           Process a wxEVT_COMMAND_TOOL_CLICKED event for a range of identifiers. 
%%                                                  Pass the ids of the tools.
%%                                                  
%%         EVT_TOOL_RCLICKED(id, func)              Process a wxEVT_COMMAND_TOOL_RCLICKED event. Pass the id of the tool.
%%                                                  
%%         EVT_TOOL_RCLICKED_RANGE(id1, id2, func)  Process a wxEVT_COMMAND_TOOL_RCLICKED event for a range of ids. Pass the ids of the tools.
%%                                                  
%%         EVT_TOOL_ENTER(id, func)                 Process a wxEVT_COMMAND_TOOL_ENTER event. 
%%                                                  Pass the id of the toolbar itself. 
%%                                                  The value of wxCommandEvent::GetSelection is the tool id, 
%%                                                  or -1 if the mouse cursor has moved off a tool.
%%                                                  
%%         EVT_COMMAND_LEFT_CLICK(id, func)         Process a wxEVT_COMMAND_LEFT_CLICK command, 
%%                                                  which is generated by a control (Windows 95 and NT only).
%%                                                  
%%         EVT_COMMAND_LEFT_DCLICK(id, func)        Process a wxEVT_COMMAND_LEFT_DCLICK command, 
%%                                                  which is generated by a control (Windows 95 and NT only).
%%                                                  
%%         EVT_COMMAND_RIGHT_CLICK(id, func)        Process a wxEVT_COMMAND_RIGHT_CLICK command, 
%%                                                  which is generated by a control (Windows 95 and NT only).
%%                                                  
%%         EVT_COMMAND_SET_FOCUS(id, func)          Process a wxEVT_COMMAND_SET_FOCUS command, 
%%                                                  which is generated by a control (Windows 95 and NT only).
%%                                                  
%%         EVT_COMMAND_KILL_FOCUS(id, func)         Process a wxEVT_COMMAND_KILL_FOCUS command, 
%%                                                  which is generated by a control (Windows 95 and NT only).
%%                                                  
%%         EVT_COMMAND_ENTER(id, func)              Process a wxEVT_COMMAND_ENTER command, which is generated by a control. 
%%
%%
%%   See Also:
%%   —————————
%%   
%%   
%%   
-module(wxCommandEvent).
-include("wxe.hrl").
-export([
              getClientData/1,
              getExtraLong/1,
              getInt/1,
              getSelection/1,
              getString/1,
              isChecked/1,isSelection/1,
              setInt/2,
              setString/2
                               ]).


%% inherited exports
-export([getId/1,getSkipped/1,getTimestamp/1,isCommandEvent/1,parent_class/1,
  resumePropagation/2,shouldPropagate/1,skip/1,skip/2,stopPropagation/1]).

-export_type([wxCommandEvent/0]).


%% @hidden
parent_class(wxEvent) -> true;
parent_class(_Class) -> erlang:error({badtype, ?MODULE}).


-type wxCommandEvent()  ::  wx:wx_object().




           %·%% GET CLIENT DATA %%·%

%%   
%%    Returns client data pointer for a listbox or 
%%    choice selection event (not valid for a deselection).
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec getClientData(This) -> term()
           when
 	         This :: wxCommandEvent().

getClientData(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                                ?CLASS(ThisT,wxCommandEvent),
                                  wxe_util:call(?wxCommandEvent_getClientData,
                                  <<ThisRef:32/?UI>>).





           %·%% GET EXTRA LONG %%·%

%%   
%%   Returns extra information dependant on the event objects type. 
%%   If the event comes from a listbox selection, it is a boolean 
%%   determining whether the event was a selection (true) or a deselection (false). 
%%   A listbox deselection only occurs for multiple-selection boxes, 
%%   and in this case the index and string values are indeterminate 
%%   and the listbox must be examined by the application.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec getExtraLong(This) -> integer()
           when
 	         This :: wxCommandEvent().

getExtraLong(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                               ?CLASS(ThisT,wxCommandEvent),
                                 wxe_util:call(?wxCommandEvent_GetExtraLong,
                                 <<ThisRef:32/?UI>>).





           %·%% GET INT %%·%

%%   
%%   Returns the integer identifier corresponding to a listbox, choice or radiobox 
%%   selection (only if the event was a selection, not a deselection), 
%%   or a boolean value representing the value of a checkbox.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec getInt(This) -> integer()
           when
 	         This :: wxCommandEvent().

getInt(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                         ?CLASS(ThisT,wxCommandEvent),
                           wxe_util:call(?wxCommandEvent_GetInt,
                           <<ThisRef:32/?UI>>).





           %·%% GET SELECTION %%·%

%%   
%%   Returns item index 
%%   for a listbox or choice selection event 
%%              (not valid for a deselection).
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec getSelection(This) -> integer()
           when
 	         This :: wxCommandEvent().

getSelection(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                               ?CLASS(ThisT,wxCommandEvent),
                                 wxe_util:call(?wxCommandEvent_GetSelection,
                                 <<ThisRef:32/?UI>>).





           %·%% GET STRING %%·%

%%   
%%   Returns item string 
%%   for a listbox or choice selection event 
%%              (not valid for a deselection).
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec getString(This) -> unicode:charlist()
           when
 	         This :: wxCommandEvent().

getString(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                            ?CLASS(ThisT,wxCommandEvent),
                              wxe_util:call(?wxCommandEvent_GetString,
                              <<ThisRef:32/?UI>>).





           %·%% IS CHECKED %%·%

%%   
%%   This method can be used with checkbox and menu events: for the checkboxes, 
%%   the method returns true for a selection event and false for a deselection one. 
%%   
%%   For the menu events, this method indicates if the menu item just has become 
%%   checked or unchecked (and thus only makes sense for checkable menu items).
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec isChecked(This) -> boolean()
           when
 	         This :: wxCommandEvent().

isChecked(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                            ?CLASS(ThisT,wxCommandEvent),
                              wxe_util:call(?wxCommandEvent_IsChecked,
                              <<ThisRef:32/?UI>>).





           %·%% IS SELECTION %%·%

%%   
%%   For a listbox or similar event, returns true if it is a selection, false if it is a deselection.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec isSelection(This) -> boolean()
           when
 	         This :: wxCommandEvent().

isSelection(#wx_ref{type=ThisT,ref=ThisRef}) ->
                                              ?CLASS(ThisT,wxCommandEvent),
                                wxe_util:call(?wxCommandEvent_IsSelection,
                                <<ThisRef:32/?UI>>).





           %·%% SET INT %%·%

%%   
%%   Sets the m_commandInt member.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec setInt(This, I) -> ok
           when
 	         This :: wxCommandEvent(), 
           I    ::        integer().

setInt(#wx_ref{type=ThisT,ref=ThisRef}, I)
           when 
           is_integer(I) ->
                          ?CLASS(ThisT,wxCommandEvent),
            wxe_util:cast(?wxCommandEvent_SetInt,
            <<ThisRef:32/?UI,I:32/?UI>>).





           %·%% SET STRING %%·%

%%   
%%    Sets the m_commandString member.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec setString(This, S) -> ok
           when
 	         This ::   wxCommandEvent(), 
           S    :: unicode:chardata().

setString(#wx_ref{type=ThisT,ref=ThisRef}, S)
           when 
           is_list(S)  ->
                        ?CLASS(ThisT,wxCommandEvent),
                   S_UC = unicode:characters_to_binary([S,0]),
                         wxe_util:cast(?wxCommandEvent_SetString,
                           <<ThisRef:32/?UI,(byte_size(S_UC)):32/?UI,(S_UC)/binary, 
                                 0:(((8- ((0+byte_size(S_UC)) band 16#7)) band 16#7))/unit:8>>).

 



%% From wxEvent




%% @hidden
stopPropagation(This) -> wxEvent:stopPropagation(This).
%% @hidden
skip(This, Options) -> wxEvent:skip(This, Options).
%% @hidden
skip(This) -> wxEvent:skip(This).
%% @hidden
shouldPropagate(This) -> wxEvent:shouldPropagate(This).
%% @hidden
resumePropagation(This,PropagationLevel) -> wxEvent:resumePropagation(This,PropagationLevel).
%% @hidden
isCommandEvent(This) -> wxEvent:isCommandEvent(This).
%% @hidden
getTimestamp(This) -> wxEvent:getTimestamp(This).
%% @hidden
getSkipped(This) -> wxEvent:getSkipped(This).
%% @hidden
getId(This) -> wxEvent:getId(This).