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_driver.h" 34 } 35 36 #include "wxe_helpers.h" 37 #include "wxe_callback_impl.h" 38 #include "wxe_memory.h" 39 40 #if !wxCHECK_VERSION(2,9,0) 41 #define wxeLocaleC wxChar * 42 #define wxeLocaleC2String(Str) wxString(Str) 43 #else 44 typedef wxString wxeLocaleC; 45 #define wxeLocaleC2String(Str) Str 46 #endif 47 48 #define WXE_NOT_INITIATED 0 49 #define WXE_INITIATED 1 50 #define WXE_EXITING 2 51 #define WXE_EXITED 3 52 #define WXE_ERROR -1 53 54 void send_msg(const char *, const wxString *); // For debugging and error msgs 55 56 class WxeApp : public wxApp 57 { 58 public: 59 virtual bool OnInit(); 60 61 virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, 62 const wxChar *cond, const wxChar *msg); 63 64 #ifdef _MACOSX 65 virtual void MacOpenFile(const wxString &filename); 66 #endif 67 68 void shutdown(wxeMetaCommand& event); 69 70 int dispatch(wxeFifo *); 71 void dispatch_cb(wxeFifo * batch, ErlDrvTermData process); 72 73 void wxe_dispatch(wxeCommand& event); 74 75 void idle(wxIdleEvent& event); 76 int dispatch_cmds(); 77 78 void dummy_close(wxEvent& Ev); 79 bool sendevent(wxEvent *event); 80 81 // MemEnv handling 82 void newMemEnv(wxeMetaCommand& event); 83 void destroyMemEnv(wxeMetaCommand& event); 84 wxeMemEnv * getMemEnv(ErlDrvTermData port); 85 86 int newPtr(void * ptr, int type, wxeMemEnv *memenv); 87 int getRef(void * ptr, wxeMemEnv *memenv, int type = 0); 88 void * getPtr(char * bp, wxeMemEnv *memenv); 89 void clearPtr(void *ptr); 90 wxeRefData * getRefData(void *ptr); 91 void registerPid(char *ptr, ErlDrvTermData pid, wxeMemEnv *memenv); 92 void init_nonconsts(wxeMemEnv *memenv, ErlDrvTermData caller); 93 94 // Code found in gen/wxe_derived_dest.h 95 bool delete_object(void *ptr, wxeRefData *refd); 96 97 wxeMemMap refmap; 98 ptrMap ptr2ref; 99 wxeMemEnv * global_me; 100 101 int recurse_level; 102 wxList * delayed_cleanup; 103 wxeFifo * delayed_delete; 104 // Temp container for callbacks 105 char *cb_buff; 106 int cb_len; 107 }; 108 109 #endif //_WXE_IMPL_H 110