summaryrefslogtreecommitdiff
path: root/lib/wx/api_gen
diff options
context:
space:
mode:
Diffstat (limited to 'lib/wx/api_gen')
-rw-r--r--lib/wx/api_gen/wx_extra/wxTaskBarIcon.c_src46
-rw-r--r--lib/wx/api_gen/wx_extra/wxTaskBarIcon.erl45
-rw-r--r--lib/wx/api_gen/wx_gen.erl4
-rw-r--r--lib/wx/api_gen/wx_gen_erl.erl65
-rw-r--r--lib/wx/api_gen/wxapi.conf2
5 files changed, 156 insertions, 6 deletions
diff --git a/lib/wx/api_gen/wx_extra/wxTaskBarIcon.c_src b/lib/wx/api_gen/wx_extra/wxTaskBarIcon.c_src
new file mode 100644
index 0000000000..1b1f37486c
--- /dev/null
+++ b/lib/wx/api_gen/wx_extra/wxTaskBarIcon.c_src
@@ -0,0 +1,46 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2011-2016. All Rights Reserved.
+%%
+%% 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.
+%%
+%% %CopyrightEnd%
+%%
+
+<<wxTaskBarIcon_class
+class EwxTaskBarIcon : public wxTaskBarIcon {
+ public: ~EwxTaskBarIcon() {((WxeApp *)wxTheApp)->clearPtr(this);};
+ EwxTaskBarIcon() : wxTaskBarIcon() {};
+
+ int createPopupMenu;
+ ErlDrvTermData port;
+
+ private:
+ virtual wxMenu* CreatePopupMenu();
+};
+wxTaskBarIcon_class>>
+
+<<wxTaskBarIcon_new
+case ~s: { // wxTaskBarIcon::wxTaskBarIcon
+ EwxTaskBarIcon * Result = new EwxTaskBarIcon();
+ Result->port = Ecmd.port;
+ if ( * (int*) bp) {
+ Result->createPopupMenu = *(int *) bp;
+ }
+
+ newPtr((void *) Result, 1, memenv);
+ rt.addRef(getRef((void *)Result,memenv), "wxTaskBarIcon");
+ break;
+}
+wxTaskBarIcon_new>>
diff --git a/lib/wx/api_gen/wx_extra/wxTaskBarIcon.erl b/lib/wx/api_gen/wx_extra/wxTaskBarIcon.erl
new file mode 100644
index 0000000000..cde9c5ead6
--- /dev/null
+++ b/lib/wx/api_gen/wx_extra/wxTaskBarIcon.erl
@@ -0,0 +1,45 @@
+%%
+%% %CopyrightBegin%
+%%
+%% Copyright Ericsson AB 2011-2016. All Rights Reserved.
+%%
+%% 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.
+%%
+%% %CopyrightEnd%
+%%
+
+<<EXPORT:wxTaskBarIcon new/0, new/1 wxTaskBarIcon:EXPORT>>
+
+<<wxTaskBarIcon_new
+%% @doc See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxtaskbaricon.html#wxtaskbariconwxtaskbaricon">external documentation</a>.
+-spec new() -> wxTaskBarIcon().
+new() ->
+ wxe_util:construct(~s, <<0:32>>).
+
+
+%% @doc Creates a TaskBarIcon with a callback function for CreatePopupMenu:
+%% <pre>Callback() -> term()</pre>
+%%
+%% See <a href="http://www.wxwidgets.org/manuals/2.8.12/wx_wxtaskbaricon.html#wxtaskbariconwxtaskbaricon">external documentation</a>.
+-spec new([Option]) -> wxTaskBarIcon() when
+ Option :: {'createPopupMenu', fun(() -> wxMenu:wxMenu())}.
+new([]) ->
+ new();
+new([{createPopupMenu, F}]) when is_function(F) ->
+ Fun = fun([_]) ->
+ #wx_ref{type=wxMenu,ref=ThisRef} = F(),
+ <<ThisRef:32/?UI>>
+ end,
+ BinFun = <<(wxe_util:get_cbId(Fun)):32/?UI, 0:32>>,
+ wxe_util:construct(?wxTaskBarIcon_new, BinFun).
+wxTaskBarIcon_new>>
diff --git a/lib/wx/api_gen/wx_gen.erl b/lib/wx/api_gen/wx_gen.erl
index d9dd624ca8..16b85be97d 100644
--- a/lib/wx/api_gen/wx_gen.erl
+++ b/lib/wx/api_gen/wx_gen.erl
@@ -1434,7 +1434,7 @@ extract_def([#xmlElement{name=name,content=[#xmlText{value=Name}]}|R], _N, Skip)
extract_def([#xmlElement{name=param}|_],Name,_) ->
throw(Name);
extract_def([#xmlElement{name=initializer,content=Cs}|_R],N,Skip) ->
- Val0 = extract_def2(Cs),
+ Val0 = string:strip(strip_comment(extract_def2(Cs))),
case Val0 of
"0x" ++ Val1 -> {N, list_to_integer(Val1, 16)};
_ ->
@@ -1458,7 +1458,7 @@ extract_def(_,N,_) ->
throw(N).
extract_def2([#xmlText{value=Val}|R]) ->
- string:strip(strip_comment(Val)) ++ extract_def2(R);
+ string:strip(Val) ++ extract_def2(R);
extract_def2([#xmlElement{content=Cs}|R]) ->
extract_def2(Cs) ++ extract_def2(R);
extract_def2([]) -> [].
diff --git a/lib/wx/api_gen/wx_gen_erl.erl b/lib/wx/api_gen/wx_gen_erl.erl
index 797533309b..e8287c4b1f 100644
--- a/lib/wx/api_gen/wx_gen_erl.erl
+++ b/lib/wx/api_gen/wx_gen_erl.erl
@@ -49,8 +49,10 @@ gen(Defs) ->
Replace = fun(C=#class{name=Name}, Dfs) ->
lists:keyreplace(Name, #class.name, Dfs, C)
end,
- [gen_class(Class) || Class <- lists:foldl(Replace, Defs, Static)],
- gen_funcnames().
+ All = lists:foldl(Replace, Defs, Static),
+ [gen_class(Class) || Class <- All],
+ gen_funcnames(),
+ gen_api_footprint(All).
gen_class(Class) ->
try
@@ -159,7 +161,13 @@ gen_class1(C=#class{name=Name,parent=Parent,methods=Ms,options=Opts}) ->
w("-export_type([~s/0]).~n", [Name]),
case lists:filter(fun({_F,Depr}) -> Depr end, ExportList) of
[] -> ok;
- Depr -> w("-deprecated([~s]).~n~n", [args(fun({EF,_}) -> EF end, ",", Depr, 60)])
+ Depr ->
+ DepStr = "not available in wxWidgets-2.9 and later",
+ w("-deprecated([~s]).~n~n",
+ [args(fun({EF,_}) ->
+ [DFun,DArgs] = string:split(EF, "/"),
+ io_lib:format("{~s,~s,\"~s\"}", [DFun,DArgs,DepStr])
+ end, ",\n ", Depr, 60)])
end,
case lists:filter(fun({_,_,Depr}) -> Depr end, InExported) of
[] -> ok;
@@ -1318,6 +1326,57 @@ gen_funcnames() ->
[w("-define(~s_~s, ~p).~n", [Class,Name,Id]) || {Class,Name,_,Id} <- Ns],
close().
+gen_api_footprint(All) ->
+ %% To be able to diff content between old and new generators.
+ open_write("wx_28_api.dump"),
+ TF = fun TF (Type) ->
+ try wx_gen:type_foot_print(Type) of
+ {class, C} -> list_to_atom(C);
+ {merged, MTs} -> [TF(MT) || {_, MT} <- MTs];
+ T -> T
+ catch _:R:ST ->
+ case Type of
+ void -> ok;
+ {merged, _,T1,_, _,T2,_} ->
+ lists:sort([TF(T1),TF(T2)]);
+ _ ->
+ io:format("ERROR: ~p~n ~p~n",[R,ST]),
+ exit(R)
+ end
+ end
+ end,
+ Out = fun(T, []) -> TF(T);
+ (void, [#param{type=T}]) -> TF(T);
+ (void, Ps) -> list_to_tuple([TF(T) || #param{type=T} <- Ps]);
+ (T, Ps) -> list_to_tuple([TF(T)|[TF(Tp) || #param{type=Tp} <- Ps]])
+ end,
+ Methods = fun(CName, Parent, #method{name=N, alias=Alias, method_type=MType,where=W,type=Type0,params=Ps}) ->
+ {Args0,Opts0} = split_optional(Ps),
+ Type = Out(Type0, [P || P=#param{in=In} <- Ps,In =/= true]),
+ Args = [TF(PT) || #param{type=PT} <- Args0],
+ case W of
+ merged_c ->
+ ignore;
+ erl_no_opt ->
+ {CName, list_to_atom(erl_func_name(N,Alias)), Type, Args, [], W, Parent};
+ _ ->
+ Opts = lists:sort([{list_to_atom(erl_option_name(ON)), TF(OT)} ||
+ #param{name=ON,type=OT} <- Opts0]),
+ {CName, list_to_atom(erl_func_name(N,Alias)), Type, Args, Opts, W, Parent}
+ end
+ end,
+ Class = fun(#class{name=CName0,parent=Parent,methods=Ms0,options=Opts}) ->
+ CName = case Parent of
+ "static" -> "wx_misc";
+ _ -> CName0
+ end,
+ [Methods(list_to_atom(CName), list_to_atom(Parent), M) || Ms <- Ms0, M <-Ms]
+ end,
+ Sorted = lists:sort(lists:append([Class(C) || C <- All])),
+ [w("~0p.~n", [E]) || E <- Sorted, E /= ignore],
+ close().
+
+
get_unique_name(ID) when is_integer(ID) ->
Tree = get(unique_names),
{Class,Name, _,_} = gb_trees:get(ID, Tree),
diff --git a/lib/wx/api_gen/wxapi.conf b/lib/wx/api_gen/wxapi.conf
index cd53a25c40..d2f8cac4c1 100644
--- a/lib/wx/api_gen/wxapi.conf
+++ b/lib/wx/api_gen/wxapi.conf
@@ -2005,7 +2005,7 @@
[wxLogNull, '~wxLogNull']}.
{class, wxTaskBarIcon, wxEvtHandler, [],
- [wxTaskBarIcon,'~wxTaskBarIcon',
+ [{wxTaskBarIcon, [{where, taylormade}]},'~wxTaskBarIcon',
%%'CreatePopupMenu', virtual overrided is a callback
%% 'IsIconInstalled', 'IsOk', not available on mac
'PopupMenu','RemoveIcon','SetIcon']}.