// ----------------------------------------------------------------------------
// 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);
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_
#define _MAXPATHLEN 1024
#endif
-extern wxChar *wxBuffer;
-
#ifdef __WXMAC__
# include "MoreFiles.h"
# include "MoreFilesExtras.h"
bool wxApp::Initialize()
{
- wxBuffer = new wxChar[BUFSIZ + 512];
-
wxClassInfo::InitializeClasses();
#if wxUSE_INTL
delete wxTheApp;
wxTheApp = (wxApp*) NULL;
- delete[] wxBuffer;
- wxBuffer = NULL;
-
wxClassInfo::CleanUpClasses();
#if wxUSE_THREADS
#define _MAXPATHLEN 500
-/* Useful buffer, initialized in wxCommonInit */
-wxChar *wxBuffer = (wxChar *) NULL;
-
/* Windows List */
wxWindowList wxTopLevelWindows;
bool wxApp::Initialize()
{
- wxBuffer = new wxChar[BUFSIZ + 512];
-
wxClassInfo::InitializeClasses();
#if wxUSE_INTL
delete wxTheApp;
wxTheApp = (wxApp*) NULL;
- delete[] wxBuffer;
- wxBuffer = NULL;
-
wxClassInfo::CleanUpClasses();
#if wxUSE_THREADS
#define _MAXPATHLEN 500
-/* Useful buffer, initialized in wxCommonInit */
-wxChar *wxBuffer = (wxChar *) NULL;
-
/* Windows List */
wxWindowList wxTopLevelWindows;
if ( MGL_init(".", NULL) == 0 )
return FALSE;
- wxBuffer = new wxChar[BUFSIZ + 512];
-
wxClassInfo::InitializeClasses();
#if wxUSE_INTL
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)
#define _MAXPATHLEN 500
-/* Useful buffer, initialized in wxCommonInit */
-wxChar *wxBuffer = (wxChar *) NULL;
-
/* Windows List */
wxWindowList wxTopLevelWindows;
#include <string.h>
-extern char *wxBuffer;
extern wxList wxPendingDelete;
wxApp *wxTheApp = 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
wxBitmap::CleanUpHandlers();
- delete[] wxBuffer;
- wxBuffer = NULL;
-
wxClassInfo::CleanUpClasses();
delete wxTheApp;
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
#define _MAXPATHLEN 500
-// Useful buffer, initialized in CommonInit
-char *wxBuffer = NULL;
-
// Windows List
wxWindowList wxTopLevelWindows;
else
{
char mnem = wxFindMnemonic (title);
- wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
-
menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
wxString title2(wxStripMenuCodes(title));
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;
}
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);
#include "wx/log.h"
#include "wx/intl.h"
#include "wx/evtloop.h"
+#include "wx/cmdline.h"
#if wxUSE_THREADS
#include "wx/thread.h"
#include <string.h>
-extern char *wxBuffer;
extern wxList wxPendingDelete;
wxApp *wxTheApp = NULL;
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 *);
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
delete wxTheApp;
wxTheApp = NULL;
- delete[] wxBuffer;
- wxBuffer = NULL;
-
wxClassInfo::CleanUpClasses();
#if wxUSE_THREADS
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[] )
{
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)
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
- wxTheApp->argc = argc;
- wxTheApp->argv = argv;
+ // 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();
win = wxGetWindowFromTable(window);
if (!win)
- return;
+ return;
switch (event->type)
{
}
default:
{
+#ifdef __WXDEBUG__
+ //wxString eventName = wxGetXEventName(XEvent& event);
+ //wxLogDebug(wxT("Event %s not handled"), eventName.c_str());
+#endif
break;
}
}
#endif
}
-// ----------------------------------------------------------------------------
-// accessors for C modules
-// ----------------------------------------------------------------------------
-
-#if 0
-extern "C" XtAppContext wxGetAppContext()
-{
- return (XtAppContext)wxTheApp->GetAppContext();
-}
-#endif
#define _MAXPATHLEN 500
-// Useful buffer, initialized in CommonInit
-char *wxBuffer = NULL;
-
// Windows List
wxWindowList wxTopLevelWindows;
}
}
+#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
*/
- wxBuffer[0] = '\0';
+ static char buf[256];
+ buf[0] = '\0';
char *tmp = copystring (s);
s = tmp;
char *p = tmp;
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
}