aboutsummaryrefslogtreecommitdiffstats
path: root/lib/wx/c_src/wxe_impl.h
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2014-01-27 14:23:15 +0100
committerDan Gudmundsson <[email protected]>2014-01-27 14:23:15 +0100
commit75bfbe5a61fa1a1dd204fdb21dc4bf7df8e8003d (patch)
treecedea2151cdc673bddfe541cf4956c5fd6b431ab /lib/wx/c_src/wxe_impl.h
parentc922ea6f82bb3d95d05d1f212b91e13f97e972b8 (diff)
parentfd055cf43486358a413a1fa22f30f0aa711d25e1 (diff)
downloadotp-75bfbe5a61fa1a1dd204fdb21dc4bf7df8e8003d.tar.gz
otp-75bfbe5a61fa1a1dd204fdb21dc4bf7df8e8003d.tar.bz2
otp-75bfbe5a61fa1a1dd204fdb21dc4bf7df8e8003d.zip
Merge branch 'dgud/wx/refactor-and-bugfixes/OTP-11586'
* dgud/wx/refactor-and-bugfixes/OTP-11586: wx: Delay all deletes if recursed in event loop wx: wx could hang if wxe_server died (or had died) when inside a callback wx: Delay memory cleanup until safe wx: Refactor C++ code wx: Add init_dialog event Update icons wx: Update icons to plain old white ones
Diffstat (limited to 'lib/wx/c_src/wxe_impl.h')
-rw-r--r--lib/wx/c_src/wxe_impl.h218
1 files changed, 25 insertions, 193 deletions
diff --git a/lib/wx/c_src/wxe_impl.h b/lib/wx/c_src/wxe_impl.h
index a3c57e2598..bb54961edd 100644
--- a/lib/wx/c_src/wxe_impl.h
+++ b/lib/wx/c_src/wxe_impl.h
@@ -1,7 +1,7 @@
/*
* %CopyrightBegin%
*
- * Copyright Ericsson AB 2008-2013. All Rights Reserved.
+ * Copyright Ericsson AB 2008-2014. 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
@@ -14,12 +14,17 @@
* the License for the specific language governing rights and limitations
* under the License.
*
- * %CopyrightEnd%
+ * %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,119 +32,16 @@ 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
-
-class intListElement {
-public:
- intListElement(int Element) {car = Element; cdr = NULL;};
- intListElement(int Element, intListElement *list)
- {car = Element; cdr = list;};
- int car;
- intListElement *cdr;
-};
-
-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;
-};
-
-class wxe_badarg
-{
-public:
- wxe_badarg(int Ref) : ref(Ref) { } ;
- int ref;
-};
-
-class wxeErlTerm : public wxClientData
-{
- 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;
-};
-
-WX_DECLARE_HASH_MAP(ErlDrvTermData, wxGLCanvas*, wxIntegerHash, wxIntegerEqual, wxeGLC);
-WX_DECLARE_HASH_MAP(ErlDrvTermData, wxeMemEnv*, wxIntegerHash, wxIntegerEqual, wxeMemMap);
+#include "wxe_helpers.h"
+#include "wxe_callback_impl.h"
+#include "wxe_memory.h"
+#define WXE_NOT_INITIATED 0
+#define WXE_INITIATED 1
+#define WXE_EXITED 2
+#define WXE_ERROR -1
-WX_DECLARE_VOIDPTR_HASH_MAP(wxeRefData *, ptrMap);
+void send_msg(const char *, wxString *); // For debugging and error msgs
class WxeApp : public wxApp
{
@@ -158,101 +60,31 @@ 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);
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);
-
+
wxeMemMap refmap;
ptrMap ptr2ref;
wxeMemEnv * global_me;
-
+
+ int recurse_level;
+ wxList * delayed_cleanup;
+ wxList * 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