diff options
Diffstat (limited to 'lib/wx/c_src/wxe_impl.h')
-rw-r--r-- | lib/wx/c_src/wxe_impl.h | 257 |
1 files changed, 54 insertions, 203 deletions
diff --git a/lib/wx/c_src/wxe_impl.h b/lib/wx/c_src/wxe_impl.h index a3c57e2598..57dac997ab 100644 --- a/lib/wx/c_src/wxe_impl.h +++ b/lib/wx/c_src/wxe_impl.h @@ -1,25 +1,31 @@ /* * %CopyrightBegin% * - * Copyright Ericsson AB 2008-2013. All Rights Reserved. + * Copyright Ericsson AB 2008-2016. All Rights Reserved. * - * The contents of this file are subject to the Erlang Public License, - * Version 1.1, (the "License"); you may not use this file except in - * compliance with the License. You should have received a copy of the - * Erlang Public License along with this software. If not, it can be - * retrieved online at http://www.erlang.org/. + * 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 * - * Software distributed under the License is distributed on an "AS IS" - * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See - * the License for the specific language governing rights and limitations - * under the License. + * http://www.apache.org/licenses/LICENSE-2.0 * - * %CopyrightEnd% + * 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% */ #ifndef _WXE_IMPL_H #define _WXE_IMPL_H +#if defined(__APPLE__) && defined(__MACH__) && !defined(__DARWIN__) +#define __DARWIN__ 1 +#endif + + #include <wx/glcanvas.h> #include <wx/treectrl.h> #include <wx/print.h> @@ -27,128 +33,42 @@ extern "C" { #include "wxe_driver.h" } -DECLARE_EVENT_TYPE(wxeEVT_META_COMMAND, -1) - -class wxeMetaCommand : public wxEvent -{ - public: - wxeMetaCommand(wxe_data *sd, int EvId) - : wxEvent(EvId, wxeEVT_META_COMMAND) - { caller = driver_caller(sd->port_handle); port = sd->port; pdl = sd->pdl; } ; - wxeMetaCommand(const wxeMetaCommand& event) - : wxEvent(event) - { caller = event.caller; port = event.port; pdl = event.pdl; }; - virtual ~wxeMetaCommand() {}; - virtual wxEvent *Clone() const { return new wxeMetaCommand(*this); } - - ErlDrvTermData caller; - ErlDrvTermData port; - ErlDrvPDL pdl; -}; - -class wxeCommand : public wxObject -{ - public: - wxeCommand(int fc,char * cbuf,int buflen, wxe_data *); - virtual ~wxeCommand(); - - ErlDrvTermData caller; - ErlDrvTermData port; - WXEBinRef * bin[3]; - char * buffer; - int len; - int op; -}; - -#define WXE_EVENT_PTR 0 -#define WXE_OBJECT_PTR 1 +#include "wxe_helpers.h" +#include "wxe_callback_impl.h" +#include "wxe_memory.h" -class intListElement { -public: - intListElement(int Element) {car = Element; cdr = NULL;}; - intListElement(int Element, intListElement *list) - {car = Element; cdr = list;}; - int car; - intListElement *cdr; -}; +#if !wxCHECK_VERSION(2,9,0) +#define wxeLocaleC wxChar * +#define wxeLocaleC2String(Str) wxString(Str) +#else +typedef wxString wxeLocaleC; +#define wxeLocaleC2String(Str) Str +#endif -class intList { -public: - intList() {list = NULL;}; - bool IsEmpty() {return list == NULL;}; - void Append(int Element) { list = new intListElement(Element, list); }; - int Pop() { - intListElement *temp = list; - int res = list->car; - list = temp->cdr; - delete temp; - return res; - } - intListElement *list; -}; +#define WXE_NOT_INITIATED 0 +#define WXE_INITIATED 1 +#define WXE_EXITING 2 +#define WXE_EXITED 3 +#define WXE_ERROR -1 -class wxe_badarg -{ -public: - wxe_badarg(int Ref) : ref(Ref) { } ; - int ref; -}; +void send_msg(const char *, const wxString *); // For debugging and error msgs -class wxeErlTerm : public wxClientData +class WxeApp : public wxApp { - public: - wxeErlTerm(WXEBinRef * data) - { - size = data->size; - bin = (char *) driver_alloc(size); - memcpy(bin, data->base, size); - } ; - ~wxeErlTerm() { driver_free(bin); }; - char * bin; - int size; -}; - -class wxeMemEnv -{ public: - wxeMemEnv(); - int next; - int max; - void ** ref2ptr; - intList free; - ~wxeMemEnv(); - ErlDrvTermData owner; -}; - -class wxeRefData { - public: - wxeRefData(unsigned int dref, int ttype, int is_new, wxeMemEnv *menv) : - ref(dref), type(ttype), alloc_in_erl(is_new), memenv(menv), pid(-1) { } ; - int ref; - int type; - // 0 = wxWindow subclasses, 1 = wxObject subclasses - // 2 = wxDialog subclasses, 3 = allocated wxObjects but not returned from new - // > 3 classes which lack virtual destr, or are supposed to be allocated on - // the stack - bool alloc_in_erl; - wxeMemEnv *memenv; - ErlDrvTermData pid; -}; + virtual bool OnInit(); -WX_DECLARE_HASH_MAP(ErlDrvTermData, wxGLCanvas*, wxIntegerHash, wxIntegerEqual, wxeGLC); -WX_DECLARE_HASH_MAP(ErlDrvTermData, wxeMemEnv*, wxIntegerHash, wxIntegerEqual, wxeMemMap); + virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, + const wxChar *cond, const wxChar *msg); +#ifdef _MACOSX + virtual void MacOpenFile(const wxString &filename); +#endif -WX_DECLARE_VOIDPTR_HASH_MAP(wxeRefData *, ptrMap); - -class WxeApp : public wxApp -{ -public: - virtual bool OnInit(); void shutdown(wxeMetaCommand& event); - int dispatch(wxList *, int, int); - void dispatch_cb(wxList * batch, wxList * temp, ErlDrvTermData process); + int dispatch(wxeFifo *); + void dispatch_cb(wxeFifo * batch, ErlDrvTermData process); void wxe_dispatch(wxeCommand& event); @@ -158,101 +78,32 @@ public: void dummy_close(wxEvent& Ev); bool sendevent(wxEvent *event); - // MemEnv handling + // MemEnv handling void newMemEnv(wxeMetaCommand& event); void destroyMemEnv(wxeMetaCommand& event); wxeMemEnv * getMemEnv(ErlDrvTermData port); - + int newPtr(void * ptr, int type, wxeMemEnv *memenv); int getRef(void * ptr, wxeMemEnv *memenv); - void * getPtr(char * bp, wxeMemEnv *memenv); + void * getPtr(char * bp, wxeMemEnv *memenv); void clearPtr(void *ptr); + wxeRefData * getRefData(void *ptr); void registerPid(char *ptr, ErlDrvTermData pid, wxeMemEnv *memenv); - void init_nonconsts(wxeMemEnv *memenv, ErlDrvTermData caller); - + void init_nonconsts(wxeMemEnv *memenv, ErlDrvTermData caller); + // Code found in gen/wxe_derived_dest.h - void delete_object(void *ptr, wxeRefData *refd); - + bool delete_object(void *ptr, wxeRefData *refd); + wxeMemMap refmap; ptrMap ptr2ref; wxeMemEnv * global_me; - + + int recurse_level; + wxList * delayed_cleanup; + wxeFifo * delayed_delete; // Temp container for callbacks char *cb_buff; int cb_len; }; -class wxETreeItemData : public wxTreeItemData -{ - public: - wxETreeItemData(int sz, char * data); - - ~wxETreeItemData(); - - int size; - char * bin; -}; - -bool sendevent(wxEvent * event, ErlDrvTermData port); -void pre_callback(); -void handle_event_callback(ErlDrvPort port, ErlDrvTermData process); - -void activateGL(ErlDrvTermData caller); -void setActiveGL(ErlDrvTermData caller, wxGLCanvas *canvas); -void deleteActiveGL(wxGLCanvas *canvas); - -void send_msg(const char *, wxString *); // For debugging and error msgs - -extern wxeGLC glc; - -class wxEPrintout : public wxPrintout -{ - public: - wxEPrintout(wxString Title, int onPrintP, int onPrepareP, - int onBeginP, int onEndP, - int onBeginD, int onEndD, - int hasP, int getPageI, ErlDrvTermData Port) : - wxPrintout(Title), - onPrintPage(onPrintP), onPreparePrinting(onPrepareP), - onBeginPrinting(onBeginP), onEndPrinting(onEndP), - onBeginDocument(onBeginD), onEndDocument(onEndD), hasPage(hasP), getPageInfo(getPageI), - port(Port) - { } ; - - ~wxEPrintout(); - - bool OnBeginDocument(int startPage, int endPage); - void OnEndDocument(); - void OnBeginPrinting(); - void OnEndPrinting(); - - void OnPreparePrinting(); - - bool HasPage(int page); - bool OnPrintPage(int page); - void GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo); - - int onPrintPage; - int onPreparePrinting; - int onBeginPrinting; - int onEndPrinting; - int onBeginDocument; - int onEndDocument; - int hasPage; - int getPageInfo; - - ErlDrvTermData port; -}; - -void clear_cb(ErlDrvTermData port, int callback); - - -// Implementation of wxListCtrlCompare -struct callbackInfo { - ErlDrvTermData port; - int callbackID; -}; - -int wxCALLBACK wxEListCtrlCompare(long item1, long item2, long callbackInfoPtr); - #endif //_WXE_IMPL_H |