wxErlang

wxSizerFlags.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
%            (`  | '¯/ |_¯ |¯\ |¯¯ |    /\  /¯_  (` 
%\     W  X \_)  |  /_,|__ |¯\ |¯  |__ /¯¯\ \_/ \_) . 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_wxsizerflags.html">wxSizerFlags</a>.
%% @type wxSizerFlags().  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%   
%%   OVERVIEW
%%   ––––––––
%%    Normally, when you add an item to a sizer via wxSizer::Add, you have to specify a lot of flags and parameters which can be unwieldy. This is where wxSizerFlags comes in: it allows you to specify all parameters using the named methods instead. For example, instead of
%%    Note that by specification, all methods of wxSizerFlags return the wxSizerFlags object itself to allowing chaining multiple methods calls like in the examples above.
%%   
%%   See Also:
%%   —————————
%%   
%%   
%%   
-module(wxSizerFlags).
-include("wxe.hrl").
-export([
          align/2,
          
          border/1,
          border/2,
          border/3,
          
          center/1,
          centre/1,
          
          destroy/1,
          
          expand/1,
          
          left/1,
          
          new/0,
          new/1,
          
          proportion/2,

          right/1]).




%% inherited exports
-export([parent_class/1]).

-export_type([wxSizerFlags/0]).




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

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




%% @equiv new([])
          -spec new() -> wxSizerFlags().

new() ->
  new([]).





           %·%% NEW %%·%

%%   
%%   Creates the wxSizer with the proportion specified by proportion.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec new([Option]) -> wxSizerFlags()
           when
           Option  ::  {proportion, integer()}.

new(Options)
           when 
           is_list(Options) ->
                   MOpts = fun({proportion, Proportion}, Acc) -> [<<1:32/?UI,Proportion:32/?UI>>|Acc];
                                                  (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:construct(?wxSizerFlags_new,
                                        <<BinOpt/binary>>).





           %·%% ALIGN %%·%

%%   
%%   Sets the alignment of this wxSizerFlags to align.
%%
%%   Note that if this method is not called, 
%%   the wxSizerFlags has no specified alignment.
%%   
%% Return Value:
%% See Also: left(), right(), centre()
%%*%%*%%
          -spec align(This, Alignment) -> wxSizerFlags()
           when
           This      :: wxSizerFlags(), 
           Alignment ::      integer().

align(#wx_ref{type=ThisT,ref=ThisRef},Alignment)
           when 
           is_integer(Alignment) ->
                                  ?CLASS(ThisT,wxSizerFlags),
                    wxe_util:call(?wxSizerFlags_Align,
                   <<ThisRef:32/?UI,Alignment:32/?UI>>).




           %·%% BORDER / 1 %%·%

%%   
%% See below...
%% @equiv border(This, [])
          -spec border(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

border(This)
           when 
           is_record(This, wx_ref) ->
  border(This, []).


%%    
%% See below...  
%% Return Value:
%% See Also:
%%*%%*%%
          -spec border(This, [Option]) -> wxSizerFlags()
           when
           This    ::        wxSizerFlags(),
           Option  :: {direction, integer()}.

border(#wx_ref{type=ThisT,ref=ThisRef}, Options)
           when 
           is_list(Options) ->
                             ?CLASS(ThisT,wxSizerFlags),
                   MOpts = fun({direction, Direction}, Acc) -> [<<1:32/?UI,Direction:32/?UI>>|Acc];
                                                (BadOpt, _) -> erlang:error({badoption, BadOpt})
                           end,
                   BinOpt = list_to_binary(lists:foldl(MOpts, [<<0:32>>], Options)),
                                        wxe_util:call(?wxSizerFlags_Border_1,
                                        <<ThisRef:32/?UI, 0:32,BinOpt/binary>>).





           %·%% BORDER / 3 %%·%

%%   
%%   Sets the wxSizerFlags to have a border of a number of pixels 
%%   specified by borderinpixels with the directions specified by direction.
%%
%%   In the overloaded version without borderinpixels parameter, 
%%   the border of default size, as returned by GetDefaultBorder, is used.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
   "http://www.wxwidgets.org/manuals/2.8.12/wx_wxsizerflags.html#wxsizerflagsborder">external documentation</a>.
          -spec border(This, Direction, BorderInPixels) -> wxSizerFlags()
           when
           This           :: wxSizerFlags(), 
           Direction      :: integer(), 
           BorderInPixels :: integer().

border(#wx_ref{type=ThisT,ref=ThisRef}, Direction, BorderInPixels)
           when 
           is_integer(Direction),
           is_integer(BorderInPixels) ->
                                       ?CLASS(ThisT,wxSizerFlags),
                         wxe_util:call(?wxSizerFlags_Border_2,
                         <<ThisRef:32/?UI,Direction:32/?UI,BorderInPixels:32/?UI>>).





           %·%% CENTER %%·%

%%   
%%    Sets the object of the wxSizerFlags to center itself in the area it is given.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec center(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

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





           %·%% CENTRE %%·%

%%   
%%    wxSizerFlags::Center for people with the other dialect of english.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec centre(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

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





           %·%% EXPAND %%·%

%%   
%%    Sets the object of the wxSizerFlags to expand to fill as much area as it can.
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec expand(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

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





           %·%% LEFT %%·%

%%   
%%    Aligns the object to the left, shortcut for Align(wxALIGN_LEFT)
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec left(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

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





           %·%% PROPORTION %%·%

%%   
%%    Sets the proportion of this wxSizerFlags to proportion
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec proportion(This, Proportion) -> wxSizerFlags()
           when
           This       :: wxSizerFlags(), 
           Proportion ::      integer().

proportion(#wx_ref{type=ThisT,ref=ThisRef}, Proportion)
           when 
           is_integer(Proportion) ->
                                   ?CLASS(ThisT,wxSizerFlags),
                     wxe_util:call(?wxSizerFlags_Proportion,
                     <<ThisRef:32/?UI,Proportion:32/?UI>>).





           %·%% RIGHT %%·%

%%   
%%    Aligns the object to the right, shortcut for Align(wxALIGN_RIGHT)
%%   
%% Return Value:
%% See Also:
%%*%%*%%
          -spec right(This) -> wxSizerFlags()
           when
           This :: wxSizerFlags().

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





           %·%% DESTROY %%·%

%%   
%%   
%% @doc Destroys this object, do not use object again
          -spec destroy(This :: wxSizerFlags()) -> ok.

destroy(Obj=#wx_ref{type=Type}) ->
                                 ?CLASS(Type,wxSizerFlags),
                wxe_util:destroy(?wxSizerFlags_destroy,Obj),
                ok.