Removed wxBuffer from several ports; added function to get XEvent name;
started on commandline parsing for wxX11 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14197 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -57,7 +57,10 @@ class WXDLLEXPORT wxPoint;
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
// Useful buffer (FIXME VZ: To be removed!!!)
|
||||
// Now only needed in Mac and MSW ports
|
||||
#if !defined(__WXMOTIF__) && !defined(__WXGTK__) && !defined(__WXX11__) && !defined(__WXMGL__)
|
||||
WXDLLEXPORT_DATA(extern wxChar*) wxBuffer;
|
||||
#endif
|
||||
|
||||
// Make a copy of this string using 'new'
|
||||
WXDLLEXPORT wxChar* copystring(const wxChar *s);
|
||||
|
@@ -69,5 +69,10 @@ void wxXColorToHSV(wxHSV *hsv,XColor *xcolor);
|
||||
void wxAllocNearestColor(Display *display,Colormap colormap,XColor *xcolor);
|
||||
void wxAllocColor(Display *display,Colormap colormap,XColor *xcolor);
|
||||
|
||||
// For debugging
|
||||
#ifdef __WXDEBUG__
|
||||
wxString wxGetXEventName(XEvent& event);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
// _WX_PRIVX_H_
|
||||
|
@@ -142,8 +142,6 @@
|
||||
#define _MAXPATHLEN 1024
|
||||
#endif
|
||||
|
||||
extern wxChar *wxBuffer;
|
||||
|
||||
#ifdef __WXMAC__
|
||||
# include "MoreFiles.h"
|
||||
# include "MoreFilesExtras.h"
|
||||
|
@@ -564,8 +564,6 @@ void wxApp::DeletePendingObjects()
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
wxBuffer = new wxChar[BUFSIZ + 512];
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
#if wxUSE_INTL
|
||||
@@ -613,9 +611,6 @@ void wxApp::CleanUp()
|
||||
delete wxTheApp;
|
||||
wxTheApp = (wxApp*) NULL;
|
||||
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
@@ -25,9 +25,6 @@
|
||||
|
||||
#define _MAXPATHLEN 500
|
||||
|
||||
/* Useful buffer, initialized in wxCommonInit */
|
||||
wxChar *wxBuffer = (wxChar *) NULL;
|
||||
|
||||
/* Windows List */
|
||||
wxWindowList wxTopLevelWindows;
|
||||
|
||||
|
@@ -564,8 +564,6 @@ void wxApp::DeletePendingObjects()
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
wxBuffer = new wxChar[BUFSIZ + 512];
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
#if wxUSE_INTL
|
||||
@@ -613,9 +611,6 @@ void wxApp::CleanUp()
|
||||
delete wxTheApp;
|
||||
wxTheApp = (wxApp*) NULL;
|
||||
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
|
@@ -25,9 +25,6 @@
|
||||
|
||||
#define _MAXPATHLEN 500
|
||||
|
||||
/* Useful buffer, initialized in wxCommonInit */
|
||||
wxChar *wxBuffer = (wxChar *) NULL;
|
||||
|
||||
/* Windows List */
|
||||
wxWindowList wxTopLevelWindows;
|
||||
|
||||
|
@@ -412,8 +412,6 @@ bool wxApp::Initialize()
|
||||
if ( MGL_init(".", NULL) == 0 )
|
||||
return FALSE;
|
||||
|
||||
wxBuffer = new wxChar[BUFSIZ + 512];
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
#if wxUSE_INTL
|
||||
@@ -497,8 +495,6 @@ void wxApp::CleanUp()
|
||||
delete wxTheFontsManager;
|
||||
wxTheFontsManager = (wxFontsManager*) NULL;
|
||||
|
||||
delete[] wxBuffer;
|
||||
|
||||
// check for memory leaks
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||
|
@@ -32,9 +32,6 @@
|
||||
|
||||
#define _MAXPATHLEN 500
|
||||
|
||||
/* Useful buffer, initialized in wxCommonInit */
|
||||
wxChar *wxBuffer = (wxChar *) NULL;
|
||||
|
||||
/* Windows List */
|
||||
wxWindowList wxTopLevelWindows;
|
||||
|
||||
|
@@ -60,7 +60,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern char *wxBuffer;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
@@ -89,8 +88,6 @@ long wxApp::sm_lastMessageTime = 0;
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
wxBuffer = new char[BUFSIZ + 512];
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
||||
@@ -158,9 +155,6 @@ void wxApp::CleanUp()
|
||||
|
||||
wxBitmap::CleanUpHandlers();
|
||||
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
delete wxTheApp;
|
||||
|
@@ -68,14 +68,13 @@ void wxControl::SetLabel(const wxString& label)
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
wxStripMenuCodes((char*) (const char*) label, wxBuffer);
|
||||
wxString buf(wxStripMenuCodes());
|
||||
wxXmString label_str(buf);
|
||||
|
||||
XmString text = XmStringCreateSimple (wxBuffer);
|
||||
XtVaSetValues (widget,
|
||||
XmNlabelString, text,
|
||||
XmNlabelString, label_str,
|
||||
XmNlabelType, XmSTRING,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
|
||||
wxString wxControl::GetLabel() const
|
||||
|
@@ -18,9 +18,6 @@
|
||||
|
||||
#define _MAXPATHLEN 500
|
||||
|
||||
// Useful buffer, initialized in CommonInit
|
||||
char *wxBuffer = NULL;
|
||||
|
||||
// Windows List
|
||||
wxWindowList wxTopLevelWindows;
|
||||
|
||||
|
@@ -526,8 +526,6 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
|
||||
else
|
||||
{
|
||||
char mnem = wxFindMnemonic (title);
|
||||
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
|
||||
|
||||
menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
|
||||
|
||||
wxString title2(wxStripMenuCodes(title));
|
||||
|
@@ -2147,12 +2147,13 @@ static void wxCanvasInputEvent(Widget drawingArea,
|
||||
case KeyPress:
|
||||
{
|
||||
KeySym keySym;
|
||||
static char buf[100];
|
||||
#if 0
|
||||
XComposeStatus compose;
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, &compose);
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, &compose);
|
||||
#endif // 0
|
||||
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL);
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, NULL);
|
||||
int id = wxCharCodeXToWX (keySym);
|
||||
|
||||
wxEventType eventType = wxEVT_CHAR;
|
||||
@@ -2200,8 +2201,9 @@ static void wxCanvasInputEvent(Widget drawingArea,
|
||||
}
|
||||
case KeyRelease:
|
||||
{
|
||||
static char buf[100];
|
||||
KeySym keySym;
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL);
|
||||
(void) XLookupString ((XKeyEvent *) & local_event, buf, 20, &keySym, NULL);
|
||||
int id = wxCharCodeXToWX (keySym);
|
||||
|
||||
wxKeyEvent event (wxEVT_KEY_UP);
|
||||
|
@@ -29,6 +29,7 @@
|
||||
#include "wx/log.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/evtloop.h"
|
||||
#include "wx/cmdline.h"
|
||||
|
||||
#if wxUSE_THREADS
|
||||
#include "wx/thread.h"
|
||||
@@ -53,7 +54,6 @@
|
||||
|
||||
#include <string.h>
|
||||
|
||||
extern char *wxBuffer;
|
||||
extern wxList wxPendingDelete;
|
||||
|
||||
wxApp *wxTheApp = NULL;
|
||||
@@ -66,6 +66,14 @@ BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
static const wxCmdLineEntryDesc g_cmdLineDesc[] =
|
||||
{
|
||||
{ wxCMD_LINE_SWITCH, "sync", "sync", "synchronize the display" },
|
||||
{ wxCMD_LINE_OPTION, "display", "display", "use the given display", wxCMD_LINE_VAL_STRING },
|
||||
|
||||
{ wxCMD_LINE_NONE }
|
||||
};
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
|
||||
|
||||
@@ -83,8 +91,6 @@ WXDisplay *wxApp::ms_display = NULL;
|
||||
|
||||
bool wxApp::Initialize()
|
||||
{
|
||||
wxBuffer = new char[BUFSIZ + 512];
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
||||
@@ -132,9 +138,6 @@ void wxApp::CleanUp()
|
||||
delete wxTheApp;
|
||||
wxTheApp = NULL;
|
||||
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
#if wxUSE_THREADS
|
||||
@@ -161,6 +164,11 @@ void wxApp::CleanUp()
|
||||
delete wxLog::SetActiveTarget(NULL);
|
||||
}
|
||||
|
||||
// This is set within wxEntryStart -- too early on
|
||||
// to put these in wxTheApp
|
||||
static int g_newArgc = 0;
|
||||
static wxChar** g_newArgv = NULL;
|
||||
|
||||
// NB: argc and argv may be changed here, pass by reference!
|
||||
int wxEntryStart( int& argc, char *argv[] )
|
||||
{
|
||||
@@ -169,6 +177,13 @@ int wxEntryStart( int& argc, char *argv[] )
|
||||
gs_pfnXErrorHandler = XSetErrorHandler( wxXErrorHandler );
|
||||
#endif // __WXDEBUG__
|
||||
|
||||
/// TODO
|
||||
#if 0
|
||||
// Parse the arguments. Is it OK to use the command line
|
||||
// parser before calling Initialize?
|
||||
wxCmdLineParser cmdLine(argv, argv);
|
||||
#endif
|
||||
|
||||
Display* xdisplay = XOpenDisplay(NULL);
|
||||
|
||||
if (!xdisplay)
|
||||
@@ -236,8 +251,18 @@ int wxEntry( int argc, char *argv[] )
|
||||
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
|
||||
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
|
||||
|
||||
// The command line may have been changed
|
||||
// by stripping out -display etc.
|
||||
if (g_newArgc > 0)
|
||||
{
|
||||
wxTheApp->argc = g_newArgc;
|
||||
wxTheApp->argv = g_newArgv;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
}
|
||||
|
||||
int retValue;
|
||||
retValue = wxEntryInitGui();
|
||||
@@ -498,6 +523,10 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
||||
}
|
||||
default:
|
||||
{
|
||||
#ifdef __WXDEBUG__
|
||||
//wxString eventName = wxGetXEventName(XEvent& event);
|
||||
//wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -775,13 +804,3 @@ void wxApp::OnAssert(const wxChar *file, int line, const wxChar *msg)
|
||||
#endif
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// accessors for C modules
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if 0
|
||||
extern "C" XtAppContext wxGetAppContext()
|
||||
{
|
||||
return (XtAppContext)wxTheApp->GetAppContext();
|
||||
}
|
||||
#endif
|
||||
|
@@ -18,9 +18,6 @@
|
||||
|
||||
#define _MAXPATHLEN 500
|
||||
|
||||
// Useful buffer, initialized in CommonInit
|
||||
char *wxBuffer = NULL;
|
||||
|
||||
// Windows List
|
||||
wxWindowList wxTopLevelWindows;
|
||||
|
||||
|
@@ -1062,6 +1062,29 @@ void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WXDEBUG__
|
||||
wxString wxGetXEventName(XEvent& event)
|
||||
{
|
||||
int type = event.xany.type;
|
||||
static char* event_name[] = {
|
||||
"", "unknown(-)", // 0-1
|
||||
"KeyPress", "KeyRelease", "ButtonPress", "ButtonRelease", // 2-5
|
||||
"MotionNotify", "EnterNotify", "LeaveNotify", "FocusIn", // 6-9
|
||||
"FocusOut", "KeymapNotify", "Expose", "GraphicsExpose", // 10-13
|
||||
"NoExpose", "VisibilityNotify", "CreateNotify", // 14-16
|
||||
"DestroyNotify", "UnmapNotify", "MapNotify", "MapRequest",// 17-20
|
||||
"ReparentNotify", "ConfigureNotify", "ConfigureRequest", // 21-23
|
||||
"GravityNotify", "ResizeRequest", "CirculateNotify", // 24-26
|
||||
"CirculateRequest", "PropertyNotify", "SelectionClear", // 27-29
|
||||
"SelectionRequest", "SelectionNotify", "ColormapNotify", // 30-32
|
||||
"ClientMessage", "MappingNotify", // 33-34
|
||||
"unknown(+)"}; // 35
|
||||
type = wxMin(35, type); type = wxMax(1, type);
|
||||
wxString str(event_name[type]);
|
||||
return str;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __WXMOTIF__
|
||||
// ----------------------------------------------------------------------------
|
||||
// accelerators
|
||||
@@ -1115,7 +1138,8 @@ char * wxFindAccelerator (const char *s)
|
||||
|
||||
*/
|
||||
|
||||
wxBuffer[0] = '\0';
|
||||
static char buf[256];
|
||||
buf[0] = '\0';
|
||||
char *tmp = copystring (s);
|
||||
s = tmp;
|
||||
char *p = tmp;
|
||||
@@ -1127,23 +1151,23 @@ char * wxFindAccelerator (const char *s)
|
||||
if (*p)
|
||||
{
|
||||
*p = '\0';
|
||||
if (wxBuffer[0])
|
||||
strcat (wxBuffer, " ");
|
||||
if (buf[0])
|
||||
strcat (buf, " ");
|
||||
if (strcmp (s, "Alt"))
|
||||
strcat (wxBuffer, s);
|
||||
strcat (buf, s);
|
||||
else
|
||||
strcat (wxBuffer, "Meta");
|
||||
strcat (buf, "Meta");
|
||||
s = p++;
|
||||
}
|
||||
else
|
||||
{
|
||||
strcat (wxBuffer, "<Key>");
|
||||
strcat (wxBuffer, s);
|
||||
strcat (buf, "<Key>");
|
||||
strcat (buf, s);
|
||||
break;
|
||||
}
|
||||
}
|
||||
delete[]tmp;
|
||||
return wxBuffer;
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user