1 /* 2 * %CopyrightBegin% 3 * 4 * Copyright Ericsson AB 2008-2017. All Rights Reserved. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 * %CopyrightEnd% 19 */ 20 21 #ifndef _WXE_IMPL_H 22 #define _WXE_IMPL_H 23 24 #if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) 25 #define __DARWIN__ 1 26 #endif 27 28 29 #include <wx/glcanvas.h> 30 #include <wx/treectrl.h> 31 #include <wx/print.h> 32 extern "C" { 33 #include "wxe_nif.h" 34 } 35 36 #include "wxe_helpers.h" 37 #include "wxe_callback_impl.h" 38 39 #include <vector> 40 41 #if !wxCHECK_VERSION(2,9,0) 42 #define wxeLocaleC wxChar * 43 #define wxeLocaleC2String(Str) wxString(Str) 44 #else 45 typedef wxString wxeLocaleC; 46 #define wxeLocaleC2String(Str) Str 47 #endif 48 49 void send_msg(const char *, const wxString *); // For debugging and error msgs 50 51 extern ErlNifResourceType* wxeMemEnvRt; 52 53 class WxeApp : public wxApp 54 { 55 public: 56 virtual bool OnInit(); 57 58 virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, 59 const wxChar *cond, const wxChar *msg); 60 61 #ifdef _MACOSX 62 virtual void MacPrintFile(const wxString &filename); 63 virtual void MacOpenFile(const wxString &filename); 64 virtual void MacOpenURL(const wxString &url); 65 virtual void MacNewFile(); 66 virtual void MacReopenApp(); 67 #endif 68 69 void init_consts(wxeMetaCommand& event); 70 void destroyMemEnv(wxeMetaCommand& event); 71 void shutdown(wxeMetaCommand& event); 72 73 int dispatch(wxeFifo *); 74 void dispatch_cb(wxeFifo * batch, wxeMemEnv *memenv, ErlNifPid process); 75 76 void wxe_dispatch(wxeCommand& event); 77 78 void idle(wxIdleEvent& event); 79 int dispatch_cmds(); 80 81 void dummy_close(wxEvent& Ev); 82 // bool sendevent(wxEvent *event); 83 // wxeMemEnv * getMemEnv(ErlDrvTermData port); 84 85 int newPtr(void * ptr, int type, wxeMemEnv *memenv); 86 int getRef(void * ptr, wxeMemEnv *memenv, int type = 0); 87 // void * getPtr(char * bp, wxeMemEnv *memenv); 88 void clearPtr(void *ptr); 89 wxeRefData * getRefData(void *ptr); 90 int registerPid(int index, ErlNifPid pid, wxeMemEnv *memenv); 91 92 // Code found in gen/wxe_derived_dest.h 93 bool delete_object(void *ptr, wxeRefData *refd); 94 95 // wxeMemMap refmap; 96 ptrMap ptr2ref; 97 wxeMemEnv * global_me; 98 99 int recurse_level; 100 wxList * delayed_cleanup; 101 wxeFifo * delayed_delete; 102 // Temp container for callbacks 103 wxeCommand * cb_return; 104 }; 105 106 #define Badarg(Argc) { throw wxe_badarg(Argc); } 107 108 typedef struct { 109 void (*nif_cb) (WxeApp *, wxeMemEnv *, wxeCommand& ); 110 const char *cname; 111 const char *fname; 112 int n; 113 } wxe_fns_t; 114 115 extern wxe_fns_t wxe_fns[]; 116 117 #endif //_WXE_IMPL_H 118