1. Assorted Motif fixes
a) tear off menus b) native dialogs c) crash in ~wxWindow fixed d) compilation and linking fixes 2. test code removed from minimal sample, text one compiles without clipboard 3. wxAppBase/wxApp small fixes git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3074 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -250,6 +250,26 @@ protected:
|
|||||||
#include "wx/stubs/app.h"
|
#include "wx/stubs/app.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// the global data
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the one and only application object - use of wxTheApp in application code
|
||||||
|
// is discouraged, consider using DECLARE_APP() after which you may call
|
||||||
|
// wxGetApp() which will return the object of the correct type (i.e. MyApp and
|
||||||
|
// not wxApp)
|
||||||
|
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// global functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Force an exit from main loop
|
||||||
|
void WXDLLEXPORT wxExit();
|
||||||
|
|
||||||
|
// Yield to other apps/messages
|
||||||
|
bool WXDLLEXPORT wxYield();
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// macros for dynamic creation of the application object
|
// macros for dynamic creation of the application object
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -14,8 +14,6 @@
|
|||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
|
||||||
#include "wx/window.h"
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
@@ -26,26 +24,6 @@
|
|||||||
class wxApp;
|
class wxApp;
|
||||||
class wxLog;
|
class wxLog;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// global data
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern wxApp *wxTheApp;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// global functions
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxExit(void);
|
|
||||||
bool wxYield(void);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define wxPRINT_WINDOWS 1
|
|
||||||
#define wxPRINT_POSTSCRIPT 2
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxApp
|
// wxApp
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -14,8 +14,6 @@
|
|||||||
#pragma interface
|
#pragma interface
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
|
||||||
#include "wx/window.h"
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
@@ -26,26 +24,6 @@
|
|||||||
class wxApp;
|
class wxApp;
|
||||||
class wxLog;
|
class wxLog;
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// global data
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
extern wxApp *wxTheApp;
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// global functions
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
void wxExit(void);
|
|
||||||
bool wxYield(void);
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
// constants
|
|
||||||
//-----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
#define wxPRINT_WINDOWS 1
|
|
||||||
#define wxPRINT_POSTSCRIPT 2
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxApp
|
// wxApp
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@@ -13,167 +13,114 @@
|
|||||||
#define _WX_APP_H_
|
#define _WX_APP_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "app.h"
|
#pragma interface "app.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
// ----------------------------------------------------------------------------
|
||||||
#include "wx/object.h"
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "wx/gdicmn.h"
|
#include "wx/gdicmn.h"
|
||||||
#include "wx/event.h"
|
#include "wx/event.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// forward declarations
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxFrame;
|
class WXDLLEXPORT wxFrame;
|
||||||
class WXDLLEXPORT wxWindow;
|
class WXDLLEXPORT wxWindow;
|
||||||
class WXDLLEXPORT wxApp ;
|
class WXDLLEXPORT wxApp ;
|
||||||
class WXDLLEXPORT wxKeyEvent;
|
class WXDLLEXPORT wxKeyEvent;
|
||||||
class WXDLLEXPORT wxLog;
|
class WXDLLEXPORT wxLog;
|
||||||
|
|
||||||
#define wxPRINT_WINDOWS 1
|
// ----------------------------------------------------------------------------
|
||||||
#define wxPRINT_POSTSCRIPT 2
|
// the wxApp class for Motif - see wxAppBase for more details
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
|
class WXDLLEXPORT wxApp : public wxAppBase
|
||||||
|
|
||||||
// Force an exit from main loop
|
|
||||||
void WXDLLEXPORT wxExit();
|
|
||||||
|
|
||||||
// Yield to other apps/messages
|
|
||||||
bool WXDLLEXPORT wxYield();
|
|
||||||
|
|
||||||
// Represents the application. Derive OnInit and declare
|
|
||||||
// a new App object to start application
|
|
||||||
class WXDLLEXPORT wxApp: public wxEvtHandler
|
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxApp)
|
DECLARE_DYNAMIC_CLASS(wxApp)
|
||||||
wxApp();
|
|
||||||
inline ~wxApp() {}
|
|
||||||
|
|
||||||
static void SetInitializerFunction(wxAppInitializerFunction fn) { m_appInitFn = fn; }
|
|
||||||
static wxAppInitializerFunction GetInitializerFunction() { return m_appInitFn; }
|
|
||||||
|
|
||||||
virtual int MainLoop();
|
|
||||||
void ExitMainLoop();
|
|
||||||
bool Initialized();
|
|
||||||
virtual bool Pending() ;
|
|
||||||
virtual void Dispatch() ;
|
|
||||||
|
|
||||||
void OnIdle(wxIdleEvent& event);
|
|
||||||
|
|
||||||
// Generic
|
|
||||||
virtual bool OnInit() { return FALSE; };
|
|
||||||
|
|
||||||
// Create an application context
|
|
||||||
virtual bool OnInitGui();
|
|
||||||
|
|
||||||
// Called to set off the main loop
|
|
||||||
virtual int OnRun() { return MainLoop(); };
|
|
||||||
virtual int OnExit() { return 0; }
|
|
||||||
|
|
||||||
/** Returns the standard icons for the msg dialogs, implemented in
|
|
||||||
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
|
|
||||||
virtual wxIcon GetStdIcon(int which) const;
|
|
||||||
|
|
||||||
inline void SetPrintMode(int mode) { m_printMode = mode; }
|
|
||||||
inline int GetPrintMode() const { return m_printMode; }
|
|
||||||
|
|
||||||
inline void SetExitOnFrameDelete(bool flag) { m_exitOnFrameDelete = flag; }
|
|
||||||
inline bool GetExitOnFrameDelete() const { return m_exitOnFrameDelete; }
|
|
||||||
|
|
||||||
inline wxString GetAppName() const {
|
|
||||||
if (m_appName != "")
|
|
||||||
return m_appName;
|
|
||||||
else return m_className;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void SetAppName(const wxString& name) { m_appName = name; };
|
|
||||||
inline wxString GetClassName() const { return m_className; }
|
|
||||||
inline void SetClassName(const wxString& name) { m_className = name; }
|
|
||||||
|
|
||||||
void SetVendorName(const wxString& vendorName) { m_vendorName = vendorName; }
|
|
||||||
const wxString& GetVendorName() const { return m_vendorName; }
|
|
||||||
|
|
||||||
wxWindow *GetTopWindow() const ;
|
|
||||||
inline void SetTopWindow(wxWindow *win) { m_topWindow = win; }
|
|
||||||
|
|
||||||
inline void SetWantDebugOutput(bool flag) { m_wantDebugOutput = flag; }
|
|
||||||
inline bool GetWantDebugOutput() { return m_wantDebugOutput; }
|
|
||||||
|
|
||||||
// Send idle event to all top-level windows.
|
|
||||||
// Returns TRUE if more idle time is requested.
|
|
||||||
bool SendIdleEvents();
|
|
||||||
|
|
||||||
// Send idle event to window and all subwindows
|
|
||||||
// Returns TRUE if more idle time is requested.
|
|
||||||
bool SendIdleEvents(wxWindow* win);
|
|
||||||
|
|
||||||
// Windows only, but for compatibility...
|
|
||||||
inline void SetAuto3D(bool flag) { m_auto3D = flag; }
|
|
||||||
inline bool GetAuto3D() const { return m_auto3D; }
|
|
||||||
|
|
||||||
// Creates a log object
|
|
||||||
virtual wxLog* CreateLogTarget();
|
|
||||||
|
|
||||||
// Motif implementation.
|
|
||||||
|
|
||||||
// Processes an X event.
|
|
||||||
virtual void ProcessXEvent(WXEvent* event);
|
|
||||||
|
|
||||||
// Returns TRUE if an accelerator has been processed
|
|
||||||
virtual bool CheckForAccelerator(WXEvent* event);
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Will always be set to the appropriate, main-style values.
|
wxApp();
|
||||||
int argc;
|
~wxApp() {}
|
||||||
char ** argv;
|
|
||||||
|
// override base class (pure) virtuals
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
virtual int MainLoop();
|
||||||
|
virtual void ExitMainLoop();
|
||||||
|
virtual bool Initialized();
|
||||||
|
virtual bool Pending() ;
|
||||||
|
virtual void Dispatch() ;
|
||||||
|
|
||||||
|
virtual bool OnInitGui();
|
||||||
|
|
||||||
|
virtual wxIcon GetStdIcon(int which) const;
|
||||||
|
|
||||||
|
// implementation from now on
|
||||||
|
// --------------------------
|
||||||
|
|
||||||
|
void OnIdle(wxIdleEvent& event);
|
||||||
|
|
||||||
|
// Send idle event to all top-level windows.
|
||||||
|
// Returns TRUE if more idle time is requested.
|
||||||
|
bool SendIdleEvents();
|
||||||
|
|
||||||
|
// Send idle event to window and all subwindows
|
||||||
|
// Returns TRUE if more idle time is requested.
|
||||||
|
bool SendIdleEvents(wxWindow* win);
|
||||||
|
|
||||||
|
// Motif implementation.
|
||||||
|
|
||||||
|
// Processes an X event.
|
||||||
|
virtual void ProcessXEvent(WXEvent* event);
|
||||||
|
|
||||||
|
// Returns TRUE if an accelerator has been processed
|
||||||
|
virtual bool CheckForAccelerator(WXEvent* event);
|
||||||
|
|
||||||
|
// Returns TRUE if a key down event has been processed
|
||||||
|
virtual bool CheckForKeyDown(WXEvent* event);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_wantDebugOutput ;
|
bool m_showOnInit;
|
||||||
wxString m_className;
|
|
||||||
wxString m_appName,
|
|
||||||
m_vendorName;
|
|
||||||
wxWindow * m_topWindow;
|
|
||||||
bool m_exitOnFrameDelete;
|
|
||||||
bool m_showOnInit;
|
|
||||||
int m_printMode; // wxPRINT_WINDOWS, wxPRINT_POSTSCRIPT
|
|
||||||
bool m_auto3D ; // Always use 3D controls, except
|
|
||||||
// where overriden
|
|
||||||
static wxAppInitializerFunction m_appInitFn;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Implementation
|
||||||
|
static bool Initialize();
|
||||||
|
static void CleanUp();
|
||||||
|
|
||||||
// Implementation
|
void DeletePendingObjects();
|
||||||
static bool Initialize();
|
bool ProcessIdle();
|
||||||
static void CleanUp();
|
|
||||||
|
|
||||||
void DeletePendingObjects();
|
|
||||||
bool ProcessIdle();
|
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
void ProcessPendingEvents();
|
void ProcessPendingEvents();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Motif-specific
|
// Motif-specific
|
||||||
inline WXAppContext GetAppContext() const { return m_appContext; }
|
WXAppContext GetAppContext() const { return m_appContext; }
|
||||||
inline WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
|
WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
|
||||||
WXColormap GetMainColormap(WXDisplay* display) ;
|
WXColormap GetMainColormap(WXDisplay* display) ;
|
||||||
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
|
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
|
||||||
inline long GetMaxRequestSize() const { return m_maxRequestSize; }
|
long GetMaxRequestSize() const { return m_maxRequestSize; }
|
||||||
|
|
||||||
// This handler is called when a property change event occurs
|
// This handler is called when a property change event occurs
|
||||||
virtual void HandlePropertyChange(WXEvent *event);
|
virtual void HandlePropertyChange(WXEvent *event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static long sm_lastMessageTime;
|
static long sm_lastMessageTime;
|
||||||
int m_nCmdShow;
|
int m_nCmdShow;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool m_keepGoing ;
|
bool m_keepGoing ;
|
||||||
|
|
||||||
// Motif-specific
|
// Motif-specific
|
||||||
WXAppContext m_appContext;
|
WXAppContext m_appContext;
|
||||||
WXWidget m_topLevelWidget;
|
WXWidget m_topLevelWidget;
|
||||||
WXColormap m_mainColormap;
|
WXColormap m_mainColormap;
|
||||||
WXDisplay* m_initialDisplay;
|
WXDisplay* m_initialDisplay;
|
||||||
long m_maxRequestSize;
|
long m_maxRequestSize;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
int WXDLLEXPORT wxEntry( int argc, char *argv[] );
|
int WXDLLEXPORT wxEntry( int argc, char *argv[] );
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
// Created: 17/09/98
|
// Created: 17/09/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_MENU_H_
|
#ifndef _WX_MENU_H_
|
||||||
@@ -36,8 +36,17 @@ class WXDLLEXPORT wxMenu: public wxEvtHandler
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
// ctor & dtor
|
// ctor & dtor
|
||||||
wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
~wxMenu();
|
wxMenu( const wxString& title, const wxFunction func)
|
||||||
|
{
|
||||||
|
Init(title, 0, func);
|
||||||
|
}
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
wxMenu( const wxString& title = wxEmptyString, long style = 0 )
|
||||||
|
{
|
||||||
|
Init(title, style);
|
||||||
|
}
|
||||||
|
virtual ~wxMenu();
|
||||||
|
|
||||||
// construct menu
|
// construct menu
|
||||||
// append items to the menu
|
// append items to the menu
|
||||||
@@ -47,7 +56,7 @@ public:
|
|||||||
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
|
void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
|
||||||
bool checkable = FALSE);
|
bool checkable = FALSE);
|
||||||
// a submenu
|
// a submenu
|
||||||
void Append(int id, const wxString& Label, wxMenu *SubMenu,
|
void Append(int id, const wxString& Label, wxMenu *SubMenu,
|
||||||
const wxString& helpString = wxEmptyString);
|
const wxString& helpString = wxEmptyString);
|
||||||
// the most generic form (create wxMenuItem first and use it's functions)
|
// the most generic form (create wxMenuItem first and use it's functions)
|
||||||
void Append(wxMenuItem *pItem);
|
void Append(wxMenuItem *pItem);
|
||||||
@@ -59,14 +68,14 @@ public:
|
|||||||
// menu item control
|
// menu item control
|
||||||
void Enable(int id, bool Flag);
|
void Enable(int id, bool Flag);
|
||||||
bool Enabled(int id) const;
|
bool Enabled(int id) const;
|
||||||
inline bool IsEnabled(int id) const { return Enabled(id); };
|
bool IsEnabled(int id) const { return Enabled(id); };
|
||||||
void Check(int id, bool Flag);
|
void Check(int id, bool Flag);
|
||||||
bool Checked(int id) const;
|
bool Checked(int id) const;
|
||||||
inline bool IsChecked(int id) const { return IsChecked(id); };
|
bool IsChecked(int id) const { return IsChecked(id); };
|
||||||
|
|
||||||
// Client data
|
// Client data
|
||||||
inline void SetClientData(void* clientData) { m_clientData = clientData; }
|
void SetClientData(void* clientData) { m_clientData = clientData; }
|
||||||
inline void* GetClientData() const { return m_clientData; }
|
void* GetClientData() const { return m_clientData; }
|
||||||
|
|
||||||
// item properties
|
// item properties
|
||||||
// title
|
// title
|
||||||
@@ -92,26 +101,29 @@ public:
|
|||||||
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
|
void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
|
||||||
|
|
||||||
void ProcessCommand(wxCommandEvent& event);
|
void ProcessCommand(wxCommandEvent& event);
|
||||||
inline void Callback(const wxFunction func) { m_callback = func; }
|
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
void Callback(const wxFunction func) { m_callback = func; }
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
|
virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
|
||||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||||
|
|
||||||
inline wxList& GetItems() const { return (wxList&) m_menuItems; }
|
wxList& GetItems() const { return (wxList&) m_menuItems; }
|
||||||
|
|
||||||
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
|
void SetInvokingWindow(wxWindow *pWin) { m_pInvokingWindow = pWin; }
|
||||||
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
|
wxWindow *GetInvokingWindow() const { return m_pInvokingWindow; }
|
||||||
|
|
||||||
//// Motif-specific
|
//// Motif-specific
|
||||||
inline WXWidget GetButtonWidget() const { return m_buttonWidget; }
|
WXWidget GetButtonWidget() const { return m_buttonWidget; }
|
||||||
inline void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
|
void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
|
||||||
inline WXWidget GetMainWidget() const { return m_menuWidget; }
|
WXWidget GetMainWidget() const { return m_menuWidget; }
|
||||||
inline wxMenu* GetParent() const { return m_menuParent; }
|
wxMenu* GetParent() const { return m_menuParent; }
|
||||||
inline int GetId() const { return m_menuId; }
|
int GetId() const { return m_menuId; }
|
||||||
inline void SetId(int id) { m_menuId = id; }
|
void SetId(int id) { m_menuId = id; }
|
||||||
inline void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
|
void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
|
||||||
inline wxMenuBar* GetMenuBar() const { return m_menuBar; }
|
wxMenuBar* GetMenuBar() const { return m_menuBar; }
|
||||||
|
|
||||||
void CreatePopup (WXWidget logicalParent, int x, int y);
|
void CreatePopup (WXWidget logicalParent, int x, int y);
|
||||||
void DestroyPopup (void);
|
void DestroyPopup (void);
|
||||||
@@ -135,8 +147,14 @@ public:
|
|||||||
void SetFont(const wxFont& colour);
|
void SetFont(const wxFont& colour);
|
||||||
void ChangeFont(bool keepOriginalSize = FALSE);
|
void ChangeFont(bool keepOriginalSize = FALSE);
|
||||||
|
|
||||||
|
// implementation from now on
|
||||||
|
WXWidget GetHandle() const { return m_menuWidget; }
|
||||||
|
bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
wxFunction m_callback;
|
wxFunction m_callback;
|
||||||
|
#endif // WXWIN_COMPATIBILITY
|
||||||
|
|
||||||
int m_noItems;
|
int m_noItems;
|
||||||
wxString m_title;
|
wxString m_title;
|
||||||
@@ -147,6 +165,8 @@ public:
|
|||||||
void* m_clientData;
|
void* m_clientData;
|
||||||
wxWindow* m_pInvokingWindow;
|
wxWindow* m_pInvokingWindow;
|
||||||
|
|
||||||
|
long m_style;
|
||||||
|
|
||||||
//// Motif-specific
|
//// Motif-specific
|
||||||
int m_numColumns;
|
int m_numColumns;
|
||||||
WXWidget m_menuWidget;
|
WXWidget m_menuWidget;
|
||||||
@@ -159,88 +179,99 @@ public:
|
|||||||
wxColour m_foregroundColour;
|
wxColour m_foregroundColour;
|
||||||
wxColour m_backgroundColour;
|
wxColour m_backgroundColour;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
|
|
||||||
|
private:
|
||||||
|
// common code for both constructors:
|
||||||
|
void Init( const wxString& title,
|
||||||
|
long style
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func = (wxFunction) NULL
|
||||||
|
#endif
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Menu Bar (a la Windows)
|
// Menu Bar (a la Windows)
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxFrame;
|
class WXDLLEXPORT wxFrame;
|
||||||
class WXDLLEXPORT wxMenuBar: public wxEvtHandler
|
class WXDLLEXPORT wxMenuBar : public wxEvtHandler
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
DECLARE_DYNAMIC_CLASS(wxMenuBar)
|
||||||
|
|
||||||
wxMenuBar( long style );
|
public:
|
||||||
wxMenuBar();
|
wxMenuBar( long style );
|
||||||
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
wxMenuBar();
|
||||||
~wxMenuBar();
|
wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
|
||||||
|
~wxMenuBar();
|
||||||
|
|
||||||
void Append(wxMenu *menu, const wxString& title);
|
void Append(wxMenu *menu, const wxString& title);
|
||||||
// Must only be used AFTER menu has been attached to frame,
|
// Must only be used AFTER menu has been attached to frame,
|
||||||
// otherwise use individual menus to enable/disable items
|
// otherwise use individual menus to enable/disable items
|
||||||
void Enable(int Id, bool Flag);
|
void Enable(int Id, bool Flag);
|
||||||
bool Enabled(int Id) const ;
|
bool Enabled(int Id) const ;
|
||||||
inline bool IsEnabled(int Id) const { return Enabled(Id); };
|
bool IsEnabled(int Id) const { return Enabled(Id); };
|
||||||
void EnableTop(int pos, bool Flag);
|
void EnableTop(int pos, bool Flag);
|
||||||
void Check(int id, bool Flag);
|
void Check(int id, bool Flag);
|
||||||
bool Checked(int id) const ;
|
bool Checked(int id) const ;
|
||||||
inline bool IsChecked(int Id) const { return Checked(Id); };
|
bool IsChecked(int Id) const { return Checked(Id); };
|
||||||
void SetLabel(int id, const wxString& label) ;
|
void SetLabel(int id, const wxString& label) ;
|
||||||
wxString GetLabel(int id) const ;
|
wxString GetLabel(int id) const ;
|
||||||
void SetLabelTop(int pos, const wxString& label) ;
|
void SetLabelTop(int pos, const wxString& label) ;
|
||||||
wxString GetLabelTop(int pos) const ;
|
wxString GetLabelTop(int pos) const ;
|
||||||
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
|
virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
|
||||||
virtual bool OnAppend(wxMenu *menu, const char *title);
|
virtual bool OnAppend(wxMenu *menu, const char *title);
|
||||||
virtual bool OnDelete(wxMenu *menu, int index);
|
virtual bool OnDelete(wxMenu *menu, int index);
|
||||||
|
|
||||||
virtual void SetHelpString(int Id, const wxString& helpString);
|
virtual void SetHelpString(int Id, const wxString& helpString);
|
||||||
virtual wxString GetHelpString(int Id) const ;
|
virtual wxString GetHelpString(int Id) const ;
|
||||||
|
|
||||||
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
|
virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
|
||||||
|
|
||||||
// Find wxMenuItem for item ID, and return item's
|
// Find wxMenuItem for item ID, and return item's
|
||||||
// menu too if itemMenu is non-NULL.
|
// menu too if itemMenu is non-NULL.
|
||||||
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
|
wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
|
||||||
|
|
||||||
inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
|
||||||
inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
wxEvtHandler *GetEventHandler() { return m_eventHandler; }
|
||||||
|
|
||||||
inline int GetMenuCount() const { return m_menuCount; }
|
int GetMenuCount() const { return m_menuCount; }
|
||||||
inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
|
wxMenu* GetMenu(int i) const { return m_menus[i]; }
|
||||||
|
|
||||||
//// Motif-specific
|
//// Motif-specific
|
||||||
inline wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
|
wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
|
||||||
inline void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
|
void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
|
||||||
inline WXWidget GetMainWidget() const { return m_mainWidget; }
|
WXWidget GetMainWidget() const { return m_mainWidget; }
|
||||||
inline void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
|
void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
|
||||||
|
|
||||||
// Create menubar
|
// Create menubar
|
||||||
bool CreateMenuBar(wxFrame* frame);
|
bool CreateMenuBar(wxFrame* frame);
|
||||||
|
|
||||||
// Destroy menubar, but keep data structures intact so we can recreate it.
|
// Destroy menubar, but keep data structures intact so we can recreate it.
|
||||||
bool DestroyMenuBar();
|
bool DestroyMenuBar();
|
||||||
|
|
||||||
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
|
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
|
||||||
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
|
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
|
||||||
const wxFont& GetFont() const { return m_font; }
|
const wxFont& GetFont() const { return m_font; }
|
||||||
|
|
||||||
void SetBackgroundColour(const wxColour& colour);
|
void SetBackgroundColour(const wxColour& colour);
|
||||||
void SetForegroundColour(const wxColour& colour);
|
void SetForegroundColour(const wxColour& colour);
|
||||||
void SetFont(const wxFont& colour);
|
void SetFont(const wxFont& colour);
|
||||||
void ChangeFont(bool keepOriginalSize = FALSE);
|
void ChangeFont(bool keepOriginalSize = FALSE);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxEvtHandler * m_eventHandler;
|
wxEvtHandler * m_eventHandler;
|
||||||
int m_menuCount;
|
int m_menuCount;
|
||||||
wxMenu ** m_menus;
|
wxMenu ** m_menus;
|
||||||
wxString * m_titles;
|
wxString * m_titles;
|
||||||
wxFrame * m_menuBarFrame;
|
wxFrame * m_menuBarFrame;
|
||||||
|
|
||||||
//// Motif-specific
|
//// Motif-specific
|
||||||
WXWidget m_mainWidget;
|
WXWidget m_mainWidget;
|
||||||
|
|
||||||
wxColour m_foregroundColour;
|
wxColour m_foregroundColour;
|
||||||
wxColour m_backgroundColour;
|
wxColour m_backgroundColour;
|
||||||
wxFont m_font;
|
wxFont m_font;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_MENU_H_
|
#endif // _WX_MENU_H_
|
||||||
|
@@ -7,7 +7,7 @@
|
|||||||
// Created: 17/09/98
|
// Created: 17/09/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_MSGBOXDLG_H_
|
#ifndef _WX_MSGBOXDLG_H_
|
||||||
@@ -20,31 +20,43 @@
|
|||||||
#include "wx/setup.h"
|
#include "wx/setup.h"
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* Message box dialog
|
// Message box dialog
|
||||||
*/
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
|
WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
|
||||||
|
|
||||||
class WXDLLEXPORT wxMessageDialog: public wxDialog
|
class WXDLLEXPORT wxMessageDialog: public wxDialog
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
|
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
|
||||||
|
|
||||||
|
public:
|
||||||
|
wxMessageDialog(wxWindow *parent,
|
||||||
|
const wxString& message,
|
||||||
|
const wxString& caption = wxMessageBoxCaptionStr,
|
||||||
|
long style = wxOK | wxCENTRE,
|
||||||
|
const wxPoint& pos = wxDefaultPosition);
|
||||||
|
|
||||||
|
int ShowModal();
|
||||||
|
|
||||||
|
// implementation only from now on
|
||||||
|
// called by the Motif callback
|
||||||
|
void SetResult(long result) { m_result = result; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxString m_caption;
|
wxString m_caption;
|
||||||
wxString m_message;
|
wxString m_message;
|
||||||
long m_dialogStyle;
|
long m_dialogStyle;
|
||||||
wxWindow * m_parent;
|
wxWindow * m_parent;
|
||||||
public:
|
long m_result;
|
||||||
wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
|
|
||||||
long style = wxOK|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
|
|
||||||
|
|
||||||
int ShowModal();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int WXDLLEXPORT wxMessageBox(const wxString& message, const wxString& caption = wxMessageBoxCaptionStr,
|
int WXDLLEXPORT wxMessageBox(const wxString& message,
|
||||||
long style = wxOK|wxCENTRE,
|
const wxString& caption = wxMessageBoxCaptionStr,
|
||||||
wxWindow *parent = NULL, int x = -1, int y = -1);
|
long style = wxOK | wxCENTRE,
|
||||||
|
wxWindow *parent = NULL,
|
||||||
|
int x = -1, int y = -1);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_MSGBOXDLG_H_
|
// _WX_MSGBOXDLG_H_
|
||||||
|
@@ -72,5 +72,37 @@ extern XColor itemColors[5] ;
|
|||||||
#define wxTOPS_INDEX 3
|
#define wxTOPS_INDEX 3
|
||||||
#define wxBOTS_INDEX 4
|
#define wxBOTS_INDEX 4
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// utility classes
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// XmString made easy to use in wxWindows (and has an added benefit of
|
||||||
|
// cleaning up automatically)
|
||||||
|
class wxXmString
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxXmString(const wxString& str)
|
||||||
|
{
|
||||||
|
m_string = XmStringCreateLtoR((char *)str.c_str(),
|
||||||
|
XmSTRING_DEFAULT_CHARSET);
|
||||||
|
}
|
||||||
|
|
||||||
|
~wxXmString() { XmStringFree(m_string); }
|
||||||
|
|
||||||
|
// semi-implicit conversion to XmString (shouldn't rely on implicit
|
||||||
|
// conversion because many of Motif functions are macros)
|
||||||
|
XmString operator()() const { return m_string; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
XmString m_string;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// macros to avoid casting WXFOO to Foo all the time
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// argument is of type "wxWindow *"
|
||||||
|
#define GetWidget(w) ((Widget)(w)->GetHandle())
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_PRIVATE_H_
|
// _WX_PRIVATE_H_
|
||||||
|
@@ -91,8 +91,6 @@ public:
|
|||||||
const wxFont *theFont = (const wxFont *) NULL)
|
const wxFont *theFont = (const wxFont *) NULL)
|
||||||
const;
|
const;
|
||||||
|
|
||||||
virtual bool PopupMenu( wxMenu *menu, int x, int y );
|
|
||||||
|
|
||||||
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
|
||||||
int range, bool refresh = TRUE );
|
int range, bool refresh = TRUE );
|
||||||
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
|
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
|
||||||
@@ -319,6 +317,7 @@ protected:
|
|||||||
int width, int height,
|
int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO);
|
int sizeFlags = wxSIZE_AUTO);
|
||||||
virtual void DoSetClientSize(int width, int height);
|
virtual void DoSetClientSize(int width, int height);
|
||||||
|
virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
|
||||||
|
|
||||||
#if wxUSE_TOOLTIPS
|
#if wxUSE_TOOLTIPS
|
||||||
virtual void DoSetToolTip( wxToolTip *tip );
|
virtual void DoSetToolTip( wxToolTip *tip );
|
||||||
|
@@ -16,8 +16,6 @@
|
|||||||
#pragma interface "app.h"
|
#pragma interface "app.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/defs.h"
|
|
||||||
#include "wx/object.h"
|
|
||||||
#include "wx/event.h"
|
#include "wx/event.h"
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
|
|
||||||
@@ -27,14 +25,6 @@ class WXDLLEXPORT wxApp ;
|
|||||||
class WXDLLEXPORT wxKeyEvent;
|
class WXDLLEXPORT wxKeyEvent;
|
||||||
class WXDLLEXPORT wxLog;
|
class WXDLLEXPORT wxLog;
|
||||||
|
|
||||||
WXDLLEXPORT_DATA(extern wxApp*) wxTheApp;
|
|
||||||
|
|
||||||
// Force an exit from main loop
|
|
||||||
void WXDLLEXPORT wxExit();
|
|
||||||
|
|
||||||
// Yield to other apps/messages
|
|
||||||
bool WXDLLEXPORT wxYield();
|
|
||||||
|
|
||||||
// Represents the application. Derive OnInit and declare
|
// Represents the application. Derive OnInit and declare
|
||||||
// a new App object to start application
|
// a new App object to start application
|
||||||
class WXDLLEXPORT wxApp : public wxAppBase
|
class WXDLLEXPORT wxApp : public wxAppBase
|
||||||
|
@@ -69,7 +69,6 @@ public:
|
|||||||
// event handlers (these functions should _not_ be virtual)
|
// event handlers (these functions should _not_ be virtual)
|
||||||
void OnQuit(wxCommandEvent& event);
|
void OnQuit(wxCommandEvent& event);
|
||||||
void OnAbout(wxCommandEvent& event);
|
void OnAbout(wxCommandEvent& event);
|
||||||
void OnTest(wxCommandEvent& event);
|
|
||||||
|
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
@@ -88,10 +87,6 @@ enum
|
|||||||
// menu items
|
// menu items
|
||||||
Minimal_Quit = 1,
|
Minimal_Quit = 1,
|
||||||
Minimal_About,
|
Minimal_About,
|
||||||
Minimal_Test,
|
|
||||||
|
|
||||||
// controls start here (the numbers are, of course, arbitrary)
|
|
||||||
Minimal_Text = 1000,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -104,10 +99,6 @@ enum
|
|||||||
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
||||||
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
EVT_MENU(Minimal_Quit, MyFrame::OnQuit)
|
||||||
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
EVT_MENU(Minimal_About, MyFrame::OnAbout)
|
||||||
|
|
||||||
EVT_MENU(Minimal_Test, MyFrame::OnTest)
|
|
||||||
|
|
||||||
EVT_PAINT(MyFrame::OnPaint)
|
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
// Create a new application object: this macro will allow wxWindows to create
|
// Create a new application object: this macro will allow wxWindows to create
|
||||||
@@ -158,7 +149,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
|
wxMenu *menuFile = new wxMenu("", wxMENU_TEAROFF);
|
||||||
|
|
||||||
menuFile->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
|
menuFile->Append(Minimal_About, "&About...\tCtrl-A", "Show about dialog");
|
||||||
menuFile->Append(Minimal_Test, "&Test...\tCtrl-T", "Test");
|
|
||||||
menuFile->AppendSeparator();
|
menuFile->AppendSeparator();
|
||||||
menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
|
menuFile->Append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program");
|
||||||
|
|
||||||
@@ -202,71 +192,3 @@ void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
|
|||||||
wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this);
|
wxMessageBox(msg, "About Minimal", wxOK | wxICON_INFORMATION, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Foo
|
|
||||||
{
|
|
||||||
Foo(int n_) { n = n_; }
|
|
||||||
|
|
||||||
int n;
|
|
||||||
};
|
|
||||||
|
|
||||||
WX_DECLARE_LIST(Foo, FooList);
|
|
||||||
|
|
||||||
#include <wx/listimpl.cpp>
|
|
||||||
|
|
||||||
WX_DEFINE_LIST(FooList);
|
|
||||||
|
|
||||||
int FooSort(const Foo **item1, const Foo **item2)
|
|
||||||
{
|
|
||||||
return (*item2)->n - (*item1)->n;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ShowList(const FooList& list)
|
|
||||||
{
|
|
||||||
wxString msg, str;
|
|
||||||
msg = "The list elements: (";
|
|
||||||
for ( FooList::Node *node = list.GetFirst(); node; node = node->GetNext() )
|
|
||||||
{
|
|
||||||
if ( !!str )
|
|
||||||
msg += ", ";
|
|
||||||
str.Printf("%d", node->GetData()->n);
|
|
||||||
msg += str;
|
|
||||||
}
|
|
||||||
|
|
||||||
msg += ')';
|
|
||||||
|
|
||||||
wxMessageBox(msg, "List contents", wxOK | wxICON_INFORMATION);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnTest(wxCommandEvent& event)
|
|
||||||
{
|
|
||||||
FooList list;
|
|
||||||
list.Append(new Foo(12));
|
|
||||||
list.Append(new Foo(3));
|
|
||||||
list.Append(new Foo(1));
|
|
||||||
list.Append(new Foo(7));
|
|
||||||
list.Append(new Foo(4));
|
|
||||||
ShowList(list);
|
|
||||||
list.Sort(FooSort);
|
|
||||||
ShowList(list);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MyFrame::OnPaint(wxPaintEvent& event)
|
|
||||||
{
|
|
||||||
wxPaintDC dc(this);
|
|
||||||
|
|
||||||
wxMemoryDC dcMem;
|
|
||||||
wxSize size(GetClientSize());
|
|
||||||
dcMem.SelectObject(wxBitmap(size.x, size.y, -1));
|
|
||||||
|
|
||||||
dcMem.SetBackground(wxBrush(wxColour(0, 0, 255), wxSOLID));
|
|
||||||
dcMem.SetTextForeground(wxColour(0, 255, 0));
|
|
||||||
dcMem.SetTextBackground(wxColour(0, 0, 0));
|
|
||||||
dcMem.SetBackgroundMode(wxSOLID);
|
|
||||||
dcMem.Clear();
|
|
||||||
dcMem.DrawText("Hello, wxWindows!", 10, 10);
|
|
||||||
|
|
||||||
wxPoint ptOrig(0, 0);
|
|
||||||
dc.Blit(ptOrig, size, &dcMem, ptOrig);
|
|
||||||
|
|
||||||
dcMem.SelectObject(wxNullBitmap);
|
|
||||||
}
|
|
||||||
|
@@ -569,8 +569,11 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
|
|||||||
EVT_MENU(TEXT_TOOLTIPS_ENABLE, MyFrame::OnToggleTooltips)
|
EVT_MENU(TEXT_TOOLTIPS_ENABLE, MyFrame::OnToggleTooltips)
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
|
#if wxUSE_CLIPBOARD
|
||||||
EVT_MENU(TEXT_CLIPBOARD_PASTE, MyFrame::OnPasteFromClipboard)
|
EVT_MENU(TEXT_CLIPBOARD_PASTE, MyFrame::OnPasteFromClipboard)
|
||||||
EVT_MENU(TEXT_CLIPBOARD_COPY, MyFrame::OnCopyToClipboard)
|
EVT_MENU(TEXT_CLIPBOARD_COPY, MyFrame::OnCopyToClipboard)
|
||||||
|
#endif // wxUSE_CLIPBOARD
|
||||||
|
|
||||||
EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText)
|
EVT_MENU(TEXT_MOVE_ENDTEXT, MyFrame::OnMoveToEndOfText)
|
||||||
EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry)
|
EVT_MENU(TEXT_MOVE_ENDENTRY, MyFrame::OnMoveToEndOfEntry)
|
||||||
|
|
||||||
|
@@ -12,7 +12,7 @@ SUFFIXES = .cpp .c
|
|||||||
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
DEFS = $(TOOLKIT_DEF) $(WXDEBUG_DEFINE)
|
||||||
LIBS = $(GUILIBS)
|
LIBS = $(GUILIBS)
|
||||||
|
|
||||||
VPATH = .:${srcdir}:${srcdir}/xmcombo:${srcdir}/../common:${srcdir}/../generic:${EXTRA_VPATH}
|
VPATH = .:${srcdir}:${srcdir}/xmcombo:${srcdir}/../common:${srcdir}/../generic:${srcdir}/../html:${EXTRA_VPATH}
|
||||||
|
|
||||||
EXTRA_DIST = "${srcdir}/../common ${srcdir}/../generic ${srcdir}"
|
EXTRA_DIST = "${srcdir}/../common ${srcdir}/../generic ${srcdir}"
|
||||||
|
|
||||||
|
@@ -10,7 +10,8 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "app.h"
|
#pragma implementation "app.h"
|
||||||
|
#pragma implementation "appbase.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/frame.h"
|
#include "wx/frame.h"
|
||||||
@@ -77,7 +78,7 @@ bool wxApp::Initialize()
|
|||||||
|
|
||||||
wxClassInfo::InitializeClasses();
|
wxClassInfo::InitializeClasses();
|
||||||
|
|
||||||
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
// GL: I'm annoyed ... I don't know where to put this and I don't want to
|
||||||
// create a module for that as it's part of the core.
|
// create a module for that as it's part of the core.
|
||||||
#if wxUSE_THREADS
|
#if wxUSE_THREADS
|
||||||
wxPendingEvents = new wxList();
|
wxPendingEvents = new wxList();
|
||||||
@@ -261,7 +262,7 @@ int wxEntry( int argc, char *argv[] )
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Static member initialization
|
// Static member initialization
|
||||||
wxAppInitializerFunction wxApp::m_appInitFn = (wxAppInitializerFunction) NULL;
|
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
|
||||||
|
|
||||||
wxApp::wxApp()
|
wxApp::wxApp()
|
||||||
{
|
{
|
||||||
@@ -272,9 +273,7 @@ wxApp::wxApp()
|
|||||||
m_appName = "";
|
m_appName = "";
|
||||||
argc = 0;
|
argc = 0;
|
||||||
argv = NULL;
|
argv = NULL;
|
||||||
m_printMode = wxPRINT_POSTSCRIPT;
|
|
||||||
m_exitOnFrameDelete = TRUE;
|
m_exitOnFrameDelete = TRUE;
|
||||||
m_auto3D = TRUE;
|
|
||||||
|
|
||||||
m_mainColormap = (WXColormap) NULL;
|
m_mainColormap = (WXColormap) NULL;
|
||||||
m_appContext = (WXAppContext) NULL;
|
m_appContext = (WXAppContext) NULL;
|
||||||
@@ -339,10 +338,24 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
{
|
{
|
||||||
XEvent* event = (XEvent*) _event;
|
XEvent* event = (XEvent*) _event;
|
||||||
|
|
||||||
if ((event->type == KeyPress) && CheckForAccelerator(_event))
|
if (event->type == KeyPress)
|
||||||
{
|
{
|
||||||
// Do nothing! We intercepted and processed the event as an accelerator.
|
if (CheckForAccelerator(_event))
|
||||||
|
{
|
||||||
|
// Do nothing! We intercepted and processed the event as an
|
||||||
|
// accelerator.
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
else if (CheckForKeyDown(_event))
|
||||||
|
{
|
||||||
|
// We intercepted and processed the key down event
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XtDispatchEvent(event);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (event->type == PropertyNotify)
|
else if (event->type == PropertyNotify)
|
||||||
{
|
{
|
||||||
@@ -351,10 +364,10 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
|||||||
}
|
}
|
||||||
else if (event->type == ResizeRequest)
|
else if (event->type == ResizeRequest)
|
||||||
{
|
{
|
||||||
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
||||||
* If resize event, don't resize until the last resize event for this
|
* If resize event, don't resize until the last resize event for this
|
||||||
* window is recieved. Prevents flicker as windows are resized.
|
* window is recieved. Prevents flicker as windows are resized.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
|
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
|
||||||
Window win = event->xany.window;
|
Window win = event->xany.window;
|
||||||
@@ -527,21 +540,6 @@ void wxApp::ProcessPendingEvents()
|
|||||||
}
|
}
|
||||||
#endif // wxUSE_THREADS
|
#endif // wxUSE_THREADS
|
||||||
|
|
||||||
wxLog* wxApp::CreateLogTarget()
|
|
||||||
{
|
|
||||||
return new wxLogGui;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxWindow* wxApp::GetTopWindow() const
|
|
||||||
{
|
|
||||||
if (m_topWindow)
|
|
||||||
return m_topWindow;
|
|
||||||
else if (wxTopLevelWindows.GetCount() > 0)
|
|
||||||
return wxTopLevelWindows.GetFirst()->GetData();
|
|
||||||
else
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create an application context
|
// Create an application context
|
||||||
bool wxApp::OnInitGui()
|
bool wxApp::OnInitGui()
|
||||||
{
|
{
|
||||||
@@ -631,6 +629,37 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxApp::CheckForKeyDown(WXEvent* event)
|
||||||
|
{
|
||||||
|
XEvent* xEvent = (XEvent*) event;
|
||||||
|
// VZ: this code doesn't work for me because it never finds the correct
|
||||||
|
// window. Also, if we go this way, we should generate KEY_UP and
|
||||||
|
// CHAR events as well, not only KEY_DOWN.
|
||||||
|
#if 0
|
||||||
|
if (xEvent->xany.type == KeyPress)
|
||||||
|
{
|
||||||
|
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
|
||||||
|
xEvent->xany.window);
|
||||||
|
wxWindow* win = NULL;
|
||||||
|
|
||||||
|
// Find the first wxWindow that corresponds to this event window
|
||||||
|
while (widget && !(win = wxGetWindowFromTable(widget)))
|
||||||
|
widget = XtParent(widget);
|
||||||
|
|
||||||
|
if (!widget || !win)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
|
||||||
|
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
|
||||||
|
|
||||||
|
win->ProcessEvent( keyEvent );
|
||||||
|
return (keyEvent.GetSkipped() != TRUE);
|
||||||
|
}
|
||||||
|
#endif // 0
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
void wxExit()
|
void wxExit()
|
||||||
{
|
{
|
||||||
int retValue = 0;
|
int retValue = 0;
|
||||||
@@ -659,3 +688,32 @@ bool wxYield()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO use XmGetPixmap (?) to get the really standard icons!
|
||||||
|
|
||||||
|
#include "wx/generic/info.xpm"
|
||||||
|
#include "wx/generic/error.xpm"
|
||||||
|
#include "wx/generic/question.xpm"
|
||||||
|
#include "wx/generic/warning.xpm"
|
||||||
|
|
||||||
|
wxIcon
|
||||||
|
wxApp::GetStdIcon(int which) const
|
||||||
|
{
|
||||||
|
switch(which)
|
||||||
|
{
|
||||||
|
case wxICON_INFORMATION:
|
||||||
|
return wxIcon(info_xpm);
|
||||||
|
|
||||||
|
case wxICON_QUESTION:
|
||||||
|
return wxIcon(question_xpm);
|
||||||
|
|
||||||
|
case wxICON_EXCLAMATION:
|
||||||
|
return wxIcon(warning_xpm);
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG("requested non existent standard icon");
|
||||||
|
// still fall through
|
||||||
|
|
||||||
|
case wxICON_HAND:
|
||||||
|
return wxIcon(error_xpm);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -58,7 +58,12 @@ IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
|
|||||||
// Menus
|
// Menus
|
||||||
|
|
||||||
// Construct a menu with optional title (then use append)
|
// Construct a menu with optional title (then use append)
|
||||||
wxMenu::wxMenu(const wxString& title, const wxFunction func)
|
void wxMenu::Init(const wxString& title,
|
||||||
|
long style
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
|
, const wxFunction func
|
||||||
|
#endif
|
||||||
|
)
|
||||||
{
|
{
|
||||||
m_title = title;
|
m_title = title;
|
||||||
m_parent = (wxEvtHandler*) NULL;
|
m_parent = (wxEvtHandler*) NULL;
|
||||||
@@ -66,6 +71,7 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func)
|
|||||||
m_noItems = 0;
|
m_noItems = 0;
|
||||||
m_menuBar = NULL;
|
m_menuBar = NULL;
|
||||||
m_pInvokingWindow = NULL;
|
m_pInvokingWindow = NULL;
|
||||||
|
m_style = style;
|
||||||
|
|
||||||
//// Motif-specific members
|
//// Motif-specific members
|
||||||
m_numColumns = 1;
|
m_numColumns = 1;
|
||||||
@@ -87,7 +93,9 @@ wxMenu::wxMenu(const wxString& title, const wxFunction func)
|
|||||||
m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
|
m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
|
||||||
m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
||||||
|
|
||||||
|
#ifdef WXWIN_COMPATIBILITY
|
||||||
Callback(func);
|
Callback(func);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// The wxWindow destructor will take care of deleting the submenus.
|
// The wxWindow destructor will take care of deleting the submenus.
|
||||||
@@ -426,72 +434,6 @@ void wxMenu::UpdateUI(wxEvtHandler* source)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxWindow::PopupMenu(wxMenu *menu, int x, int y)
|
|
||||||
{
|
|
||||||
Widget widget = (Widget) GetMainWidget();
|
|
||||||
|
|
||||||
/* The menuId field seems to be usused, so we'll use it to
|
|
||||||
indicate whether a menu is popped up or not:
|
|
||||||
0: Not currently created as a popup
|
|
||||||
-1: Created as a popup, but not active
|
|
||||||
1: Active popup.
|
|
||||||
*/
|
|
||||||
|
|
||||||
if (menu->GetParent() && (menu->GetId() != -1))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (menu->GetMainWidget()) {
|
|
||||||
menu->DestroyMenu(TRUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu->SetId(1); /* Mark as popped-up */
|
|
||||||
menu->CreateMenu(NULL, widget, menu);
|
|
||||||
menu->SetInvokingWindow(this);
|
|
||||||
|
|
||||||
menu->UpdateUI();
|
|
||||||
|
|
||||||
// menu->SetParent(parent);
|
|
||||||
// parent->children->Append(menu); // Store menu for later deletion
|
|
||||||
|
|
||||||
Widget menuWidget = (Widget) menu->GetMainWidget();
|
|
||||||
|
|
||||||
int rootX = 0;
|
|
||||||
int rootY = 0;
|
|
||||||
|
|
||||||
int deviceX = x;
|
|
||||||
int deviceY = y;
|
|
||||||
/*
|
|
||||||
if (this->IsKindOf(CLASSINFO(wxCanvas)))
|
|
||||||
{
|
|
||||||
wxCanvas *canvas = (wxCanvas *) this;
|
|
||||||
deviceX = canvas->GetDC ()->LogicalToDeviceX (x);
|
|
||||||
deviceY = canvas->GetDC ()->LogicalToDeviceY (y);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
Display *display = XtDisplay (widget);
|
|
||||||
Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget));
|
|
||||||
Window thisWindow = XtWindow (widget);
|
|
||||||
Window childWindow;
|
|
||||||
XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY,
|
|
||||||
&rootX, &rootY, &childWindow);
|
|
||||||
|
|
||||||
XButtonPressedEvent event;
|
|
||||||
event.type = ButtonPress;
|
|
||||||
event.button = 1;
|
|
||||||
|
|
||||||
event.x = deviceX;
|
|
||||||
event.y = deviceY;
|
|
||||||
|
|
||||||
event.x_root = rootX;
|
|
||||||
event.y_root = rootY;
|
|
||||||
|
|
||||||
XmMenuPosition (menuWidget, &event);
|
|
||||||
XtManageChild (menuWidget);
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Menu Bar
|
// Menu Bar
|
||||||
wxMenuBar::wxMenuBar()
|
wxMenuBar::wxMenuBar()
|
||||||
{
|
{
|
||||||
@@ -836,13 +778,20 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
|
|||||||
wxString title(m_titles[i]);
|
wxString title(m_titles[i]);
|
||||||
menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE));
|
menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE));
|
||||||
|
|
||||||
/*
|
|
||||||
* COMMENT THIS OUT IF YOU DON'T LIKE A RIGHT-JUSTIFIED HELP MENU
|
|
||||||
*/
|
|
||||||
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
|
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
|
||||||
|
|
||||||
if (strcmp (wxBuffer, "Help") == 0)
|
if (strcmp (wxBuffer, "Help") == 0)
|
||||||
XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
|
XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
|
||||||
|
|
||||||
|
// tear off menu support
|
||||||
|
#if (XmVersion >= 1002)
|
||||||
|
if ( menu->IsTearOff() )
|
||||||
|
{
|
||||||
|
XtVaSetValues(GetWidget(menu),
|
||||||
|
XmNtearOffModel, XmTEAR_OFF_ENABLED,
|
||||||
|
NULL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetBackgroundColour(m_backgroundColour);
|
SetBackgroundColour(m_backgroundColour);
|
||||||
|
@@ -6,21 +6,87 @@
|
|||||||
// Created: 04/01/98
|
// Created: 04/01/98
|
||||||
// RCS-ID: $$
|
// RCS-ID: $$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "msgdlg.h"
|
#pragma implementation "msgdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <X11/Xlib.h>
|
||||||
|
|
||||||
|
#include <Xm/Xm.h>
|
||||||
|
#include <Xm/MessageB.h>
|
||||||
|
|
||||||
|
#include "wx/app.h"
|
||||||
|
#include "wx/intl.h"
|
||||||
#include "wx/motif/msgdlg.h"
|
#include "wx/motif/msgdlg.h"
|
||||||
|
#include "wx/motif/private.h"
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
IMPLEMENT_CLASS(wxMessageDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, const wxString& caption,
|
// ============================================================================
|
||||||
long style, const wxPoint& pos)
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// the callbacks for message box buttons
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// the common part
|
||||||
|
static void msgboxCallBack(Widget w, int client_data, int id)
|
||||||
|
{
|
||||||
|
// close the dialog
|
||||||
|
XtUnmanageChild(w);
|
||||||
|
|
||||||
|
wxMessageDialog *dlg = (wxMessageDialog *)client_data;
|
||||||
|
dlg->SetResult(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msgboxCallBackOk(Widget w,
|
||||||
|
int client_data,
|
||||||
|
XmAnyCallbackStruct *call_data)
|
||||||
|
{
|
||||||
|
msgboxCallBack(w, client_data, wxID_OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msgboxCallBackCancel(Widget w,
|
||||||
|
int client_data,
|
||||||
|
XmAnyCallbackStruct *call_data)
|
||||||
|
{
|
||||||
|
msgboxCallBack(w, client_data, wxID_CANCEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void msgboxCallBackClose(Widget w,
|
||||||
|
int client_data,
|
||||||
|
XmAnyCallbackStruct *call_data)
|
||||||
|
{
|
||||||
|
msgboxCallBack(w, client_data, wxID_CANCEL);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxMessageDialog
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxMessageDialog::wxMessageDialog(wxWindow *parent,
|
||||||
|
const wxString& message,
|
||||||
|
const wxString& caption,
|
||||||
|
long style,
|
||||||
|
const wxPoint& pos)
|
||||||
{
|
{
|
||||||
m_caption = caption;
|
m_caption = caption;
|
||||||
m_message = message;
|
m_message = message;
|
||||||
@@ -30,7 +96,119 @@ wxMessageDialog::wxMessageDialog(wxWindow *parent, const wxString& message, cons
|
|||||||
|
|
||||||
int wxMessageDialog::ShowModal()
|
int wxMessageDialog::ShowModal()
|
||||||
{
|
{
|
||||||
// TODO
|
Widget (*dialogCreateFunction)(Widget, String, ArgList, Cardinal) = NULL;
|
||||||
return wxID_CANCEL;
|
if ( m_dialogStyle & wxYES_NO )
|
||||||
|
{
|
||||||
|
// if we have [Yes], it must be a question
|
||||||
|
dialogCreateFunction = XmCreateQuestionDialog;
|
||||||
|
|
||||||
|
// TODO we could support this by using the help button...
|
||||||
|
wxASSERT_MSG( !(m_dialogStyle & wxCANCEL), "not supported" );
|
||||||
|
}
|
||||||
|
else if ( m_dialogStyle & wxICON_STOP )
|
||||||
|
{
|
||||||
|
// error dialog is the one with error icon...
|
||||||
|
dialogCreateFunction = XmCreateErrorDialog;
|
||||||
|
}
|
||||||
|
else if ( m_dialogStyle & wxICON_EXCLAMATION )
|
||||||
|
{
|
||||||
|
// ...and the warning dialog too
|
||||||
|
dialogCreateFunction = XmCreateWarningDialog;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// finally, use the info dialog by default
|
||||||
|
dialogCreateFunction = XmCreateInformationDialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
// prepare the arg list
|
||||||
|
Arg args[2];
|
||||||
|
int ac = 0;
|
||||||
|
|
||||||
|
wxXmString text(m_message);
|
||||||
|
wxXmString title(m_caption);
|
||||||
|
XtSetArg(args[ac], XmNmessageString, text()); ac++;
|
||||||
|
XtSetArg(args[ac], XmNdialogTitle, title()); ac++;
|
||||||
|
|
||||||
|
// do create message box
|
||||||
|
Widget wParent = m_parent ? GetWidget(m_parent) : NULL;
|
||||||
|
if ( !wParent )
|
||||||
|
{
|
||||||
|
wxWindow *window = wxTheApp->GetTopWindow();
|
||||||
|
if ( !window )
|
||||||
|
{
|
||||||
|
wxFAIL_MSG("can't show message box without parent window");
|
||||||
|
|
||||||
|
return wxID_CANCEL;
|
||||||
|
}
|
||||||
|
|
||||||
|
wParent = GetWidget(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
Widget wMsgBox = (*dialogCreateFunction)(wParent, "", args, ac);
|
||||||
|
|
||||||
|
wxCHECK_MSG( wMsgBox, wxID_CANCEL, "msg box creation failed" );
|
||||||
|
|
||||||
|
// remove the [Help] button which wouldn't do anything anyhow
|
||||||
|
XtUnmanageChild(XmMessageBoxGetChild(wMsgBox, XmDIALOG_HELP_BUTTON));
|
||||||
|
|
||||||
|
// and the [Cancel] button too if we were not asked for it
|
||||||
|
if ( !(m_dialogStyle & wxCANCEL) )
|
||||||
|
{
|
||||||
|
Widget wBtnCancel = XmMessageBoxGetChild(wMsgBox,
|
||||||
|
XmDIALOG_CANCEL_BUTTON);
|
||||||
|
|
||||||
|
// ... unless it's a wxYES_NO dialog in which case we just rename
|
||||||
|
// [Cancel] to [No] instead
|
||||||
|
if ( m_dialogStyle & wxYES_NO )
|
||||||
|
{
|
||||||
|
Widget wBtnOk = XmMessageBoxGetChild(wMsgBox,
|
||||||
|
XmDIALOG_OK_BUTTON);
|
||||||
|
|
||||||
|
wxXmString yes(_("Yes")), no(_("No"));
|
||||||
|
XtVaSetValues(wBtnOk, XmNlabelString, yes(), NULL);
|
||||||
|
XtVaSetValues(wBtnCancel, XmNlabelString, no(), NULL);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
XtUnmanageChild(wBtnCancel);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// set the callbacks for the message box buttons
|
||||||
|
XtAddCallback(wMsgBox, XmNokCallback,
|
||||||
|
(XtCallbackProc)msgboxCallBackOk, (XtPointer)this);
|
||||||
|
XtAddCallback(wMsgBox, XmNcancelCallback,
|
||||||
|
(XtCallbackProc)msgboxCallBackCancel, (XtPointer)this);
|
||||||
|
|
||||||
|
XtAddCallback(wMsgBox, XmNunmapCallback,
|
||||||
|
(XtCallbackProc)msgboxCallBackClose, (XtPointer)this);
|
||||||
|
|
||||||
|
// show it as a modal dialog
|
||||||
|
XtManageChild(wMsgBox);
|
||||||
|
XtAddGrab(wMsgBox, True, False);
|
||||||
|
|
||||||
|
// the m_result will be changed when message box goes away
|
||||||
|
m_result = -1;
|
||||||
|
|
||||||
|
// local message loop
|
||||||
|
XtAppContext context = XtWidgetToApplicationContext(wParent);
|
||||||
|
XEvent event;
|
||||||
|
while ( m_result == -1 )
|
||||||
|
{
|
||||||
|
XtAppNextEvent(context, &event);
|
||||||
|
XtDispatchEvent(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
// translate the result if necessary
|
||||||
|
if ( m_dialogStyle & wxYES_NO )
|
||||||
|
{
|
||||||
|
if ( m_result == wxID_OK )
|
||||||
|
m_result = wxID_YES;
|
||||||
|
else if ( m_result == wxID_CANCEL )
|
||||||
|
m_result = wxID_NO;
|
||||||
|
}
|
||||||
|
|
||||||
|
return m_result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -53,6 +53,7 @@
|
|||||||
#include <Xm/ScrollBar.h>
|
#include <Xm/ScrollBar.h>
|
||||||
#include <Xm/Frame.h>
|
#include <Xm/Frame.h>
|
||||||
#include <Xm/Label.h>
|
#include <Xm/Label.h>
|
||||||
|
#include <Xm/RowColumn.h> // for XmMenuPosition
|
||||||
|
|
||||||
#include "wx/motif/private.h"
|
#include "wx/motif/private.h"
|
||||||
|
|
||||||
@@ -369,6 +370,9 @@ wxWindow::~wxWindow()
|
|||||||
|
|
||||||
ClearUpdateRects();
|
ClearUpdateRects();
|
||||||
|
|
||||||
|
if ( m_parent )
|
||||||
|
m_parent->RemoveChild( this );
|
||||||
|
|
||||||
// If m_drawingArea, we're a fully-fledged window with drawing area,
|
// If m_drawingArea, we're a fully-fledged window with drawing area,
|
||||||
// scrollbars etc. (what wxCanvas used to be)
|
// scrollbars etc. (what wxCanvas used to be)
|
||||||
if ( m_drawingArea )
|
if ( m_drawingArea )
|
||||||
@@ -1040,6 +1044,76 @@ void wxWindow::DoSetToolTip(wxToolTip * WXUNUSED(tooltip))
|
|||||||
|
|
||||||
#endif // wxUSE_TOOLTIPS
|
#endif // wxUSE_TOOLTIPS
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// popup menus
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y)
|
||||||
|
{
|
||||||
|
Widget widget = (Widget) GetMainWidget();
|
||||||
|
|
||||||
|
/* The menuId field seems to be usused, so we'll use it to
|
||||||
|
indicate whether a menu is popped up or not:
|
||||||
|
0: Not currently created as a popup
|
||||||
|
-1: Created as a popup, but not active
|
||||||
|
1: Active popup.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (menu->GetParent() && (menu->GetId() != -1))
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
if (menu->GetMainWidget()) {
|
||||||
|
menu->DestroyMenu(TRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
menu->SetId(1); /* Mark as popped-up */
|
||||||
|
menu->CreateMenu(NULL, widget, menu);
|
||||||
|
menu->SetInvokingWindow(this);
|
||||||
|
|
||||||
|
menu->UpdateUI();
|
||||||
|
|
||||||
|
// menu->SetParent(parent);
|
||||||
|
// parent->children->Append(menu); // Store menu for later deletion
|
||||||
|
|
||||||
|
Widget menuWidget = (Widget) menu->GetMainWidget();
|
||||||
|
|
||||||
|
int rootX = 0;
|
||||||
|
int rootY = 0;
|
||||||
|
|
||||||
|
int deviceX = x;
|
||||||
|
int deviceY = y;
|
||||||
|
/*
|
||||||
|
if (this->IsKindOf(CLASSINFO(wxCanvas)))
|
||||||
|
{
|
||||||
|
wxCanvas *canvas = (wxCanvas *) this;
|
||||||
|
deviceX = canvas->GetDC ()->LogicalToDeviceX (x);
|
||||||
|
deviceY = canvas->GetDC ()->LogicalToDeviceY (y);
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
Display *display = XtDisplay (widget);
|
||||||
|
Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget));
|
||||||
|
Window thisWindow = XtWindow (widget);
|
||||||
|
Window childWindow;
|
||||||
|
XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY,
|
||||||
|
&rootX, &rootY, &childWindow);
|
||||||
|
|
||||||
|
XButtonPressedEvent event;
|
||||||
|
event.type = ButtonPress;
|
||||||
|
event.button = 1;
|
||||||
|
|
||||||
|
event.x = deviceX;
|
||||||
|
event.y = deviceY;
|
||||||
|
|
||||||
|
event.x_root = rootX;
|
||||||
|
event.y_root = rootY;
|
||||||
|
|
||||||
|
XmMenuPosition (menuWidget, &event);
|
||||||
|
XtManageChild (menuWidget);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// moving and resizing
|
// moving and resizing
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user