- Get wxGLCanvas from 1.68 working.
-- wxClipboard
-
-- EVT_KEY_DOWN, EVT_KEY_UP events.
-
Low Priority
------------
- Documentation: mention include files with each class.
+- Document wxTime.
+
- Get Karsten to remove trashed CVS files:
include/wx/msw/magnif1.cur
#if defined(__WXMSW__)
#include "wx/msw/ole/dataobj.h"
#elif defined(__WXMOTIF__)
-#include "wx/motif/dnd.h"
+#include "wx/motif/dataobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataobj.h"
#elif defined(__WXQT__)
#include "wx/setup.h"
#include "wx/list.h"
+#include "wx/module.h"
bool WXDLLEXPORT wxOpenClipboard();
bool WXDLLEXPORT wxClipboardOpen();
bool WXDLLEXPORT wxCloseClipboard();
bool WXDLLEXPORT wxEmptyClipboard();
-bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat);
-bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0);
-wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL);
-int WXDLLEXPORT wxEnumClipboardFormats(int dataFormat);
-int WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
-bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount);
+bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
+bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
+wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
+wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat);
+wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
+bool WXDLLEXPORT wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount);
+
+//-----------------------------------------------------------------------------
+// wxClipboard
+//-----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxDataObject;
+class WXDLLEXPORT wxClipboard: public wxObject
+{
+ DECLARE_DYNAMIC_CLASS(wxClipboard)
+
+public:
+
+ wxClipboard();
+ ~wxClipboard();
+
+ // open the clipboard before SetData() and GetData()
+ virtual bool Open();
+
+ // close the clipboard after SetData() and GetData()
+ virtual void Close();
+
+ // can be called several times
+ virtual bool SetData( wxDataObject *data );
+
+ // format available on the clipboard ?
+ // supply ID if private format, the same as wxPrivateDataObject::SetId()
+ virtual bool IsSupportedFormat( wxDataFormat format, const wxString &id = wxEmptyString );
+
+ // fill data with data on the clipboard (if available)
+ virtual bool GetData( wxDataObject *data );
+
+ // clears wxTheClipboard and the system's clipboard if possible
+ virtual void Clear();
+
+ // implementation
+
+ bool m_open;
+ wxList m_data;
+};
+
+/* The clipboard */
+WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
+
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
+
+class wxClipboardModule: public wxModule
+{
+ DECLARE_DYNAMIC_CLASS(wxClipboardModule)
+
+public:
+ wxClipboardModule() {}
+ bool OnInit();
+ void OnExit();
+};
+
+// This is the old, 1.68 implementation
+#if 0
/* A clipboard client holds data belonging to the clipboard.
For plain text, a client is not necessary. */
/* The clipboard */
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
+#endif
+ // Old clipboard class
+
#endif
// _WX_CLIPBRD_H_
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.h
-// Purpose: Declaration of the wxDropTarget, wxDropSource class etc.
+// Purpose: declaration of wxDropTarget, wxDropSource classes
// Author: Julian Smart
// RCS-ID: $Id$
-// Copyright: (c) 1998 Julian Smart
+// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
+
#ifndef _WX_DND_H_
#define _WX_DND_H_
#ifdef __GNUG__
-#pragma interface "dnd.h"
+#pragma interface
#endif
#include "wx/defs.h"
+
+#if wxUSE_DRAG_AND_DROP
+
#include "wx/object.h"
#include "wx/string.h"
+#include "wx/dataobj.h"
#include "wx/cursor.h"
//-------------------------------------------------------------------------
class WXDLLEXPORT wxWindow;
-class WXDLLEXPORT wxDataObject;
-class WXDLLEXPORT wxTextDataObject;
-class WXDLLEXPORT wxFileDataObject;
-
class WXDLLEXPORT wxDropTarget;
class WXDLLEXPORT wxTextDropTarget;
class WXDLLEXPORT wxFileDropTarget;
+class WXDLLEXPORT wxPrivateDropTarget;
class WXDLLEXPORT wxDropSource;
-//-------------------------------------------------------------------------
-// wxDataObject
-//-------------------------------------------------------------------------
-
-class WXDLLEXPORT wxDataObject: public wxObject
-{
-public:
- // all data formats (values are the same as in windows.h, do not change!)
- enum StdFormat
- {
- Invalid,
- Text,
- Bitmap,
- MetafilePict,
- Sylk,
- Dif,
- Tiff,
- OemText,
- Dib,
- Palette,
- Pendata,
- Riff,
- Wave,
- UnicodeText,
- EnhMetafile,
- Hdrop,
- Locale,
- Max
- };
-
- // function to return symbolic name of clipboard format (debug messages)
- static const char *GetFormatName(wxDataFormat format);
-
- // ctor & dtor
- wxDataObject() {};
- ~wxDataObject() {};
-
- // pure virtuals to override
- // get the best suited format for our data
- virtual wxDataFormat GetPreferredFormat() const = 0;
- // decide if we support this format (should be one of values of
- // StdFormat enumerations or a user-defined format)
- virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
- // get the (total) size of data
- virtual size_t GetDataSize() const = 0;
- // copy raw data to provided pointer
- virtual void GetDataHere(void *pBuf) const = 0;
-
-};
-
-// ----------------------------------------------------------------------------
-// wxTextDataObject is a specialization of wxDataObject for text data
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxTextDataObject : public wxDataObject
-{
-public:
- // ctors
- wxTextDataObject() { }
- wxTextDataObject(const wxString& strText) : m_strText(strText) { }
- void Init(const wxString& strText) { m_strText = strText; }
-
- // implement base class pure virtuals
- virtual wxDataFormat GetPreferredFormat() const
- { return wxDF_TEXT; }
- virtual bool IsSupportedFormat(wxDataFormat format) const
- { return format == wxDF_TEXT; }
- virtual size_t GetDataSize() const
- { return m_strText.Len() + 1; } // +1 for trailing '\0'of course
- virtual void GetDataHere(void *pBuf) const
- { memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
-
-private:
- wxString m_strText;
-
-};
-
-// ----------------------------------------------------------------------------
-// wxFileDataObject is a specialization of wxDataObject for file names
-// ----------------------------------------------------------------------------
-
-class WXDLLEXPORT wxFileDataObject : public wxDataObject
-{
-public:
-
- wxFileDataObject(void) { }
- void AddFile( const wxString &file )
- { m_files += file; m_files += ";"; }
-
- // implement base class pure virtuals
- virtual wxDataFormat GetPreferredFormat() const
- { return wxDF_FILENAME; }
- virtual bool IsSupportedFormat(wxDataFormat format) const
- { return format == wxDF_FILENAME; }
- virtual size_t GetDataSize() const
- { return m_files.Len() + 1; } // +1 for trailing '\0'of course
- virtual void GetDataHere(void *pBuf) const
- { memcpy(pBuf, m_files.c_str(), GetDataSize()); }
-
-private:
- wxString m_files;
-
-};
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
virtual void OnEnter() { }
virtual void OnLeave() { }
- virtual bool OnDrop( long x, long y, const void *pData ) = 0;
+ virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
-// protected:
-
- friend wxWindow;
-
// Override these to indicate what kind of data you support:
virtual size_t GetFormatCount() const = 0;
virtual wxDataFormat GetFormat(size_t n) const = 0;
+
+ // implementation
};
//-------------------------------------------------------------------------
public:
wxTextDropTarget() {};
- virtual bool OnDrop( long x, long y, const void *pData );
+ virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropText( long x, long y, const char *psz );
protected:
virtual wxDataFormat GetFormat(size_t n) const;
};
+//-------------------------------------------------------------------------
+// wxPrivateDropTarget
+//-------------------------------------------------------------------------
+
+class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget
+{
+public:
+
+ wxPrivateDropTarget();
+
+ // you have to override OnDrop to get at the data
+
+ // the string ID identifies the format of clipboard or DnD data. a word
+ // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
+ // to the clipboard - the latter with the Id "WXWORD_FORMAT".
+
+ void SetId( const wxString& id )
+ { m_id = id; }
+
+ wxString GetId()
+ { return m_id; }
+
+private:
+
+ virtual size_t GetFormatCount() const;
+ virtual wxDataFormat GetFormat(size_t n) const;
+
+ wxString m_id;
+};
+
// ----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
// ----------------------------------------------------------------------------
wxFileDropTarget() {};
- virtual bool OnDrop(long x, long y, const void *pData);
+ virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropFiles( long x, long y,
- size_t nFiles, const char * const aszFiles[]);
+ size_t nFiles, const char * const aszFiles[] );
protected:
// wxDropSource
//-------------------------------------------------------------------------
- enum wxDragResult
- {
- wxDragError, // error prevented the d&d operation from completing
- wxDragNone, // drag target didn't accept the data
- wxDragCopy, // the data was successfully copied
- wxDragMove, // the data was successfully moved
- wxDragCancel // the operation was cancelled by user (not an error)
- };
+enum wxDragResult
+{
+ wxDragError, // error prevented the d&d operation from completing
+ wxDragNone, // drag target didn't accept the data
+ wxDragCopy, // the data was successfully copied
+ wxDragMove, // the data was successfully moved
+ wxDragCancel // the operation was cancelled by user (not an error)
+};
class WXDLLEXPORT wxDropSource: public wxObject
{
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
-
- protected:
+ // implementation
+#if 0
+ void RegisterWindow(void);
+ void UnregisterWindow(void);
+
+ wxWindow *m_window;
+ wxDragResult m_retValue;
wxDataObject *m_data;
+
+ wxCursor m_defaultCursor;
+ wxCursor m_goaheadCursor;
+#endif
};
+#endif
+
+ // wxUSE_DRAG_AND_DROP
+
#endif
//_WX_DND_H_
void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event);
- void OnChar(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event);
public:
wxAcceleratorRefData();
~wxAcceleratorRefData();
-
+
public:
int m_count;
wxAcceleratorEntry* m_entries;
{
wxAcceleratorRefData* data = new wxAcceleratorRefData;
m_refData = data;
-
+
data->m_count = n;
data->m_entries = new wxAcceleratorEntry[n];
int i;
for (i = 0; i < n; i++)
data->m_entries[i] = entries[i];
-
+
}
bool wxAcceleratorTable::Ok() const
bool eventCtrlDown = event.ControlDown();
bool eventShiftDown = event.ShiftDown();
int eventKeyCode = event.KeyCode();
-
+
bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT);
bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL);
bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
int accKeyCode = GetKeyCode();
int accKeyCode2 = GetKeyCode();
if (isascii(accKeyCode2))
- accKeyCode2 = wxToLower(accKeyCode2);
-
+ accKeyCode2 = wxToLower(accKeyCode2);
+
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
- (eventShiftDown == accShiftDown) &&
- ((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
+ (eventShiftDown == accShiftDown) &&
+ ((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
}
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
- EVT_IDLE(wxApp::OnIdle)
+EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
#endif
#else
wxBuffer = new char[BUFSIZ + 512];
#endif
-
+
wxClassInfo::InitializeClasses();
-
+
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize();
-
+
wxInitializeStockLists();
wxInitializeStockObjects();
-
+
#if wxUSE_WX_RESOURCES
wxInitializeResourceSystem();
#endif
-
- // For PostScript printing
+
+ // For PostScript printing
#if wxUSE_POSTSCRIPT
-/* Done using wxModule now
+ /* Done using wxModule now
wxInitializePrintSetupData();
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase();
-*/
+ */
#endif
-
+
wxBitmap::InitStandardHandlers();
-
+
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
-
+
wxModule::RegisterModules();
if (!wxModule::InitializeModules()) return FALSE;
-
+
return TRUE;
}
{
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
-
+
wxModule::CleanUpModules();
-
+
#if wxUSE_WX_RESOURCES
wxCleanUpResourceSystem();
#endif
-
+
wxDeleteStockObjects() ;
-
+
// Destroy all GDI lists, etc.
-
+
delete wxTheBrushList;
wxTheBrushList = NULL;
-
+
delete wxThePenList;
wxThePenList = NULL;
-
+
delete wxTheFontList;
wxTheFontList = NULL;
-
+
delete wxTheBitmapList;
wxTheBitmapList = NULL;
-
+
delete wxTheColourDatabase;
wxTheColourDatabase = NULL;
-
+
#if wxUSE_POSTSCRIPT
-/* Done using wxModule now
+ /* Done using wxModule now
wxInitializePrintSetupData(FALSE);
delete wxThePrintPaperDatabase;
wxThePrintPaperDatabase = NULL;
-*/
+ */
#endif
-
+
wxBitmap::CleanUpHandlers();
-
+
delete[] wxBuffer;
wxBuffer = NULL;
-
+
wxClassInfo::CleanUpClasses();
-
+
delete wxTheApp;
wxTheApp = NULL;
-
+
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself,
// wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{
- wxLogDebug("There were memory leaks.\n");
- wxDebugContext::Dump();
- wxDebugContext::PrintStatistics();
+ wxLogDebug("There were memory leaks.\n");
+ wxDebugContext::Dump();
+ wxDebugContext::PrintStatistics();
}
#endif
-
+
// do it as the very last thing because everything else can log messages
wxLog::DontCreateOnDemand();
// do it as the very last thing because everything else can log messages
// checked, but this is a reasonable compromise.
wxDebugContext::SetCheckpoint();
#endif
-
+
if (!wxApp::Initialize())
- return FALSE;
-
+ return FALSE;
+
if (!wxTheApp)
{
- if (!wxApp::GetInitializerFunction())
- {
- printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
- return 0;
- };
-
- wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
+ if (!wxApp::GetInitializerFunction())
+ {
+ printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
+ return 0;
+ };
+
+ wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
};
-
+
if (!wxTheApp)
{
- printf( "wxWindows error: wxTheApp == NULL\n" );
- return 0;
+ printf( "wxWindows error: wxTheApp == NULL\n" );
+ return 0;
};
-
+
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
-
+
wxTheApp->argc = argc;
wxTheApp->argv = argv;
-
+
// GUI-specific initialization, such as creating an app context.
wxTheApp->OnInitGui();
-
+
// Here frames insert themselves automatically
// into wxTopLevelWindows by getting created
// in OnInit().
-
+
int retValue = 0;
if (wxTheApp->OnInit())
{
- if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
+ if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
}
-
+
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
- pLog->Flush();
-
+ pLog->Flush();
+
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
- // for further messages
-
+ // for further messages
+
if (wxTheApp->GetTopWindow())
{
- delete wxTheApp->GetTopWindow();
- wxTheApp->SetTopWindow(NULL);
+ delete wxTheApp->GetTopWindow();
+ wxTheApp->SetTopWindow(NULL);
}
-
+
wxTheApp->DeletePendingObjects();
-
+
wxTheApp->OnExit();
-
+
wxApp::CleanUp();
-
+
return retValue;
};
m_printMode = wxPRINT_POSTSCRIPT;
m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE;
-
+
m_mainColormap = (WXColormap) NULL;
m_appContext = (WXAppContext) NULL;
m_topLevelWidget = (WXWidget) NULL;
bool wxApp::Initialized()
{
if (GetTopWindow())
- return TRUE;
+ return TRUE;
else
- return FALSE;
+ return FALSE;
}
int wxApp::MainLoop()
{
m_keepGoing = TRUE;
-
- /*
+
+ /*
* Sit around forever waiting to process X-events. Property Change
* event are handled special, because they have to refer to
* the root window rather than to a widget. therefore we can't
* use an Xt-eventhandler.
*/
-
+
XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()),
- XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
- PropertyChangeMask);
-
+ XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
+ PropertyChangeMask);
+
XEvent event;
-
+
// Use this flag to allow breaking the loop via wxApp::ExitMainLoop()
while (m_keepGoing)
{
- XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
-
- ProcessXEvent((WXEvent*) & event);
-
- if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
- {
- if (!ProcessIdle())
- {
- // TODO: Robert, what's this for?
+ XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
+
+ ProcessXEvent((WXEvent*) & event);
+
+ if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
+ {
+ if (!ProcessIdle())
+ {
+ // TODO: Robert, what's this for?
#if wxUSE_THREADS
- wxMutexGuiLeave();
- usleep(20);
- wxMutexGuiEnter();
+ wxMutexGuiLeave();
+ usleep(20);
+ wxMutexGuiEnter();
#endif
- }
- }
-
+ }
+ }
+
}
-
+
return 0;
}
void wxApp::ProcessXEvent(WXEvent* _event)
{
XEvent* event = (XEvent*) _event;
-
+
if ((event->type == KeyPress) && CheckForAccelerator(_event))
{
// Do nothing! We intercepted and processed the event as an accelerator.
}
else if (event->type == ResizeRequest)
{
- /* Terry Gitnick <terryg@scientech.com> - 1/21/98
- * If resize event, don't resize until the last resize event for this
- * window is recieved. Prevents flicker as windows are resized.
- */
-
+ /* Terry Gitnick <terryg@scientech.com> - 1/21/98
+ * If resize event, don't resize until the last resize event for this
+ * window is recieved. Prevents flicker as windows are resized.
+ */
+
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
Window win = event->xany.window;
XEvent report;
-
+
// to avoid flicker
report = * event;
while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report));
-
+
// TODO: when implementing refresh optimization, we can use
// XtAddExposureToRegion to expand the window's paint region.
-
+
XtDispatchEvent(event);
}
else
wxIdleEvent event;
event.SetEventObject(this);
ProcessEvent(event);
-
+
return event.MoreRequested();
}
bool wxApp::Pending()
{
XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
-
+
// Fix by Doug from STI, to prevent a stall if non-X event
// is found.
return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
// Dispatch a message.
void wxApp::Dispatch()
{
-// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
-
+ // XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+
XEvent event;
XtAppNextEvent((XtAppContext) GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event);
void wxApp::OnIdle(wxIdleEvent& event)
{
static bool inOnIdle = FALSE;
-
+
// Avoid recursion (via ProcessEvent default case)
if (inOnIdle)
- return;
-
+ return;
+
inOnIdle = TRUE;
-
+
// 'Garbage' collection of windows deleted with Close().
DeletePendingObjects();
-
+
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
- pLog->Flush();
-
+ pLog->Flush();
+
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
-
+
if (needMore)
- event.RequestMore(TRUE);
-
+ event.RequestMore(TRUE);
+
inOnIdle = FALSE;
}
bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
- wxNode* node = wxTopLevelWindows.First();
- while (node)
- {
- wxWindow* win = (wxWindow*) node->Data();
- if (SendIdleEvents(win))
+ wxNode* node = wxTopLevelWindows.First();
+ while (node)
+ {
+ wxWindow* win = (wxWindow*) node->Data();
+ if (SendIdleEvents(win))
needMore = TRUE;
-
- node = node->Next();
- }
+
+ node = node->Next();
+ }
return needMore;
}
bool wxApp::SendIdleEvents(wxWindow* win)
{
bool needMore = FALSE;
-
- wxIdleEvent event;
- event.SetEventObject(win);
- win->ProcessEvent(event);
-
+
+ wxIdleEvent event;
+ event.SetEventObject(win);
+ win->ProcessEvent(event);
+
if (event.MoreRequested())
needMore = TRUE;
-
- wxNode* node = win->GetChildren().First();
- while (node)
- {
- wxWindow* win = (wxWindow*) node->Data();
- if (SendIdleEvents(win))
+
+ wxNode* node = win->GetChildren().First();
+ while (node)
+ {
+ wxWindow* win = (wxWindow*) node->Data();
+ if (SendIdleEvents(win))
needMore = TRUE;
-
- node = node->Next();
- }
+
+ node = node->Next();
+ }
return needMore ;
}
wxNode *node = wxPendingDelete.First();
while (node)
{
- wxObject *obj = (wxObject *)node->Data();
-
- delete obj;
-
- if (wxPendingDelete.Member(obj))
- delete node;
-
- // Deleting one object may have deleted other pending
- // objects, so start from beginning of list again.
- node = wxPendingDelete.First();
+ wxObject *obj = (wxObject *)node->Data();
+
+ delete obj;
+
+ if (wxPendingDelete.Member(obj))
+ delete node;
+
+ // Deleting one object may have deleted other pending
+ // objects, so start from beginning of list again.
+ node = wxPendingDelete.First();
}
}
XtToolkitInitialize() ;
wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ;
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
- (const char*) wxTheApp->GetClassName(), NULL,
+ (const char*) wxTheApp->GetClassName(), NULL,
# if XtSpecificationRelease < 5
- 0,(Cardinal*) &argc,argv) ;
+ 0,(Cardinal*) &argc,argv) ;
# else
- 0,&argc,argv) ;
+ 0,&argc,argv) ;
# endif
if (!dpy) {
- cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
- exit(-1);
+ cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
+ exit(-1);
}
m_initialDisplay = (WXDisplay*) dpy;
-
+
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
- applicationShellWidgetClass,dpy,
- NULL,0) ;
-
+ applicationShellWidgetClass,dpy,
+ NULL,0) ;
+
// Add general resize proc
XtActionsRec rec;
rec.string = "resize";
rec.proc = (XtActionProc)wxWidgetResizeProc;
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
-
+
GetMainColormap(dpy);
m_maxRequestSize = XMaxRequestSize((Display*) dpy);
-
+
return TRUE;
}
WXColormap wxApp::GetMainColormap(WXDisplay* display)
{
if (!display) /* Must be called first with non-NULL display */
- return m_mainColormap;
-
+ return m_mainColormap;
+
Colormap c =
- DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
- DefaultScreen((Display*) display)));
-
+ DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
+ DefaultScreen((Display*) display)));
+
if (!m_mainColormap)
- m_mainColormap = (WXColormap) c;
-
+ m_mainColormap = (WXColormap) c;
+
return (WXColormap) c;
}
// TODO: should get display for the window, not the current display
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_CHAR);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
-
+
// Now we have a wxKeyEvent and we have a wxWindow.
// Go up the hierarchy until we find a matching accelerator,
// or we get to the top.
{
int retValue = 0;
if (wxTheApp)
- retValue = wxTheApp->OnExit();
-
+ retValue = wxTheApp->OnExit();
+
wxApp::CleanUp();
/*
- * Exit in some platform-specific way. Not recommended that the app calls this:
- * only for emergencies.
- */
+ * Exit in some platform-specific way. Not recommended that the app calls this:
+ * only for emergencies.
+ */
exit(retValue);
}
bool wxYield()
{
while (wxTheApp && wxTheApp->Pending())
- wxTheApp->Dispatch();
+ wxTheApp->Dispatch();
return TRUE;
}
#include "wx/motif/private.h"
-// TODO: correct symbol, path?
#if wxUSE_XPM
#include <X11/xpm.h>
#endif
m_quality = 0;
m_numColors = 0;
m_bitmapMask = NULL;
-
+
m_pixmap = (WXPixmap) 0;
m_display = (WXDisplay*) 0;
-
+
m_freePixmap = TRUE; //TODO: necessary?
m_freeColors = (unsigned long*) 0;
m_freeColorsCount = 0;
-
+
// These 5 variables are for wxControl
m_insensPixmap = (WXPixmap) 0;
m_labelPixmap = (WXPixmap) 0;
{
if (m_labelPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap);
-
+
if (m_armPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_armPixmap);
-
+
if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap);
-
+
if (m_image)
{
XmUninstallImage ((XImage*) m_image);
XtFree ((char *) (XImage*) m_image);
}
-
+
if (m_insensImage)
{
XmUninstallImage ((XImage*) m_insensImage);
}
if (m_pixmap && m_freePixmap)
XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap);
-
+
if (m_freeColors)
{
- int screen = DefaultScreen((Display*) m_display);
- Colormap cmp = DefaultColormap((Display*) m_display,screen);
- long llp;
- for(llp = 0;llp < m_freeColorsCount;llp++)
- XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
- delete m_freeColors;
+ int screen = DefaultScreen((Display*) m_display);
+ Colormap cmp = DefaultColormap((Display*) m_display,screen);
+ long llp;
+ for(llp = 0;llp < m_freeColorsCount;llp++)
+ XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
+ delete m_freeColors;
};
-
+
if (m_bitmapMask)
delete m_bitmapMask;
m_bitmapMask = NULL;
wxBitmap::wxBitmap()
{
m_refData = NULL;
-
+
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
{
m_refData = new wxBitmapRefData;
-
+
(void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, depth);
-
+
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(int w, int h, int d)
{
(void)Create(w, h, d);
-
+
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
{
(void) Create(data, type, width, height, depth);
-
+
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
wxBitmap::wxBitmap(const wxString& filename, long type)
{
LoadFile(filename, (int)type);
-
+
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
{
// Pass the control to the Create function using a global
sg_Control = control;
-
+
(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
-
+
sg_Control = (wxControl*) NULL;
}
bool wxBitmap::Create(int w, int h, int d)
{
UnRef();
-
+
m_refData = new wxBitmapRefData;
-
+
if (d < 1)
- d = wxDisplayDepth();
-
+ d = wxDisplayDepth();
+
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;
M_BITMAPDATA->m_depth = d;
M_BITMAPDATA->m_freePixmap = TRUE;
-
+
Display *dpy = (Display*) wxGetDisplay();
-
+
M_BITMAPDATA->m_display = dpy; /* MATTHEW: [4] Remember the display */
-
+
M_BITMAPDATA->m_pixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
- w, h, d);
-
+ w, h, d);
+
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_pixmap != (WXPixmap) 0) ;
return M_BITMAPDATA->m_ok;
}
bool wxBitmap::LoadFile(const wxString& filename, long type)
{
UnRef();
-
+
m_refData = new wxBitmapRefData;
-
+
wxBitmapHandler *handler = FindHandler(type);
-
+
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
-
+
return FALSE;
}
-
+
return handler->LoadFile(this, filename, type, -1, -1);
}
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
{
UnRef();
-
+
m_refData = new wxBitmapRefData;
-
+
wxBitmapHandler *handler = FindHandler(type);
-
+
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
-
+
return FALSE;
}
-
+
return handler->Create(this, data, type, width, height, depth);
}
bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *palette)
{
wxBitmapHandler *handler = FindHandler(type);
-
+
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
-
+
return FALSE;
- }
-
- return handler->SaveFile(this, filename, type, palette);
+ }
+
+ return handler->SaveFile(this, filename, type, palette);
}
void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_width = w;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_height = h;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_depth = d;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_quality = q;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_ok = isOk;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_bitmapPalette = palette ;
}
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
-
+
M_BITMAPDATA->m_bitmapMask = mask ;
}
{
wxBitmapHandler *handler = (wxBitmapHandler *)node->Data();
if ( handler->GetExtension() == extension &&
- (bitmapType == -1 || handler->GetType() == bitmapType) )
+ (bitmapType == -1 || handler->GetType() == bitmapType) )
return handler;
node = node->Next();
}
}
/*
- * wxMask
- */
+* wxMask
+*/
wxMask::wxMask()
{
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
{
m_pixmap = (WXPixmap) 0;
-
+
Create(bitmap, colour);
}
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
{
m_pixmap = (WXPixmap) 0;
-
+
Create(bitmap, paletteIndex);
}
wxMask::wxMask(const wxBitmap& bitmap)
{
m_pixmap = (WXPixmap) 0;
-
+
Create(bitmap);
}
// Create a mask from a mono bitmap (copies the bitmap).
bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap))
{
-// TODO
+ // TODO
return FALSE;
}
// the transparent area
bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), int WXUNUSED(paletteIndex))
{
-// TODO
+ // TODO
return FALSE;
}
// the transparent area
bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(colour))
{
-// TODO
+ // TODO
return FALSE;
}
/*
- * wxBitmapHandler
- */
+* wxBitmapHandler
+*/
IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type),
- int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth))
+ int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth))
{
return FALSE;
}
bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), long WXUNUSED(type),
- int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
+ int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
{
return FALSE;
}
bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type),
- const wxPalette *WXUNUSED(palette))
+ const wxPalette *WXUNUSED(palette))
{
return FALSE;
}
/*
- * Standard handlers
- */
+* Standard handlers
+*/
class WXDLLEXPORT wxXBMFileHandler: public wxBitmapHandler
{
m_extension = "xbm";
m_type = wxBITMAP_TYPE_XBM;
};
-
+
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
+ int desiredWidth, int desiredHeight);
};
IMPLEMENT_DYNAMIC_CLASS(wxXBMFileHandler, wxBitmapHandler)
bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags),
- int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
+ int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
{
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
-
+
int hotX, hotY;
unsigned int w, h;
Pixmap pixmap;
-
+
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPDATA->m_display = (WXDisplay*) dpy;
-
+
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
- (char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
+ (char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
M_BITMAPHANDLERDATA->m_width = w;
M_BITMAPHANDLERDATA->m_height = h;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
-
+
if ((value == BitmapFileInvalid) ||
(value == BitmapOpenFailed) ||
(value == BitmapNoMemory))
}
else
M_BITMAPHANDLERDATA->m_ok = TRUE;
-
+
return M_BITMAPHANDLERDATA->m_ok ;
}
m_extension = "xbm";
m_type = wxBITMAP_TYPE_XBM_DATA;
};
-
+
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
};
IMPLEMENT_DYNAMIC_CLASS(wxXBMDataHandler, wxBitmapHandler)
bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
- int width, int height, int WXUNUSED(depth))
+ int width, int height, int WXUNUSED(depth))
{
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
-
+
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
-
+
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height);
M_BITMAPHANDLERDATA->m_ok = (M_BITMAPHANDLERDATA->m_pixmap != (WXPixmap) 0) ;
-
+
// code for wxControl. TODO: can we avoid doing this until we need it?
// E.g. have CreateButtonPixmaps which is called on demand.
XImage* image = (XImage *) XtMalloc (sizeof (XImage));
image->bitmap_bit_order = LSBFirst;
image->bitmap_pad = 8;
image->bytes_per_line = (width + 7) >> 3;
-
+
char tmp[128];
sprintf (tmp, "Im%x", (unsigned int) image);
XmInstallImage (image, tmp);
-
+
// Build our manually stipped pixmap.
-
+
int bpl = (width + 7) / 8;
char *data1 = new char[height * bpl];
char* bits = (char*) data;
insensImage->bitmap_bit_order = LSBFirst;
insensImage->bitmap_pad = 8;
insensImage->bytes_per_line = bpl;
-
+
sprintf (tmp, "Not%x", (unsigned int)insensImage);
XmInstallImage (insensImage, tmp);
-
+
M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;
-
+
return TRUE;
}
m_extension = "xpm";
m_type = wxBITMAP_TYPE_XPM;
};
-
+
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
- int desiredWidth, int desiredHeight);
+ int desiredWidth, int desiredHeight);
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
};
IMPLEMENT_DYNAMIC_CLASS(wxXPMFileHandler, wxBitmapHandler)
bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WXUNUSED(flags),
- int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight) )
+ int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight) )
{
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
-
+
XpmAttributes xpmAttr;
Pixmap pixmap;
Pixmap mask = 0;
-
+
M_BITMAPHANDLERDATA->m_ok = FALSE;
xpmAttr.valuemask = XpmReturnInfos | XpmCloseness;
xpmAttr.closeness = 40000;
int errorStatus = XpmReadFileToPixmap(dpy,
RootWindow(dpy, DefaultScreen(dpy)), (char*) (const char*) name,
&pixmap, &mask, &xpmAttr);
-
+
if (errorStatus == XpmSuccess)
{
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
M_BITMAPHANDLERDATA->m_bitmapMask = new wxMask;
M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask);
}
-
+
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
-
+
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
-
- /*
+
+ /*
if ( xpmAttr.npixels > 2 )
{
- M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ...
+ M_BITMAPHANDLERDATA->m_depth = 8; // TODO: next time not just a guess :-) ...
} else
{
- M_BITMAPHANDLERDATA->m_depth = 1; // mono
+ M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
- */
-
+ */
+
M_BITMAPHANDLERDATA->m_depth = depthRet;
-
- M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
-
- XpmFreeAttributes(&xpmAttr);
-
+
+ M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
+
+ XpmFreeAttributes(&xpmAttr);
+
M_BITMAPHANDLERDATA->m_ok = TRUE;
return TRUE;
} else
{
-// XpmDebugError(errorStatus, name);
+ // XpmDebugError(errorStatus, name);
M_BITMAPHANDLERDATA->m_ok = FALSE;
return FALSE;
}
}
bool wxXPMFileHandler::SaveFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(type),
- const wxPalette *WXUNUSED(palette))
+ const wxPalette *WXUNUSED(palette))
{
if (M_BITMAPHANDLERDATA->m_ok && M_BITMAPHANDLERDATA->m_pixmap)
{
Display *dpy = (Display*) M_BITMAPHANDLERDATA->m_display;
int errorStatus = XpmWriteFileFromPixmap(dpy, (char*) (const char*) name,
- (Pixmap) M_BITMAPHANDLERDATA->m_pixmap,
- (M_BITMAPHANDLERDATA->m_bitmapMask ? (Pixmap) M_BITMAPHANDLERDATA->m_bitmapMask->GetPixmap() : (Pixmap) 0),
- (XpmAttributes *) NULL);
+ (Pixmap) M_BITMAPHANDLERDATA->m_pixmap,
+ (M_BITMAPHANDLERDATA->m_bitmapMask ? (Pixmap) M_BITMAPHANDLERDATA->m_bitmapMask->GetPixmap() : (Pixmap) 0),
+ (XpmAttributes *) NULL);
if (errorStatus == XpmSuccess)
- return TRUE;
+ return TRUE;
else
- return FALSE;
+ return FALSE;
}
else
return FALSE;
m_extension = "xpm";
m_type = wxBITMAP_TYPE_XPM_DATA;
};
-
+
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
};
IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
- int width, int height, int WXUNUSED(depth))
+ int width, int height, int WXUNUSED(depth))
{
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
-
+
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
-
+
XpmAttributes xpmAttr;
-
+
xpmAttr.valuemask = XpmReturnInfos; /* nothing yet, but get infos back */
-
+
XpmColorSymbol symbolicColors[4];
if (sg_Control && sg_Control->GetMainWidget())
{
xpmAttr.colorsymbols = symbolicColors;
xpmAttr.valuemask |= XpmColorSymbols; // add flag
}
-
+
Pixmap pixmap;
Pixmap mask = 0;
int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)),
- (char**) data, &pixmap, &mask, &xpmAttr);
+ (char**) data, &pixmap, &mask, &xpmAttr);
if (ErrorStatus == XpmSuccess)
{
// Set attributes
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
-
+
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
-
- /*
- if ( xpmAttr.npixels > 2 )
- {
+
+ /*
+ if ( xpmAttr.npixels > 2 )
+ {
M_BITMAPHANDLERDATA->m_depth = 8; // next time not just a guess :-) ...
- } else
- {
+ } else
+ {
M_BITMAPHANDLERDATA->m_depth = 1; // mono
- }
- */
-
+ }
+ */
+
M_BITMAPHANDLERDATA->m_depth = depthRet;
-
+
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
}
else
{
-// XpmDebugError(ErrorStatus, NULL);
+ // XpmDebugError(ErrorStatus, NULL);
M_BITMAPHANDLERDATA->m_ok = FALSE;
}
return M_BITMAPHANDLERDATA->m_ok ;
// Initialize all standard bitmap or derived class handlers here.
AddHandler(new wxXBMFileHandler);
AddHandler(new wxXBMDataHandler);
-
+
// XPM is considered standard for Moif, although it can be omitted if absolutely
// necessary.
#if wxUSE_XPM
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
{
- if (M_BITMAPDATA->m_image == (WXPixmap) 0)
- return M_BITMAPDATA->m_pixmap;
-
- Display *dpy = (Display*) M_BITMAPDATA->m_display;
-
+ if (M_BITMAPDATA->m_image == (WXPixmap) 0)
+ return M_BITMAPDATA->m_pixmap;
+
+ Display *dpy = (Display*) M_BITMAPDATA->m_display;
+
#ifdef FOO
-/*
- If we do:
- if (labelPixmap) return labelPixmap;
- things can be wrong, because colors can have been changed.
-
- If we do:
- if (labelPixmap)
- XmDestroyPixmap(DefaultScreenOfDisplay(dpy),labelPixmap) ;
- we got BadDrawable if the pixmap is referenced by multiples widgets
-
- this is a catch22!!
-
- So, before doing thing really clean, I just do nothing; if the pixmap is
- referenced by many widgets, Motif performs caching functions.
- And if pixmap is referenced with multiples colors, we just have some
- memory leaks... I hope we can deal with them...
- */
- // Must be destroyed, because colours can have been changed!
- if (M_BITMAPDATA->m_labelPixmap)
- XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_labelPixmap);
+ /*
+ If we do:
+ if (labelPixmap) return labelPixmap;
+ things can be wrong, because colors can have been changed.
+
+ If we do:
+ if (labelPixmap)
+ XmDestroyPixmap(DefaultScreenOfDisplay(dpy),labelPixmap) ;
+ we got BadDrawable if the pixmap is referenced by multiples widgets
+
+ this is a catch22!!
+
+ So, before doing thing really clean, I just do nothing; if the pixmap is
+ referenced by many widgets, Motif performs caching functions.
+ And if pixmap is referenced with multiples colors, we just have some
+ memory leaks... I hope we can deal with them...
+ */
+ // Must be destroyed, because colours can have been changed!
+ if (M_BITMAPDATA->m_labelPixmap)
+ XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_labelPixmap);
#endif
-
- char tmp[128];
- sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
-
- Pixel fg, bg;
- Widget widget = (Widget) w;
-
- while (XmIsGadget ( widget ))
- widget = XtParent (widget);
- XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
-
- M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
-
- return M_BITMAPDATA->m_labelPixmap;
+
+ char tmp[128];
+ sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
+
+ Pixel fg, bg;
+ Widget widget = (Widget) w;
+
+ while (XmIsGadget ( widget ))
+ widget = XtParent (widget);
+ XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
+
+ M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
+
+ return M_BITMAPDATA->m_labelPixmap;
}
WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
{
- if (M_BITMAPDATA->m_image == (WXPixmap) 0)
- return M_BITMAPDATA->m_pixmap;
-
- Display *dpy = (Display*) M_BITMAPDATA->m_display;
+ if (M_BITMAPDATA->m_image == (WXPixmap) 0)
+ return M_BITMAPDATA->m_pixmap;
+
+ Display *dpy = (Display*) M_BITMAPDATA->m_display;
#ifdef FOO
- See GetLabelPixmap () comment
- // Must be destroyed, because colours can have been changed!
- if (M_BITMAPDATA->m_armPixmap)
- XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap);
+ See GetLabelPixmap () comment
+ // Must be destroyed, because colours can have been changed!
+ if (M_BITMAPDATA->m_armPixmap)
+ XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap);
#endif
-
- char tmp[128];
- sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
-
- Pixel fg, bg;
- Widget widget = (Widget) w;
-
- XtVaGetValues (widget, XmNarmColor, &bg, NULL);
- while (XmIsGadget (widget))
- widget = XtParent (widget);
- XtVaGetValues (widget, XmNforeground, &fg, NULL);
-
- M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
-
- return M_BITMAPDATA->m_armPixmap;
+
+ char tmp[128];
+ sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
+
+ Pixel fg, bg;
+ Widget widget = (Widget) w;
+
+ XtVaGetValues (widget, XmNarmColor, &bg, NULL);
+ while (XmIsGadget (widget))
+ widget = XtParent (widget);
+ XtVaGetValues (widget, XmNforeground, &fg, NULL);
+
+ M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
+
+ return M_BITMAPDATA->m_armPixmap;
}
WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
{
- Display *dpy = (Display*) M_BITMAPDATA->m_display;
-
- if (M_BITMAPDATA->m_insensPixmap)
- return M_BITMAPDATA->m_insensPixmap;
-
- if (!w)
- {
- M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap);
+ Display *dpy = (Display*) M_BITMAPDATA->m_display;
+
if (M_BITMAPDATA->m_insensPixmap)
- return M_BITMAPDATA->m_insensPixmap;
- else
- return M_BITMAPDATA->m_pixmap;
- }
-
- if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
- return M_BITMAPDATA->m_pixmap;
-
+ return M_BITMAPDATA->m_insensPixmap;
+
+ if (!w)
+ {
+ M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap);
+ if (M_BITMAPDATA->m_insensPixmap)
+ return M_BITMAPDATA->m_insensPixmap;
+ else
+ return M_BITMAPDATA->m_pixmap;
+ }
+
+ if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
+ return M_BITMAPDATA->m_pixmap;
+
#ifdef FOO
- See GetLabelPixmap () comment
- // Must be destroyed, because colours can have been changed!
- if (M_BITMAPDATA->m_insensPixmap)
- XmDestroyPixmap (DefaultScreenOfDisplay (dpy), (Pixmap) M_BITMAPDATA->m_insensPixmap);
+ See GetLabelPixmap () comment
+ // Must be destroyed, because colours can have been changed!
+ if (M_BITMAPDATA->m_insensPixmap)
+ XmDestroyPixmap (DefaultScreenOfDisplay (dpy), (Pixmap) M_BITMAPDATA->m_insensPixmap);
#endif
-
- char tmp[128];
- sprintf (tmp, "Not%x", (unsigned int) M_BITMAPDATA->m_insensImage);
-
- Pixel fg, bg;
- Widget widget = (Widget) w;
-
- while (XmIsGadget (widget))
- widget = XtParent (widget);
- XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
-
- M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
-
- return M_BITMAPDATA->m_insensPixmap;
+
+ char tmp[128];
+ sprintf (tmp, "Not%x", (unsigned int) M_BITMAPDATA->m_insensImage);
+
+ Pixel fg, bg;
+ Widget widget = (Widget) w;
+
+ while (XmIsGadget (widget))
+ widget = XtParent (widget);
+ XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
+
+ M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
+
+ return M_BITMAPDATA->m_insensPixmap;
}
// We may need this sometime...
/****************************************************************************
-NAME
- XCreateInsensitivePixmap - create a grayed-out copy of a pixmap
-
-SYNOPSIS
+ NAME
+ XCreateInsensitivePixmap - create a grayed-out copy of a pixmap
+
+ SYNOPSIS
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
-
-DESCRIPTION
- This function creates a grayed-out copy of the argument pixmap, suitable
- for use as a XmLabel's XmNlabelInsensitivePixmap resource.
-
-RETURN VALUES
- The return value is the new Pixmap id or zero on error. Errors include
- a NULL display argument or an invalid Pixmap argument.
-
-ERRORS
- If one of the XLib functions fail, it will produce a X error. The
- default X error handler prints a diagnostic and calls exit().
-
-SEE ALSO
- XCopyArea(3), XCreateBitmapFromData(3), XCreateGC(3), XCreatePixmap(3),
- XFillRectangle(3), exit(2)
-
-AUTHOR
- John R Veregge - john@puente.jpl.nasa.gov
- Advanced Engineering and Prototyping Group (AEG)
- Information Systems Technology Section (395)
- Jet Propulsion Lab - Calif Institute of Technology
-
+
+ DESCRIPTION
+ This function creates a grayed-out copy of the argument pixmap, suitable
+ for use as a XmLabel's XmNlabelInsensitivePixmap resource.
+
+ RETURN VALUES
+ The return value is the new Pixmap id or zero on error. Errors include
+ a NULL display argument or an invalid Pixmap argument.
+
+ ERRORS
+ If one of the XLib functions fail, it will produce a X error. The
+ default X error handler prints a diagnostic and calls exit().
+
+ SEE ALSO
+ XCopyArea(3), XCreateBitmapFromData(3), XCreateGC(3), XCreatePixmap(3),
+ XFillRectangle(3), exit(2)
+
+ AUTHOR
+ John R Veregge - john@puente.jpl.nasa.gov
+ Advanced Engineering and Prototyping Group (AEG)
+ Information Systems Technology Section (395)
+ Jet Propulsion Lab - Calif Institute of Technology
+
*****************************************************************************/
Pixmap
XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
{
-static
- char stipple_data[] =
- {
- 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
+ static
+ char stipple_data[] =
+ {
+ 0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA
- };
+ };
GC gc;
Pixmap ipixmap, stipple;
unsigned width, height, depth;
-
+
Window window; /* These return values */
unsigned border; /* from XGetGeometry() */
int x, y; /* are not needed. */
-
+
ipixmap = 0;
-
+
if ( NULL == display || 0 == pixmap )
- return ipixmap;
-
+ return ipixmap;
+
if ( 0 == XGetGeometry( display, pixmap, &window, &x, &y,
- &width, &height, &border, &depth )
- )
- return ipixmap; /* BadDrawable: probably an invalid pixmap */
-
- /* Get the stipple pixmap to be used to 'gray-out' the argument pixmap.
+ &width, &height, &border, &depth )
+ )
+ return ipixmap; /* BadDrawable: probably an invalid pixmap */
+
+ /* Get the stipple pixmap to be used to 'gray-out' the argument pixmap.
*/
stipple = XCreateBitmapFromData( display, pixmap, stipple_data, 16, 16 );
if ( 0 != stipple )
{
- gc = XCreateGC( display, pixmap, (XtGCMask)0, (XGCValues*)NULL );
- if ( NULL != gc )
- {
- /* Create an identical copy of the argument pixmap.
- */
- ipixmap = XCreatePixmap( display, pixmap, width, height, depth );
- if ( 0 != ipixmap )
+ gc = XCreateGC( display, pixmap, (XtGCMask)0, (XGCValues*)NULL );
+ if ( NULL != gc )
{
- /* Copy the argument pixmap into the new pixmap.
- */
- XCopyArea( display, pixmap, ipixmap,
- gc, 0, 0, width, height, 0, 0 );
-
- /* Refill the new pixmap using the stipple algorithm/pixmap.
- */
- XSetStipple( display, gc, stipple );
- XSetFillStyle( display, gc, FillStippled );
- XFillRectangle( display, ipixmap, gc, 0, 0, width, height );
+ /* Create an identical copy of the argument pixmap.
+ */
+ ipixmap = XCreatePixmap( display, pixmap, width, height, depth );
+ if ( 0 != ipixmap )
+ {
+ /* Copy the argument pixmap into the new pixmap.
+ */
+ XCopyArea( display, pixmap, ipixmap,
+ gc, 0, 0, width, height, 0, 0 );
+
+ /* Refill the new pixmap using the stipple algorithm/pixmap.
+ */
+ XSetStipple( display, gc, stipple );
+ XSetFillStyle( display, gc, FillStippled );
+ XFillRectangle( display, ipixmap, gc, 0, 0, width, height );
+ }
+ XFreeGC( display, gc );
}
- XFreeGC( display, gc );
- }
- XFreePixmap( display, stipple );
+ XFreePixmap( display, stipple );
}
return ipixmap;
}
wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour)
{
wxBitmap newBitmap(bitmap.GetWidth(),
- bitmap.GetHeight(),
- bitmap.GetDepth());
+ bitmap.GetHeight(),
+ bitmap.GetDepth());
wxMemoryDC destDC;
wxMemoryDC srcDC;
srcDC.SelectObject(bitmap);
destDC.SelectObject(newBitmap);
-
+
wxBrush brush(colour, wxSOLID);
destDC.SetOptimization(FALSE);
destDC.SetBackground(brush);
destDC.Clear();
destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
-
+
return newBitmap;
}
}
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
m_buttonBitmap = bitmap;
m_buttonBitmapOriginal = bitmap;
m_buttonBitmapSelected = bitmap;
m_buttonBitmapSelectedOriginal = bitmap;
-
+
SetName(name);
SetValidator(validator);
parent->AddChild(this);
-
+
m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ;
m_windowStyle = style;
m_marginX = 0;
m_marginY = 0;
-
-/*
+
+ /*
int x = pos.x;
int y = pos.y;
int width = size.x;
int height = size.y;
-*/
-
+ */
+
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
-
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
- /*
- * Patch Note (important)
- * There is no major reason to put a defaultButtonThickness here.
- * Not requesting it give the ability to put wxButton with a spacing
- * as small as requested. However, if some button become a DefaultButton,
- * other buttons are no more aligned -- This is why we set
- * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
- * in the ::SetDefaultButton method.
- */
+
+ /*
+ * Patch Note (important)
+ * There is no major reason to put a defaultButtonThickness here.
+ * Not requesting it give the ability to put wxButton with a spacing
+ * as small as requested. However, if some button become a DefaultButton,
+ * other buttons are no more aligned -- This is why we set
+ * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
+ * in the ::SetDefaultButton method.
+ */
Widget buttonWidget = XtVaCreateManagedWidget ("button",
-
- // Gadget causes problems for default button operation.
+
+ // Gadget causes problems for default button operation.
#if wxUSE_GADGETS
- xmPushButtonGadgetClass, parentWidget,
+ xmPushButtonGadgetClass, parentWidget,
#else
- xmPushButtonWidgetClass, parentWidget,
+ xmPushButtonWidgetClass, parentWidget,
#endif
-// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
- NULL);
-
+ // XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
+ NULL);
+
m_mainWidget = (WXWidget) buttonWidget;
-
+
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
-
+
ChangeBackgroundColour ();
-
+
DoSetBitmap();
-
+
XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
- (XtPointer) this);
-
+ (XtPointer) this);
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
return TRUE;
}
wxBitmapButton::~wxBitmapButton()
{
SetBitmapLabel(wxNullBitmap);
-
+
if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()), (Pixmap) m_insensPixmap);
}
{
m_buttonBitmapOriginal = bitmap;
m_buttonBitmap = bitmap;
-
+
DoSetBitmap();
}
{
m_buttonBitmapSelected = sel;
m_buttonBitmapSelectedOriginal = sel;
-
+
DoSetBitmap();
};
{
m_buttonBitmapDisabled = disabled;
m_buttonBitmapDisabledOriginal = disabled;
-
+
DoSetBitmap();
};
Pixmap pixmap = 0;
Pixmap insensPixmap = 0;
Pixmap armPixmap = 0;
-
+
// Must re-make the bitmap to have its transparent areas drawn
// in the current widget background colour.
if (m_buttonBitmapOriginal.GetMask())
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
- NULL);
-
+ NULL);
+
wxColour col;
col.SetPixel(backgroundPixel);
-
+
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapOriginal, col);
m_buttonBitmap = newBitmap;
-
+
pixmap = (Pixmap) m_buttonBitmap.GetPixmap();
}
else
pixmap = (Pixmap) m_buttonBitmap.GetLabelPixmap(m_mainWidget);
-
+
if (m_buttonBitmapDisabledOriginal.Ok())
{
if (m_buttonBitmapDisabledOriginal.GetMask())
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
- NULL);
-
+ NULL);
+
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapDisabledOriginal, col);
m_buttonBitmapDisabled = newBitmap;
-
+
insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetPixmap();
}
else
}
else
insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget);
-
+
// Now make the bitmap representing the armed state
if (m_buttonBitmapSelectedOriginal.Ok())
{
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNarmColor, &backgroundPixel,
- NULL);
-
+ NULL);
+
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapSelectedOriginal, col);
m_buttonBitmapSelected = newBitmap;
-
+
armPixmap = (Pixmap) m_buttonBitmapSelected.GetPixmap();
}
else
- armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
+ armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
}
else
- armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
-
+ armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
+
if (insensPixmap == pixmap) // <- the Get...Pixmap()-functions return the same pixmap!
{
insensPixmap =
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
m_insensPixmap = (WXPixmap) insensPixmap;
}
-
+
XtVaSetValues ((Widget) m_mainWidget,
XmNlabelPixmap, pixmap,
XmNlabelInsensitivePixmap, insensPixmap,
XtVaSetValues ((Widget) m_mainWidget,
XmNlabelType, XmSTRING,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
- XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
+ XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
NULL);
}
void wxBitmapButton::ChangeBackgroundColour()
{
DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE);
-
+
// Must reset the bitmaps since the colours have changed.
DoSetBitmap();
}
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
{
- m_style = data.m_style;
- m_stipple = data.m_stipple;
- m_colour = data.m_colour;
+ m_style = data.m_style;
+ m_stipple = data.m_stipple;
+ m_colour = data.m_colour;
}
wxBrushRefData::~wxBrushRefData()
wxBrush::wxBrush(const wxColour& col, int Style)
{
m_refData = new wxBrushRefData;
-
+
M_BRUSHDATA->m_colour = col;
M_BRUSHDATA->m_style = Style;
-
+
RealizeResource();
-
+
if ( wxTheBrushList )
wxTheBrushList->AddBrush(this);
}
wxBrush::wxBrush(const wxBitmap& stipple)
{
m_refData = new wxBrushRefData;
-
+
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_stipple = stipple;
-
+
RealizeResource();
-
+
if ( wxTheBrushList )
wxTheBrushList->AddBrush(this);
}
void wxBrush::Unshare()
{
- // Don't change shared data
- if (!m_refData)
+ // Don't change shared data
+ if (!m_refData)
{
- m_refData = new wxBrushRefData();
- }
+ m_refData = new wxBrushRefData();
+ }
else
{
- wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxBrush::SetColour(const wxColour& col)
{
Unshare();
-
+
M_BRUSHDATA->m_colour = col;
-
+
RealizeResource();
}
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
Unshare();
-
+
M_BRUSHDATA->m_colour.Set(r, g, b);
-
+
RealizeResource();
}
void wxBrush::SetStyle(int Style)
{
Unshare();
-
+
M_BRUSHDATA->m_style = Style;
-
+
RealizeResource();
}
void wxBrush::SetStipple(const wxBitmap& Stipple)
{
Unshare();
-
+
M_BRUSHDATA->m_stipple = Stipple;
-
+
RealizeResource();
}
// Button
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont();
-
+
parent->AddChild((wxButton *)this);
-
+
if (id == -1)
m_windowId = NewControlId();
else
m_windowId = id;
-
+
wxString label1(wxStripMenuCodes(label));
-
+
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
-
+
/*
- * Patch Note (important)
- * There is no major reason to put a defaultButtonThickness here.
- * Not requesting it give the ability to put wxButton with a spacing
- * as small as requested. However, if some button become a DefaultButton,
- * other buttons are no more aligned -- This is why we set
- * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
- * in the ::SetDefaultButton method.
- */
+ * Patch Note (important)
+ * There is no major reason to put a defaultButtonThickness here.
+ * Not requesting it give the ability to put wxButton with a spacing
+ * as small as requested. However, if some button become a DefaultButton,
+ * other buttons are no more aligned -- This is why we set
+ * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
+ * in the ::SetDefaultButton method.
+ */
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
- xmPushButtonWidgetClass,
- parentWidget,
- XmNfontList, fontList,
- XmNlabelString, text,
-// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
- NULL);
-
+ xmPushButtonWidgetClass,
+ parentWidget,
+ XmNfontList, fontList,
+ XmNlabelString, text,
+ // XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
+ NULL);
+
XmStringFree (text);
-
+
XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
- (XtPointer) this);
-
+ (XtPointer) this);
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
wxWindow *parent = (wxWindow *)GetParent();
if (parent)
parent->SetDefaultItem(this);
-
- // We initially do not set XmNdefaultShadowThickness, to have small buttons.
- // Unfortunately, buttons are now mis-aligned. We try to correct this
- // now -- setting this ressource to 1 for each button in the same row.
- // Because it's very hard to find wxButton in the same row,
- // correction is straighforward: we set resource for all wxButton
- // in this parent (but not sub panels)
- for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
+
+ // We initially do not set XmNdefaultShadowThickness, to have small buttons.
+ // Unfortunately, buttons are now mis-aligned. We try to correct this
+ // now -- setting this ressource to 1 for each button in the same row.
+ // Because it's very hard to find wxButton in the same row,
+ // correction is straighforward: we set resource for all wxButton
+ // in this parent (but not sub panels)
+ for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{
- wxButton *item = (wxButton *) node->Data ();
- if (item->IsKindOf(CLASSINFO(wxButton)))
- {
- bool managed = XtIsManaged((Widget) item->GetMainWidget());
- if (managed)
- XtUnmanageChild ((Widget) item->GetMainWidget());
-
- XtVaSetValues ((Widget) item->GetMainWidget(),
- XmNdefaultButtonShadowThickness, 1,
- NULL);
-
- if (managed)
- XtManageChild ((Widget) item->GetMainWidget());
- }
+ wxButton *item = (wxButton *) node->Data ();
+ if (item->IsKindOf(CLASSINFO(wxButton)))
+ {
+ bool managed = XtIsManaged((Widget) item->GetMainWidget());
+ if (managed)
+ XtUnmanageChild ((Widget) item->GetMainWidget());
+
+ XtVaSetValues ((Widget) item->GetMainWidget(),
+ XmNdefaultButtonShadowThickness, 1,
+ NULL);
+
+ if (managed)
+ XtManageChild ((Widget) item->GetMainWidget());
+ }
} // while
-
-// XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
- XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
+
+ // XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
+ XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
}
void wxButton::Command (wxCommandEvent & event)
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
{
- if (!wxGetWindowFromTable(w))
- // Widget has been deleted!
- return;
-
- wxButton *item = (wxButton *) clientData;
- wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
- event.SetEventObject(item);
- item->ProcessCommand (event);
+ if (!wxGetWindowFromTable(w))
+ // Widget has been deleted!
+ return;
+
+ wxButton *item = (wxButton *) clientData;
+ wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
}
void wxButton::ChangeFont(bool keepOriginalSize)
#include "wx/motif/private.h"
void wxCheckBoxCallback (Widget w, XtPointer clientData,
- XtPointer ptr);
+ XtPointer ptr);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
// Single check box item
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont();
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
-
+
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
-
+
XmString text = XmStringCreateSimple (label1);
Widget parentWidget = (Widget) parent->GetClientWidget();
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
-
+
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
- xmToggleButtonWidgetClass, parentWidget,
- XmNfontList, fontList,
- XmNlabelString, text,
- NULL);
+ xmToggleButtonWidgetClass, parentWidget,
+ XmNfontList, fontList,
+ XmNlabelString, text,
+ NULL);
XmStringFree (text);
-
+
XtAddCallback ((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc) wxCheckBoxCallback,
- (XtPointer) this);
-
+ (XtPointer) this);
+
XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE);
-
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
return TRUE;
}
// Bitmap checkbox
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_windowStyle = style;
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
-
+
// TODO: Create the bitmap checkbox
-
+
return FALSE;
}
}
void wxCheckBoxCallback (Widget w, XtPointer clientData,
- XtPointer ptr)
+ XtPointer ptr)
{
- wxCheckBox *item = (wxCheckBox *) clientData;
-
- if (item->InSetValue())
- return;
+ wxCheckBox *item = (wxCheckBox *) clientData;
- wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
- event.SetInt((int) item->GetValue ());
- event.SetEventObject(item);
- item->ProcessCommand (event);
+ if (item->InSetValue())
+ return;
+
+ wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
+ event.SetInt((int) item->GetValue ());
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
}
void wxCheckBox::ChangeFont(bool keepOriginalSize)
void wxCheckBox::ChangeBackgroundColour()
{
- wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
- (wxColour*) NULL);
-
- XtVaSetValues ((Widget) m_mainWidget,
- XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
- XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
- XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
- XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
- NULL);
-
- XtVaSetValues ((Widget) m_mainWidget,
- XmNselectColor, g_itemColors[wxSELE_INDEX].pixel,
- NULL);
+ wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
+ (wxColour*) NULL);
+
+ XtVaSetValues ((Widget) m_mainWidget,
+ XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
+ XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
+ XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
+ XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
+ NULL);
+
+ XtVaSetValues ((Widget) m_mainWidget,
+ XmNselectColor, g_itemColors[wxSELE_INDEX].pixel,
+ NULL);
}
void wxCheckBox::ChangeForegroundColour()
// ============================================================================
#if !USE_SHARED_LIBRARY
- IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
+IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
#endif
// ----------------------------------------------------------------------------
int nStrings, const wxString choices[],
long style, const wxValidator& val,
const wxString& name)
- : wxListBox()
+ : wxListBox()
{
// TODO: you'll probably need a separate Create instead of using
// the wxListBox one as here.
#endif
void wxChoiceCallback (Widget w, XtPointer clientData,
- XtPointer ptr);
+ XtPointer ptr);
wxChoice::wxChoice()
{
}
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size,
+ int n, const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_menuWidget = (WXWidget) 0;
m_widgetList = (WXWidget*) 0;
m_formWidget = (WXWidget) 0;
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont();
-
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
- xmRowColumnWidgetClass, parentWidget,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- XmNpacking, XmPACK_TIGHT,
- XmNorientation, XmHORIZONTAL,
- NULL);
-
+ xmRowColumnWidgetClass, parentWidget,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNpacking, XmPACK_TIGHT,
+ XmNorientation, XmHORIZONTAL,
+ NULL);
+
XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL);
-
- /*
+
+ /*
* Create the popup menu
*/
m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, "choiceMenu", NULL, 0);
-
-// int i;
+
+ // int i;
if (n > 0)
{
int i;
for (i = 0; i < n; i++)
Append (choices[i]);
}
-
- /*
+
+ /*
* Create button
*/
Arg args[10];
Cardinal argcnt = 0;
-
+
XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget);
argcnt++;
XtSetArg (args[argcnt], XmNmarginWidth, 0);
XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT);
argcnt++;
m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, "choiceButton", args, argcnt);
-
+
m_mainWidget = m_buttonWidget;
-
+
XtManageChild ((Widget) m_buttonWidget);
-
+
// New code from Roland Haenel (roland_haenel@ac.cybercity.de)
// Some time ago, I reported a problem with wxChoice-items under
// Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems
XtUnmanageChild (optionLabel);
#endif
#endif
-
+
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
+
ChangeFont(FALSE);
-
+
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
wxChoice::~wxChoice()
{
- // For some reason destroying the menuWidget
- // can cause crashes on some machines. It will
- // be deleted implicitly by deleting the parent form
- // anyway.
-// XtDestroyWidget (menuWidget);
+ // For some reason destroying the menuWidget
+ // can cause crashes on some machines. It will
+ // be deleted implicitly by deleting the parent form
+ // anyway.
+ // XtDestroyWidget (menuWidget);
if (m_widgetList)
delete[] m_widgetList;
-
+
if (GetMainWidget())
{
DetachWidget(GetMainWidget()); // Removes event handlers
DetachWidget(m_formWidget);
-
+
XtDestroyWidget((Widget) m_formWidget);
m_formWidget = (WXWidget) 0;
-
+
// Presumably the other widgets have been deleted now, via the form
m_mainWidget = (WXWidget) 0;
m_buttonWidget = (WXWidget) 0;
void wxChoice::Append(const wxString& item)
{
- wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
- Widget w = XtVaCreateManagedWidget (wxBuffer,
+ wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
+ Widget w = XtVaCreateManagedWidget (wxBuffer,
#if USE_GADGETS
- xmPushButtonGadgetClass, (Widget) m_menuWidget,
+ xmPushButtonGadgetClass, (Widget) m_menuWidget,
#else
- xmPushButtonWidgetClass, (Widget) m_menuWidget,
+ xmPushButtonWidgetClass, (Widget) m_menuWidget,
#endif
- NULL);
-
- DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
-
- if (m_windowFont.Ok())
- XtVaSetValues (w,
- XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
- NULL);
-
- WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
- int i;
- if (m_widgetList)
- for (i = 0; i < m_noStrings; i++)
- new_widgetList[i] = m_widgetList[i];
-
- new_widgetList[m_noStrings] = (WXWidget) w;
-
- if (m_widgetList)
- delete[] m_widgetList;
- m_widgetList = new_widgetList;
-
- char mnem = wxFindMnemonic ((char*) (const char*) item);
- if (mnem != 0)
- XtVaSetValues (w, XmNmnemonic, mnem, NULL);
-
- XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
-
- if (m_noStrings == 0 && m_buttonWidget)
- {
- XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
- Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
- XmString text = XmStringCreateSimple ((char*) (const char*) item);
- XtVaSetValues (label,
- XmNlabelString, text,
- NULL);
- XmStringFree (text);
- }
- wxNode *node = m_stringList.Add (item);
- XtVaSetValues (w, XmNuserData, node->Data (), NULL);
-
- m_noStrings ++;
+ NULL);
+
+ DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
+
+ if (m_windowFont.Ok())
+ XtVaSetValues (w,
+ XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
+ NULL);
+
+ WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
+ int i;
+ if (m_widgetList)
+ for (i = 0; i < m_noStrings; i++)
+ new_widgetList[i] = m_widgetList[i];
+
+ new_widgetList[m_noStrings] = (WXWidget) w;
+
+ if (m_widgetList)
+ delete[] m_widgetList;
+ m_widgetList = new_widgetList;
+
+ char mnem = wxFindMnemonic ((char*) (const char*) item);
+ if (mnem != 0)
+ XtVaSetValues (w, XmNmnemonic, mnem, NULL);
+
+ XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
+
+ if (m_noStrings == 0 && m_buttonWidget)
+ {
+ XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
+ Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
+ XmString text = XmStringCreateSimple ((char*) (const char*) item);
+ XtVaSetValues (label,
+ XmNlabelString, text,
+ NULL);
+ XmStringFree (text);
+ }
+ wxNode *node = m_stringList.Add (item);
+ XtVaSetValues (w, XmNuserData, node->Data (), NULL);
+
+ m_noStrings ++;
}
void wxChoice::Delete(int WXUNUSED(n))
{
wxFAIL_MSG( "Sorry, wxChoice::Delete isn't implemented yet. Maybe you'd like to volunteer? :-)" );
-
+
// What should we do -- remove the callback for this button widget,
// delete the m_stringList entry, delete the button widget, construct a new widget list
// (see Append)
-
+
// TODO
m_noStrings --;
}
int wxChoice::GetSelection() const
{
- XmString text;
- char *s;
- Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
- XtVaGetValues (label,
- XmNlabelString, &text,
- NULL);
-
- if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
- {
- int i = 0;
- for (wxNode * node = m_stringList.First (); node; node = node->Next ())
- {
- char *s1 = (char *) node->Data ();
- if (s1 == s || strcmp (s1, s) == 0)
+ XmString text;
+ char *s;
+ Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
+ XtVaGetValues (label,
+ XmNlabelString, &text,
+ NULL);
+
+ if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
+ {
+ int i = 0;
+ for (wxNode * node = m_stringList.First (); node; node = node->Next ())
{
- XmStringFree(text) ;
- XtFree (s);
- return i;
- }
- else
- i++;
- } // for()
-
- XmStringFree(text) ;
- XtFree (s);
- return -1;
- }
- XmStringFree(text) ;
- return -1;
+ char *s1 = (char *) node->Data ();
+ if (s1 == s || strcmp (s1, s) == 0)
+ {
+ XmStringFree(text) ;
+ XtFree (s);
+ return i;
+ }
+ else
+ i++;
+ } // for()
+
+ XmStringFree(text) ;
+ XtFree (s);
+ return -1;
+ }
+ XmStringFree(text) ;
+ return -1;
}
void wxChoice::SetSelection(int n)
{
- m_inSetValue = TRUE;
-
- wxNode *node = m_stringList.Nth (n);
- if (node)
+ m_inSetValue = TRUE;
+
+ wxNode *node = m_stringList.Nth (n);
+ if (node)
{
- Dimension selectionWidth, selectionHeight;
-
- char *s = (char *) node->Data ();
- XmString text = XmStringCreateSimple (s);
- XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
- Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
- XtVaSetValues (label,
- XmNlabelString, text,
- NULL);
- XmStringFree (text);
- XtVaSetValues ((Widget) m_buttonWidget,
- XmNwidth, selectionWidth, XmNheight, selectionHeight,
- XmNmenuHistory, (Widget) m_widgetList[n], NULL);
+ Dimension selectionWidth, selectionHeight;
+
+ char *s = (char *) node->Data ();
+ XmString text = XmStringCreateSimple (s);
+ XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
+ Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
+ XtVaSetValues (label,
+ XmNlabelString, text,
+ NULL);
+ XmStringFree (text);
+ XtVaSetValues ((Widget) m_buttonWidget,
+ XmNwidth, selectionWidth, XmNheight, selectionHeight,
+ XmNmenuHistory, (Widget) m_widgetList[n], NULL);
}
- m_inSetValue = FALSE;
+ m_inSetValue = FALSE;
}
int wxChoice::FindString(const wxString& s) const
wxString wxChoice::GetString(int n) const
{
- wxNode *node = m_stringList.Nth (n);
- if (node)
- return wxString((char *) node->Data ());
- else
- return wxEmptyString;
+ wxNode *node = m_stringList.Nth (n);
+ if (node)
+ return wxString((char *) node->Data ());
+ else
+ return wxEmptyString;
}
void wxChoice::SetColumns(int n)
{
- if (n<1) n = 1 ;
-
- short numColumns = n ;
- Arg args[3];
-
- XtSetArg(args[0], XmNnumColumns, numColumns);
- XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
- XtSetValues((Widget) m_menuWidget,args,2) ;
+ if (n<1) n = 1 ;
+
+ short numColumns = n ;
+ Arg args[3];
+
+ XtSetArg(args[0], XmNnumColumns, numColumns);
+ XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
+ XtSetValues((Widget) m_menuWidget,args,2) ;
}
int wxChoice::GetColumns(void) const
{
- short numColumns ;
-
- XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
- return numColumns ;
+ short numColumns ;
+
+ XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
+ return numColumns ;
}
void wxChoice::SetFocus()
{
- XmProcessTraversal(XtParent((Widget)m_mainWidget), XmTRAVERSE_CURRENT);
+ XmProcessTraversal(XtParent((Widget)m_mainWidget), XmTRAVERSE_CURRENT);
}
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
{
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
bool managed = XtIsManaged((Widget) m_formWidget);
-
+
if (managed)
XtUnmanageChild ((Widget) m_formWidget);
-
+
int actualWidth = width, actualHeight = height;
-
+
if (width > -1)
{
int i;
for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetList[i], XmNwidth, actualWidth, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNwidth, actualWidth,
- NULL);
+ NULL);
}
if (height > -1)
{
for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetList[i], XmNheight, actualHeight, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNheight, actualHeight,
- NULL);
+ NULL);
}
-
+
if (managed)
XtManageChild ((Widget) m_formWidget);
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
+
wxControl::SetSize (x, y, width, height, sizeFlags);
}
{
int sel = FindString (s);
if (sel > -1)
- {
- SetSelection (sel);
- return TRUE;
- }
+ {
+ SetSelection (sel);
+ return TRUE;
+ }
else
return FALSE;
}
wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
event.SetEventObject(item);
event.m_commandInt = item->FindString (s);
-// event.m_commandString = s;
+ // event.m_commandString = s;
item->ProcessCommand (event);
}
}
{
int width, height, width1, height1;
GetSize(& width, & height);
-
+
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget));
XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
-
+
/* TODO: why does this cause a crash in XtWidgetToApplicationContext?
int i;
for (i = 0; i < m_noStrings; i++)
- XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
+ XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
*/
GetSize(& width1, & height1);
if (keepOriginalSize && (width != width1 || height != height1))
#include "wx/utils.h"
#include "wx/metafile.h"
#include "wx/clipbrd.h"
+#include "wx/dataobj.h"
+
+#include <Xm/Xm.h>
+#include <Xm/CutPaste.h>
#include <string.h>
#if !USE_SHARED_LIBRARY
-IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
-IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
+// IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
+// IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
#endif
+static bool gs_clipboardIsOpen = FALSE;
+
bool wxOpenClipboard()
{
- // TODO
- return FALSE;
+ if (!gs_clipboardIsOpen)
+ {
+ gs_clipboardIsOpen = TRUE;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
bool wxCloseClipboard()
{
- // TODO
- return FALSE;
+ if (gs_clipboardIsOpen)
+ {
+ gs_clipboardIsOpen = FALSE;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
bool wxEmptyClipboard()
{
- // TODO
- return FALSE;
+ // No equivalent in Motif
+ return TRUE;
}
bool wxClipboardOpen()
{
- // TODO
- return FALSE;
+ return gs_clipboardIsOpen;
}
-bool wxIsClipboardFormatAvailable(int dataFormat)
+bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
- // TODO
- return FALSE;
+ // Only text is supported.
+ if (dataFormat != wxDF_TEXT)
+ return FALSE;
+
+ unsigned long numBytes = 0;
+ long privateId = 0;
+
+ Window window = (Window) 0;
+ if (wxTheApp->GetTopWindow())
+ window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
+
+ int success = XmClipboardRetrieve((Display*) wxGetDisplay(),
+ window, "TEXT", (XtPointer) 0, 0, & numBytes, & privateId) ;
+
+ // Assume only text is supported. If we have anything at all,
+ // or the clipboard is locked so we're not sure, we say we support it.
+ if (success == ClipboardNoData)
+ return FALSE;
+ else
+ return TRUE;
}
-bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
+bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width, int height)
{
- // TODO
- return FALSE;
+ if (dataFormat != wxDF_TEXT)
+ return FALSE;
+
+ char* data = (char*) obj;
+
+ XmString text = XmStringCreateSimple ("CLIPBOARD");
+ Window window = (Window) 0;
+ if (wxTheApp->GetTopWindow())
+ window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
+
+ long itemId = 0;
+ int result = 0;
+
+ while ((result =
+ XmClipboardStartCopy((Display*) wxGetDisplay(),
+ window,
+ text,
+ XtLastTimestampProcessed((Display*) wxGetDisplay()),
+ (Widget) 0,
+ (XmCutPasteProc) 0,
+ & itemId)) != ClipboardSuccess)
+
+ ;
+
+ XmStringFree (text);
+
+ long dataId = 0;
+ while ((result =
+ XmClipboardCopy((Display*) wxGetDisplay(),
+ window,
+ itemId,
+ "TEXT",
+ (XtPointer) data,
+ strlen(data) + 1,
+ 0,
+ & dataId)) != ClipboardSuccess)
+
+ ;
+
+ while (( result =
+ XmClipboardEndCopy((Display*) wxGetDisplay(),
+ window, itemId) ) != ClipboardSuccess)
+
+ ;
+
+ return TRUE;
}
-wxObject *wxGetClipboardData(int dataFormat, long *len)
+wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
- // TODO
+ if (dataFormat != wxDF_TEXT)
+ return (wxObject*) NULL;
+
+ bool done = FALSE;
+ long id = 0;
+ unsigned long numBytes = 0;
+ int result = 0;
+ Window window = (Window) 0;
+ if (wxTheApp->GetTopWindow())
+ window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
+
+ int currentDataSize = 256;
+ char* data = new char[currentDataSize];
+
+ while (!done)
+ {
+ if (result == ClipboardTruncate)
+ {
+ delete[] data;
+ currentDataSize = 2*currentDataSize;
+ data = new char[currentDataSize];
+ }
+ result = XmClipboardRetrieve((Display*) wxGetDisplay(),
+ window,
+ "TEXT",
+ (XtPointer) data,
+ currentDataSize,
+ &numBytes,
+ &id);
+
+ switch (result)
+ {
+ case ClipboardSuccess:
+ {
+ if (len)
+ *len = strlen(data) + 1;
+ return (wxObject*) data;
+ break;
+ }
+ case ClipboardTruncate:
+ case ClipboardLocked:
+ {
+ break;
+ }
+ default:
+ case ClipboardNoData:
+ {
+ return (wxObject*) NULL;
+ break;
+ }
+ }
+
+ }
+
return NULL;
}
-int wxEnumClipboardFormats(int dataFormat)
+wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
- // TODO
- return 0;
+ // Only wxDF_TEXT supported
+ if (dataFormat == (wxDataFormat) 0)
+ return wxDF_TEXT;
+ else
+ return (wxDataFormat) 0;
}
-int wxRegisterClipboardFormat(char *formatName)
+wxDataFormat wxRegisterClipboardFormat(char *formatName)
{
- // TODO
- return 0;
+ // Not supported
+ return (wxDataFormat) 0;
}
-bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
+bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount)
{
- // TODO
- return FALSE;
+ // Only wxDF_TEXT supported
+ if (dataFormat == wxDF_TEXT)
+ {
+ strcpy(formatName, "TEXT");
+ return TRUE;
+ }
+ else
+ return FALSE;
}
-/*
- * Generalized clipboard implementation by Matthew Flatt
- */
+//-----------------------------------------------------------------------------
+// wxClipboard
+//-----------------------------------------------------------------------------
-wxClipboard *wxTheClipboard = NULL;
+IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
-void wxInitClipboard()
-{
- if (!wxTheClipboard)
- wxTheClipboard = new wxClipboard;
-}
+wxClipboard* wxTheClipboard = (wxClipboard*) NULL;
wxClipboard::wxClipboard()
{
- clipOwner = NULL;
- cbString = NULL;
+ m_open = FALSE;
}
wxClipboard::~wxClipboard()
{
- if (clipOwner)
- clipOwner->BeingReplaced();
- if (cbString)
- delete[] cbString;
+ Clear();
}
-static int FormatStringToID(char *str)
+void wxClipboard::Clear()
{
- if (!strcmp(str, "TEXT"))
- return wxDF_TEXT;
-
- return wxRegisterClipboardFormat(str);
+ wxNode* node = m_data.First();
+ while (node)
+ {
+ wxDataObject* data = (wxDataObject*) node->Data();
+ delete data;
+ node = node->Next();
+ }
+ m_data.Clear();
}
-void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
+bool wxClipboard::Open()
{
- bool got_selection;
+ wxCHECK_MSG( !m_open, FALSE, "clipboard already open" );
+
+ m_open = TRUE;
- if (clipOwner)
- clipOwner->BeingReplaced();
- clipOwner = client;
- if (cbString) {
- delete[] cbString;
- cbString = NULL;
- }
-
- if (wxOpenClipboard()) {
- char **formats, *data;
- int i;
- int ftype;
- long size;
-
- formats = clipOwner->formats.ListToArray(FALSE);
- for (i = clipOwner->formats.Number(); i--; ) {
- ftype = FormatStringToID(formats[i]);
- data = clipOwner->GetData(formats[i], &size);
- if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
- got_selection = FALSE;
- break;
- }
- }
+ return wxOpenClipboard();
+}
- if (i < 0)
- got_selection = wxCloseClipboard();
- } else
- got_selection = FALSE;
+bool wxClipboard::SetData( wxDataObject *data )
+{
+ wxCHECK_MSG( data, FALSE, "data is invalid" );
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ switch (data->GetFormat())
+ {
+ case wxDF_TEXT:
+ case wxDF_OEMTEXT:
+ {
+ wxTextDataObject* textDataObject = (wxTextDataObject*) data;
+ wxString str(textDataObject->GetText());
+ return wxSetClipboardData(data->GetFormat(), (wxObject*) (const char*) str);
+ break;
+ }
+ case wxDF_BITMAP:
+ case wxDF_DIB:
+ {
+ wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
+ wxBitmap bitmap(bitmapDataObject->GetBitmap());
+ return wxSetClipboardData(data->GetFormat(), & bitmap);
+ break;
+ }
+ default:
+ {
+ return FALSE;
+ }
+ }
- got_selection = FALSE; // Assume another process takes over
+ return FALSE;
+}
- if (!got_selection) {
- clipOwner->BeingReplaced();
- clipOwner = NULL;
- }
+void wxClipboard::Close()
+{
+ wxCHECK_RET( m_open, "clipboard not open" );
+
+ m_open = FALSE;
+ wxCloseClipboard();
}
-wxClipboardClient *wxClipboard::GetClipboardClient()
+bool wxClipboard::IsSupportedFormat( wxDataFormat format, const wxString& WXUNUSED(id) )
{
- return clipOwner;
+ return wxIsClipboardFormatAvailable(format);
}
-void wxClipboard::SetClipboardString(char *str, long time)
+bool wxClipboard::GetData( wxDataObject *data )
{
- bool got_selection;
+ wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
+
+ switch (data->GetFormat())
+ {
+ case wxDF_TEXT:
+ case wxDF_OEMTEXT:
+ {
+ wxTextDataObject* textDataObject = (wxTextDataObject*) data;
+ char* s = (char*) wxGetClipboardData(data->GetFormat());
+ if (s)
+ {
+ textDataObject->SetText(s);
+ delete[] s;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ break;
+ }
+ case wxDF_BITMAP:
+ case wxDF_DIB:
+ {
+ wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
+ wxBitmap* bitmap = (wxBitmap*) wxGetClipboardData(data->GetFormat());
+ if (bitmap)
+ {
+ bitmapDataObject->SetBitmap(* bitmap);
+ delete bitmap;
+ return TRUE;
+ }
+ else
+ return FALSE;
+ break;
+ }
+ default:
+ {
+ return FALSE;
+ }
+ }
+ return FALSE;
+}
- if (clipOwner) {
- clipOwner->BeingReplaced();
- clipOwner = NULL;
- }
- if (cbString)
- delete[] cbString;
+//-----------------------------------------------------------------------------
+// wxClipboardModule
+//-----------------------------------------------------------------------------
- cbString = str;
+IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
- if (wxOpenClipboard()) {
- if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
- got_selection = FALSE;
- else
- got_selection = wxCloseClipboard();
- } else
- got_selection = FALSE;
+bool wxClipboardModule::OnInit()
+{
+ wxTheClipboard = new wxClipboard();
+
+ return TRUE;
+}
- got_selection = FALSE; // Assume another process takes over
+void wxClipboardModule::OnExit()
+{
+ if (wxTheClipboard) delete wxTheClipboard;
+ wxTheClipboard = (wxClipboard*) NULL;
+}
+
+
+#if 0
+
+/*
+* Old clipboard implementation by Matthew Flatt
+*/
+
+wxClipboard *wxTheClipboard = NULL;
+
+void wxInitClipboard()
+{
+ if (!wxTheClipboard)
+ wxTheClipboard = new wxClipboard;
+}
- if (!got_selection) {
- delete[] cbString;
+wxClipboard::wxClipboard()
+{
+ clipOwner = NULL;
cbString = NULL;
- }
}
-char *wxClipboard::GetClipboardString(long time)
+wxClipboard::~wxClipboard()
+{
+ if (clipOwner)
+ clipOwner->BeingReplaced();
+ if (cbString)
+ delete[] cbString;
+}
+
+static int FormatStringToID(char *str)
{
- char *str;
- long length;
+ if (!strcmp(str, "TEXT"))
+ return wxDF_TEXT;
+
+ return wxRegisterClipboardFormat(str);
+}
- str = GetClipboardData("TEXT", &length, time);
- if (!str) {
- str = new char[1];
- *str = 0;
- }
+void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
+{
+ bool got_selection;
+
+ if (clipOwner)
+ clipOwner->BeingReplaced();
+ clipOwner = client;
+ if (cbString) {
+ delete[] cbString;
+ cbString = NULL;
+ }
+
+ if (wxOpenClipboard()) {
+ char **formats, *data;
+ int i;
+ int ftype;
+ long size;
+
+ formats = clipOwner->formats.ListToArray(FALSE);
+ for (i = clipOwner->formats.Number(); i--; ) {
+ ftype = FormatStringToID(formats[i]);
+ data = clipOwner->GetData(formats[i], &size);
+ if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
+ got_selection = FALSE;
+ break;
+ }
+ }
+
+ if (i < 0)
+ got_selection = wxCloseClipboard();
+ } else
+ got_selection = FALSE;
+
+ got_selection = FALSE; // Assume another process takes over
+
+ if (!got_selection) {
+ clipOwner->BeingReplaced();
+ clipOwner = NULL;
+ }
+}
- return str;
+wxClipboardClient *wxClipboard::GetClipboardClient()
+{
+ return clipOwner;
}
-char *wxClipboard::GetClipboardData(char *format, long *length, long time)
+void wxClipboard::SetClipboardString(char *str, long time)
{
- if (clipOwner) {
- if (clipOwner->formats.Member(format))
- return clipOwner->GetData(format, length);
- else
- return NULL;
- } else if (cbString) {
- if (!strcmp(format, "TEXT"))
- return copystring(cbString);
- else
- return NULL;
- } else {
+ bool got_selection;
+
+ if (clipOwner) {
+ clipOwner->BeingReplaced();
+ clipOwner = NULL;
+ }
+ if (cbString)
+ delete[] cbString;
+
+ cbString = str;
+
if (wxOpenClipboard()) {
- receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
- length);
- wxCloseClipboard();
+ if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
+ got_selection = FALSE;
+ else
+ got_selection = wxCloseClipboard();
} else
- receivedString = NULL;
+ got_selection = FALSE;
+
+ got_selection = FALSE; // Assume another process takes over
+
+ if (!got_selection) {
+ delete[] cbString;
+ cbString = NULL;
+ }
+}
+
+char *wxClipboard::GetClipboardString(long time)
+{
+ char *str;
+ long length;
+
+ str = GetClipboardData("TEXT", &length, time);
+ if (!str) {
+ str = new char[1];
+ *str = 0;
+ }
+
+ return str;
+}
- return receivedString;
- }
+char *wxClipboard::GetClipboardData(char *format, long *length, long time)
+{
+ if (clipOwner) {
+ if (clipOwner->formats.Member(format))
+ return clipOwner->GetData(format, length);
+ else
+ return NULL;
+ } else if (cbString) {
+ if (!strcmp(format, "TEXT"))
+ return copystring(cbString);
+ else
+ return NULL;
+ } else {
+ if (wxOpenClipboard()) {
+ receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
+ length);
+ wxCloseClipboard();
+ } else
+ receivedString = NULL;
+
+ return receivedString;
+ }
}
+#endif
wxColour& wxColour::operator =(const wxColour& col)
{
- m_red = col.m_red;
- m_green = col.m_green;
- m_blue = col.m_blue;
- m_isInit = col.m_isInit;
- m_pixel = col.m_pixel;
- return *this;
+ m_red = col.m_red;
+ m_green = col.m_green;
+ m_blue = col.m_blue;
+ m_isInit = col.m_isInit;
+ m_pixel = col.m_pixel;
+ return *this;
}
void wxColour::InitFromName(const wxString& col)
int wxColour::AllocColour(WXDisplay* display, bool realloc)
{
if ((m_pixel != -1) && !realloc)
- return m_pixel;
-
+ return m_pixel;
+
XColor color;
color.red = (unsigned short) Red ();
color.red |= color.red << 8;
color.green |= color.green << 8;
color.blue = (unsigned short) Blue ();
color.blue |= color.blue << 8;
-
+
color.flags = DoRed | DoGreen | DoBlue;
-
+
WXColormap cmap = wxTheApp->GetMainColormap(display);
-
+
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
{
- m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
- return m_pixel;
+ m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
+ return m_pixel;
}
else
{
- m_pixel = (int) color.pixel;
- return m_pixel;
+ m_pixel = (int) color.pixel;
+ return m_pixel;
}
}
Chris Breeze <chris@hel.co.uk>
Improvements:
1) More efficient calculation of RGB distance of colour cell from
- the desired colour. There is no need to take the sqrt of 'dist', and
- since we are only interested in the top 8-bits of R, G and B we
- can perform integer arithmetic.
+the desired colour. There is no need to take the sqrt of 'dist', and
+since we are only interested in the top 8-bits of R, G and B we
+can perform integer arithmetic.
2) Attempt to allocate a read-only colour when a close match is found.
- A read-only colour will not change.
+A read-only colour will not change.
3) Fall back to the closest match if no read-only colours are available.
-Possible further improvements:
-1) Scan the lookup table and sort the colour cells in order of
-increasing
- distance from the desired colour. Then attempt to allocate a
-read-only
- colour starting from the nearest match.
-2) Linear RGB distance is not a particularly good method of colour
-matching
- (though it is quick). Converting the colour to HLS and then comparing
- may give better matching.
+ Possible further improvements:
+ 1) Scan the lookup table and sort the colour cells in order of
+ increasing
+ distance from the desired colour. Then attempt to allocate a
+ read-only
+ colour starting from the nearest match.
+ 2) Linear RGB distance is not a particularly good method of colour
+ matching
+ (though it is quick). Converting the colour to HLS and then comparing
+ may give better matching.
-------------------------------------------*/
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap)
{
if (cmap == (Colormap) NULL)
- cmap = (Colormap) wxTheApp->GetMainColormap(display);
-
+ cmap = (Colormap) wxTheApp->GetMainColormap(display);
+
int numPixVals = XDisplayCells(display, DefaultScreen (display));
int mindist = 256 * 256 * 3;
int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
int green = desiredColor->green >> 8;
int blue = desiredColor->blue >> 8;
const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B
-
+
for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++)
{
XColor matching_color;
matching_color.pixel = pixelcount;
XQueryColor(display,cmap,&matching_color);
-
+
int delta_red = red - (matching_color.red >> 8);
int delta_green = green - (matching_color.green >> 8);
int delta_blue = blue - (matching_color.blue >> 8);
-
+
int dist = delta_red * delta_red +
- delta_green * delta_green +
- delta_blue * delta_blue;
-
+ delta_green * delta_green +
+ delta_blue * delta_blue;
+
if (dist <= threshold)
{
// try to allocate a read-only colour...
#include "xmcombo/xmcombo.h"
void wxComboBoxCallback (Widget w, XtPointer clientData,
- XmComboBoxSelectionCallbackStruct * cbs);
+ XmComboBoxSelectionCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
#endif
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size,
- int n, const wxString choices[],
- long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size,
+ int n, const wxString choices[],
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
// m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour();
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name,
- xmComboBoxWidgetClass, parentWidget,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- XmNshowLabel, False,
- XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
- XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
- XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
- NULL);
-
+ xmComboBoxWidgetClass, parentWidget,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNshowLabel, False,
+ XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
+ XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
+ XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
+ NULL);
+
XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback,
- (XtPointer) this);
+ (XtPointer) this);
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
- (XtPointer) this);
-
+ (XtPointer) this);
+
int i;
for (i = 0; i < n; i++)
{
m_stringList.Add(choices[i]);
}
m_noStrings = n;
-
+
m_mainWidget = (Widget) buttonWidget;
-
+
XtManageChild (buttonWidget);
-
+
SetValue(value);
-
+
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
-
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
wxNode *node = m_stringList.Nth(n);
if (node)
{
- delete[] (char *)node->Data();
- delete node;
+ delete[] (char *)node->Data();
+ delete node;
}
m_noStrings--;
}
int wxComboBox::GetSelection (void) const
{
- int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
- if (sel == 0)
- return -1;
- else
- return sel - 1;
+ int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
+ if (sel == 0)
+ return -1;
+ else
+ return sel - 1;
}
wxString wxComboBox::GetString(int n) const
{
wxNode *node = m_stringList.Nth (n);
if (node)
- return wxString((char *) node->Data ());
+ return wxString((char *) node->Data ());
else
- return wxEmptyString;
+ return wxEmptyString;
}
wxString wxComboBox::GetStringSelection() const
int wxComboBox::FindString(const wxString& s) const
{
- int *pos_list = NULL;
- int count = 0;
- XmString text = XmStringCreateSimple ((char*) (const char*) s);
- bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
- text, &pos_list, &count) != 0);
-
- XmStringFree(text);
-
- if (found && count > 0)
- {
- int pos = pos_list[0] - 1;
- free(pos_list);
- return pos;
- }
-
- return -1;
+ int *pos_list = NULL;
+ int count = 0;
+ XmString text = XmStringCreateSimple ((char*) (const char*) s);
+ bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
+ text, &pos_list, &count) != 0);
+
+ XmStringFree(text);
+
+ if (found && count > 0)
+ {
+ int pos = pos_list[0] - 1;
+ free(pos_list);
+ return pos;
+ }
+
+ return -1;
}
// Clipboard operations
void wxComboBox::Replace(long from, long to, const wxString& value)
{
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
- (char*) (const char*) value);
+ (char*) (const char*) value);
}
void wxComboBox::Remove(long from, long to)
}
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
- XmComboBoxSelectionCallbackStruct * cbs)
+ XmComboBoxSelectionCallbackStruct * cbs)
{
wxComboBox *item = (wxComboBox *) clientData;
-
+
switch (cbs->reason)
{
- case XmCR_SINGLE_SELECT:
- case XmCR_BROWSE_SELECT:
+ case XmCR_SINGLE_SELECT:
+ case XmCR_BROWSE_SELECT:
{
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId());
- event.m_commandInt = cbs->index - 1;
- // event.m_commandString = item->GetString (event.m_commandInt);
- event.m_extraLong = TRUE;
- event.SetEventObject(item);
- item->ProcessCommand (event);
- break;
+ event.m_commandInt = cbs->index - 1;
+ // event.m_commandString = item->GetString (event.m_commandInt);
+ event.m_extraLong = TRUE;
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
+ break;
}
- case XmCR_VALUE_CHANGED:
+ case XmCR_VALUE_CHANGED:
{
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
- event.m_commandInt = -1;
- // event.m_commandString = item->GetValue();
- event.m_extraLong = TRUE;
- event.SetEventObject(item);
- item->ProcessCommand (event);
+ event.m_commandInt = -1;
+ // event.m_commandString = item->GetValue();
+ event.m_extraLong = TRUE;
+ event.SetEventObject(item);
+ item->ProcessCommand (event);
break;
}
- default:
- break;
+ default:
+ break;
}
}
Widget widget = (Widget) GetLabelWidget() ;
if (!widget)
return;
-
+
wxStripMenuCodes((char*) (const char*) label, wxBuffer);
-
+
XmString text = XmStringCreateSimple (wxBuffer);
XtVaSetValues (widget,
- XmNlabelString, text,
- XmNlabelType, XmSTRING,
- NULL);
+ XmNlabelString, text,
+ XmNlabelType, XmSTRING,
+ NULL);
XmStringFree (text);
}
Widget widget = (Widget) GetLabelWidget() ;
if (!widget)
return wxEmptyString;
-
+
XmString text;
char *s;
XtVaGetValues (widget,
- XmNlabelString, &text,
- NULL);
-
+ XmNlabelString, &text,
+ NULL);
+
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{
wxString str(s);
void wxControl::ProcessCommand (wxCommandEvent & event)
{
- // Tries:
- // 1) A callback function (to become obsolete)
- // 2) OnCommand, starting at this window and working up parent hierarchy
- // 3) OnCommand then calls ProcessEvent to search the event tables.
- if (m_callback)
+ // Tries:
+ // 1) A callback function (to become obsolete)
+ // 2) OnCommand, starting at this window and working up parent hierarchy
+ // 3) OnCommand then calls ProcessEvent to search the event tables.
+ if (m_callback)
{
- (void) (*(m_callback)) (*this, event);
+ (void) (*(m_callback)) (*this, event);
}
else
{
- GetEventHandler()->OnCommand(*this, event);
+ GetEventHandler()->OnCommand(*this, event);
}
}
void wxControl::Centre (int direction)
{
- int x, y, width, height, panel_width, panel_height, new_x, new_y;
-
- wxWindow *parent = (wxWindow *) GetParent ();
- if (!parent)
- return;
-
- parent->GetClientSize (&panel_width, &panel_height);
- GetSize (&width, &height);
- GetPosition (&x, &y);
-
- new_x = x;
- new_y = y;
-
- if (direction & wxHORIZONTAL)
- new_x = (int) ((panel_width - width) / 2);
-
- if (direction & wxVERTICAL)
- new_y = (int) ((panel_height - height) / 2);
-
- SetSize (new_x, new_y, width, height);
+ int x, y, width, height, panel_width, panel_height, new_x, new_y;
+
+ wxWindow *parent = (wxWindow *) GetParent ();
+ if (!parent)
+ return;
+
+ parent->GetClientSize (&panel_width, &panel_height);
+ GetSize (&width, &height);
+ GetPosition (&x, &y);
+
+ new_x = x;
+ new_y = y;
+
+ if (direction & wxHORIZONTAL)
+ new_x = (int) ((panel_width - width) / 2);
+
+ if (direction & wxVERTICAL)
+ new_y = (int) ((panel_height - height) / 2);
+
+ SetSize (new_x, new_y, width, height);
}
wxDC::wxDC(void)
{
- m_ok = FALSE;
- m_optimize = FALSE;
- m_colour = TRUE;
- m_clipping = FALSE;
-
- m_mm_to_pix_x = 1.0;
- m_mm_to_pix_y = 1.0;
-
- m_logicalOriginX = 0;
- m_logicalOriginY = 0;
- m_deviceOriginX = 0;
- m_deviceOriginY = 0;
- m_internalDeviceOriginX = 0;
- m_internalDeviceOriginY = 0;
- m_externalDeviceOriginX = 0;
- m_externalDeviceOriginY = 0;
-
- m_logicalScaleX = 1.0;
- m_logicalScaleY = 1.0;
- m_userScaleX = 1.0;
- m_userScaleY = 1.0;
- m_scaleX = 1.0;
- m_scaleY = 1.0;
-
- m_mappingMode = MM_TEXT;
- m_needComputeScaleX = FALSE;
- m_needComputeScaleY = FALSE;
-
- m_signX = 1; // default x-axis left to right
- m_signY = 1; // default y-axis top down
-
- m_maxX = m_maxY = -100000;
- m_minY = m_minY = 100000;
-
- m_logicalFunction = wxCOPY;
-// m_textAlignment = wxALIGN_TOP_LEFT;
- m_backgroundMode = wxTRANSPARENT;
-
- m_textForegroundColour = *wxBLACK;
- m_textBackgroundColour = *wxWHITE;
- m_pen = *wxBLACK_PEN;
- m_font = *wxNORMAL_FONT;
- m_brush = *wxTRANSPARENT_BRUSH;
- m_backgroundBrush = *wxWHITE_BRUSH;
-
- m_isInteractive = FALSE;
-
-// m_palette = wxAPP_COLOURMAP;
+ m_ok = FALSE;
+ m_optimize = FALSE;
+ m_colour = TRUE;
+ m_clipping = FALSE;
+
+ m_mm_to_pix_x = 1.0;
+ m_mm_to_pix_y = 1.0;
+
+ m_logicalOriginX = 0;
+ m_logicalOriginY = 0;
+ m_deviceOriginX = 0;
+ m_deviceOriginY = 0;
+ m_internalDeviceOriginX = 0;
+ m_internalDeviceOriginY = 0;
+ m_externalDeviceOriginX = 0;
+ m_externalDeviceOriginY = 0;
+
+ m_logicalScaleX = 1.0;
+ m_logicalScaleY = 1.0;
+ m_userScaleX = 1.0;
+ m_userScaleY = 1.0;
+ m_scaleX = 1.0;
+ m_scaleY = 1.0;
+
+ m_mappingMode = MM_TEXT;
+ m_needComputeScaleX = FALSE;
+ m_needComputeScaleY = FALSE;
+
+ m_signX = 1; // default x-axis left to right
+ m_signY = 1; // default y-axis top down
+
+ m_maxX = m_maxY = -100000;
+ m_minY = m_minY = 100000;
+
+ m_logicalFunction = wxCOPY;
+ // m_textAlignment = wxALIGN_TOP_LEFT;
+ m_backgroundMode = wxTRANSPARENT;
+
+ m_textForegroundColour = *wxBLACK;
+ m_textBackgroundColour = *wxWHITE;
+ m_pen = *wxBLACK_PEN;
+ m_font = *wxNORMAL_FONT;
+ m_brush = *wxTRANSPARENT_BRUSH;
+ m_backgroundBrush = *wxWHITE_BRUSH;
+
+ m_isInteractive = FALSE;
+
+ // m_palette = wxAPP_COLOURMAP;
};
wxDC::~wxDC(void)
{
if (!bitmap.Ok())
return;
-
+
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
-
-/* Not sure if we need this. The mask should leave the
- * masked areas as per the original background of this DC.
+
+ /* Not sure if we need this. The mask should leave the
+ * masked areas as per the original background of this DC.
if (useMask)
{
- // There might be transparent areas, so make these
- // the same colour as this DC
- memDC.SetBackground(* GetBackground());
- memDC.Clear();
+ // There might be transparent areas, so make these
+ // the same colour as this DC
+ memDC.SetBackground(* GetBackground());
+ memDC.Clear();
}
-*/
-
+ */
+
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask);
-
+
memDC.SelectObject(wxNullBitmap);
};
void wxDC::DrawPoint( wxPoint& point )
{
- DrawPoint( point.x, point.y );
+ DrawPoint( point.x, point.y );
};
void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
{
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for( wxNode *node = list->First(); node; node = node->Next() )
- {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- };
- DrawPolygon( n, points, xoffset, yoffset, fillStyle );
- delete[] points;
+ int n = list->Number();
+ wxPoint *points = new wxPoint[n];
+
+ int i = 0;
+ for( wxNode *node = list->First(); node; node = node->Next() )
+ {
+ wxPoint *point = (wxPoint *)node->Data();
+ points[i].x = point->x;
+ points[i++].y = point->y;
+ };
+ DrawPolygon( n, points, xoffset, yoffset, fillStyle );
+ delete[] points;
};
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
{
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for( wxNode *node = list->First(); node; node = node->Next() )
- {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- };
- DrawLines( n, points, xoffset, yoffset );
- delete []points;
+ int n = list->Number();
+ wxPoint *points = new wxPoint[n];
+
+ int i = 0;
+ for( wxNode *node = list->First(); node; node = node->Next() )
+ {
+ wxPoint *point = (wxPoint *)node->Data();
+ points[i].x = point->x;
+ points[i++].y = point->y;
+ };
+ DrawLines( n, points, xoffset, yoffset );
+ delete []points;
};
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{
- wxList list;
- list.Append( (wxObject*)new wxPoint(x1, y1) );
- list.Append( (wxObject*)new wxPoint(x2, y2) );
- list.Append( (wxObject*)new wxPoint(x3, y3) );
- DrawSpline(&list);
- wxNode *node = list.First();
- while (node)
- {
- wxPoint *p = (wxPoint*)node->Data();
- delete p;
- node = node->Next();
- };
+ wxList list;
+ list.Append( (wxObject*)new wxPoint(x1, y1) );
+ list.Append( (wxObject*)new wxPoint(x2, y2) );
+ list.Append( (wxObject*)new wxPoint(x3, y3) );
+ DrawSpline(&list);
+ wxNode *node = list.First();
+ while (node)
+ {
+ wxPoint *p = (wxPoint*)node->Data();
+ delete p;
+ node = node->Next();
+ };
};
void wxDC::DrawSpline( int n, wxPoint points[] )
{
- wxList list;
- for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
- DrawSpline( &list );
+ wxList list;
+ for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
+ DrawSpline( &list );
};
void wxDC::SetClippingRegion( long x, long y, long width, long height )
{
- m_clipping = TRUE;
- m_clipX1 = x;
- m_clipY1 = y;
- m_clipX2 = x + width;
- m_clipY2 = y + height;
+ m_clipping = TRUE;
+ m_clipX1 = x;
+ m_clipY1 = y;
+ m_clipX2 = x + width;
+ m_clipY2 = y + height;
};
void wxDC::DestroyClippingRegion(void)
{
- m_clipping = FALSE;
+ m_clipping = FALSE;
};
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
{
- if (m_clipping)
- {
- if (x) *x = m_clipX1;
- if (y) *y = m_clipY1;
- if (width) *width = (m_clipX2 - m_clipX1);
- if (height) *height = (m_clipY2 - m_clipY1);
- }
- else
- *x = *y = *width = *height = 0;
+ if (m_clipping)
+ {
+ if (x) *x = m_clipX1;
+ if (y) *y = m_clipY1;
+ if (width) *width = (m_clipX2 - m_clipX1);
+ if (height) *height = (m_clipY2 - m_clipY1);
+ }
+ else
+ *x = *y = *width = *height = 0;
};
void wxDC::GetSize( int* width, int* height ) const
{
- *width = m_maxX-m_minX;
- *height = m_maxY-m_minY;
+ *width = m_maxX-m_minX;
+ *height = m_maxY-m_minY;
};
void wxDC::GetSizeMM( long* width, long* height ) const
{
- int w = 0;
- int h = 0;
- GetSize( &w, &h );
- *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
- *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
+ int w = 0;
+ int h = 0;
+ GetSize( &w, &h );
+ *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
+ *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
};
void wxDC::SetTextForeground( const wxColour &col )
{
- if (!Ok()) return;
- m_textForegroundColour = col;
+ if (!Ok()) return;
+ m_textForegroundColour = col;
};
void wxDC::SetTextBackground( const wxColour &col )
{
- if (!Ok()) return;
- m_textBackgroundColour = col;
+ if (!Ok()) return;
+ m_textBackgroundColour = col;
};
void wxDC::SetMapMode( int mode )
{
- switch (mode)
- {
+ switch (mode)
+ {
case MM_TWIPS:
- SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
- break;
+ SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
+ break;
case MM_POINTS:
- SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
- break;
+ SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
+ break;
case MM_METRIC:
- SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
- break;
+ SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
+ break;
case MM_LOMETRIC:
- SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
- break;
+ SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
+ break;
default:
case MM_TEXT:
- SetLogicalScale( 1.0, 1.0 );
- break;
- };
- if (mode != MM_TEXT)
- {
- m_needComputeScaleX = TRUE;
- m_needComputeScaleY = TRUE;
- };
+ SetLogicalScale( 1.0, 1.0 );
+ break;
+ };
+ if (mode != MM_TEXT)
+ {
+ m_needComputeScaleX = TRUE;
+ m_needComputeScaleY = TRUE;
+ };
};
void wxDC::SetUserScale( double x, double y )
{
- // allow negative ? -> no
- m_userScaleX = x;
- m_userScaleY = y;
- ComputeScaleAndOrigin();
+ // allow negative ? -> no
+ m_userScaleX = x;
+ m_userScaleY = y;
+ ComputeScaleAndOrigin();
};
void wxDC::GetUserScale( double *x, double *y )
{
- if (x) *x = m_userScaleX;
- if (y) *y = m_userScaleY;
+ if (x) *x = m_userScaleX;
+ if (y) *y = m_userScaleY;
};
void wxDC::SetLogicalScale( double x, double y )
{
- // allow negative ?
- m_logicalScaleX = x;
- m_logicalScaleY = y;
- ComputeScaleAndOrigin();
+ // allow negative ?
+ m_logicalScaleX = x;
+ m_logicalScaleY = y;
+ ComputeScaleAndOrigin();
};
void wxDC::GetLogicalScale( double *x, double *y )
{
- if (x) *x = m_logicalScaleX;
- if (y) *y = m_logicalScaleY;
+ if (x) *x = m_logicalScaleX;
+ if (y) *y = m_logicalScaleY;
};
void wxDC::SetLogicalOrigin( long x, long y )
{
- m_logicalOriginX = x * m_signX; // is this still correct ?
- m_logicalOriginY = y * m_signY;
- ComputeScaleAndOrigin();
+ m_logicalOriginX = x * m_signX; // is this still correct ?
+ m_logicalOriginY = y * m_signY;
+ ComputeScaleAndOrigin();
};
void wxDC::GetLogicalOrigin( long *x, long *y )
{
- if (x) *x = m_logicalOriginX;
- if (y) *y = m_logicalOriginY;
+ if (x) *x = m_logicalOriginX;
+ if (y) *y = m_logicalOriginY;
};
void wxDC::SetDeviceOrigin( long x, long y )
{
- m_externalDeviceOriginX = x;
- m_externalDeviceOriginY = y;
- ComputeScaleAndOrigin();
+ m_externalDeviceOriginX = x;
+ m_externalDeviceOriginY = y;
+ ComputeScaleAndOrigin();
};
void wxDC::GetDeviceOrigin( long *x, long *y )
{
-// if (x) *x = m_externalDeviceOriginX;
-// if (y) *y = m_externalDeviceOriginY;
- if (x) *x = m_deviceOriginX;
- if (y) *y = m_deviceOriginY;
+ // if (x) *x = m_externalDeviceOriginX;
+ // if (y) *y = m_externalDeviceOriginY;
+ if (x) *x = m_deviceOriginX;
+ if (y) *y = m_deviceOriginY;
};
void wxDC::SetInternalDeviceOrigin( long x, long y )
{
- m_internalDeviceOriginX = x;
- m_internalDeviceOriginY = y;
- ComputeScaleAndOrigin();
+ m_internalDeviceOriginX = x;
+ m_internalDeviceOriginY = y;
+ ComputeScaleAndOrigin();
};
void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{
- if (x) *x = m_internalDeviceOriginX;
- if (y) *y = m_internalDeviceOriginY;
+ if (x) *x = m_internalDeviceOriginX;
+ if (y) *y = m_internalDeviceOriginY;
};
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
- m_signX = (xLeftRight ? 1 : -1);
- m_signY = (yBottomUp ? -1 : 1);
- ComputeScaleAndOrigin();
+ m_signX = (xLeftRight ? 1 : -1);
+ m_signY = (yBottomUp ? -1 : 1);
+ ComputeScaleAndOrigin();
};
long wxDC::DeviceToLogicalX(long x) const
{
- return XDEV2LOG(x);
+ return XDEV2LOG(x);
};
long wxDC::DeviceToLogicalY(long y) const
{
- return YDEV2LOG(y);
+ return YDEV2LOG(y);
};
long wxDC::DeviceToLogicalXRel(long x) const
{
- return XDEV2LOGREL(x);
+ return XDEV2LOGREL(x);
};
long wxDC::DeviceToLogicalYRel(long y) const
{
- return YDEV2LOGREL(y);
+ return YDEV2LOGREL(y);
};
long wxDC::LogicalToDeviceX(long x) const
{
- return XLOG2DEV(x);
+ return XLOG2DEV(x);
};
long wxDC::LogicalToDeviceY(long y) const
{
- return YLOG2DEV(y);
+ return YLOG2DEV(y);
};
long wxDC::LogicalToDeviceXRel(long x) const
{
- return XLOG2DEVREL(x);
+ return XLOG2DEVREL(x);
};
long wxDC::LogicalToDeviceYRel(long y) const
{
- return YLOG2DEVREL(y);
+ return YLOG2DEVREL(y);
};
-
+
void wxDC::CalcBoundingBox( long x, long y )
{
- if (x < m_minX) m_minX = x;
- if (y < m_minY) m_minY = y;
- if (x > m_maxX) m_maxX = x;
- if (y > m_maxY) m_maxY = y;
+ if (x < m_minX) m_minX = x;
+ if (y < m_minY) m_minY = y;
+ if (x > m_maxX) m_maxX = x;
+ if (y > m_maxY) m_maxY = y;
};
void wxDC::ComputeScaleAndOrigin(void)
{
- // CMB: copy scale to see if it changes
- double origScaleX = m_scaleX;
- double origScaleY = m_scaleY;
-
- m_scaleX = m_logicalScaleX * m_userScaleX;
- m_scaleY = m_logicalScaleY * m_userScaleY;
-
- m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
- m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
-
- // CMB: if scale has changed call SetPen to recalulate the line width
- if (m_scaleX != origScaleX || m_scaleY != origScaleY)
- {
- // this is a bit artificial, but we need to force wxDC to think
- // the pen has changed
- wxPen* pen = & GetPen();
- wxPen tempPen;
- m_pen = tempPen;
- SetPen(* pen);
- }
+ // CMB: copy scale to see if it changes
+ double origScaleX = m_scaleX;
+ double origScaleY = m_scaleY;
+
+ m_scaleX = m_logicalScaleX * m_userScaleX;
+ m_scaleY = m_logicalScaleY * m_userScaleY;
+
+ m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
+ m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
+
+ // CMB: if scale has changed call SetPen to recalulate the line width
+ if (m_scaleX != origScaleX || m_scaleY != origScaleY)
+ {
+ // this is a bit artificial, but we need to force wxDC to think
+ // the pen has changed
+ wxPen* pen = & GetPen();
+ wxPen tempPen;
+ m_pen = tempPen;
+ SetPen(* pen);
+ }
};
/////////////////////////////////////////////////////////////////////////////
/*
- About pens, brushes, and the autoSetting flag:
-
- Under X, pens and brushes control some of the same X drawing
- parameters. Therefore, it is impossible to independently maintain
- the current pen and the current brush. Also, some settings depend
- on the current logical function. The m_currentFill, etc. instance
- variables remember state across the brush and pen.
-
- Since pens are used more than brushes, the autoSetting flag
- is used to indicate that a brush was recently used, and SetPen
- must be called to reinstall the current pen's parameters.
- If autoSetting includes 0x2, then the pens color may need
- to be set based on XOR.
-
- There is, unfortunately, some confusion between setting the
- current pen/brush and actually installing the brush/pen parameters.
- Both functionalies are perform by SetPen and SetBrush. C'est la vie.
+About pens, brushes, and the autoSetting flag:
+
+ Under X, pens and brushes control some of the same X drawing
+ parameters. Therefore, it is impossible to independently maintain
+ the current pen and the current brush. Also, some settings depend
+ on the current logical function. The m_currentFill, etc. instance
+ variables remember state across the brush and pen.
+
+ Since pens are used more than brushes, the autoSetting flag
+ is used to indicate that a brush was recently used, and SetPen
+ must be called to reinstall the current pen's parameters.
+ If autoSetting includes 0x2, then the pens color may need
+ to be set based on XOR.
+
+ There is, unfortunately, some confusion between setting the
+ current pen/brush and actually installing the brush/pen parameters.
+ Both functionalies are perform by SetPen and SetBrush. C'est la vie.
*/
#ifdef __GNUG__
#define RAD2DEG 57.2957795131
// Fudge factor. Obsolete?
- // No. Robert Roebling
+// No. Robert Roebling
#define WX_GC_CF 1
//-----------------------------------------------------------------------------
m_currentPenDash = (char*) NULL;
m_currentStyle = -1;
m_currentFill = -1;
-// m_currentBkMode = wxTRANSPARENT;
+ // m_currentBkMode = wxTRANSPARENT;
m_colour = wxColourDisplay();
m_display = (WXDisplay*) NULL;
m_currentRegion = (WXRegion) 0;
wxWindowDC::wxWindowDC( wxWindow *window )
{
wxASSERT_MSG( (window != (wxWindow*) NULL), "You must pass a valid wxWindow to wxWindowDC/wxClientDC/wxPaintDC constructor." );
-
+
m_window = window;
m_gc = (WXGC) 0;
m_gcBacking = (WXGC) 0;
m_currentPenDash = (char*) NULL;
m_currentStyle = -1;
m_currentFill = -1;
-// m_currentBkMode = wxTRANSPARENT;
+ // m_currentBkMode = wxTRANSPARENT;
m_colour = wxColourDisplay();
m_currentRegion = (WXRegion) 0;
m_userRegion = (WXRegion) 0;
m_ok = TRUE;
m_autoSetting = 0;
-
+
m_display = window->GetXDisplay();
m_pixmap = window->GetXWindow();
Display* display = (Display*) m_display;
-
+
XSetWindowColormap (display, (Pixmap) m_pixmap, (Colormap) wxTheApp->GetMainColormap(m_display));
-
+
XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display));
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
- &gcvalues);
-
+ &gcvalues);
+
if (m_window->GetBackingPixmap())
{
- m_gcBacking = (WXGC) XCreateGC (display, RootWindow (display,
- DefaultScreen (display)),
- GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
- &gcvalues);
+ m_gcBacking = (WXGC) XCreateGC (display, RootWindow (display,
+ DefaultScreen (display)),
+ GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
+ &gcvalues);
}
-
+
m_backgroundPixel = (int) gcvalues.background;
-
+
// Get the current Font so we can set it back later
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
{
if (m_gc && (m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
{
- XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+ XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
}
-
+
if (m_gc)
XFreeGC ((Display*) m_display, (GC) m_gc);
m_gc = (WXGC) 0;
-
+
if (m_gcBacking)
XFreeGC ((Display*) m_display, (GC) m_gcBacking);
m_gcBacking = (WXGC) 0;
-
+
if (m_currentRegion)
XDestroyRegion ((Region) m_currentRegion);
m_currentRegion = (WXRegion) 0;
-
+
if (m_userRegion)
XDestroyRegion ((Region) m_userRegion);
m_userRegion = (WXRegion) 0;
};
void wxWindowDC::FloodFill( long WXUNUSED(x1), long WXUNUSED(y1),
- const wxColour& WXUNUSED(col), int WXUNUSED(style) )
+ const wxColour& WXUNUSED(col), int WXUNUSED(style) )
{
- // TODO
+ // TODO
};
bool wxWindowDC::GetPixel( long WXUNUSED(x1), long WXUNUSED(y1), wxColour *WXUNUSED(col) ) const
{
- // TODO
- return FALSE;
+ // TODO
+ return FALSE;
};
void wxWindowDC::DrawLine( long x1, long y1, long x2, long y2 )
{
- if (!Ok()) return;
-
- int x1d, y1d, x2d, y2d;
-
- // FreeGetPixelCache();
-
- x1d = XLOG2DEV(x1);
- y1d = YLOG2DEV(y1);
- x2d = XLOG2DEV(x2);
- y2d = YLOG2DEV(y2);
-
- if (m_autoSetting)
- SetPen (m_pen);
-
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x1d, y1d, x2d, y2d);
-
- if (m_window && m_window->GetBackingPixmap())
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- XLOG2DEV_2(x1), YLOG2DEV_2(y1),
- XLOG2DEV_2(x2), YLOG2DEV_2(y2));
-
- CalcBoundingBox(x1, y1);
- CalcBoundingBox(x2, y2);
+ if (!Ok()) return;
+
+ int x1d, y1d, x2d, y2d;
+
+ // FreeGetPixelCache();
+
+ x1d = XLOG2DEV(x1);
+ y1d = YLOG2DEV(y1);
+ x2d = XLOG2DEV(x2);
+ y2d = YLOG2DEV(y2);
+
+ if (m_autoSetting)
+ SetPen (m_pen);
+
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x1d, y1d, x2d, y2d);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2(x1), YLOG2DEV_2(y1),
+ XLOG2DEV_2(x2), YLOG2DEV_2(y2));
+
+ CalcBoundingBox(x1, y1);
+ CalcBoundingBox(x2, y2);
};
void wxWindowDC::CrossHair( long x, long y )
{
- if (!Ok()) return;
-
- if (m_autoSetting)
- SetPen (m_pen);
-
- int xx = XLOG2DEV (x);
- int yy = YLOG2DEV (y);
- int ww, hh;
- wxDisplaySize (&ww, &hh);
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, yy,
- ww, yy);
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xx, 0,
- xx, hh);
-
- if (m_window && m_window->GetBackingPixmap())
+ if (!Ok()) return;
+
+ if (m_autoSetting)
+ SetPen (m_pen);
+
+ int xx = XLOG2DEV (x);
+ int yy = YLOG2DEV (y);
+ int ww, hh;
+ wxDisplaySize (&ww, &hh);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, yy,
+ ww, yy);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xx, 0,
+ xx, hh);
+
+ if (m_window && m_window->GetBackingPixmap())
{
- xx = XLOG2DEV_2 (x);
- yy = YLOG2DEV_2 (y);
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- 0, yy,
- ww, yy);
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- xx, 0,
- xx, hh);
+ xx = XLOG2DEV_2 (x);
+ yy = YLOG2DEV_2 (y);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ 0, yy,
+ ww, yy);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xx, 0,
+ xx, hh);
}
};
void wxWindowDC::DrawArc( long x1, long y1, long x2, long y2, long xc, long yc )
{
- if (!Ok()) return;
-
-// FreeGetPixelCache();
-
- int xx1 = XLOG2DEV (x1);
- int yy1 = YLOG2DEV (y1);
- int xx2 = XLOG2DEV (x2);
- int yy2 = YLOG2DEV (y2);
- int xxc = XLOG2DEV (xc);
- int yyc = YLOG2DEV (yc);
- int xxc_2 = XLOG2DEV_2 (xc);
- int yyc_2 = YLOG2DEV_2 (yc);
-
- long dx = xx1 - xxc;
- long dy = yy1 - yyc;
- double radius = sqrt (dx * dx + dy * dy);
- long r = (long) radius;
-
- double radius1, radius2;
-
- if (xx1 == xx2 && yy1 == yy2)
+ if (!Ok()) return;
+
+ // FreeGetPixelCache();
+
+ int xx1 = XLOG2DEV (x1);
+ int yy1 = YLOG2DEV (y1);
+ int xx2 = XLOG2DEV (x2);
+ int yy2 = YLOG2DEV (y2);
+ int xxc = XLOG2DEV (xc);
+ int yyc = YLOG2DEV (yc);
+ int xxc_2 = XLOG2DEV_2 (xc);
+ int yyc_2 = YLOG2DEV_2 (yc);
+
+ long dx = xx1 - xxc;
+ long dy = yy1 - yyc;
+ double radius = sqrt (dx * dx + dy * dy);
+ long r = (long) radius;
+
+ double radius1, radius2;
+
+ if (xx1 == xx2 && yy1 == yy2)
{
- radius1 = 0.0;
- radius2 = 360.0;
+ radius1 = 0.0;
+ radius2 = 360.0;
}
- else if (radius == 0.0)
- radius1 = radius2 = 0.0;
- else
- {
- if (xx1 - xxc == 0)
- if (yy1 - yyc < 0)
- radius1 = 90.0;
- else
- radius1 = -90.0;
- else
- radius1 = -atan2 ((double) (yy1 - yyc), (double) (xx1 - xxc)) * 360.0 / (2 * M_PI);
-
- if (xx2 - xxc == 0)
- if (yy2 - yyc < 0)
- radius2 = 90.0;
+ else if (radius == 0.0)
+ radius1 = radius2 = 0.0;
else
- radius2 = -90.0;
- else
- radius2 = -atan2 ((double) (yy2 - yyc), (double) (xx2 - xxc)) * 360.0 / (2 * M_PI);
+ {
+ if (xx1 - xxc == 0)
+ if (yy1 - yyc < 0)
+ radius1 = 90.0;
+ else
+ radius1 = -90.0;
+ else
+ radius1 = -atan2 ((double) (yy1 - yyc), (double) (xx1 - xxc)) * 360.0 / (2 * M_PI);
+
+ if (xx2 - xxc == 0)
+ if (yy2 - yyc < 0)
+ radius2 = 90.0;
+ else
+ radius2 = -90.0;
+ else
+ radius2 = -atan2 ((double) (yy2 - yyc), (double) (xx2 - xxc)) * 360.0 / (2 * M_PI);
}
- radius1 *= 64.0;
- radius2 *= 64.0;
- int alpha1 = (int) radius1;
- int alpha2 = (int) (radius2 - radius1);
- while (alpha2 <= 0)
- alpha2 += 360 * 64;
- while (alpha2 > 360 * 64)
- alpha2 -= 360 * 64;
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ radius1 *= 64.0;
+ radius2 *= 64.0;
+ int alpha1 = (int) radius1;
+ int alpha2 = (int) (radius2 - radius1);
+ while (alpha2 <= 0)
+ alpha2 += 360 * 64;
+ while (alpha2 > 360 * 64)
+ alpha2 -= 360 * 64;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
- SetBrush (m_brush);
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc,
- xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
-
- if (m_window && m_window->GetBackingPixmap())
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
-
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) (GC) m_gc,
+ xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
+
}
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
if (m_autoSetting)
SetPen (m_pen);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
- xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
-
- if (m_window && m_window->GetBackingPixmap())
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc,
+ xxc - r, yyc - r, 2 * r, 2 * r, alpha1, alpha2);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ xxc_2 - r, yyc_2 - r, 2 * r, 2 * r, alpha1, alpha2);
}
- CalcBoundingBox (x1, y1);
- CalcBoundingBox (x2, y2);
+ CalcBoundingBox (x1, y1);
+ CalcBoundingBox (x2, y2);
};
void wxWindowDC::DrawEllipticArc( long x, long y, long width, long height, double sa, double ea )
{
- if (!Ok()) return;
-
- int xd, yd, wd, hd;
-
- xd = XLOG2DEV(x);
- yd = YLOG2DEV(y);
- wd = XLOG2DEVREL(width);
- hd = YLOG2DEVREL(height);
-
- if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
- if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
- int start = int(sa*64);
- int end = int(ea*64);
- if (start<0) start+=360*64;
- if (end <0) end +=360*64;
- if (end>start) end-=start;
- else end+=360*64-start;
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ if (!Ok()) return;
+
+ int xd, yd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wd = XLOG2DEVREL(width);
+ hd = YLOG2DEVREL(height);
+
+ if (sa>=360 || sa<=-360) sa=sa-int(sa/360)*360;
+ if (ea>=360 || ea<=-360) ea=ea-int(ea/360)*360;
+ int start = int(sa*64);
+ int end = int(ea*64);
+ if (start<0) start+=360*64;
+ if (end <0) end +=360*64;
+ if (end>start) end-=start;
+ else end+=360*64-start;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
- m_autoSetting = TRUE; // must be reset
-
- SetBrush (m_brush);
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start, end);
-
- if (m_window && m_window->GetBackingPixmap())
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
+ m_autoSetting = TRUE; // must be reset
+
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start, end);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
}
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
- if (m_autoSetting)
- SetPen (m_pen);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start,end);
- if (m_window && m_window->GetBackingPixmap())
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, start,end);
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),wd,hd,start,end);
}
- CalcBoundingBox (x, y);
- CalcBoundingBox (x + width, y + height);
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
};
void wxWindowDC::DrawPoint( long x, long y )
{
- if (!Ok()) return;
-
-// FreeGetPixelCache();
-
- if (m_pen.Ok() && m_autoSetting)
- SetPen (m_pen);
-
- XDrawPoint ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y));
- if (m_window && m_window->GetBackingPixmap())
- XDrawPoint ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y));
-
- CalcBoundingBox (x, y);
+ if (!Ok()) return;
+
+ // FreeGetPixelCache();
+
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
+
+ XDrawPoint ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y));
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawPoint ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, XLOG2DEV_2 (x), YLOG2DEV_2 (y));
+
+ CalcBoundingBox (x, y);
};
void wxWindowDC::DrawLines( int n, wxPoint points[], long xoffset, long yoffset )
{
- if (!Ok()) return;
-
-// FreeGetPixelCache();
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
- {
- if (m_autoSetting)
- SetPen (m_pen);
-
- XPoint *xpoints = new XPoint[n];
- int i;
-
- for (i = 0; i < n; i++)
- {
- xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
- xpoints[i].y = YLOG2DEV (points[i].y + yoffset);
- }
- XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0);
-
- if (m_window && m_window->GetBackingPixmap())
+ if (!Ok()) return;
+
+ // FreeGetPixelCache();
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
- for (i = 0; i < n; i++)
+ if (m_autoSetting)
+ SetPen (m_pen);
+
+ XPoint *xpoints = new XPoint[n];
+ int i;
+
+ for (i = 0; i < n; i++)
{
- xpoints[i].x = XLOG2DEV_2 (points[i].x + xoffset);
- xpoints[i].y = YLOG2DEV_2 (points[i].y + yoffset);
+ xpoints[i].x = XLOG2DEV (points[i].x + xoffset);
+ xpoints[i].y = YLOG2DEV (points[i].y + yoffset);
+ }
+ XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints, n, 0);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ for (i = 0; i < n; i++)
+ {
+ xpoints[i].x = XLOG2DEV_2 (points[i].x + xoffset);
+ xpoints[i].y = YLOG2DEV_2 (points[i].y + yoffset);
+ }
+ XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints, n, 0);
}
- XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints, n, 0);
+ delete[]xpoints;
}
- delete[]xpoints;
- }
};
void wxWindowDC::DrawLines( wxList *list, long xoffset, long yoffset )
{
- if (!Ok()) return;
-
- if (m_pen.GetStyle() == wxTRANSPARENT) return;
-
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for(wxNode *node = list->First(); node; node = node->Next()) {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- }
- DrawLines(n, points, xoffset, yoffset);
- delete []points;
+ if (!Ok()) return;
+
+ if (m_pen.GetStyle() == wxTRANSPARENT) return;
+
+ int n = list->Number();
+ wxPoint *points = new wxPoint[n];
+
+ int i = 0;
+ for(wxNode *node = list->First(); node; node = node->Next()) {
+ wxPoint *point = (wxPoint *)node->Data();
+ points[i].x = point->x;
+ points[i++].y = point->y;
+ }
+ DrawLines(n, points, xoffset, yoffset);
+ delete []points;
};
void wxWindowDC::DrawPolygon( int n, wxPoint points[],
- long xoffset, long yoffset, int fillStyle )
+ long xoffset, long yoffset, int fillStyle )
{
-// FreeGetPixelCache();
-
- XPoint *xpoints1 = new XPoint[n + 1];
- XPoint *xpoints2 = new XPoint[n + 1];
- int i;
- for (i = 0; i < n; i++)
+ // FreeGetPixelCache();
+
+ XPoint *xpoints1 = new XPoint[n + 1];
+ XPoint *xpoints2 = new XPoint[n + 1];
+ int i;
+ for (i = 0; i < n; i++)
{
- xpoints1[i].x = XLOG2DEV (points[i].x + xoffset);
- xpoints1[i].y = YLOG2DEV (points[i].y + yoffset);
- xpoints2[i].x = XLOG2DEV_2 (points[i].x + xoffset);
- xpoints2[i].y = YLOG2DEV_2 (points[i].y + yoffset);
- CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
+ xpoints1[i].x = XLOG2DEV (points[i].x + xoffset);
+ xpoints1[i].y = YLOG2DEV (points[i].y + yoffset);
+ xpoints2[i].x = XLOG2DEV_2 (points[i].x + xoffset);
+ xpoints2[i].y = YLOG2DEV_2 (points[i].y + yoffset);
+ CalcBoundingBox (points[i].x + xoffset, points[i].y + yoffset);
}
-
- // Close figure for XDrawLines (not needed for XFillPolygon)
- xpoints1[i].x = xpoints1[0].x;
- xpoints1[i].y = xpoints1[0].y;
- xpoints2[i].x = xpoints2[0].x;
- xpoints2[i].y = xpoints2[0].y;
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+
+ // Close figure for XDrawLines (not needed for XFillPolygon)
+ xpoints1[i].x = xpoints1[0].x;
+ xpoints1[i].y = xpoints1[0].y;
+ xpoints2[i].x = xpoints2[0].x;
+ xpoints2[i].y = xpoints2[0].y;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
- SetBrush (m_brush);
- XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
- XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n, Complex, 0);
- XSetFillRule ((Display*) m_display, (GC) m_gc, EvenOddRule); // default mode
- if (m_window && m_window->GetBackingPixmap())
- {
- XSetFillRule ((Display*) m_display,(GC) m_gcBacking,
- fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
- XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n, Complex, 0);
- XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode
- }
- }
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ SetBrush (m_brush);
+ XSetFillRule ((Display*) m_display, (GC) m_gc, fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
+ XFillPolygon ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n, Complex, 0);
+ XSetFillRule ((Display*) m_display, (GC) m_gc, EvenOddRule); // default mode
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XSetFillRule ((Display*) m_display,(GC) m_gcBacking,
+ fillStyle == wxODDEVEN_RULE ? EvenOddRule : WindingRule);
+ XFillPolygon ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n, Complex, 0);
+ XSetFillRule ((Display*) m_display,(GC) m_gcBacking, EvenOddRule); // default mode
+ }
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
- if (m_autoSetting)
- SetPen (m_pen);
- XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0);
-
- if (m_window && m_window->GetBackingPixmap())
- XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0);
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawLines ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xpoints1, n + 1, 0);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawLines ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, xpoints2, n + 1, 0);
}
-
- delete[]xpoints1;
- delete[]xpoints2;
+
+ delete[]xpoints1;
+ delete[]xpoints2;
};
void wxWindowDC::DrawPolygon( wxList *list, long xoffset,
long yoffset, int fillStyle )
{
- if (!Ok()) return;
-
- int n = list->Number();
- wxPoint *points = new wxPoint[n];
-
- int i = 0;
- for(wxNode *node = list->First(); node; node = node->Next()) {
- wxPoint *point = (wxPoint *)node->Data();
- points[i].x = point->x;
- points[i++].y = point->y;
- }
- DrawPolygon(n, points, xoffset, yoffset,fillStyle);
- delete[] points;
+ if (!Ok()) return;
+
+ int n = list->Number();
+ wxPoint *points = new wxPoint[n];
+
+ int i = 0;
+ for(wxNode *node = list->First(); node; node = node->Next()) {
+ wxPoint *point = (wxPoint *)node->Data();
+ points[i].x = point->x;
+ points[i++].y = point->y;
+ }
+ DrawPolygon(n, points, xoffset, yoffset,fillStyle);
+ delete[] points;
};
void wxWindowDC::DrawRectangle( long x, long y, long width, long height )
{
- if (!Ok()) return;
-
-// FreeGetPixelCache();
-
- int xd, yd, wfd, hfd, wd, hd;
-
- xd = XLOG2DEV(x);
- yd = YLOG2DEV(y);
- wfd = XLOG2DEVREL(width);
- wd = wfd - WX_GC_CF;
- hfd = YLOG2DEVREL(height);
- hd = hfd - WX_GC_CF;
-
- if (wfd == 0 || hfd == 0) return;
- if (wd < 0) { wd = - wd; xd = xd - wd; }
- if (hd < 0) { hd = - hd; yd = yd - hd; }
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ if (!Ok()) return;
+
+ // FreeGetPixelCache();
+
+ int xd, yd, wfd, hfd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wfd = XLOG2DEVREL(width);
+ wd = wfd - WX_GC_CF;
+ hfd = YLOG2DEVREL(height);
+ hd = hfd - WX_GC_CF;
+
+ if (wfd == 0 || hfd == 0) return;
+ if (wd < 0) { wd = - wd; xd = xd - wd; }
+ if (hd < 0) { hd = - hd; yd = yd - hd; }
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
{
- SetBrush (m_brush);
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd);
-
- if (m_window && m_window->GetBackingPixmap())
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ SetBrush (m_brush);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wfd, hfd);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y),
wfd, hfd);
}
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
{
- if (m_autoSetting)
- SetPen (m_pen);
- XDrawRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd);
-
- if (m_window && m_window->GetBackingPixmap())
- XDrawRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y),
wd, hd);
}
- CalcBoundingBox (x, y);
- CalcBoundingBox (x + width, y + height);
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
};
void wxWindowDC::DrawRoundedRectangle( long x, long y, long width, long height, double radius )
{
- if (!Ok()) return;
-
-// FreeGetPixelCache();
-
- // If radius is negative, it's a proportion of the smaller dimension.
-
- if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
-
- int xd = XLOG2DEV (x);
- int yd = YLOG2DEV (y);
- int rd = XLOG2DEVREL ((long) radius);
- int wd = XLOG2DEVREL (width) - WX_GC_CF;
- int hd = YLOG2DEVREL (height) - WX_GC_CF;
-
- int rw_d = rd * 2;
- int rh_d = rw_d;
-
- // If radius is zero use DrawRectangle() instead to avoid
- // X drawing errors with small radii
- if (rd == 0)
- {
- DrawRectangle( x, y, width, height );
- return;
- }
-
- // Draw nothing if transformed w or h is 0
- if (wd == 0 || hd == 0) return;
-
- // CMB: adjust size if outline is drawn otherwise the result is
- // 1 pixel too wide and high
- if (m_pen.GetStyle() != wxTRANSPARENT)
- {
- wd--;
- hd--;
- }
-
- // CMB: ensure dd is not larger than rectangle otherwise we
- // get an hour glass shape
- if (rw_d > wd) rw_d = wd;
- if (rw_d > hd) rw_d = hd;
- rd = rw_d / 2;
-
- // For backing pixmap
- int xd2 = XLOG2DEV_2 (x);
- int yd2 = YLOG2DEV_2 (y);
- int rd2 = XLOG2DEVREL ((long) radius);
- int wd2 = XLOG2DEVREL (width) ;
- int hd2 = YLOG2DEVREL (height) ;
-
- int rw_d2 = rd2 * 2;
- int rh_d2 = rw_d2;
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
- {
- SetBrush (m_brush);
-
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
- wd - rw_d, hd);
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
- wd, hd - rh_d);
-
- // Arcs start from 3 o'clock, positive angles anticlockwise
- // Top-left
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
- rw_d, rh_d, 90 * 64, 90 * 64);
- // Top-right
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
-// rw_d, rh_d, 0, 90 * 64);
- rw_d, rh_d, 0, 91 * 64);
- // Bottom-right
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
- yd + hd - rh_d,
-// rw_d, rh_d, 270 * 64, 90 * 64);
- rw_d, rh_d, 269 * 64, 92 * 64);
- // Bottom-left
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
- rw_d, rh_d, 180 * 64, 90 * 64);
-
- if (m_window && m_window->GetBackingPixmap())
+ if (!Ok()) return;
+
+ // FreeGetPixelCache();
+
+ // If radius is negative, it's a proportion of the smaller dimension.
+
+ if (radius < 0.0) radius = - radius * ((width < height) ? width : height);
+
+ int xd = XLOG2DEV (x);
+ int yd = YLOG2DEV (y);
+ int rd = XLOG2DEVREL ((long) radius);
+ int wd = XLOG2DEVREL (width) - WX_GC_CF;
+ int hd = YLOG2DEVREL (height) - WX_GC_CF;
+
+ int rw_d = rd * 2;
+ int rh_d = rw_d;
+
+ // If radius is zero use DrawRectangle() instead to avoid
+ // X drawing errors with small radii
+ if (rd == 0)
{
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + rd2, yd2, wd2 - rw_d2, hd2);
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2 + rd2, wd2, hd2 - rh_d2);
-
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2, rw_d2, rh_d2, 90 * 64, 90 * 64);
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + wd2 - rw_d2, yd2,
-// rw_d2, rh_d2, 0, 90 * 64);
- rw_d2, rh_d2, 0, 91 * 64);
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + wd2 - rw_d2,
- yd2 + hd2 - rh_d2,
-// rw_d2, rh_d2, 270 * 64, 90 * 64);
- rw_d2, rh_d2, 269 * 64, 92 * 64);
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2 + hd2 - rh_d2,
- rw_d2, rh_d2, 180 * 64, 90 * 64);
+ DrawRectangle( x, y, width, height );
+ return;
}
- }
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
- {
- SetPen (m_pen);
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
- xd + wd - rd + 1, yd);
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd + hd,
- xd + wd - rd, yd + hd);
-
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
- xd, yd + hd - rd);
- XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd, yd + rd,
- xd + wd, yd + hd - rd + 1);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
- rw_d, rh_d, 90 * 64, 90 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
-// rw_d, rh_d, 0, 90 * 64);
- rw_d, rh_d, 0, 91 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
- yd + hd - rh_d,
- rw_d, rh_d, 269 * 64, 92 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
- rw_d, rh_d, 180 * 64, 90 * 64);
-
- if (m_window && m_window->GetBackingPixmap())
+
+ // Draw nothing if transformed w or h is 0
+ if (wd == 0 || hd == 0) return;
+
+ // CMB: adjust size if outline is drawn otherwise the result is
+ // 1 pixel too wide and high
+ if (m_pen.GetStyle() != wxTRANSPARENT)
{
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + rd2, yd2,
- xd2 + wd2 - rd2 + 1, yd2);
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + rd2, yd2 + hd2,
- xd2 + wd2 - rd2, yd2 + hd2);
-
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2 + rd2,
- xd2, yd2 + hd2 - rd2);
- XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + wd2, yd2 + rd2,
- xd2 + wd2, yd2 + hd2 - rd2 + 1);
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2,
- rw_d2, rh_d2, 90 * 64, 90 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + wd2 - rw_d2, yd2,
-// rw_d2, rh_d2, 0, 90 * 64);
- rw_d2, rh_d2, 0, 91 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2 + wd2 - rw_d2,
- yd2 + hd2 - rh_d2,
- rw_d2, rh_d2, 269 * 64, 92 * 64);
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- xd2, yd2 + hd2 - rh_d2,
- rw_d2, rh_d2, 180 * 64, 90 * 64);
+ wd--;
+ hd--;
}
- }
- CalcBoundingBox (x, y);
- CalcBoundingBox (x + width, y + height);
-
-
+
+ // CMB: ensure dd is not larger than rectangle otherwise we
+ // get an hour glass shape
+ if (rw_d > wd) rw_d = wd;
+ if (rw_d > hd) rw_d = hd;
+ rd = rw_d / 2;
+
+ // For backing pixmap
+ int xd2 = XLOG2DEV_2 (x);
+ int yd2 = YLOG2DEV_2 (y);
+ int rd2 = XLOG2DEVREL ((long) radius);
+ int wd2 = XLOG2DEVREL (width) ;
+ int hd2 = YLOG2DEVREL (height) ;
+
+ int rw_d2 = rd2 * 2;
+ int rh_d2 = rw_d2;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
+ wd - rw_d, hd);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
+ wd, hd - rh_d);
+
+ // Arcs start from 3 o'clock, positive angles anticlockwise
+ // Top-left
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
+ rw_d, rh_d, 90 * 64, 90 * 64);
+ // Top-right
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
+ // rw_d, rh_d, 0, 90 * 64);
+ rw_d, rh_d, 0, 91 * 64);
+ // Bottom-right
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
+ yd + hd - rh_d,
+ // rw_d, rh_d, 270 * 64, 90 * 64);
+ rw_d, rh_d, 269 * 64, 92 * 64);
+ // Bottom-left
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
+ rw_d, rh_d, 180 * 64, 90 * 64);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2, wd2 - rw_d2, hd2);
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + rd2, wd2, hd2 - rh_d2);
+
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2, rw_d2, rh_d2, 90 * 64, 90 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2, yd2,
+ // rw_d2, rh_d2, 0, 90 * 64);
+ rw_d2, rh_d2, 0, 91 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2,
+ yd2 + hd2 - rh_d2,
+ // rw_d2, rh_d2, 270 * 64, 90 * 64);
+ rw_d2, rh_d2, 269 * 64, 92 * 64);
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 180 * 64, 90 * 64);
+ }
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ SetPen (m_pen);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd,
+ xd + wd - rd + 1, yd);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + rd, yd + hd,
+ xd + wd - rd, yd + hd);
+
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + rd,
+ xd, yd + hd - rd);
+ XDrawLine ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd, yd + rd,
+ xd + wd, yd + hd - rd + 1);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd,
+ rw_d, rh_d, 90 * 64, 90 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d, yd,
+ // rw_d, rh_d, 0, 90 * 64);
+ rw_d, rh_d, 0, 91 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd + wd - rw_d,
+ yd + hd - rh_d,
+ rw_d, rh_d, 269 * 64, 92 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd + hd - rh_d,
+ rw_d, rh_d, 180 * 64, 90 * 64);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2,
+ xd2 + wd2 - rd2 + 1, yd2);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + rd2, yd2 + hd2,
+ xd2 + wd2 - rd2, yd2 + hd2);
+
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + rd2,
+ xd2, yd2 + hd2 - rd2);
+ XDrawLine ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2, yd2 + rd2,
+ xd2 + wd2, yd2 + hd2 - rd2 + 1);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2,
+ rw_d2, rh_d2, 90 * 64, 90 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2, yd2,
+ // rw_d2, rh_d2, 0, 90 * 64);
+ rw_d2, rh_d2, 0, 91 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2 + wd2 - rw_d2,
+ yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 269 * 64, 92 * 64);
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ xd2, yd2 + hd2 - rh_d2,
+ rw_d2, rh_d2, 180 * 64, 90 * 64);
+ }
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+
+
};
void wxWindowDC::DrawEllipse( long x, long y, long width, long height )
{
- if (!Ok()) return;
-
- // Check for negative width and height
- if (height < 0)
- {
- y = y + height;
- height = - height ;
- }
-
- if (width < 0)
- {
- x = x + width;
- width = - width ;
- }
-
-// FreeGetPixelCache();
-
- static const int angle = 23040;
-
- int xd, yd, wd, hd;
-
- xd = XLOG2DEV(x);
- yd = YLOG2DEV(y);
- wd = XLOG2DEVREL(width) ;
- hd = YLOG2DEVREL(height) ;
-
- if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ if (!Ok()) return;
+
+ // Check for negative width and height
+ if (height < 0)
{
- SetBrush (m_brush);
- XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
- if (m_window && m_window->GetBackingPixmap())
- XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- XLOG2DEV_2 (x), YLOG2DEV_2 (y),
- XLOG2DEVREL (width) - WX_GC_CF,
- YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ y = y + height;
+ height = - height ;
}
-
- if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+
+ if (width < 0)
{
- if (m_autoSetting)
- SetPen (m_pen);
- XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
- if (m_window && m_window->GetBackingPixmap())
- XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- XLOG2DEV_2 (x), YLOG2DEV_2 (y),
- XLOG2DEVREL (width) - WX_GC_CF,
- YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ x = x + width;
+ width = - width ;
}
- CalcBoundingBox (x, y);
- CalcBoundingBox (x + width, y + height);
-
+
+ // FreeGetPixelCache();
+
+ static const int angle = 23040;
+
+ int xd, yd, wd, hd;
+
+ xd = XLOG2DEV(x);
+ yd = YLOG2DEV(y);
+ wd = XLOG2DEVREL(width) ;
+ hd = YLOG2DEVREL(height) ;
+
+ if (m_brush.Ok() && m_brush.GetStyle () != wxTRANSPARENT)
+ {
+ SetBrush (m_brush);
+ XFillArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
+ if (m_window && m_window->GetBackingPixmap())
+ XFillArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ XLOG2DEVREL (width) - WX_GC_CF,
+ YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ }
+
+ if (m_pen.Ok() && m_pen.GetStyle () != wxTRANSPARENT)
+ {
+ if (m_autoSetting)
+ SetPen (m_pen);
+ XDrawArc ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, xd, yd, wd, hd, 0, angle);
+ if (m_window && m_window->GetBackingPixmap())
+ XDrawArc ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y),
+ XLOG2DEVREL (width) - WX_GC_CF,
+ YLOG2DEVREL (height) - WX_GC_CF, 0, angle);
+ }
+ CalcBoundingBox (x, y);
+ CalcBoundingBox (x + width, y + height);
+
};
bool wxWindowDC::CanDrawBitmap(void) const
{
- return TRUE;
+ return TRUE;
};
/* Used when copying between drawables on different (Display*) m_displays.
- Not very fast, but better than giving up.
- */
+Not very fast, but better than giving up.
+*/
static void XCopyRemote(Display *src_display, Display *dest_display,
- Drawable src, Drawable dest,
- GC destgc,
- int srcx, int srcy,
- unsigned int w, unsigned int h,
- int destx, int desty,
- bool more, XImage **cache)
+ Drawable src, Drawable dest,
+ GC destgc,
+ int srcx, int srcy,
+ unsigned int w, unsigned int h,
+ int destx, int desty,
+ bool more, XImage **cache)
{
- XImage *image, *destimage;
- Colormap destcm, srccm;
+ XImage *image, *destimage;
+ Colormap destcm, srccm;
#define CACHE_SIZE 256
- unsigned int i, j;
- unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE];
- int k, cache_pos, all_cache;
-
- if (!cache || !*cache)
- image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap);
- else
- image = *cache;
-
- destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap);
-
- srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display);
- destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display);
-
- cache_pos = 0;
- all_cache = FALSE;
-
- for (i = 0; i < w; i++)
- for (j = 0; j < h; j++) {
- unsigned long pixel;
- XColor xcol;
-
- pixel = XGetPixel(image, i, j);
- for (k = cache_pos; k--; )
- if (cachesrc[k] == pixel) {
- pixel = cachedest[k];
- goto install;
- }
- if (all_cache)
- for (k = CACHE_SIZE; k-- > cache_pos; )
- if (cachesrc[k] == pixel) {
- pixel = cachedest[k];
- goto install;
- }
-
- cachesrc[cache_pos] = xcol.pixel = pixel;
- XQueryColor(src_display, srccm, &xcol);
- if (!XAllocColor(dest_display, destcm, &xcol))
- xcol.pixel = 0;
- cachedest[cache_pos] = pixel = xcol.pixel;
-
- if (++cache_pos >= CACHE_SIZE) {
+ unsigned int i, j;
+ unsigned long cachesrc[CACHE_SIZE], cachedest[CACHE_SIZE];
+ int k, cache_pos, all_cache;
+
+ if (!cache || !*cache)
+ image = XGetImage(src_display, src, srcx, srcy, w, h, AllPlanes, ZPixmap);
+ else
+ image = *cache;
+
+ destimage = XGetImage(dest_display, dest, destx, desty, w, h, AllPlanes, ZPixmap);
+
+ srccm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) src_display);
+ destcm = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dest_display);
+
cache_pos = 0;
- all_cache = TRUE;
- }
-
- install:
- XPutPixel(destimage, i, j, pixel);
- }
-
- XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h);
- XDestroyImage(destimage);
-
- if (more)
- *cache = image;
- else
- XDestroyImage(image);
+ all_cache = FALSE;
+
+ for (i = 0; i < w; i++)
+ for (j = 0; j < h; j++) {
+ unsigned long pixel;
+ XColor xcol;
+
+ pixel = XGetPixel(image, i, j);
+ for (k = cache_pos; k--; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+ if (all_cache)
+ for (k = CACHE_SIZE; k-- > cache_pos; )
+ if (cachesrc[k] == pixel) {
+ pixel = cachedest[k];
+ goto install;
+ }
+
+ cachesrc[cache_pos] = xcol.pixel = pixel;
+ XQueryColor(src_display, srccm, &xcol);
+ if (!XAllocColor(dest_display, destcm, &xcol))
+ xcol.pixel = 0;
+ cachedest[cache_pos] = pixel = xcol.pixel;
+
+ if (++cache_pos >= CACHE_SIZE) {
+ cache_pos = 0;
+ all_cache = TRUE;
+ }
+
+install:
+ XPutPixel(destimage, i, j, pixel);
+ }
+
+ XPutImage(dest_display, dest, destgc, destimage, 0, 0, destx, desty, w, h);
+ XDestroyImage(destimage);
+
+ if (more)
+ *cache = image;
+ else
+ XDestroyImage(image);
}
void wxWindowDC::DrawIcon( const wxIcon &icon, long x, long y)
{
- if (!Ok()) return;
-
- if (!icon.Ok()) return;
-
- DrawBitmap(icon, x, y, TRUE);
-
+ if (!Ok()) return;
+
+ if (!icon.Ok()) return;
+
+ DrawBitmap(icon, x, y, TRUE);
+
#if 0
-// FreeGetPixelCache();
-
- // Be sure that foreground pixels (1) of
- // the Icon will be painted with pen colour. [m_pen.SetColour()]
- // Background pixels (0) will be painted with
- // last selected background color. [::SetBackground]
- if (m_pen.Ok() && m_autoSetting)
- SetPen (m_pen);
-
- int width, height;
- Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
- width = icon.GetWidth();
- height = icon.GetHeight();
- if (icon.GetDisplay() == m_display)
- {
- if (icon.GetDepth() <= 1)
- {
- XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
- 0, 0, width, height,
- (int) XLOG2DEV (x), (int) YLOG2DEV (y), 1);
- }
- else
- {
- XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
- 0, 0, width, height,
- (int) XLOG2DEV (x), (int) YLOG2DEV (y));
- }
-
-
- if (m_window && m_window->GetBackingPixmap())
- {
- if (icon.GetDepth() <= 1)
- {
- XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- 0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1);
- }
- else
- {
- XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- 0, 0, width, height,
- (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y));
- }
- }
- } else { /* Remote copy (different (Display*) m_displays) */
- XImage *cache = NULL;
- if (m_window && m_window->GetBackingPixmap())
- XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),
- (GC) m_gcBacking, 0, 0, width, height,
- (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache);
- XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
- 0, 0, width, height,
- (int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
- }
- CalcBoundingBox (x, y);
-#endif
-};
-
-bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
- wxDC *source, long xsrc, long ysrc, int rop, bool useMask )
-{
- if (!Ok()) return FALSE;
-
- wxASSERT_MSG( (source->IsKindOf(CLASSINFO(wxWindowDC))), "Blit source DC must be wxWindowDC or derived class." );
-
- wxWindowDC* sourceDC = (wxWindowDC*) source;
-
-// FreeGetPixelCache();
-
- // Be sure that foreground pixels (1) of
- // the Icon will be painted with pen colour. [m_pen.SetColour()]
- // Background pixels (0) will be painted with
- // last selected background color. [::SetBackground]
- if (m_pen.Ok() && m_autoSetting)
- SetPen (m_pen);
-
- if (m_pixmap && sourceDC->m_pixmap)
- {
- /* MATTHEW: [9] */
- int orig = m_logicalFunction;
-
- SetLogicalFunction (rop);
-
- if (m_display != sourceDC->m_display)
- {
- XImage *cache = NULL;
-
- if (m_window && m_window->GetBackingPixmap())
- XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
- (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),
- (GC) m_gcBacking,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest),
- TRUE, &cache);
-
- if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
- {
- wxMemoryDC *memDC = (wxMemoryDC *)source;
- wxBitmap& sel = memDC->GetBitmap();
- if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
- {
- XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
- XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
- }
- }
-
- XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV (xdest), YLOG2DEV (ydest),
- FALSE, &cache);
-
- if ( useMask )
- {
- XSetClipMask ((Display*) m_display, (GC) m_gc, None);
- XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
- }
+ // FreeGetPixelCache();
+
+ // Be sure that foreground pixels (1) of
+ // the Icon will be painted with pen colour. [m_pen.SetColour()]
+ // Background pixels (0) will be painted with
+ // last selected background color. [::SetBackground]
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
- } else
+ int width, height;
+ Pixmap iconPixmap = (Pixmap) icon.GetPixmap();
+ width = icon.GetWidth();
+ height = icon.GetHeight();
+ if (icon.GetDisplay() == m_display)
{
- if (m_window && m_window->GetBackingPixmap())
- {
-// +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1
- if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1)
+ if (icon.GetDepth() <= 1)
{
- XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest), 1);
+ XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y), 1);
}
- else
+ else
{
- XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest));
+ XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y));
}
- }
- if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
- {
- wxMemoryDC *memDC = (wxMemoryDC *)source;
- wxBitmap& sel = memDC->GetBitmap();
- if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+
+
+ if (m_window && m_window->GetBackingPixmap())
{
- XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
- XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
+ if (icon.GetDepth() <= 1)
+ {
+ XCopyPlane ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ 0, 0, width, height, (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ 0, 0, width, height,
+ (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y));
+ }
}
+ } else { /* Remote copy (different (Display*) m_displays) */
+ XImage *cache = NULL;
+ if (m_window && m_window->GetBackingPixmap())
+ XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_window->GetBackingPixmap(),
+ (GC) m_gcBacking, 0, 0, width, height,
+ (int) XLOG2DEV_2 (x), (int) YLOG2DEV_2 (y), TRUE, &cache);
+ XCopyRemote((Display*) icon.GetDisplay(), (Display*) m_display, iconPixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ 0, 0, width, height,
+ (int) XLOG2DEV (x), (int) YLOG2DEV (y), FALSE, &cache);
}
+ CalcBoundingBox (x, y);
+#endif
+};
- // Check if we're copying from a mono bitmap
- if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
- ((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
- {
- XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV (xdest), YLOG2DEV (ydest), 1);
- }
- else
- {
- XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
- source->LogicalToDeviceX (xsrc),
- source->LogicalToDeviceY (ysrc),
- source->LogicalToDeviceXRel(width),
- source->LogicalToDeviceYRel(height),
- XLOG2DEV (xdest), YLOG2DEV (ydest));
-
- }
- if ( useMask )
- {
- XSetClipMask ((Display*) m_display, (GC) m_gc, None);
- XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
- }
-
- } /* Remote/local (Display*) m_display */
- CalcBoundingBox (xdest, ydest);
- CalcBoundingBox (xdest + width, ydest + height);
+bool wxWindowDC::Blit( long xdest, long ydest, long width, long height,
+ wxDC *source, long xsrc, long ysrc, int rop, bool useMask )
+{
+ if (!Ok()) return FALSE;
- SetLogicalFunction(orig);
-
- return TRUE;
+ wxASSERT_MSG( (source->IsKindOf(CLASSINFO(wxWindowDC))), "Blit source DC must be wxWindowDC or derived class." );
+
+ wxWindowDC* sourceDC = (wxWindowDC*) source;
+
+ // FreeGetPixelCache();
+
+ // Be sure that foreground pixels (1) of
+ // the Icon will be painted with pen colour. [m_pen.SetColour()]
+ // Background pixels (0) will be painted with
+ // last selected background color. [::SetBackground]
+ if (m_pen.Ok() && m_autoSetting)
+ SetPen (m_pen);
+
+ if (m_pixmap && sourceDC->m_pixmap)
+ {
+ /* MATTHEW: [9] */
+ int orig = m_logicalFunction;
+
+ SetLogicalFunction (rop);
+
+ if (m_display != sourceDC->m_display)
+ {
+ XImage *cache = NULL;
+
+ if (m_window && m_window->GetBackingPixmap())
+ XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display,
+ (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),
+ (GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest),
+ TRUE, &cache);
+
+ if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
+ {
+ wxMemoryDC *memDC = (wxMemoryDC *)source;
+ wxBitmap& sel = memDC->GetBitmap();
+ if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
+ }
+ }
+
+ XCopyRemote((Display*) sourceDC->m_display, (Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest),
+ FALSE, &cache);
+
+ if ( useMask )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
+ }
+
+ } else
+ {
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ // +++ MARKUS (mho@comnets.rwth-aachen): error on blitting bitmaps with depth 1
+ if (source->IsKindOf(CLASSINFO(wxMemoryDC)) && ((wxMemoryDC*) source)->GetBitmap().GetDepth() == 1)
+ {
+ XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV_2 (xdest), YLOG2DEV_2 (ydest));
+ }
+ }
+ if ( useMask && source->IsKindOf(CLASSINFO(wxMemoryDC)) )
+ {
+ wxMemoryDC *memDC = (wxMemoryDC *)source;
+ wxBitmap& sel = memDC->GetBitmap();
+ if ( sel.Ok() && sel.GetMask() && sel.GetMask()->GetPixmap() )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, (Pixmap) sel.GetMask()->GetPixmap());
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, XLOG2DEV (xdest), YLOG2DEV (ydest));
+ }
+ }
+
+ // Check if we're copying from a mono bitmap
+ if (source->IsKindOf(CLASSINFO(wxMemoryDC)) &&
+ ((wxMemoryDC*)source)->GetBitmap().Ok() && (((wxMemoryDC*)source)->GetBitmap().GetDepth () == 1))
+ {
+ XCopyPlane ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest), 1);
+ }
+ else
+ {
+ XCopyArea ((Display*) m_display, (Pixmap) sourceDC->m_pixmap, (Pixmap) m_pixmap, (GC) m_gc,
+ source->LogicalToDeviceX (xsrc),
+ source->LogicalToDeviceY (ysrc),
+ source->LogicalToDeviceXRel(width),
+ source->LogicalToDeviceYRel(height),
+ XLOG2DEV (xdest), YLOG2DEV (ydest));
+
+ }
+ if ( useMask )
+ {
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ XSetClipOrigin ((Display*) m_display, (GC) m_gc, 0, 0);
+ }
+
+ } /* Remote/local (Display*) m_display */
+ CalcBoundingBox (xdest, ydest);
+ CalcBoundingBox (xdest + width, ydest + height);
+
+ SetLogicalFunction(orig);
+
+ return TRUE;
}
return FALSE;
};
/* Helper function for 16-bit fonts */
static int str16len(const char *s)
{
- int count = 0;
-
- while (s[0] && s[1]) {
- count++;
- s += 2;
- }
-
- return count;
+ int count = 0;
+
+ while (s[0] && s[1]) {
+ count++;
+ s += 2;
+ }
+
+ return count;
}
void wxWindowDC::DrawText( const wxString &text, long x, long y, bool use16 )
{
- if (!Ok()) return;
-
- // Since X draws from the baseline of the text, must
- // add the text height
- int cx = 0;
- int cy = 0;
- int ascent = 0;
- int slen;
-
- if (use16)
- slen = str16len(text);
- else
- slen = strlen(text);
-
- if (m_font.Ok())
+ if (!Ok()) return;
+
+ // Since X draws from the baseline of the text, must
+ // add the text height
+ int cx = 0;
+ int cy = 0;
+ int ascent = 0;
+ int slen;
+
+ if (use16)
+ slen = str16len(text);
+ else
+ slen = strlen(text);
+
+ if (m_font.Ok())
{
- WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
- int direction, descent;
- XCharStruct overall_return;
- if (use16)
- (void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction,
- &ascent, &descent, &overall_return);
- else
- (void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction,
- &ascent, &descent, &overall_return);
- cx = overall_return.width;
- cy = ascent + descent;
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
+ int direction, descent;
+ XCharStruct overall_return;
+ if (use16)
+ (void)XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *)(const char*) text, slen, &direction,
+ &ascent, &descent, &overall_return);
+ else
+ (void)XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) text, slen, &direction,
+ &ascent, &descent, &overall_return);
+ cx = overall_return.width;
+ cy = ascent + descent;
}
-
- // First draw a rectangle representing the text background,
- // if a text background is specified
- if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT))
+
+ // First draw a rectangle representing the text background,
+ // if a text background is specified
+ if (m_textBackgroundColour.Ok () && (m_backgroundMode != wxTRANSPARENT))
{
- wxColour oldPenColour = m_currentColour;
- m_currentColour = m_textBackgroundColour;
- bool sameColour = (oldPenColour.Ok () && m_textBackgroundColour.Ok () &&
- (oldPenColour.Red () == m_textBackgroundColour.Red ()) &&
- (oldPenColour.Blue () == m_textBackgroundColour.Blue ()) &&
- (oldPenColour.Green () == m_textBackgroundColour.Green ()));
-
- // This separation of the big && test required for gcc2.7/HP UX 9.02
- // or pixel value can be corrupted!
- sameColour = (sameColour &&
- (oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel()));
-
- if (!sameColour || !GetOptimization())
- {
- int pixel = m_textBackgroundColour.AllocColour(m_display);
+ wxColour oldPenColour = m_currentColour;
m_currentColour = m_textBackgroundColour;
-
- // Set the GC to the required colour
- if (pixel > -1)
+ bool sameColour = (oldPenColour.Ok () && m_textBackgroundColour.Ok () &&
+ (oldPenColour.Red () == m_textBackgroundColour.Red ()) &&
+ (oldPenColour.Blue () == m_textBackgroundColour.Blue ()) &&
+ (oldPenColour.Green () == m_textBackgroundColour.Green ()));
+
+ // This separation of the big && test required for gcc2.7/HP UX 9.02
+ // or pixel value can be corrupted!
+ sameColour = (sameColour &&
+ (oldPenColour.GetPixel() == m_textBackgroundColour.GetPixel()));
+
+ if (!sameColour || !GetOptimization())
{
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ int pixel = m_textBackgroundColour.AllocColour(m_display);
+ m_currentColour = m_textBackgroundColour;
+
+ // Set the GC to the required colour
+ if (pixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
}
- }
- else
- m_textBackgroundColour = oldPenColour ;
-
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy);
- if (m_window && m_window->GetBackingPixmap())
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
+ else
+ m_textBackgroundColour = oldPenColour ;
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y), cx, cy);
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y), cx, cy);
}
-
- // Now set the text foreground and draw the text
- if (m_textForegroundColour.Ok ())
- {
- wxColour oldPenColour = m_currentColour;
- m_currentColour = m_textForegroundColour;
- bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () &&
- (oldPenColour.Red () == m_currentColour.Red ()) &&
- (oldPenColour.Blue () == m_currentColour.Blue ()) &&
- (oldPenColour.Green () == m_currentColour.Green ()) &&
- (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
-
- if (!sameColour || !GetOptimization())
- {
- int pixel = -1;
- if (!m_colour) // Mono display
+
+ // Now set the text foreground and draw the text
+ if (m_textForegroundColour.Ok ())
+ {
+ wxColour oldPenColour = m_currentColour;
+ m_currentColour = m_textForegroundColour;
+ bool sameColour = (oldPenColour.Ok () && m_currentColour.Ok () &&
+ (oldPenColour.Red () == m_currentColour.Red ()) &&
+ (oldPenColour.Blue () == m_currentColour.Blue ()) &&
+ (oldPenColour.Green () == m_currentColour.Green ()) &&
+ (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
+
+ if (!sameColour || !GetOptimization())
{
- // Unless foreground is really white, draw it in black
- unsigned char red = m_textForegroundColour.Red ();
- unsigned char blue = m_textForegroundColour.Blue ();
- unsigned char green = m_textForegroundColour.Green ();
- if (red == (unsigned char) 255 && blue == (unsigned char) 255
- && green == (unsigned char) 255)
- {
- m_currentColour = *wxWHITE;
- pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour.SetPixel(pixel);
- m_textForegroundColour.SetPixel(pixel);
- }
- else
- {
- m_currentColour = *wxBLACK;
- pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour.SetPixel(pixel);
- m_textForegroundColour.SetPixel(pixel);
- }
+ int pixel = -1;
+ if (!m_colour) // Mono display
+ {
+ // Unless foreground is really white, draw it in black
+ unsigned char red = m_textForegroundColour.Red ();
+ unsigned char blue = m_textForegroundColour.Blue ();
+ unsigned char green = m_textForegroundColour.Green ();
+ if (red == (unsigned char) 255 && blue == (unsigned char) 255
+ && green == (unsigned char) 255)
+ {
+ m_currentColour = *wxWHITE;
+ pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour.SetPixel(pixel);
+ m_textForegroundColour.SetPixel(pixel);
+ }
+ else
+ {
+ m_currentColour = *wxBLACK;
+ pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour.SetPixel(pixel);
+ m_textForegroundColour.SetPixel(pixel);
+ }
+ }
+ else
+ {
+ pixel = m_textForegroundColour.AllocColour((Display*) m_display);
+ m_currentColour.SetPixel(pixel);
+ }
+
+ // Set the GC to the required colour
+ if (pixel > -1)
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
}
else
- {
- pixel = m_textForegroundColour.AllocColour((Display*) m_display);
- m_currentColour.SetPixel(pixel);
- }
-
- // Set the GC to the required colour
- if (pixel > -1)
- {
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
- }
- }
- else
- m_textForegroundColour = oldPenColour;
- }
-
- // We need to add the ascent, not the whole height, since X draws
- // at the point above the descender.
- if (use16)
- XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
- (XChar2b *)(char*) (const char*) text, slen);
- else
- XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
- text, slen);
-
- if (m_window && m_window->GetBackingPixmap()) {
+ m_textForegroundColour = oldPenColour;
+ }
+
+ // We need to add the ascent, not the whole height, since X draws
+ // at the point above the descender.
if (use16)
- XDrawString16((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XDrawString16((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
+ (XChar2b *)(char*) (const char*) text, slen);
+ else
+ XDrawString((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, XLOG2DEV (x), YLOG2DEV (y) + ascent,
+ text, slen);
+
+ if (m_window && m_window->GetBackingPixmap()) {
+ if (use16)
+ XDrawString16((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent,
(XChar2b *)(char*) (const char*) text, slen);
- else
- XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
- XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen);
- }
-
- long w, h;
- GetTextExtent (text, &w, &h);
- CalcBoundingBox (x + w, y + h);
- CalcBoundingBox (x, y);
+ else
+ XDrawString((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(), (GC) m_gcBacking,
+ XLOG2DEV_2 (x), YLOG2DEV_2 (y) + ascent, (char*) (const char*) text, slen);
+ }
+
+ long w, h;
+ GetTextExtent (text, &w, &h);
+ CalcBoundingBox (x + w, y + h);
+ CalcBoundingBox (x, y);
};
bool wxWindowDC::CanGetTextExtent(void) const
{
- return TRUE;
+ return TRUE;
};
void wxWindowDC::GetTextExtent( const wxString &string, long *width, long *height,
- long *descent, long *externalLeading,
- wxFont *font, bool use16 )
+ long *descent, long *externalLeading,
+ wxFont *font, bool use16 )
{
- if (!Ok()) return;
-
- wxFont* theFont = font;
- if (!theFont)
- theFont = & m_font;
-
- if (!theFont->Ok())
- {
- // TODO: this should be an error log function
- wxFAIL_MSG("set a valid font before calling GetTextExtent!");
-
- *width = -1;
- *height = -1;
- return;
- }
-
- WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
- int direction, ascent, descent2;
- XCharStruct overall;
- int slen;
-
- if (use16) slen = str16len(string); else slen = strlen(string);
-
- if (use16)
- XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
- &ascent, &descent2, &overall);
- else
- XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
- &ascent, &descent2, &overall);
-
- *width = XDEV2LOGREL (overall.width);
- *height = YDEV2LOGREL (ascent + descent2);
- if (descent)
- *descent = descent2;
- if (externalLeading)
- *externalLeading = 0;
+ if (!Ok()) return;
+
+ wxFont* theFont = font;
+ if (!theFont)
+ theFont = & m_font;
+
+ if (!theFont->Ok())
+ {
+ // TODO: this should be an error log function
+ wxFAIL_MSG("set a valid font before calling GetTextExtent!");
+
+ *width = -1;
+ *height = -1;
+ return;
+ }
+
+ WXFontStructPtr pFontStruct = theFont->GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
+
+ int direction, ascent, descent2;
+ XCharStruct overall;
+ int slen;
+
+ if (use16) slen = str16len(string); else slen = strlen(string);
+
+ if (use16)
+ XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
+ &ascent, &descent2, &overall);
+ else
+ XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
+ &ascent, &descent2, &overall);
+
+ *width = XDEV2LOGREL (overall.width);
+ *height = YDEV2LOGREL (ascent + descent2);
+ if (descent)
+ *descent = descent2;
+ if (externalLeading)
+ *externalLeading = 0;
};
long wxWindowDC::GetCharWidth(void)
{
- if (!Ok()) return 0;
-
- if (!m_font.Ok())
- return 0;
-
- WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display);
-
- int direction, ascent, descent;
- XCharStruct overall;
- XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+ if (!Ok()) return 0;
+
+ if (!m_font.Ok())
+ return 0;
+
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY * m_logicalScaleY, m_display);
+
+ int direction, ascent, descent;
+ XCharStruct overall;
+ XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
- return XDEV2LOGREL(overall.width);
+ return XDEV2LOGREL(overall.width);
};
long wxWindowDC::GetCharHeight(void)
{
- if (!Ok()) return 0;
-
- if (!m_font.Ok())
- return 0;
-
- WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
- int direction, ascent, descent;
- XCharStruct overall;
- XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+ if (!Ok()) return 0;
+
+ if (!m_font.Ok())
+ return 0;
+
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
+
+ int direction, ascent, descent;
+ XCharStruct overall;
+ XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
-// return XDEV2LOGREL(overall.ascent + overall.descent);
- return XDEV2LOGREL(ascent + descent);
+ // return XDEV2LOGREL(overall.ascent + overall.descent);
+ return XDEV2LOGREL(ascent + descent);
};
void wxWindowDC::Clear(void)
{
- if (!Ok()) return;
-
- int w, h;
- if (m_window)
+ if (!Ok()) return;
+
+ int w, h;
+ if (m_window)
{
- m_window->GetSize(&w, &h);
-
- if (m_window && m_window->GetBackingPixmap())
- {
- w = m_window->GetPixmapWidth();
- h = m_window->GetPixmapHeight();
- }
+ m_window->GetSize(&w, &h);
+
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ w = m_window->GetPixmapWidth();
+ h = m_window->GetPixmapHeight();
+ }
}
- else
+ else
{
if (this->IsKindOf(CLASSINFO(wxMemoryDC)))
{
- wxMemoryDC* memDC = (wxMemoryDC*) this;
- w = memDC->GetBitmap().GetWidth();
- h = memDC->GetBitmap().GetHeight();
- }
+ wxMemoryDC* memDC = (wxMemoryDC*) this;
+ w = memDC->GetBitmap().GetWidth();
+ h = memDC->GetBitmap().GetHeight();
+ }
else
- return;
+ return;
}
-
- wxBrush saveBrush = m_brush;
- SetBrush (m_backgroundBrush);
-
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h);
-
- if (m_window && m_window->GetBackingPixmap())
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h);
-
- m_brush = saveBrush;
+
+ wxBrush saveBrush = m_brush;
+ SetBrush (m_backgroundBrush);
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, 0, 0, w, h);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, 0, 0, w, h);
+
+ m_brush = saveBrush;
};
void wxWindowDC::Clear(const wxRect& rect)
{
- if (!Ok()) return;
-
- int x = rect.x; int y = rect.y;
- int w = rect.width; int h = rect.height;
-
- wxBrush saveBrush = m_brush;
- SetBrush (m_backgroundBrush);
-
- XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h);
-
- if (m_window && m_window->GetBackingPixmap())
- XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h);
-
- m_brush = saveBrush;
+ if (!Ok()) return;
+
+ int x = rect.x; int y = rect.y;
+ int w = rect.width; int h = rect.height;
+
+ wxBrush saveBrush = m_brush;
+ SetBrush (m_backgroundBrush);
+
+ XFillRectangle ((Display*) m_display, (Pixmap) m_pixmap, (GC) m_gc, x, y, w, h);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XFillRectangle ((Display*) m_display, (Pixmap) m_window->GetBackingPixmap(),(GC) m_gcBacking, x, y, w, h);
+
+ m_brush = saveBrush;
};
void wxWindowDC::SetFont( const wxFont &font )
{
- if (!Ok()) return;
-
- m_font = font;
-
- if (!m_font.Ok())
- {
- if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+ if (!Ok()) return;
+
+ m_font = font;
+
+ if (!m_font.Ok())
{
- XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+ if ((m_oldFont != (WXFont) 0) && ((long) m_oldFont != -1))
+ {
+ XSetFont ((Display*) m_display, (GC) m_gc, (Font) m_oldFont);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFont ((Display*) m_display,(GC) m_gcBacking, (Font) m_oldFont);
+ }
+ return;
}
- return;
- }
-
- WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
-
- Font fontId = ((XFontStruct*)pFontStruct)->fid;
- XSetFont ((Display*) m_display, (GC) m_gc, fontId);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetFont ((Display*) m_display,(GC) m_gcBacking, fontId);
+
+ WXFontStructPtr pFontStruct = m_font.GetFontStruct(m_userScaleY*m_logicalScaleY, m_display);
+
+ Font fontId = ((XFontStruct*)pFontStruct)->fid;
+ XSetFont ((Display*) m_display, (GC) m_gc, fontId);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFont ((Display*) m_display,(GC) m_gcBacking, fontId);
};
void wxWindowDC::SetPen( const wxPen &pen )
{
- if (!Ok()) return;
-
- m_pen = pen;
- if (!m_pen.Ok())
- return;
-
- wxBitmap oldStipple = m_currentStipple;
- int oldStyle = m_currentStyle;
- int oldFill = m_currentFill;
- int old_pen_width = m_currentPenWidth;
- int old_pen_join = m_currentPenJoin;
- int old_pen_cap = m_currentPenCap;
- int old_pen_nb_dash = m_currentPenDashCount;
- char *old_pen_dash = m_currentPenDash;
-
- wxColour oldPenColour = m_currentColour;
- m_currentColour = m_pen.GetColour ();
- m_currentStyle = m_pen.GetStyle ();
- m_currentFill = m_pen.GetStyle (); // TODO?
- m_currentPenWidth = m_pen.GetWidth ();
- m_currentPenJoin = m_pen.GetJoin ();
- m_currentPenCap = m_pen.GetCap ();
- m_currentPenDashCount = m_pen.GetDashCount();
- m_currentPenDash = m_pen.GetDash();
-
- if (m_currentStyle == wxSTIPPLE)
- m_currentStipple = * m_pen.GetStipple ();
-
- bool sameStyle = (oldStyle == m_currentStyle &&
- oldFill == m_currentFill &&
- old_pen_join == m_currentPenJoin &&
- old_pen_cap == m_currentPenCap &&
- old_pen_nb_dash == m_currentPenDashCount &&
- old_pen_dash == m_currentPenDash &&
- old_pen_width == m_currentPenWidth);
-
- bool sameColour = (oldPenColour.Ok () &&
- (oldPenColour.Red () == m_currentColour.Red ()) &&
- (oldPenColour.Blue () == m_currentColour.Blue ()) &&
- (oldPenColour.Green () == m_currentColour.Green ()) &&
- (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
-
- if (!sameStyle || !GetOptimization())
+ if (!Ok()) return;
+
+ m_pen = pen;
+ if (!m_pen.Ok())
+ return;
+
+ wxBitmap oldStipple = m_currentStipple;
+ int oldStyle = m_currentStyle;
+ int oldFill = m_currentFill;
+ int old_pen_width = m_currentPenWidth;
+ int old_pen_join = m_currentPenJoin;
+ int old_pen_cap = m_currentPenCap;
+ int old_pen_nb_dash = m_currentPenDashCount;
+ char *old_pen_dash = m_currentPenDash;
+
+ wxColour oldPenColour = m_currentColour;
+ m_currentColour = m_pen.GetColour ();
+ m_currentStyle = m_pen.GetStyle ();
+ m_currentFill = m_pen.GetStyle (); // TODO?
+ m_currentPenWidth = m_pen.GetWidth ();
+ m_currentPenJoin = m_pen.GetJoin ();
+ m_currentPenCap = m_pen.GetCap ();
+ m_currentPenDashCount = m_pen.GetDashCount();
+ m_currentPenDash = m_pen.GetDash();
+
+ if (m_currentStyle == wxSTIPPLE)
+ m_currentStipple = * m_pen.GetStipple ();
+
+ bool sameStyle = (oldStyle == m_currentStyle &&
+ oldFill == m_currentFill &&
+ old_pen_join == m_currentPenJoin &&
+ old_pen_cap == m_currentPenCap &&
+ old_pen_nb_dash == m_currentPenDashCount &&
+ old_pen_dash == m_currentPenDash &&
+ old_pen_width == m_currentPenWidth);
+
+ bool sameColour = (oldPenColour.Ok () &&
+ (oldPenColour.Red () == m_currentColour.Red ()) &&
+ (oldPenColour.Blue () == m_currentColour.Blue ()) &&
+ (oldPenColour.Green () == m_currentColour.Green ()) &&
+ (oldPenColour.GetPixel() == m_currentColour.GetPixel()));
+
+ if (!sameStyle || !GetOptimization())
{
- int scaled_width = (int) XLOG2DEVREL (m_pen.GetWidth ());
- if (scaled_width < 0)
- scaled_width = 0;
-
- int style;
- int join;
- int cap;
- static char dotted[] =
- {2, 5};
- static char short_dashed[] =
- {4, 4};
- static char long_dashed[] =
- {4, 8};
- static char dotted_dashed[] =
- {6, 6, 2, 6};
-
- // We express dash pattern in pen width unit, so we are
- // independent of zoom factor and so on...
- int req_nb_dash;
- char *req_dash;
-
- switch (m_pen.GetStyle ())
- {
+ int scaled_width = (int) XLOG2DEVREL (m_pen.GetWidth ());
+ if (scaled_width < 0)
+ scaled_width = 0;
+
+ int style;
+ int join;
+ int cap;
+ static char dotted[] =
+ {2, 5};
+ static char short_dashed[] =
+ {4, 4};
+ static char long_dashed[] =
+ {4, 8};
+ static char dotted_dashed[] =
+ {6, 6, 2, 6};
+
+ // We express dash pattern in pen width unit, so we are
+ // independent of zoom factor and so on...
+ int req_nb_dash;
+ char *req_dash;
+
+ switch (m_pen.GetStyle ())
+ {
case wxUSER_DASH:
- req_nb_dash = m_currentPenDashCount;
- req_dash = m_currentPenDash;
- style = LineOnOffDash;
- break;
+ req_nb_dash = m_currentPenDashCount;
+ req_dash = m_currentPenDash;
+ style = LineOnOffDash;
+ break;
case wxDOT:
- req_nb_dash = 2;
- req_dash = dotted;
- style = LineOnOffDash;
- break;
+ req_nb_dash = 2;
+ req_dash = dotted;
+ style = LineOnOffDash;
+ break;
case wxSHORT_DASH:
- req_nb_dash = 2;
- req_dash = short_dashed;
- style = LineOnOffDash;
- break;
+ req_nb_dash = 2;
+ req_dash = short_dashed;
+ style = LineOnOffDash;
+ break;
case wxLONG_DASH:
- req_nb_dash = 2;
- req_dash = long_dashed;
- style = LineOnOffDash;
- break;
+ req_nb_dash = 2;
+ req_dash = long_dashed;
+ style = LineOnOffDash;
+ break;
case wxDOT_DASH:
- req_nb_dash = 4;
- req_dash = dotted_dashed;
- style = LineOnOffDash;
- break;
+ req_nb_dash = 4;
+ req_dash = dotted_dashed;
+ style = LineOnOffDash;
+ break;
case wxSTIPPLE:
case wxSOLID:
case wxTRANSPARENT:
default:
- style = LineSolid;
- req_dash = NULL;
- req_nb_dash = 0;
- }
-
- if (req_dash && req_nb_dash)
- {
- char *real_req_dash = new char[req_nb_dash];
- if (real_req_dash)
- {
- int factor = scaled_width == 0 ? 1 : scaled_width;
- for (int i = 0; i < req_nb_dash; i++)
- real_req_dash[i] = req_dash[i] * factor;
- XSetDashes ((Display*) m_display, (GC) m_gc, 0, real_req_dash, req_nb_dash);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, real_req_dash, req_nb_dash);
- delete[]real_req_dash;
+ style = LineSolid;
+ req_dash = NULL;
+ req_nb_dash = 0;
}
- else
+
+ if (req_dash && req_nb_dash)
{
- // No Memory. We use non-scaled dash pattern...
- XSetDashes ((Display*) m_display, (GC) m_gc, 0, req_dash, req_nb_dash);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, req_dash, req_nb_dash);
+ char *real_req_dash = new char[req_nb_dash];
+ if (real_req_dash)
+ {
+ int factor = scaled_width == 0 ? 1 : scaled_width;
+ for (int i = 0; i < req_nb_dash; i++)
+ real_req_dash[i] = req_dash[i] * factor;
+ XSetDashes ((Display*) m_display, (GC) m_gc, 0, real_req_dash, req_nb_dash);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, real_req_dash, req_nb_dash);
+ delete[]real_req_dash;
+ }
+ else
+ {
+ // No Memory. We use non-scaled dash pattern...
+ XSetDashes ((Display*) m_display, (GC) m_gc, 0, req_dash, req_nb_dash);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetDashes ((Display*) m_display,(GC) m_gcBacking, 0, req_dash, req_nb_dash);
+ }
}
- }
-
- switch (m_pen.GetCap ())
- {
+
+ switch (m_pen.GetCap ())
+ {
case wxCAP_PROJECTING:
- cap = CapProjecting;
- break;
+ cap = CapProjecting;
+ break;
case wxCAP_BUTT:
- cap = CapButt;
- break;
+ cap = CapButt;
+ break;
case wxCAP_ROUND:
default:
- cap = (scaled_width <= 1) ? CapNotLast : CapRound;
- break;
- }
-
- switch (m_pen.GetJoin ())
- {
+ cap = (scaled_width <= 1) ? CapNotLast : CapRound;
+ break;
+ }
+
+ switch (m_pen.GetJoin ())
+ {
case wxJOIN_BEVEL:
- join = JoinBevel;
- break;
+ join = JoinBevel;
+ break;
case wxJOIN_MITER:
- join = JoinMiter;
- break;
+ join = JoinMiter;
+ break;
case wxJOIN_ROUND:
default:
- join = JoinRound;
- break;
- }
-
- XSetLineAttributes ((Display*) m_display, (GC) m_gc, scaled_width, style, cap, join);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetLineAttributes ((Display*) m_display,(GC) m_gcBacking, scaled_width, style, cap, join);
+ join = JoinRound;
+ break;
+ }
+
+ XSetLineAttributes ((Display*) m_display, (GC) m_gc, scaled_width, style, cap, join);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetLineAttributes ((Display*) m_display,(GC) m_gcBacking, scaled_width, style, cap, join);
}
-
+
if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization()))
{
- Pixmap myStipple;
-
- oldStipple = wxNullBitmap; // For later reset!!
-
- switch (m_currentFill)
- {
+ Pixmap myStipple;
+
+ oldStipple = wxNullBitmap; // For later reset!!
+
+ switch (m_currentFill)
+ {
case wxBDIAGONAL_HATCH:
- if (bdiag == (Pixmap) 0)
- bdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- bdiag_bits, bdiag_width, bdiag_height);
- myStipple = bdiag;
- break;
+ if (bdiag == (Pixmap) 0)
+ bdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ bdiag_bits, bdiag_width, bdiag_height);
+ myStipple = bdiag;
+ break;
case wxFDIAGONAL_HATCH:
- if (fdiag == (Pixmap) 0)
- fdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- fdiag_bits, fdiag_width, fdiag_height);
- myStipple = fdiag;
- break;
+ if (fdiag == (Pixmap) 0)
+ fdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ fdiag_bits, fdiag_width, fdiag_height);
+ myStipple = fdiag;
+ break;
case wxCROSS_HATCH:
- if (cross == (Pixmap) 0)
- cross = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- cross_bits, cross_width, cross_height);
- myStipple = cross;
- break;
+ if (cross == (Pixmap) 0)
+ cross = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ cross_bits, cross_width, cross_height);
+ myStipple = cross;
+ break;
case wxHORIZONTAL_HATCH:
- if (horiz == (Pixmap) 0)
- horiz = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- horiz_bits, horiz_width, horiz_height);
- myStipple = horiz;
- break;
+ if (horiz == (Pixmap) 0)
+ horiz = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ horiz_bits, horiz_width, horiz_height);
+ myStipple = horiz;
+ break;
case wxVERTICAL_HATCH:
- if (verti == (Pixmap) 0)
- verti = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- verti_bits, verti_width, verti_height);
- myStipple = verti;
- break;
+ if (verti == (Pixmap) 0)
+ verti = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ verti_bits, verti_width, verti_height);
+ myStipple = verti;
+ break;
case wxCROSSDIAG_HATCH:
default:
- if (cdiag == (Pixmap) 0)
- cdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- cdiag_bits, cdiag_width, cdiag_height);
- myStipple = cdiag;
- break;
- }
- XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
+ if (cdiag == (Pixmap) 0)
+ cdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ cdiag_bits, cdiag_width, cdiag_height);
+ myStipple = cdiag;
+ break;
+ }
+ XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
}
else if (m_currentStipple.Ok()
- && ((m_currentStipple != oldStipple) || !GetOptimization()))
+ && ((m_currentStipple != oldStipple) || !GetOptimization()))
{
- XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
-
- if (m_window && m_window->GetBackingPixmap())
- XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
+ XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
}
-
+
if ((m_currentFill != oldFill) || !GetOptimization())
{
- int fill_style;
-
- if (m_currentFill == wxSTIPPLE)
- fill_style = FillStippled;
- else if (IS_HATCH (m_currentFill))
- fill_style = FillStippled;
- else
- fill_style = FillSolid;
- XSetFillStyle ((Display*) m_display, (GC) m_gc, fill_style);
- if (m_window && m_window->GetBackingPixmap())
- XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, fill_style);
+ int fill_style;
+
+ if (m_currentFill == wxSTIPPLE)
+ fill_style = FillStippled;
+ else if (IS_HATCH (m_currentFill))
+ fill_style = FillStippled;
+ else
+ fill_style = FillSolid;
+ XSetFillStyle ((Display*) m_display, (GC) m_gc, fill_style);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, fill_style);
}
-
+
// must test m_logicalFunction, because it involves background!
if (!sameColour || !GetOptimization()
- || ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2)))
+ || ((m_logicalFunction == wxXOR) || (m_autoSetting & 0x2)))
{
- int pixel = -1;
- if (m_pen.GetStyle () == wxTRANSPARENT)
- pixel = m_backgroundPixel;
- else if (!m_colour)
- {
- unsigned char red = m_pen.GetColour ().Red ();
- unsigned char blue = m_pen.GetColour ().Blue ();
- unsigned char green = m_pen.GetColour ().Green ();
- if (red == (unsigned char) 255 && blue == (unsigned char) 255
- && green == (unsigned char) 255)
+ int pixel = -1;
+ if (m_pen.GetStyle () == wxTRANSPARENT)
+ pixel = m_backgroundPixel;
+ else if (!m_colour)
{
- pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour = *wxWHITE;
- m_pen.GetColour().SetPixel(pixel);
- m_currentColour.SetPixel(pixel);
+ unsigned char red = m_pen.GetColour ().Red ();
+ unsigned char blue = m_pen.GetColour ().Blue ();
+ unsigned char green = m_pen.GetColour ().Green ();
+ if (red == (unsigned char) 255 && blue == (unsigned char) 255
+ && green == (unsigned char) 255)
+ {
+ pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour = *wxWHITE;
+ m_pen.GetColour().SetPixel(pixel);
+ m_currentColour.SetPixel(pixel);
+ }
+ else
+ {
+ pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour = *wxBLACK;
+ m_pen.GetColour().SetPixel(pixel);
+ }
}
else
{
- pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour = *wxBLACK;
- m_pen.GetColour().SetPixel(pixel);
- }
- }
- else
- {
- pixel = m_pen.GetColour ().AllocColour(m_display);
- m_currentColour.SetPixel(pixel);
- }
-
- // Finally, set the GC to the required colour
- if (pixel > -1)
- {
- if (m_logicalFunction == wxXOR)
- {
- XGCValues values;
- XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values);
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background);
+ pixel = m_pen.GetColour ().AllocColour(m_display);
+ m_currentColour.SetPixel(pixel);
}
- else
+
+ // Finally, set the GC to the required colour
+ if (pixel > -1)
{
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ if (m_logicalFunction == wxXOR)
+ {
+ XGCValues values;
+ XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values);
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background);
+ }
+ else
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
}
}
- }
- else
- m_pen.GetColour().SetPixel(oldPenColour.GetPixel());
-
- m_autoSetting = 0;
+ else
+ m_pen.GetColour().SetPixel(oldPenColour.GetPixel());
+
+ m_autoSetting = 0;
};
void wxWindowDC::SetBrush( const wxBrush &brush )
{
- if (!Ok()) return;
-
- m_brush = brush;
-
- if (!m_brush.Ok() || m_brush.GetStyle () == wxTRANSPARENT)
- return;
-
- int oldFill = m_currentFill;
- wxBitmap oldStipple = m_currentStipple;
-
- m_autoSetting |= 0x1;
-
- m_currentFill = m_brush.GetStyle ();
- if (m_currentFill == wxSTIPPLE)
- m_currentStipple = * m_brush.GetStipple ();
-
- wxColour oldBrushColour(m_currentColour);
- m_currentColour = m_brush.GetColour ();
-
- bool sameColour = (oldBrushColour.Ok () &&
- (oldBrushColour.Red () == m_currentColour.Red ()) &&
- (oldBrushColour.Blue () == m_currentColour.Blue ()) &&
- (oldBrushColour.Green () == m_currentColour.Green ()) &&
- (oldBrushColour.GetPixel() == m_currentColour.GetPixel()));
-
- if ((oldFill != m_brush.GetStyle ()) || !GetOptimization())
- {
- switch (brush.GetStyle ())
- {
+ if (!Ok()) return;
+
+ m_brush = brush;
+
+ if (!m_brush.Ok() || m_brush.GetStyle () == wxTRANSPARENT)
+ return;
+
+ int oldFill = m_currentFill;
+ wxBitmap oldStipple = m_currentStipple;
+
+ m_autoSetting |= 0x1;
+
+ m_currentFill = m_brush.GetStyle ();
+ if (m_currentFill == wxSTIPPLE)
+ m_currentStipple = * m_brush.GetStipple ();
+
+ wxColour oldBrushColour(m_currentColour);
+ m_currentColour = m_brush.GetColour ();
+
+ bool sameColour = (oldBrushColour.Ok () &&
+ (oldBrushColour.Red () == m_currentColour.Red ()) &&
+ (oldBrushColour.Blue () == m_currentColour.Blue ()) &&
+ (oldBrushColour.Green () == m_currentColour.Green ()) &&
+ (oldBrushColour.GetPixel() == m_currentColour.GetPixel()));
+
+ if ((oldFill != m_brush.GetStyle ()) || !GetOptimization())
+ {
+ switch (brush.GetStyle ())
+ {
case wxTRANSPARENT:
- break;
+ break;
case wxBDIAGONAL_HATCH:
case wxCROSSDIAG_HATCH:
case wxFDIAGONAL_HATCH:
case wxHORIZONTAL_HATCH:
case wxVERTICAL_HATCH:
case wxSTIPPLE:
- {
- // Chris Breeze 23/07/97: use background mode to determine whether
- // fill style should be solid or transparent
- int style = (m_backgroundMode == wxSOLID ? FillOpaqueStippled : FillStippled);
- XSetFillStyle ((Display*) m_display, (GC) m_gc, style);
- if (m_window && m_window->GetBackingPixmap())
- XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style);
- }
- break;
+ {
+ // Chris Breeze 23/07/97: use background mode to determine whether
+ // fill style should be solid or transparent
+ int style = (m_backgroundMode == wxSOLID ? FillOpaqueStippled : FillStippled);
+ XSetFillStyle ((Display*) m_display, (GC) m_gc, style);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, style);
+ }
+ break;
case wxSOLID:
default:
- XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid);
- if (m_window && m_window->GetBackingPixmap())
- XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, FillSolid);
- }
- }
-
- if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization()))
+ XSetFillStyle ((Display*) m_display, (GC) m_gc, FillSolid);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFillStyle ((Display*) m_display,(GC) m_gcBacking, FillSolid);
+ }
+ }
+
+ if (IS_HATCH(m_currentFill) && ((m_currentFill != oldFill) || !GetOptimization()))
{
- Pixmap myStipple;
-
- switch (m_currentFill)
- {
+ Pixmap myStipple;
+
+ switch (m_currentFill)
+ {
case wxBDIAGONAL_HATCH:
- if (bdiag == (Pixmap) 0)
- bdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- bdiag_bits, bdiag_width, bdiag_height);
- myStipple = bdiag;
- break;
+ if (bdiag == (Pixmap) 0)
+ bdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ bdiag_bits, bdiag_width, bdiag_height);
+ myStipple = bdiag;
+ break;
case wxFDIAGONAL_HATCH:
- if (fdiag == (Pixmap) 0)
- fdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- fdiag_bits, fdiag_width, fdiag_height);
- myStipple = fdiag;
- break;
+ if (fdiag == (Pixmap) 0)
+ fdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ fdiag_bits, fdiag_width, fdiag_height);
+ myStipple = fdiag;
+ break;
case wxCROSS_HATCH:
- if (cross == (Pixmap) 0)
- cross = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- cross_bits, cross_width, cross_height);
- myStipple = cross;
- break;
+ if (cross == (Pixmap) 0)
+ cross = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ cross_bits, cross_width, cross_height);
+ myStipple = cross;
+ break;
case wxHORIZONTAL_HATCH:
- if (horiz == (Pixmap) 0)
- horiz = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- horiz_bits, horiz_width, horiz_height);
- myStipple = horiz;
- break;
+ if (horiz == (Pixmap) 0)
+ horiz = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ horiz_bits, horiz_width, horiz_height);
+ myStipple = horiz;
+ break;
case wxVERTICAL_HATCH:
- if (verti == (Pixmap) 0)
- verti = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- verti_bits, verti_width, verti_height);
- myStipple = verti;
- break;
+ if (verti == (Pixmap) 0)
+ verti = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ verti_bits, verti_width, verti_height);
+ myStipple = verti;
+ break;
case wxCROSSDIAG_HATCH:
default:
- if (cdiag == (Pixmap) 0)
- cdiag = XCreateBitmapFromData ((Display*) m_display,
- RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
- cdiag_bits, cdiag_width, cdiag_height);
- myStipple = cdiag;
- break;
- }
- XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
-
- if (m_window && m_window->GetBackingPixmap())
- XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
+ if (cdiag == (Pixmap) 0)
+ cdiag = XCreateBitmapFromData ((Display*) m_display,
+ RootWindow ((Display*) m_display, DefaultScreen ((Display*) m_display)),
+ cdiag_bits, cdiag_width, cdiag_height);
+ myStipple = cdiag;
+ break;
+ }
+ XSetStipple ((Display*) m_display, (GC) m_gc, myStipple);
+
+ if (m_window && m_window->GetBackingPixmap())
+ XSetStipple ((Display*) m_display,(GC) m_gcBacking, myStipple);
}
// X can forget the stipple value when resizing a window (apparently)
// so always set the stipple.
else if (m_currentStipple.Ok()) // && m_currentStipple != oldStipple)
{
- XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
- if (m_window && m_window->GetBackingPixmap())
- XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
+ XSetStipple ((Display*) m_display, (GC) m_gc, (Pixmap) m_currentStipple.GetPixmap());
+ if (m_window && m_window->GetBackingPixmap())
+ XSetStipple ((Display*) m_display,(GC) m_gcBacking, (Pixmap) m_currentStipple.GetPixmap());
}
-
+
// must test m_logicalFunction, because it involves background!
if (!sameColour || !GetOptimization() || m_logicalFunction == wxXOR)
{
- int pixel = -1;
- if (!m_colour)
- {
- // Policy - on a monochrome screen, all brushes are white,
- // except when they're REALLY black!!!
- unsigned char red = m_brush.GetColour ().Red ();
- unsigned char blue = m_brush.GetColour ().Blue ();
- unsigned char green = m_brush.GetColour ().Green ();
-
- if (red == (unsigned char) 0 && blue == (unsigned char) 0
- && green == (unsigned char) 0)
+ int pixel = -1;
+ if (!m_colour)
+ {
+ // Policy - on a monochrome screen, all brushes are white,
+ // except when they're REALLY black!!!
+ unsigned char red = m_brush.GetColour ().Red ();
+ unsigned char blue = m_brush.GetColour ().Blue ();
+ unsigned char green = m_brush.GetColour ().Green ();
+
+ if (red == (unsigned char) 0 && blue == (unsigned char) 0
+ && green == (unsigned char) 0)
{
- pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour = *wxBLACK;
- m_brush.GetColour().SetPixel(pixel);
- m_currentColour.SetPixel(pixel);
+ pixel = (int) BlackPixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour = *wxBLACK;
+ m_brush.GetColour().SetPixel(pixel);
+ m_currentColour.SetPixel(pixel);
}
- else
+ else
{
- pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
- m_currentColour = *wxWHITE;
- m_brush.GetColour().SetPixel(pixel);
- m_currentColour.SetPixel(pixel);
+ pixel = (int) WhitePixel ((Display*) m_display, DefaultScreen ((Display*) m_display));
+ m_currentColour = *wxWHITE;
+ m_brush.GetColour().SetPixel(pixel);
+ m_currentColour.SetPixel(pixel);
}
-
- // N.B. comment out the above line and uncomment the following lines
- // if you want non-white colours to be black on a monochrome display.
- /*
- if (red == (unsigned char )255 && blue == (unsigned char)255
- && green == (unsigned char)255)
- pixel = (int)WhitePixel((Display*) m_display, DefaultScreen((Display*) m_display));
- else
- pixel = (int)BlackPixel((Display*) m_display, DefaultScreen((Display*) m_display));
- */
- }
- else if (m_brush.GetStyle () != wxTRANSPARENT)
- {
- pixel = m_brush.GetColour().AllocColour(m_display);
- m_currentColour.SetPixel(pixel);
- }
- if (pixel > -1)
- {
- // Finally, set the GC to the required colour
- if (m_logicalFunction == wxXOR)
+
+ // N.B. comment out the above line and uncomment the following lines
+ // if you want non-white colours to be black on a monochrome display.
+ /*
+ if (red == (unsigned char )255 && blue == (unsigned char)255
+ && green == (unsigned char)255)
+ pixel = (int)WhitePixel((Display*) m_display, DefaultScreen((Display*) m_display));
+ else
+ pixel = (int)BlackPixel((Display*) m_display, DefaultScreen((Display*) m_display));
+ */
+ }
+ else if (m_brush.GetStyle () != wxTRANSPARENT)
{
- XGCValues values;
- XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values);
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background);
+ pixel = m_brush.GetColour().AllocColour(m_display);
+ m_currentColour.SetPixel(pixel);
}
- else
+ if (pixel > -1)
{
- XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
- if (m_window && m_window->GetBackingPixmap())
- XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ // Finally, set the GC to the required colour
+ if (m_logicalFunction == wxXOR)
+ {
+ XGCValues values;
+ XGetGCValues ((Display*) m_display, (GC) m_gc, GCBackground, &values);
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel ^ values.background);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel ^ values.background);
+ }
+ else
+ {
+ XSetForeground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetForeground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ }
}
- }
}
- else
- m_brush.GetColour().SetPixel(oldBrushColour.GetPixel());
+ else
+ m_brush.GetColour().SetPixel(oldBrushColour.GetPixel());
};
void wxWindowDC::SetBackground( const wxBrush &brush )
{
- if (!Ok()) return;
-
- m_backgroundBrush = brush;
-
- if (!m_backgroundBrush.Ok())
- return;
-
- int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
-
- // XSetWindowBackground doesn't work for non-Window pixmaps
- if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
- XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
-
- // Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
- // And Blit,... (Any fct that use XCopyPlane, in fact.)
- XSetBackground ((Display*) m_display, (GC) m_gc, pixel);
- if (m_window && m_window->GetBackingPixmap())
- XSetBackground ((Display*) m_display,(GC) m_gcBacking, pixel);
+ if (!Ok()) return;
+
+ m_backgroundBrush = brush;
+
+ if (!m_backgroundBrush.Ok())
+ return;
+
+ int pixel = m_backgroundBrush.GetColour().AllocColour(m_display);
+
+ // XSetWindowBackground doesn't work for non-Window pixmaps
+ if (!this->IsKindOf(CLASSINFO(wxMemoryDC)))
+ XSetWindowBackground ((Display*) m_display, (Pixmap) m_pixmap, pixel);
+
+ // Necessary for ::DrawIcon, which use fg/bg pixel or the GC.
+ // And Blit,... (Any fct that use XCopyPlane, in fact.)
+ XSetBackground ((Display*) m_display, (GC) m_gc, pixel);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetBackground ((Display*) m_display,(GC) m_gcBacking, pixel);
};
void wxWindowDC::SetLogicalFunction( int function )
{
- int x_function;
-
- /* MATTHEW: [9] */
- if (m_logicalFunction == function)
- return;
-
- switch (function)
+ int x_function;
+
+ /* MATTHEW: [9] */
+ if (m_logicalFunction == function)
+ return;
+
+ switch (function)
{
case wxCLEAR:
- x_function = GXclear;
- break;
+ x_function = GXclear;
+ break;
case wxXOR:
- x_function = GXxor;
- break;
+ x_function = GXxor;
+ break;
case wxINVERT:
- x_function = GXinvert;
- break;
+ x_function = GXinvert;
+ break;
case wxOR_REVERSE:
- x_function = GXorReverse;
- break;
+ x_function = GXorReverse;
+ break;
case wxAND_REVERSE:
- x_function = GXandReverse;
- break;
+ x_function = GXandReverse;
+ break;
case wxAND:
- x_function = GXand;
- break;
+ x_function = GXand;
+ break;
case wxOR:
- x_function = GXor;
- break;
+ x_function = GXor;
+ break;
case wxAND_INVERT:
- x_function = GXandInverted;
- break;
+ x_function = GXandInverted;
+ break;
case wxNO_OP:
- x_function = GXnoop;
- break;
+ x_function = GXnoop;
+ break;
case wxNOR:
- x_function = GXnor;
- break;
+ x_function = GXnor;
+ break;
case wxEQUIV:
- x_function = GXequiv;
- break;
+ x_function = GXequiv;
+ break;
case wxSRC_INVERT:
- x_function = GXcopyInverted;
- break;
+ x_function = GXcopyInverted;
+ break;
case wxOR_INVERT:
- x_function = GXorInverted;
- break;
+ x_function = GXorInverted;
+ break;
case wxNAND:
- x_function = GXnand;
- break;
+ x_function = GXnand;
+ break;
case wxSET:
- x_function = GXset;
- break;
+ x_function = GXset;
+ break;
case wxCOPY:
default:
- x_function = GXcopy;
- break;
+ x_function = GXcopy;
+ break;
}
-
- XSetFunction((Display*) m_display, (GC) m_gc, x_function);
- if (m_window && m_window->GetBackingPixmap())
- XSetFunction((Display*) m_display, (GC) m_gcBacking, x_function);
-
- if ((m_logicalFunction == wxXOR) != (function == wxXOR))
- /* MATTHEW: [9] Need to redo pen simply */
- m_autoSetting |= 0x2;
-
- m_logicalFunction = function;
-
+
+ XSetFunction((Display*) m_display, (GC) m_gc, x_function);
+ if (m_window && m_window->GetBackingPixmap())
+ XSetFunction((Display*) m_display, (GC) m_gcBacking, x_function);
+
+ if ((m_logicalFunction == wxXOR) != (function == wxXOR))
+ /* MATTHEW: [9] Need to redo pen simply */
+ m_autoSetting |= 0x2;
+
+ m_logicalFunction = function;
+
};
void wxWindowDC::SetTextForeground( const wxColour &col )
{
- if (!Ok()) return;
-
- if (m_textForegroundColour == col) return;
-
- m_textForegroundColour = col;
-
+ if (!Ok()) return;
+
+ if (m_textForegroundColour == col) return;
+
+ m_textForegroundColour = col;
+
};
void wxWindowDC::SetTextBackground( const wxColour &col )
{
- if (!Ok()) return;
-
- if (m_textBackgroundColour == col) return;
-
- m_textBackgroundColour = col;
- if (!m_textBackgroundColour.Ok()) return;
+ if (!Ok()) return;
+
+ if (m_textBackgroundColour == col) return;
+
+ m_textBackgroundColour = col;
+ if (!m_textBackgroundColour.Ok()) return;
};
void wxWindowDC::SetBackgroundMode( int mode )
{
- m_backgroundMode = mode;
-
+ m_backgroundMode = mode;
+
};
void wxWindowDC::SetPalette( const wxPalette& palette )
{
- if (m_window)
- {
- if (palette.Ok())
- /* Use GetXColormap */
- XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(),
- (Colormap) palette.GetXColormap());
- else
- /* Use wxGetMainColormap */
- XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(),
- (Colormap) wxTheApp->GetMainColormap(m_display));
- }
+ if (m_window)
+ {
+ if (palette.Ok())
+ /* Use GetXColormap */
+ XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(),
+ (Colormap) palette.GetXColormap());
+ else
+ /* Use wxGetMainColormap */
+ XSetWindowColormap ((Display*) m_display, (Window) m_window->GetXWindow(),
+ (Colormap) wxTheApp->GetMainColormap(m_display));
+ }
};
// Helper function
void wxWindowDC:: SetDCClipping ()
{
- // m_userRegion is the region set by calling SetClippingRegion
-
- if (m_currentRegion)
- XDestroyRegion ((Region) m_currentRegion);
-
- // We need to take into account
- // clipping imposed on a window by a repaint.
- // We'll combine it with the user region. But for now,
- // just use the currently-defined user clipping region.
- if (m_userRegion || (m_window && m_window->GetUpdateRegion().Ok()) )
- m_currentRegion = (WXRegion) XCreateRegion ();
- else
- m_currentRegion = (WXRegion) NULL;
-
- if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion)
- XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion);
- else if (m_userRegion)
- XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion);
- else if (m_window && m_window->GetUpdateRegion().Ok())
- XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
-(Region) m_currentRegion);
-
- if (m_currentRegion)
+ // m_userRegion is the region set by calling SetClippingRegion
+
+ if (m_currentRegion)
+ XDestroyRegion ((Region) m_currentRegion);
+
+ // We need to take into account
+ // clipping imposed on a window by a repaint.
+ // We'll combine it with the user region. But for now,
+ // just use the currently-defined user clipping region.
+ if (m_userRegion || (m_window && m_window->GetUpdateRegion().Ok()) )
+ m_currentRegion = (WXRegion) XCreateRegion ();
+ else
+ m_currentRegion = (WXRegion) NULL;
+
+ if ((m_window && m_window->GetUpdateRegion().Ok()) && m_userRegion)
+ XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_userRegion, (Region) m_currentRegion);
+ else if (m_userRegion)
+ XIntersectRegion ((Region) m_userRegion, (Region) m_userRegion, (Region) m_currentRegion);
+ else if (m_window && m_window->GetUpdateRegion().Ok())
+ XIntersectRegion ((Region) m_window->GetUpdateRegion().GetXRegion(), (Region) m_window->GetUpdateRegion().GetXRegion(),
+ (Region) m_currentRegion);
+
+ if (m_currentRegion)
{
- XSetRegion ((Display*) m_display, (GC) m_gc, (Region) m_currentRegion);
+ XSetRegion ((Display*) m_display, (GC) m_gc, (Region) m_currentRegion);
}
- else
+ else
{
- XSetClipMask ((Display*) m_display, (GC) m_gc, None);
+ XSetClipMask ((Display*) m_display, (GC) m_gc, None);
}
-
+
}
void wxWindowDC::SetClippingRegion( long x, long y, long width, long height )
{
- wxDC::SetClippingRegion( x, y, width, height );
-
- if (m_userRegion)
- XDestroyRegion ((Region) m_userRegion);
- m_userRegion = (WXRegion) XCreateRegion ();
- XRectangle r;
- r.x = XLOG2DEV (x);
- r.y = YLOG2DEV (y);
- r.width = XLOG2DEVREL(width);
- r.height = YLOG2DEVREL(height);
- XUnionRectWithRegion (&r, (Region) m_userRegion, (Region) m_userRegion);
-
- SetDCClipping ();
-
- // Needs to work differently for Pixmap: without this,
- // there's a nasty (Display*) m_display bug. 8/12/94
- if (m_window && m_window->GetBackingPixmap())
- {
- XRectangle rects[1];
- rects[0].x = XLOG2DEV_2(x);
- rects[0].y = YLOG2DEV_2(y);
- rects[0].width = XLOG2DEVREL(width);
- rects[0].height = YLOG2DEVREL(height);
- XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
- }
+ wxDC::SetClippingRegion( x, y, width, height );
+
+ if (m_userRegion)
+ XDestroyRegion ((Region) m_userRegion);
+ m_userRegion = (WXRegion) XCreateRegion ();
+ XRectangle r;
+ r.x = XLOG2DEV (x);
+ r.y = YLOG2DEV (y);
+ r.width = XLOG2DEVREL(width);
+ r.height = YLOG2DEVREL(height);
+ XUnionRectWithRegion (&r, (Region) m_userRegion, (Region) m_userRegion);
+
+ SetDCClipping ();
+
+ // Needs to work differently for Pixmap: without this,
+ // there's a nasty (Display*) m_display bug. 8/12/94
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XRectangle rects[1];
+ rects[0].x = XLOG2DEV_2(x);
+ rects[0].y = YLOG2DEV_2(y);
+ rects[0].width = XLOG2DEVREL(width);
+ rects[0].height = YLOG2DEVREL(height);
+ XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
+ }
};
void wxWindowDC::SetClippingRegion( const wxRegion& region )
{
- wxRect box = region.GetBox();
-
- wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
-
- if (m_userRegion)
- XDestroyRegion ((Region) m_userRegion);
- m_userRegion = (WXRegion) XCreateRegion ();
-
- XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
-
- SetDCClipping ();
-
- // Needs to work differently for Pixmap: without this,
- // there's a nasty (Display*) m_display bug. 8/12/94
- if (m_window && m_window->GetBackingPixmap())
- {
- XRectangle rects[1];
- rects[0].x = XLOG2DEV_2(box.x);
- rects[0].y = YLOG2DEV_2(box.y);
- rects[0].width = XLOG2DEVREL(box.width);
- rects[0].height = YLOG2DEVREL(box.height);
- XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
- }
+ wxRect box = region.GetBox();
+
+ wxDC::SetClippingRegion( box.x, box.y, box.width, box.height );
+
+ if (m_userRegion)
+ XDestroyRegion ((Region) m_userRegion);
+ m_userRegion = (WXRegion) XCreateRegion ();
+
+ XUnionRegion((Region) m_userRegion, (Region) region.GetXRegion(), (Region) m_userRegion);
+
+ SetDCClipping ();
+
+ // Needs to work differently for Pixmap: without this,
+ // there's a nasty (Display*) m_display bug. 8/12/94
+ if (m_window && m_window->GetBackingPixmap())
+ {
+ XRectangle rects[1];
+ rects[0].x = XLOG2DEV_2(box.x);
+ rects[0].y = YLOG2DEV_2(box.y);
+ rects[0].width = XLOG2DEVREL(box.width);
+ rects[0].height = YLOG2DEVREL(box.height);
+ XSetClipRectangles((Display*) m_display, (GC) m_gcBacking, 0, 0, rects, 1, Unsorted);
+ }
};
void wxWindowDC::DestroyClippingRegion(void)
{
- wxDC::DestroyClippingRegion();
-
- if (m_userRegion)
- XDestroyRegion ((Region) m_userRegion);
- m_userRegion = NULL;
-
- SetDCClipping ();
-
- XGCValues gc_val;
- gc_val.clip_mask = None;
- if (m_window && m_window->GetBackingPixmap())
- XChangeGC((Display*) m_display, (GC) m_gcBacking, GCClipMask, &gc_val);
+ wxDC::DestroyClippingRegion();
+
+ if (m_userRegion)
+ XDestroyRegion ((Region) m_userRegion);
+ m_userRegion = NULL;
+
+ SetDCClipping ();
+
+ XGCValues gc_val;
+ gc_val.clip_mask = None;
+ if (m_window && m_window->GetBackingPixmap())
+ XChangeGC((Display*) m_display, (GC) m_gcBacking, GCClipMask, &gc_val);
};
// ----------------------------------- spline code ----------------------------------------
double a3, double b3, double a4, double b4);
void wx_clear_stack(void);
int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
- double *y3, double *x4, double *y4);
+ double *y3, double *x4, double *y4);
void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
- double x4, double y4);
+ double x4, double y4);
static bool wx_spline_add_point(double x, double y);
static void wx_spline_draw_point_array(wxDC *dc);
/* iterative version */
void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
- double b4)
+ double b4)
{
register double xmid, ymid;
double x1, y1, x2, y2, x3, y3, x4, y4;
-
+
wx_clear_stack();
wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
-
+
while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
xmid = (double)half(x2, x3);
ymid = (double)half(y2, y3);
- if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
- fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
+ if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
+ fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
wx_spline_add_point( x1, y1 );
wx_spline_add_point( xmid, ymid );
- } else {
+ } else {
wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
- (double)half(x3, x4), (double)half(y3, y4), x4, y4);
+ (double)half(x3, x4), (double)half(y3, y4), x4, y4);
wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
- (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
- }
+ (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
+ }
}
}
double *x3, double *y3, double *x4, double *y4)
{
if (wx_stack_count == 0)
- return (0);
+ return (0);
wx_stack_top--;
wx_stack_count--;
*x1 = wx_stack_top->x1;
static bool wx_spline_add_point(double x, double y)
{
- wxPoint *point = new wxPoint ;
- point->x = (int) x;
- point->y = (int) y;
- wx_spline_point_list.Append((wxObject*)point);
- return TRUE;
+ wxPoint *point = new wxPoint ;
+ point->x = (int) x;
+ point->y = (int) y;
+ wx_spline_point_list.Append((wxObject*)point);
+ return TRUE;
}
static void wx_spline_draw_point_array(wxDC *dc)
{
- dc->DrawLines(&wx_spline_point_list, 0, 0 );
- wxNode *node = wx_spline_point_list.First();
- while (node)
- {
- wxPoint *point = (wxPoint *)node->Data();
- delete point;
- delete node;
- node = wx_spline_point_list.First();
- }
+ dc->DrawLines(&wx_spline_point_list, 0, 0 );
+ wxNode *node = wx_spline_point_list.First();
+ while (node)
+ {
+ wxPoint *point = (wxPoint *)node->Data();
+ delete point;
+ delete node;
+ node = wx_spline_point_list.First();
+ }
}
void wxWindowDC::DrawSpline( wxList *points )
wxPoint *p;
double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
double x1, y1, x2, y2;
-
+
wxNode *node = points->First();
p = (wxPoint *)node->Data();
-
+
x1 = p->x;
y1 = p->y;
-
+
node = node->Next();
p = (wxPoint *)node->Data();
-
+
x2 = p->x;
y2 = p->y;
cx1 = (double)((x1 + x2) / 2);
cy1 = (double)((y1 + y2) / 2);
cx2 = (double)((cx1 + x2) / 2);
cy2 = (double)((cy1 + y2) / 2);
-
+
wx_spline_add_point(x1, y1);
-
+
while ((node = node->Next()) != NULL)
{
p = (wxPoint *)node->Data();
- x1 = x2;
- y1 = y2;
- x2 = p->x;
- y2 = p->y;
+ x1 = x2;
+ y1 = y2;
+ x2 = p->x;
+ y2 = p->y;
cx4 = (double)(x1 + x2) / 2;
cy4 = (double)(y1 + y2) / 2;
cx3 = (double)(x1 + cx4) / 2;
cy3 = (double)(y1 + cy4) / 2;
-
+
wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
-
- cx1 = cx4;
- cy1 = cy4;
+
+ cx1 = cx4;
+ cy1 = cy4;
cx2 = (double)(cx1 + x2) / 2;
cy2 = (double)(cy1 + y2) / 2;
}
-
+
wx_spline_add_point( cx1, cy1 );
wx_spline_add_point( x2, y2 );
-
+
wx_spline_draw_point_array( this );
};
/*
- * wxPaintDC
- */
+* wxPaintDC
+*/
wxPaintDC::wxPaintDC(wxWindow* win): wxWindowDC(win)
{
wxRegion* region = NULL;
-
+
// Combine all the update rects into a region
if (win->m_updateRects.Number() > 0)
{
for (i = 0; i < win->m_updateRects.Number(); i++)
{
wxRect* rect = (wxRect*) win->m_updateRects.Nth(i)->Data();
- /*
+ /*
cout << "wxPaintDC. wxRect: " << rect->x << ", " << rect->y << ", ";
cout << rect->width << ", " << rect->height << "\n\n";
- */
-
+ */
+
if (!region)
region = new wxRegion(*rect);
else
win->GetClientSize(&cw, &ch);
region = new wxRegion(wxRect(0, 0, cw, ch));
}
-
+
win->m_updateRegion = *region;
-
+
// Set the clipping region. Any user-defined region will be combined with this
// one in SetDCClipping.
XSetRegion ((Display*) m_display, (GC) m_gc, (Region) region->GetXRegion());
-
+
delete region;
}
{
m_ok = TRUE;
m_display = wxGetDisplay();
-
+
Display* display = (Display*) m_display;
-
+
XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display));
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
- &gcvalues);
-
+ &gcvalues);
+
m_backgroundPixel = (int) gcvalues.background;
-
+
// Get the current Font so we can set it back later
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
m_display = ((wxWindowDC*)dc)->GetDisplay();
else
m_display = wxGetDisplay();
-
+
Display* display = (Display*) m_display;
-
+
XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display));
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
- &gcvalues);
-
+ &gcvalues);
+
m_backgroundPixel = (int) gcvalues.background;
-
+
// Get the current Font so we can set it back later
XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
{
- m_bitmap = bitmap;
-
- if (m_gc)
- XFreeGC((Display*) m_display, (GC) m_gc);
- m_gc = (WXGC) NULL;
-
- if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
- {
- m_pixmap = m_bitmap.GetPixmap();
- Display* display = (Display*) m_display;
-
- XGCValues gcvalues;
- gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
- gcvalues.background = WhitePixel (display, DefaultScreen (display));
- gcvalues.graphics_exposures = False;
- gcvalues.line_width = 1;
- m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
- GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
- &gcvalues);
-
- m_backgroundPixel = (int) gcvalues.background;
-
- // Get the current Font so we can set it back later
- XGCValues valReturn;
- XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
- m_oldFont = (WXFont) valReturn.font;
-
- bool oldOpt = GetOptimization();
- SetOptimization(FALSE);
+ m_bitmap = bitmap;
- SetBrush (* wxWHITE_BRUSH);
- SetPen (* wxBLACK_PEN);
-
- SetOptimization(oldOpt);
-
- m_ok = TRUE;
- }
- else
- {
- m_ok = FALSE;
- m_pixmap = (WXPixmap) 0;
- };
+ if (m_gc)
+ XFreeGC((Display*) m_display, (GC) m_gc);
+ m_gc = (WXGC) NULL;
+
+ if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
+ {
+ m_pixmap = m_bitmap.GetPixmap();
+ Display* display = (Display*) m_display;
+
+ XGCValues gcvalues;
+ gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
+ gcvalues.background = WhitePixel (display, DefaultScreen (display));
+ gcvalues.graphics_exposures = False;
+ gcvalues.line_width = 1;
+ m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
+ GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
+ &gcvalues);
+
+ m_backgroundPixel = (int) gcvalues.background;
+
+ // Get the current Font so we can set it back later
+ XGCValues valReturn;
+ XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
+ m_oldFont = (WXFont) valReturn.font;
+
+ bool oldOpt = GetOptimization();
+ SetOptimization(FALSE);
+
+ SetBrush (* wxWHITE_BRUSH);
+ SetPen (* wxBLACK_PEN);
+
+ SetOptimization(oldOpt);
+
+ m_ok = TRUE;
+ }
+ else
+ {
+ m_ok = FALSE;
+ m_pixmap = (WXPixmap) 0;
+ };
};
void wxMemoryDC::GetSize( int *width, int *height ) const
{
- if (m_bitmap.Ok())
- {
- if (width) (*width) = m_bitmap.GetWidth();
- if (height) (*height) = m_bitmap.GetHeight();
- }
- else
- {
- if (width) (*width) = 0;
- if (height) (*height) = 0;
- };
+ if (m_bitmap.Ok())
+ {
+ if (width) (*width) = m_bitmap.GetWidth();
+ if (height) (*height) = m_bitmap.GetHeight();
+ }
+ else
+ {
+ if (width) (*width) = 0;
+ if (height) (*height) = 0;
+ };
};
// Create a DC representing the whole screen
wxScreenDC::wxScreenDC()
{
- m_display = wxGetDisplay();
- Display* display = (Display*) m_display;
-
- if (sm_overlayWindow)
- {
- m_pixmap = sm_overlayWindow;
- m_deviceOriginX = - sm_overlayWindowX;
- m_deviceOriginY = - sm_overlayWindowY;
- }
- else
- m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
-
- XGCValues gcvalues;
- gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
- gcvalues.background = WhitePixel (display, DefaultScreen (display));
- gcvalues.graphics_exposures = False;
- gcvalues.subwindow_mode = IncludeInferiors;
- gcvalues.line_width = 1;
- m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
- GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
- &gcvalues);
-
- m_backgroundPixel = (int) gcvalues.background;
- m_ok = TRUE;
+ m_display = wxGetDisplay();
+ Display* display = (Display*) m_display;
+
+ if (sm_overlayWindow)
+ {
+ m_pixmap = sm_overlayWindow;
+ m_deviceOriginX = - sm_overlayWindowX;
+ m_deviceOriginY = - sm_overlayWindowY;
+ }
+ else
+ m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
+
+ XGCValues gcvalues;
+ gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
+ gcvalues.background = WhitePixel (display, DefaultScreen (display));
+ gcvalues.graphics_exposures = False;
+ gcvalues.subwindow_mode = IncludeInferiors;
+ gcvalues.line_width = 1;
+ m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
+ GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
+ &gcvalues);
+
+ m_backgroundPixel = (int) gcvalues.background;
+ m_ok = TRUE;
}
wxScreenDC::~wxScreenDC()
bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
{
- wxRect rect;
- int x, y, width, height;
- window->GetPosition(& x, & y);
- if (window->GetParent())
- window->GetParent()->ClientToScreen(& x, & y);
- window->GetSize(& width, & height);
- rect.x = x; rect.y = y;
- rect.width = width; rect.height = height;
-
- return StartDrawingOnTop(& rect);
+ wxRect rect;
+ int x, y, width, height;
+ window->GetPosition(& x, & y);
+ if (window->GetParent())
+ window->GetParent()->ClientToScreen(& x, & y);
+ window->GetSize(& width, & height);
+ rect.x = x; rect.y = y;
+ rect.width = width; rect.height = height;
+
+ return StartDrawingOnTop(& rect);
}
bool wxScreenDC::StartDrawingOnTop(wxRect* rect)
{
- if (sm_overlayWindow)
- return FALSE;
-
- Display *dpy = (Display*) wxGetDisplay();
- Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
-
- int x = 0;
- int y = 0;
- int width, height;
- wxDisplaySize(&width, &height);
-
- if (rect)
- {
- x = rect->x; y = rect->y;
- width = rect->width; height = rect->height;
- }
- sm_overlayWindowX = x;
- sm_overlayWindowY = y;
-
- XSetWindowAttributes attributes;
- attributes.override_redirect = True;
- unsigned long valueMask = CWOverrideRedirect;
-
- sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
- wxDisplayDepth(), InputOutput,
- DefaultVisual(dpy, 0), valueMask,
- & attributes);
-
- if (sm_overlayWindow)
- {
- XMapWindow(dpy, (Window) sm_overlayWindow);
- return TRUE;
- }
- else
- return FALSE;
+ if (sm_overlayWindow)
+ return FALSE;
+
+ Display *dpy = (Display*) wxGetDisplay();
+ Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
+
+ int x = 0;
+ int y = 0;
+ int width, height;
+ wxDisplaySize(&width, &height);
+
+ if (rect)
+ {
+ x = rect->x; y = rect->y;
+ width = rect->width; height = rect->height;
+ }
+ sm_overlayWindowX = x;
+ sm_overlayWindowY = y;
+
+ XSetWindowAttributes attributes;
+ attributes.override_redirect = True;
+ unsigned long valueMask = CWOverrideRedirect;
+
+ sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
+ wxDisplayDepth(), InputOutput,
+ DefaultVisual(dpy, 0), valueMask,
+ & attributes);
+
+ if (sm_overlayWindow)
+ {
+ XMapWindow(dpy, (Window) sm_overlayWindow);
+ return TRUE;
+ }
+ else
+ return FALSE;
}
bool wxScreenDC::EndDrawingOnTop()
{
- if (sm_overlayWindow)
- {
- XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
- sm_overlayWindow = 0;
- return TRUE;
- }
- else
- return FALSE;
+ if (sm_overlayWindow)
+ {
+ XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
+ sm_overlayWindow = 0;
+ return TRUE;
+ }
+ else
+ return FALSE;
}
static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs);
static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *);
static void wxDialogBoxEventHandler (Widget wid,
- XtPointer client_data,
- XEvent* event,
- Boolean *continueToDispatch);
+ XtPointer client_data,
+ XEvent* event,
+ Boolean *continueToDispatch);
static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call);
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
- EVT_BUTTON(wxID_OK, wxDialog::OnOK)
- EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
- EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
- EVT_CHAR_HOOK(wxDialog::OnCharHook)
- EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
- EVT_CLOSE(wxDialog::OnCloseWindow)
+EVT_BUTTON(wxID_OK, wxDialog::OnOK)
+EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
+EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
+EVT_CHAR_HOOK(wxDialog::OnCharHook)
+EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
+EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE()
#endif
}
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
m_windowStyle = style;
m_modalShowing = FALSE;
m_dialogTitle = title;
-
+
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK;
-
+
SetName(name);
-
+
if (!parent)
wxTopLevelWindows.Append(this);
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
-
+
Widget parentWidget = (Widget) 0;
if (parent)
parentWidget = (Widget) parent->GetTopWidget();
if (!parent)
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
-
+
wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
-
+
Arg args[2];
XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
m_mainWidget = (WXWidget) dialogShell;
-
+
// We don't want margins, since there is enough elsewhere.
XtVaSetValues(dialogShell,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- XmNresizePolicy, XmRESIZE_NONE,
- NULL) ;
-
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL) ;
+
Widget shell = XtParent(dialogShell) ;
if (!title.IsNull())
{
XmString str = XmStringCreateSimple((char*) (const char*)title);
XtVaSetValues(dialogShell,
- XmNdialogTitle, str,
- NULL);
+ XmNdialogTitle, str,
+ NULL);
XmStringFree(str);
}
-
+
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
ChangeFont(FALSE);
-
+
wxAddWindowToTable(dialogShell, this);
-
+
// Intercept CLOSE messages from the window manager
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
-
+
/* Remove and add WM_DELETE_WINDOW so ours is only handler */
/* Why do we have to do this for wxDialog, but not wxFrame? */
XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
-
+
// Modified Steve Hammes for Motif 2.0
#if (XmREVISION > 1 || XmVERSION > 1)
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
#else
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
#endif
-
+
XtTranslations ptr ;
XtOverrideTranslations(dialogShell,
- ptr = XtParseTranslationTable("<Configure>: resize()"));
+ ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
-
+
// Can't remember what this was about... but I think it's necessary.
-
+
if (wxUSE_INVISIBLE_RESIZE)
{
- if (pos.x > -1)
- XtVaSetValues(dialogShell, XmNx, pos.x,
- NULL);
- if (pos.y > -1)
- XtVaSetValues(dialogShell, XmNy, pos.y,
- NULL);
-
- if (size.x > -1)
- XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
- if (size.y > -1)
- XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
+ if (pos.x > -1)
+ XtVaSetValues(dialogShell, XmNx, pos.x,
+ NULL);
+ if (pos.y > -1)
+ XtVaSetValues(dialogShell, XmNy, pos.y,
+ NULL);
+
+ if (size.x > -1)
+ XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
+ if (size.y > -1)
+ XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
}
-
+
// This patch come from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning(shell))
{
int decor = 0 ;
if (m_windowStyle & wxRESIZE_BORDER)
- decor |= MWM_DECOR_RESIZEH ;
+ decor |= MWM_DECOR_RESIZEH ;
if (m_windowStyle & wxSYSTEM_MENU)
- decor |= MWM_DECOR_MENU;
+ decor |= MWM_DECOR_MENU;
if ((m_windowStyle & wxCAPTION) ||
(m_windowStyle & wxTINY_CAPTION_HORIZ) ||
(m_windowStyle & wxTINY_CAPTION_VERT))
- decor |= MWM_DECOR_TITLE;
+ decor |= MWM_DECOR_TITLE;
if (m_windowStyle & wxTHICK_FRAME)
- decor |= MWM_DECOR_BORDER;
+ decor |= MWM_DECOR_BORDER;
if (m_windowStyle & wxMINIMIZE_BOX)
- decor |= MWM_DECOR_MINIMIZE;
+ decor |= MWM_DECOR_MINIMIZE;
if (m_windowStyle & wxMAXIMIZE_BOX)
- decor |= MWM_DECOR_MAXIMIZE;
-
+ decor |= MWM_DECOR_MAXIMIZE;
+
XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
}
// This allows non-Motif window managers to support at least the
// no-decorations case.
else
{
- if ((m_windowStyle & wxCAPTION) != wxCAPTION)
- XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
+ if ((m_windowStyle & wxCAPTION) != wxCAPTION)
+ XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
}
-
+
XtRealizeWidget(dialogShell);
-
+
XtAddCallback(dialogShell,XmNunmapCallback,
- (XtCallbackProc)wxUnmapBulletinBoard,this) ;
-
+ (XtCallbackProc)wxUnmapBulletinBoard,this) ;
+
// Positioning of the dialog doesn't work properly unless the dialog
// is managed, so we manage without mapping to the screen.
// To show, we map the shell (actually it's parent).
if (!wxUSE_INVISIBLE_RESIZE)
XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
-
+
if (!wxUSE_INVISIBLE_RESIZE)
{
XtManageChild(dialogShell);
SetSize(pos.x, pos.y, size.x, size.y);
}
XtAddEventHandler(dialogShell,ExposureMask,FALSE,
- wxDialogBoxRepaintProc, (XtPointer) this);
-
+ wxDialogBoxRepaintProc, (XtPointer) this);
+
XtAddEventHandler(dialogShell,
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
- FALSE,
- wxDialogBoxEventHandler,
- (XtPointer)this);
-
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
+ FALSE,
+ wxDialogBoxEventHandler,
+ (XtPointer)this);
+
ChangeBackgroundColour();
-
+
return TRUE;
}
m_windowStyle |= wxDIALOG_MODAL ;
else
if ( m_windowStyle & wxDIALOG_MODAL )
- m_windowStyle -= wxDIALOG_MODAL ;
-
- wxModelessWindows.DeleteObject(this);
- if (!flag)
- wxModelessWindows.Append(this);
+ m_windowStyle -= wxDIALOG_MODAL ;
+
+ wxModelessWindows.DeleteObject(this);
+ if (!flag)
+ wxModelessWindows.Append(this);
}
wxDialog::~wxDialog()
m_modalShowing = FALSE;
if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
{
- XtUnmapWidget((Widget) m_mainWidget);
+ XtUnmapWidget((Widget) m_mainWidget);
}
-
+
wxTopLevelWindows.DeleteObject(this);
-
+
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
- wxModelessWindows.DeleteObject(this);
-
+ wxModelessWindows.DeleteObject(this);
+
// If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{
- wxTheApp->SetTopWindow(NULL);
-
- if (wxTheApp->GetExitOnFrameDelete())
- {
- wxTheApp->ExitMainLoop();
- }
+ wxTheApp->SetTopWindow(NULL);
+
+ if (wxTheApp->GetExitOnFrameDelete())
+ {
+ wxTheApp->ExitMainLoop();
+ }
}
-
+
// This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
// but I think this should work, if we destroy the children first.
// Note that this might need to be done for wxFrame also.
DestroyChildren();
-
+
// This causes a crash in e.g. the resource sample when closing
// the example dialog. TODO: Probably not necessary (?)
#if 0
// this might remain on the screen.
Display* display;
if (m_mainWidget)
- display = XtDisplay((Widget) m_mainWidget);
+ display = XtDisplay((Widget) m_mainWidget);
else
- display = (Display*) wxGetDisplay();
-
+ display = (Display*) wxGetDisplay();
+
XSync(display, FALSE);
XEvent event;
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
- XFlush(display);
- XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
- XtDispatchEvent(&event);
+ XFlush(display);
+ XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
+ XtDispatchEvent(&event);
}
#endif
}
// By default, pressing escape cancels the dialog
void wxDialog::OnCharHook(wxKeyEvent& event)
{
- if (event.m_keyCode == WXK_ESCAPE)
- {
- // Behaviour changed in 2.0: we'll send a Cancel message
- // to the dialog instead of Close.
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent);
-
- return;
- }
- // We didn't process this event.
- event.Skip();
+ if (event.m_keyCode == WXK_ESCAPE)
+ {
+ // Behaviour changed in 2.0: we'll send a Cancel message
+ // to the dialog instead of Close.
+ wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+ cancelEvent.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(cancelEvent);
+
+ return;
+ }
+ // We didn't process this event.
+ event.Skip();
}
void wxDialog::Iconize(bool WXUNUSED(iconize))
{
- // Can't iconize a dialog in Motif, apparently
- // TODO: try using the parent of m_mainShell.
-// XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
+ // Can't iconize a dialog in Motif, apparently
+ // TODO: try using the parent of m_mainShell.
+ // XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
}
bool wxDialog::IsIconized() const
{
- /*
- Boolean iconic;
- XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
+/*
+Boolean iconic;
+XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
- return iconic;
- */
+ return iconic;
+ */
return FALSE;
}
{
XmString str = XmStringCreateSimple((char*) (const char*) title);
XtVaSetValues((Widget) m_mainWidget,
- XmNtitle, (char*) (const char*) title,
- XmNdialogTitle, str, // Roberto Cocchi
- XmNiconName, (char*) (const char*) title,
- NULL);
+ XmNtitle, (char*) (const char*) title,
+ XmNdialogTitle, str, // Roberto Cocchi
+ XmNiconName, (char*) (const char*) title,
+ NULL);
XmStringFree(str);
}
}
wxString wxDialog::GetTitle() const
{
- return m_dialogTitle;
+ return m_dialogTitle;
}
void wxDialog::Centre(int direction)
{
- int x_offset,y_offset ;
- int display_width, display_height;
- int width, height, x, y;
- wxWindow *parent = GetParent();
- if ((direction & wxCENTER_FRAME) && parent)
- {
- parent->GetPosition(&x_offset,&y_offset) ;
- parent->GetSize(&display_width,&display_height) ;
- }
- else
- {
- wxDisplaySize(&display_width, &display_height);
- x_offset = 0 ;
- y_offset = 0 ;
- }
-
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- if (direction & wxHORIZONTAL)
- x = (int)((display_width - width)/2);
- if (direction & wxVERTICAL)
- y = (int)((display_height - height)/2);
-
- SetSize(x+x_offset, y+y_offset, width, height);
+ int x_offset,y_offset ;
+ int display_width, display_height;
+ int width, height, x, y;
+ wxWindow *parent = GetParent();
+ if ((direction & wxCENTER_FRAME) && parent)
+ {
+ parent->GetPosition(&x_offset,&y_offset) ;
+ parent->GetSize(&display_width,&display_height) ;
+ }
+ else
+ {
+ wxDisplaySize(&display_width, &display_height);
+ x_offset = 0 ;
+ y_offset = 0 ;
+ }
+
+ GetSize(&width, &height);
+ GetPosition(&x, &y);
+
+ if (direction & wxHORIZONTAL)
+ x = (int)((display_width - width)/2);
+ if (direction & wxVERTICAL)
+ y = (int)((display_height - height)/2);
+
+ SetSize(x+x_offset, y+y_offset, width, height);
}
void wxDialog::Raise()
{
Window parent_window = XtWindow((Widget) m_mainWidget),
- next_parent = XtWindow((Widget) m_mainWidget),
- root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
+ next_parent = XtWindow((Widget) m_mainWidget),
+ root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
- Window *theChildren; unsigned int n;
- parent_window = next_parent;
- XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
+ Window *theChildren; unsigned int n;
+ parent_window = next_parent;
+ XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
}
XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
}
void wxDialog::Lower()
{
Window parent_window = XtWindow((Widget) m_mainWidget),
- next_parent = XtWindow((Widget) m_mainWidget),
- root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
+ next_parent = XtWindow((Widget) m_mainWidget),
+ root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
- Window *theChildren; unsigned int n;
- parent_window = next_parent;
- XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
+ Window *theChildren; unsigned int n;
+ parent_window = next_parent;
+ XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
}
XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
}
bool wxDialog::Show(bool show)
{
m_isShown = show;
-
+
if (show)
{
if (!wxUSE_INVISIBLE_RESIZE)
- XtMapWidget(XtParent((Widget) m_mainWidget));
+ XtMapWidget(XtParent((Widget) m_mainWidget));
else
- XtManageChild((Widget) m_mainWidget) ;
-
+ XtManageChild((Widget) m_mainWidget) ;
+
XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
-
+
}
else
{
XtUnmapWidget(XtParent((Widget) m_mainWidget));
else
XtUnmanageChild((Widget) m_mainWidget) ;
-
- XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
- XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
+
+ XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
+ XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
}
-
+
return TRUE;
}
int wxDialog::ShowModal()
{
m_windowStyle |= wxDIALOG_MODAL;
-
+
Show(TRUE);
-
+
if (m_modalShowing)
return 0;
-
+
wxModalShowingStack.Insert((wxObject *)TRUE);
-
+
m_modalShowing = TRUE;
XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
-
+
XEvent event;
-
+
// Loop until we signal that the dialog should be closed
while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
{
-// XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
-
+ // XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
wxTheApp->ProcessXEvent((WXEvent*) &event);
}
-
+
// Remove modal dialog flag from stack
wxNode *node = wxModalShowingStack.First();
if (node)
- delete node;
-
+ delete node;
+
// Now process all events in case they get sent to a destroyed dialog
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
{
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
-
+
wxTheApp->ProcessXEvent((WXEvent*) &event);
}
-
+
// TODO: is it safe to call this, if the dialog may have been deleted
// by now? Probably only if we're using delayed deletion of dialogs.
return GetReturnCode();
{
if (!m_modalShowing)
return;
-
+
SetReturnCode(retCode);
-
+
// Strangely, we don't seem to need this now.
// XtRemoveGrab((Widget) m_mainWidget);
-
+
Show(FALSE);
-
+
m_modalShowing = FALSE;
-
+
wxNode *node = wxModalShowingStack.First();
if (node)
- node->SetData((wxObject *)FALSE);
+ node->SetData((wxObject *)FALSE);
}
// Standard buttons
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
- if ( Validate() && TransferDataFromWindow() )
- {
+ if ( Validate() && TransferDataFromWindow() )
+ {
if ( IsModal() )
EndModal(wxID_OK);
else
{
- SetReturnCode(wxID_OK);
- this->Show(FALSE);
+ SetReturnCode(wxID_OK);
+ this->Show(FALSE);
}
- }
+ }
}
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
{
- if (Validate())
- TransferDataFromWindow();
- // TODO probably need to disable the Apply button until things change again
+ if (Validate())
+ TransferDataFromWindow();
+ // TODO probably need to disable the Apply button until things change again
}
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
else
{
SetReturnCode(wxID_CANCEL);
- this->Show(FALSE);
+ this->Show(FALSE);
}
}
bool wxDialog::OnClose()
{
- // Behaviour changed in 2.0: we'll send a Cancel message by default,
+ // Behaviour changed in 2.0: we'll send a Cancel message by default,
// which may close the dialog.
// Check for looping if the Cancel event handler calls Close()
-
+
static wxList closing;
-
+
if ( closing.Member(this) )
return FALSE;
-
+
closing.Append(this);
-
- wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
- cancelEvent.SetEventObject( this );
- GetEventHandler()->ProcessEvent(cancelEvent);
-
+
+ wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
+ cancelEvent.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(cancelEvent);
+
closing.DeleteObject(this);
-
- return FALSE;
+
+ return FALSE;
}
void wxDialog::OnCloseWindow(wxCloseEvent& event)
// Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy()
{
- if (!wxPendingDelete.Member(this))
- wxPendingDelete.Append(this);
- return TRUE;
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+ return TRUE;
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
- SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
- Refresh();
+ SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
+ Refresh();
}
void wxDialog::Fit()
// Handle a close event from the window manager
static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data,
- XmAnyCallbackStruct *WXUNUSED(cbs))
+ XmAnyCallbackStruct *WXUNUSED(cbs))
{
- wxDialog *dialog = (wxDialog *)client_data;
- wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
- closeEvent.SetEventObject(dialog);
-
- // May delete the dialog (with delayed deletion)
- dialog->GetEventHandler()->ProcessEvent(closeEvent);
+ wxDialog *dialog = (wxDialog *)client_data;
+ wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
+ closeEvent.SetEventObject(dialog);
+
+ // May delete the dialog (with delayed deletion)
+ dialog->GetEventHandler()->ProcessEvent(closeEvent);
}
// TODO: Preferably, we should have a universal repaint proc.
// Meanwhile, use a special one for dialogs.
static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
{
- Window window;
- Display *display;
-
- wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
- if (!win)
- return;
-
- switch(event -> type)
- {
- case Expose :
- {
- window = (Window) win -> GetXWindow();
- display = (Display *) win -> GetXDisplay();
-
- wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
- event->xexpose.width, event->xexpose.height);
- win->m_updateRects.Append((wxObject*) rect);
-
- if (event -> xexpose.count == 0)
- {
- wxPaintEvent event(win->GetId());
- event.SetEventObject(win);
- win->GetEventHandler()->ProcessEvent(event);
-
- win->ClearUpdateRects();
- }
- break;
- }
- default :
- {
- cout << "\n\nNew Event ! is = " << event -> type << "\n";
- break;
- }
- }
+ Window window;
+ Display *display;
+
+ wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
+ if (!win)
+ return;
+
+ switch(event -> type)
+ {
+ case Expose :
+ {
+ window = (Window) win -> GetXWindow();
+ display = (Display *) win -> GetXDisplay();
+
+ wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
+ event->xexpose.width, event->xexpose.height);
+ win->m_updateRects.Append((wxObject*) rect);
+
+ if (event -> xexpose.count == 0)
+ {
+ wxPaintEvent event(win->GetId());
+ event.SetEventObject(win);
+ win->GetEventHandler()->ProcessEvent(event);
+
+ win->ClearUpdateRects();
+ }
+ break;
+ }
+ default :
+ {
+ cout << "\n\nNew Event ! is = " << event -> type << "\n";
+ break;
+ }
+ }
}
static void wxDialogBoxEventHandler (Widget wid,
- XtPointer WXUNUSED(client_data),
- XEvent* event,
- Boolean *continueToDispatch)
-{
- wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
- if (dialog)
- {
- wxMouseEvent wxevent(wxEVT_NULL);
- if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
- {
- wxevent.SetEventObject(dialog);
- wxevent.SetId(dialog->GetId());
- dialog->GetEventHandler()->ProcessEvent(wxevent);
- }
- else
+ XtPointer WXUNUSED(client_data),
+ XEvent* event,
+ Boolean *continueToDispatch)
+{
+ wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
+ if (dialog)
{
- // An attempt to implement OnCharHook by calling OnCharHook first;
- // if this returns TRUE, set continueToDispatch to False
- // (don't continue processing).
- // Otherwise set it to True and call OnChar.
- wxKeyEvent keyEvent(wxEVENT_TYPE_CHAR);
- if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
- {
- keyEvent.SetEventObject(dialog);
- keyEvent.SetId(dialog->GetId());
- keyEvent.SetEventType(wxEVT_CHAR_HOOK);
- if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
+ wxMouseEvent wxevent(wxEVT_NULL);
+ if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
{
- *continueToDispatch = False;
- return;
+ wxevent.SetEventObject(dialog);
+ wxevent.SetId(dialog->GetId());
+ dialog->GetEventHandler()->ProcessEvent(wxevent);
}
else
{
- keyEvent.SetEventType(wxEVT_CHAR);
- dialog->GetEventHandler()->ProcessEvent(keyEvent);
- }
- }
+ // An attempt to implement OnCharHook by calling OnCharHook first;
+ // if this returns TRUE, set continueToDispatch to False
+ // (don't continue processing).
+ // Otherwise set it to True and call OnChar.
+ wxKeyEvent keyEvent(wxEVENT_TYPE_CHAR);
+ if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
+ {
+ keyEvent.SetEventObject(dialog);
+ keyEvent.SetId(dialog->GetId());
+ keyEvent.SetEventType(wxEVT_CHAR_HOOK);
+ if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
+ {
+ *continueToDispatch = False;
+ return;
+ }
+ else
+ {
+ keyEvent.SetEventType(wxEVT_CHAR);
+ dialog->GetEventHandler()->ProcessEvent(keyEvent);
+ }
+ }
+ }
}
- }
- *continueToDispatch = True;
+ *continueToDispatch = True;
}
static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
{
- /* This gets called when the dialog is being shown, which
- * defeats modal showing.
- client->m_modalShowing = FALSE ;
- client->m_isShown = FALSE;
- */
+/* This gets called when the dialog is being shown, which
+* defeats modal showing.
+client->m_modalShowing = FALSE ;
+client->m_isShown = FALSE;
+ */
}
void wxDialog::ChangeFont(bool keepOriginalSize)
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp
-// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
+// Purpose: wxDropTarget, wxDropSource classes
// Author: Julian Smart
-// Modified by:
-// Created: 17/09/98
-// RCS-ID: $Id$
+// Id: $Id$
// Copyright: (c) 1998 Julian Smart
-// Licence: wxWindows licence
+// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dnd.h"
#endif
+#include "wx/setup.h"
+
+#if wxUSE_DRAG_AND_DROP
+
#include "wx/dnd.h"
#include "wx/window.h"
#include "wx/app.h"
#include "wx/gdicmn.h"
+#include "wx/intl.h"
+#include "wx/utils.h"
+#include "wx/log.h"
+
+#include <X11/Xlib.h>
// ----------------------------------------------------------------------------
// global
wxDropTarget::wxDropTarget()
{
-};
+}
wxDropTarget::~wxDropTarget()
{
-};
+}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
-bool wxTextDropTarget::OnDrop( long x, long y, const void *pData )
+bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
{
- OnDropText( x, y, (const char*)pData );
+ OnDropText( x, y, (const char*)data );
return TRUE;
-};
+}
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{
- printf( "Got dropped text: %s.\n", psz );
- printf( "At x: %d, y: %d.\n", (int)x, (int)y );
+ wxLogDebug( "Got dropped text: %s.", psz );
+ wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
return TRUE;
-};
+}
size_t wxTextDropTarget::GetFormatCount() const
{
// wxFileDropTarget
// ----------------------------------------------------------------------------
-bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
+bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
{
- printf( "Got %d dropped files.\n", (int)nFiles );
- printf( "At x: %d, y: %d.\n", (int)x, (int)y );
+ wxLogDebug( "Got %d dropped files.", (int)nFiles );
+ wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
+ for (size_t i = 0; i < nFiles; i++)
+ {
+ wxLogDebug( aszFiles[i] );
+ }
return TRUE;
}
-bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) )
+bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
{
- char *str = "/this/is/a/path.txt";
-
- return OnDropFiles(x, y, 1, &str );
+ size_t number = 0;
+ char *text = (char*) data;
+ for (size_t i = 0; i < size; i++)
+ if (text[i] == 0) number++;
+
+ if (number == 0) return TRUE;
+
+ char **files = new char*[number];
+
+ text = (char*) data;
+ for (size_t i = 0; i < number; i++)
+ {
+ files[i] = text;
+ int len = strlen( text );
+ text += len+1;
+ }
+
+ bool ret = OnDropFiles( x, y, 1, files );
+
+ free( files );
+
+ return ret;
}
size_t wxFileDropTarget::GetFormatCount() const
// wxDropSource
//-------------------------------------------------------------------------
-//-----------------------------------------------------------------------------
-// drag request
-
wxDropSource::wxDropSource( wxWindow *win )
{
- // TODO
- // m_window = win;
- m_data = NULL;
+#if 0
+ m_window = win;
+ m_data = (wxDataObject *) NULL;
+ m_retValue = wxDragCancel;
- // m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
- // m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-};
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
+#endif
+}
wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
{
- // TODO
- // m_window = win;
- m_data = &data;
-
- // m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
- // m_goaheadCursor = wxCursor( wxCURSOR_HAND );
-};
+#if 0
+ g_blockEventsOnDrag = TRUE;
+
+ m_window = win;
+ m_widget = win->m_widget;
+ if (win->m_wxwindow) m_widget = win->m_wxwindow;
+ m_retValue = wxDragCancel;
+
+ m_data = &data;
+
+ m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
+ m_goaheadCursor = wxCursor( wxCURSOR_HAND );
+#endif
+}
void wxDropSource::SetData( wxDataObject &data )
{
- m_data = &data;
-};
+// m_data = &data;
+}
wxDropSource::~wxDropSource(void)
{
-};
+// if (m_data) delete m_data;
+}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
- // TODO
- return wxDragError;
-};
+ // wxASSERT_MSG( m_data, "wxDragSource: no data" );
+
+ return wxDragNone;
+#if 0
+ if (!m_data) return (wxDragResult) wxDragNone;
+ if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone;
+
+ RegisterWindow();
+
+ // TODO
+
+ UnregisterWindow();
+
+ g_blockEventsOnDrag = FALSE;
+
+ return m_retValue;
+#endif
+}
+
+#if 0
+void wxDropSource::RegisterWindow(void)
+{
+ if (!m_data) return;
+
+ wxString formats;
+
+ wxDataFormat df = m_data->GetPreferredFormat();
+
+ switch (df)
+ {
+ case wxDF_TEXT:
+ formats += "text/plain";
+ break;
+ case wxDF_FILENAME:
+ formats += "file:ALL";
+ break;
+ default:
+ break;
+ }
+
+ char *str = WXSTRINGCAST formats;
+
+ // TODO
+}
+void wxDropSource::UnregisterWindow(void)
+{
+ if (!m_widget) return;
+
+ // TODO
+}
+#endif
+
+
+#endif
+ // wxUSE_DRAG_AND_DROP
#endif
#define DEFAULT_FILE_SELECTOR_SIZE 0
- // Let Motif defines the size of File
- // Selector Box (if 1), or fix it to
- // wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
+// Let Motif defines the size of File
+// Selector Box (if 1), or fix it to
+// wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
#define wxFSB_WIDTH 600
#define wxFSB_HEIGHT 500
{
// If there's a default extension specified but no filter, we create a suitable
// filter.
-
+
wxString filter2("");
if ( defaultExtension && !filter )
filter2 = wxString("*.") + wxString(defaultExtension) ;
else if ( filter )
filter2 = filter;
-
+
wxString defaultDirString;
if (defaultDir)
defaultDirString = defaultDir;
else
defaultDirString = "";
-
+
wxString defaultFilenameString;
if (defaultFileName)
defaultFilenameString = defaultFileName;
else
defaultFilenameString = "";
-
+
wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
-
+
if ( fileDialog.ShowModal() == wxID_OK )
{
strcpy(wxBuffer, (const char *)fileDialog.GetPath());
wxWindow* parent,
int x,
int y)
-
+
{
wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
-
+
if ( fileDialog.ShowModal() == wxID_OK )
{
*defaultFilterIndex = fileDialog.GetFilterIndex();
bool wxFileDialog::m_fileSelectorReturned = FALSE;
void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data),
- XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
+ XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
{
- wxFileDialog::m_fileSelectorAnswer = "";
- wxFileDialog::m_fileSelectorReturned = TRUE;
+ wxFileDialog::m_fileSelectorAnswer = "";
+ wxFileDialog::m_fileSelectorReturned = TRUE;
}
void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSelectionBoxCallbackStruct *cbs)
{
- char *filename = NULL;
- if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
- wxFileDialog::m_fileSelectorAnswer = "";
- wxFileDialog::m_fileSelectorReturned = TRUE;
- } else {
- if (filename) {
- wxFileDialog::m_fileSelectorAnswer = filename;
- XtFree(filename);
+ char *filename = NULL;
+ if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
+ wxFileDialog::m_fileSelectorAnswer = "";
+ wxFileDialog::m_fileSelectorReturned = TRUE;
+ } else {
+ if (filename) {
+ wxFileDialog::m_fileSelectorAnswer = filename;
+ XtFree(filename);
+ }
+ wxFileDialog::m_fileSelectorReturned = TRUE;
}
- wxFileDialog::m_fileSelectorReturned = TRUE;
- }
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
- const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
- long style, const wxPoint& pos)
+ const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
+ long style, const wxPoint& pos)
{
m_message = message;
m_dialogStyle = style;
int wxFileDialog::ShowModal()
{
- wxBeginBusyCursor();
-
-// static char fileBuf[512];
- Widget parentWidget = (Widget) 0;
- if (m_parent)
- {
- parentWidget = (Widget) m_parent->GetTopWidget();
- }
- else
- parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
-
- Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
- XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
-
- Widget shell = XtParent(fileSel);
-
- if (!m_message.IsNull())
- XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
-
- wxString entirePath("");
-
- if ((m_dir != "") && (m_fileName != ""))
- {
- entirePath = m_dir + wxString("/") + m_fileName;
- }
- else if ((m_dir != "") && (m_fileName == ""))
- {
- entirePath = m_dir + wxString("/");
- }
- else if ((m_dir == "") && (m_fileName != ""))
- {
- entirePath = m_fileName;
- }
-
- if (entirePath != "")
- {
- Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
- XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
- }
-
- if (m_wildCard != "")
- {
- wxString filter("");
- if (m_dir != "")
- filter = m_dir + wxString("/") + m_wildCard;
+ wxBeginBusyCursor();
+
+ // static char fileBuf[512];
+ Widget parentWidget = (Widget) 0;
+ if (m_parent)
+ {
+ parentWidget = (Widget) m_parent->GetTopWidget();
+ }
else
- filter = m_wildCard;
-
- Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
- XmTextSetString(filterWidget, (char*) (const char*) filter);
- XmFileSelectionDoSearch(fileSel, NULL);
- }
-
- // Suggested by Terry Gitnick, 16/9/97, because of change in Motif
- // file selector on Solaris 1.5.1.
- if ( m_dir != "" )
- {
- XmString thePath = XmStringCreateLtoR ((char*) (const char*) m_dir,
- XmSTRING_DEFAULT_CHARSET);
-
- XtVaSetValues (fileSel,
- XmNdirectory, thePath,
- NULL);
-
- XmStringFree(thePath);
- }
-
- XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
- XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
-
-//#if XmVersion > 1000
-// I'm not sure about what you mean with XmVersion.
-// If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
-// (Motif1.1.4 ==> XmVersion 1100 )
-// Nevertheless, I put here a #define, so anyone can choose in (I)makefile...
-//
+ parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
+
+ Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
+ XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
+
+ Widget shell = XtParent(fileSel);
+
+ if (!m_message.IsNull())
+ XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
+
+ wxString entirePath("");
+
+ if ((m_dir != "") && (m_fileName != ""))
+ {
+ entirePath = m_dir + wxString("/") + m_fileName;
+ }
+ else if ((m_dir != "") && (m_fileName == ""))
+ {
+ entirePath = m_dir + wxString("/");
+ }
+ else if ((m_dir == "") && (m_fileName != ""))
+ {
+ entirePath = m_fileName;
+ }
+
+ if (entirePath != "")
+ {
+ Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
+ XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
+ }
+
+ if (m_wildCard != "")
+ {
+ wxString filter("");
+ if (m_dir != "")
+ filter = m_dir + wxString("/") + m_wildCard;
+ else
+ filter = m_wildCard;
+
+ Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
+ XmTextSetString(filterWidget, (char*) (const char*) filter);
+ XmFileSelectionDoSearch(fileSel, NULL);
+ }
+
+ // Suggested by Terry Gitnick, 16/9/97, because of change in Motif
+ // file selector on Solaris 1.5.1.
+ if ( m_dir != "" )
+ {
+ XmString thePath = XmStringCreateLtoR ((char*) (const char*) m_dir,
+ XmSTRING_DEFAULT_CHARSET);
+
+ XtVaSetValues (fileSel,
+ XmNdirectory, thePath,
+ NULL);
+
+ XmStringFree(thePath);
+ }
+
+ XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
+ XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
+
+ //#if XmVersion > 1000
+ // I'm not sure about what you mean with XmVersion.
+ // If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
+ // (Motif1.1.4 ==> XmVersion 1100 )
+ // Nevertheless, I put here a #define, so anyone can choose in (I)makefile...
+ //
#if !DEFAULT_FILE_SELECTOR_SIZE
- int width = wxFSB_WIDTH;
- int height = wxFSB_HEIGHT;
- XtVaSetValues(fileSel,
- XmNwidth, width,
- XmNheight, height,
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
+ int width = wxFSB_WIDTH;
+ int height = wxFSB_HEIGHT;
+ XtVaSetValues(fileSel,
+ XmNwidth, width,
+ XmNheight, height,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
#endif
-
- XtManageChild(fileSel);
-
- m_fileSelectorAnswer = "";
- m_fileSelectorReturned = FALSE;
-
- wxEndBusyCursor();
-
- XtAddGrab(XtParent(fileSel), TRUE, FALSE);
- XEvent event;
- while (!m_fileSelectorReturned)
- {
- XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
- }
- XtRemoveGrab(XtParent(fileSel));
-
- XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
-
-// XtDestroyWidget(fileSel);
- XtUnmapWidget(XtParent(fileSel));
- XtDestroyWidget(XtParent(fileSel));
-
- // Now process all events, because otherwise
- // this might remain on the screen
- XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
- while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
- {
- XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
- XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
- XtDispatchEvent(&event);
- }
-
- m_path = m_fileSelectorAnswer;
- m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
- m_dir = wxPathOnly(m_path);
-
- if (m_fileName == "")
- return wxID_CANCEL;
- else
- return wxID_OK;
+
+ XtManageChild(fileSel);
+
+ m_fileSelectorAnswer = "";
+ m_fileSelectorReturned = FALSE;
+
+ wxEndBusyCursor();
+
+ XtAddGrab(XtParent(fileSel), TRUE, FALSE);
+ XEvent event;
+ while (!m_fileSelectorReturned)
+ {
+ XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+ }
+ XtRemoveGrab(XtParent(fileSel));
+
+ XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
+
+ // XtDestroyWidget(fileSel);
+ XtUnmapWidget(XtParent(fileSel));
+ XtDestroyWidget(XtParent(fileSel));
+
+ // Now process all events, because otherwise
+ // this might remain on the screen
+ XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
+ while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
+ {
+ XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
+ XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
+ XtDispatchEvent(&event);
+ }
+
+ m_path = m_fileSelectorAnswer;
+ m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
+ m_dir = wxPathOnly(m_path);
+
+ if (m_fileName == "")
+ return wxID_CANCEL;
+ else
+ return wxID_OK;
}
// Generic file load/save dialog
static char *
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
{
- char *ext = (char *)extension;
-
- char prompt[50];
- wxString str;
- if (load)
- str = "Load %s file";
- else
- str = "Save %s file";
- sprintf(prompt, wxGetTranslation(str), what);
-
- if (*ext == '.') ext++;
- char wild[60];
- sprintf(wild, "*.%s", ext);
-
- return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
+ char *ext = (char *)extension;
+
+ char prompt[50];
+ wxString str;
+ if (load)
+ str = "Load %s file";
+ else
+ str = "Save %s file";
+ sprintf(prompt, wxGetTranslation(str), what);
+
+ if (*ext == '.') ext++;
+ char wild[60];
+ sprintf(wild, "*.%s", ext);
+
+ return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
}
// Generic file load dialog
char *
wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
{
- return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
+ return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
}
char *
wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
{
- return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
+ return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
}
{
XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
XmFontList fontList = (XmFontList) m_fontList;
-
+
XmFontListFree (fontList);
-
- // TODO: why does freeing the font produce a segv???
+
+ // TODO: why does freeing the font produce a segv???
// Note that XFreeFont wasn't called in wxWin 1.68 either.
- // XFreeFont((Display*) m_display, fontStruct);
+ // XFreeFont((Display*) m_display, fontStruct);
}
wxFontRefData::wxFontRefData()
m_weight = data.m_weight;
m_underlined = data.m_underlined;
m_faceName = data.m_faceName;
-
+
// Don't have to copy actual fonts, because they'll be created
// on demand.
}
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{
Create(pointSize, family, style, weight, underlined, faceName);
-
+
if ( wxTheFontList )
wxTheFontList->Append(this);
}
{
UnRef();
m_refData = new wxFontRefData;
-
+
M_FONTDATA->m_family = family;
M_FONTDATA->m_style = style;
M_FONTDATA->m_weight = weight;
M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_underlined = underlined;
M_FONTDATA->m_faceName = faceName;
-
+
RealizeResource();
-
+
return TRUE;
}
void wxFont::Unshare()
{
- // Don't change shared data
- if (!m_refData)
+ // Don't change shared data
+ if (!m_refData)
{
- m_refData = new wxFontRefData();
- }
+ m_refData = new wxFontRefData();
+ }
else
{
- wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxFont::SetPointSize(int pointSize)
{
Unshare();
-
+
M_FONTDATA->m_pointSize = pointSize;
-
+
RealizeResource();
}
void wxFont::SetFamily(int family)
{
Unshare();
-
+
M_FONTDATA->m_family = family;
-
+
RealizeResource();
}
void wxFont::SetStyle(int style)
{
Unshare();
-
+
M_FONTDATA->m_style = style;
-
+
RealizeResource();
}
void wxFont::SetWeight(int weight)
{
Unshare();
-
+
M_FONTDATA->m_weight = weight;
-
+
RealizeResource();
}
void wxFont::SetFaceName(const wxString& faceName)
{
Unshare();
-
+
M_FONTDATA->m_faceName = faceName;
-
+
RealizeResource();
}
void wxFont::SetUnderlined(bool underlined)
{
Unshare();
-
+
M_FONTDATA->m_underlined = underlined;
-
+
RealizeResource();
}
wxString wxFont::GetFamilyString() const
{
- wxString fam("");
- switch (GetFamily())
- {
+ wxString fam("");
+ switch (GetFamily())
+ {
case wxDECORATIVE:
- fam = "wxDECORATIVE";
- break;
+ fam = "wxDECORATIVE";
+ break;
case wxROMAN:
- fam = "wxROMAN";
- break;
+ fam = "wxROMAN";
+ break;
case wxSCRIPT:
- fam = "wxSCRIPT";
- break;
+ fam = "wxSCRIPT";
+ break;
case wxSWISS:
- fam = "wxSWISS";
- break;
+ fam = "wxSWISS";
+ break;
case wxMODERN:
- fam = "wxMODERN";
- break;
+ fam = "wxMODERN";
+ break;
case wxTELETYPE:
- fam = "wxTELETYPE";
- break;
+ fam = "wxTELETYPE";
+ break;
default:
- fam = "wxDEFAULT";
- break;
- }
- return fam;
+ fam = "wxDEFAULT";
+ break;
+ }
+ return fam;
}
/* New font system */
{
wxString str("");
if (M_FONTDATA)
- str = M_FONTDATA->m_faceName ;
+ str = M_FONTDATA->m_faceName ;
return str;
}
wxString styl("");
switch (GetStyle())
{
- case wxITALIC:
- styl = "wxITALIC";
- break;
- case wxSLANT:
- styl = "wxSLANT";
- break;
- default:
- styl = "wxNORMAL";
- break;
+ case wxITALIC:
+ styl = "wxITALIC";
+ break;
+ case wxSLANT:
+ styl = "wxSLANT";
+ break;
+ default:
+ styl = "wxNORMAL";
+ break;
}
return styl;
}
wxString w("");
switch (GetWeight())
{
- case wxBOLD:
- w = "wxBOLD";
- break;
- case wxLIGHT:
- w = "wxLIGHT";
- break;
- default:
- w = "wxNORMAL";
- break;
+ case wxBOLD:
+ w = "wxBOLD";
+ break;
+ case wxLIGHT:
+ w = "wxLIGHT";
+ break;
+ default:
+ w = "wxNORMAL";
+ break;
}
return w;
}
// font to list in the private data for future reference.
wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
{
- if (!Ok())
- return (wxXFont*) NULL;
-
- long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
- int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
-
- wxNode* node = M_FONTDATA->m_fonts.First();
- while (node)
- {
- wxXFont* f = (wxXFont*) node->Data();
- if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
- return f;
- node = node->Next();
- }
-
- WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
- M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
-
- if (!font)
- {
- // search up and down by stepsize 10
- int max_size = pointSize + 20 * (1 + (pointSize/180));
- int min_size = pointSize - 20 * (1 + (pointSize/180));
- int i;
-
- // Search for smaller size (approx.)
- for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10)
- font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
- // Search for larger size (approx.)
- for (i=pointSize+10; !font && i <= max_size; i += 10)
- font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
- // Try default family
- if (!font && M_FONTDATA->m_family != wxDEFAULT)
- font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
- M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
- // Bogus font
- if (!font)
- font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
- M_FONTDATA->m_underlined);
+ if (!Ok())
+ return (wxXFont*) NULL;
+
+ long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
+ int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
+
+ wxNode* node = M_FONTDATA->m_fonts.First();
+ while (node)
+ {
+ wxXFont* f = (wxXFont*) node->Data();
+ if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
+ return f;
+ node = node->Next();
+ }
+
+ WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
+ M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
+
+ if (!font)
+ {
+ // search up and down by stepsize 10
+ int max_size = pointSize + 20 * (1 + (pointSize/180));
+ int min_size = pointSize - 20 * (1 + (pointSize/180));
+ int i;
+
+ // Search for smaller size (approx.)
+ for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10)
+ font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
+ // Search for larger size (approx.)
+ for (i=pointSize+10; !font && i <= max_size; i += 10)
+ font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
+ // Try default family
+ if (!font && M_FONTDATA->m_family != wxDEFAULT)
+ font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
+ M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
+ // Bogus font
+ if (!font)
+ font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
+ M_FONTDATA->m_underlined);
wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." );
- }
- if (font)
- {
- wxXFont* f = new wxXFont;
- f->m_fontStruct = font;
- f->m_display = ( display ? display : wxGetDisplay() );
- f->m_scale = intScale;
- f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
- M_FONTDATA->m_fonts.Append(f);
- return f;
- }
- return (wxXFont*) NULL;
+ }
+ if (font)
+ {
+ wxXFont* f = new wxXFont;
+ f->m_fontStruct = font;
+ f->m_display = ( display ? display : wxGetDisplay() );
+ f->m_scale = intScale;
+ f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
+ M_FONTDATA->m_fonts.Append(f);
+ return f;
+ }
+ return (wxXFont*) NULL;
}
WXFontStructPtr wxFont::LoadQueryFont(int pointSize, int family, int style,
- int weight, bool underlined) const
+ int weight, bool underlined) const
{
char *xfamily;
char *xstyle;
char *xweight;
switch (family)
{
- case wxDECORATIVE: xfamily = "lucida";
- break;
- case wxROMAN: xfamily = "times";
- break;
- case wxMODERN: xfamily = "courier";
- break;
- case wxSWISS: xfamily = "lucida";
- break;
- case wxDEFAULT:
- default: xfamily = "*";
+ case wxDECORATIVE: xfamily = "lucida";
+ break;
+ case wxROMAN: xfamily = "times";
+ break;
+ case wxMODERN: xfamily = "courier";
+ break;
+ case wxSWISS: xfamily = "lucida";
+ break;
+ case wxDEFAULT:
+ default: xfamily = "*";
}
switch (style)
{
- case wxITALIC: xstyle = "i";
- break;
- case wxSLANT: xstyle = "o";
- break;
- case wxNORMAL: xstyle = "r";
- break;
- default: xstyle = "*";
- break;
+ case wxITALIC: xstyle = "i";
+ break;
+ case wxSLANT: xstyle = "o";
+ break;
+ case wxNORMAL: xstyle = "r";
+ break;
+ default: xstyle = "*";
+ break;
}
switch (weight)
{
- case wxBOLD: xweight = "bold";
- break;
- case wxLIGHT:
- case wxNORMAL: xweight = "medium";
- break;
- default: xweight = "*";
- break;
+ case wxBOLD: xweight = "bold";
+ break;
+ case wxLIGHT:
+ case wxNORMAL: xweight = "medium";
+ break;
+ default: xweight = "*";
+ break;
}
-
+
sprintf(wxBuffer, "-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*",
- xfamily, xweight, xstyle, pointSize);
-
+ xfamily, xweight, xstyle, pointSize);
+
Display *dpy = (Display*) wxGetDisplay();
XFontStruct* font = XLoadQueryFont(dpy, wxBuffer);
-
+
return (WXFontStructPtr) font;
}
void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
- XCrossingEvent * event);
+ XCrossingEvent * event);
extern wxList wxModelessWindows;
extern wxList wxPendingDelete;
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxFrame, wxWindow)
- EVT_SIZE(wxFrame::OnSize)
- EVT_ACTIVATE(wxFrame::OnActivate)
- EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
- EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
- EVT_IDLE(wxFrame::OnIdle)
- EVT_CLOSE(wxFrame::OnCloseWindow)
+EVT_SIZE(wxFrame::OnSize)
+EVT_ACTIVATE(wxFrame::OnActivate)
+EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight)
+EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
+EVT_IDLE(wxFrame::OnIdle)
+EVT_CLOSE(wxFrame::OnCloseWindow)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow)
m_frameToolBar = NULL ;
m_frameMenuBar = NULL;
m_frameStatusBar = NULL;
-
+
m_windowParent = NULL;
m_iconized = FALSE;
-
+
//// Motif-specific
m_frameShell = (WXWidget) NULL;
m_frameWidget = (WXWidget) NULL;;
}
bool wxFrame::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
- if (!parent)
- wxTopLevelWindows.Append(this);
-
- SetName(name);
-
- m_windowStyle = style;
- m_frameMenuBar = NULL;
- m_frameToolBar = NULL ;
- m_frameStatusBar = NULL;
-
- //// Motif-specific
- m_frameShell = (WXWidget) NULL;
- m_frameWidget = (WXWidget) NULL;;
- m_workArea = (WXWidget) NULL;;
- m_clientArea = (WXWidget) NULL;;
- m_visibleStatus = TRUE;
- m_title = "";
-
- m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
- m_foregroundColour = *wxBLACK;
- m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
-
- if ( id > -1 )
- m_windowId = id;
- else
- m_windowId = (int)NewControlId();
-
- if (parent) parent->AddChild(this);
-
- wxModelessWindows.Append(this);
-
- int x = pos.x; int y = pos.y;
- int width = size.x; int height = size.y;
-
- if (wxTopLevelUsed)
- // Change suggested by Matthew Flatt
- m_frameShell = (WXWidget) XtAppCreateShell(name, wxTheApp->GetClassName(), topLevelShellWidgetClass, (Display*) wxGetDisplay(), NULL, 0);
- else
- {
- m_frameShell = wxTheApp->GetTopLevelWidget();
- wxTopLevelUsed = TRUE;
- }
-
- XtVaSetValues((Widget) m_frameShell,
- // Allows menu to resize
- XmNallowShellResize, True,
- XmNdeleteResponse, XmDO_NOTHING,
- XmNmappedWhenManaged, False,
- XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
- NULL);
-
- if (!title.IsNull())
+ if (!parent)
+ wxTopLevelWindows.Append(this);
+
+ SetName(name);
+
+ m_windowStyle = style;
+ m_frameMenuBar = NULL;
+ m_frameToolBar = NULL ;
+ m_frameStatusBar = NULL;
+
+ //// Motif-specific
+ m_frameShell = (WXWidget) NULL;
+ m_frameWidget = (WXWidget) NULL;;
+ m_workArea = (WXWidget) NULL;;
+ m_clientArea = (WXWidget) NULL;;
+ m_visibleStatus = TRUE;
+ m_title = "";
+
+ m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
+ m_foregroundColour = *wxBLACK;
+ m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
+
+ if ( id > -1 )
+ m_windowId = id;
+ else
+ m_windowId = (int)NewControlId();
+
+ if (parent) parent->AddChild(this);
+
+ wxModelessWindows.Append(this);
+
+ int x = pos.x; int y = pos.y;
+ int width = size.x; int height = size.y;
+
+ if (wxTopLevelUsed)
+ // Change suggested by Matthew Flatt
+ m_frameShell = (WXWidget) XtAppCreateShell(name, wxTheApp->GetClassName(), topLevelShellWidgetClass, (Display*) wxGetDisplay(), NULL, 0);
+ else
+ {
+ m_frameShell = wxTheApp->GetTopLevelWidget();
+ wxTopLevelUsed = TRUE;
+ }
+
XtVaSetValues((Widget) m_frameShell,
- XmNtitle, (const char*) title,
- NULL);
-
- m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
- xmMainWindowWidgetClass, (Widget) m_frameShell,
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
-
- m_workArea = (WXWidget) XtVaCreateWidget("form",
- xmFormWidgetClass, (Widget) m_frameWidget,
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
-
- m_clientArea = (WXWidget) XtVaCreateWidget("client",
- xmBulletinBoardWidgetClass, (Widget) m_workArea,
- XmNmarginWidth, 0,
- XmNmarginHeight, 0,
- XmNrightAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
-// XmNresizePolicy, XmRESIZE_ANY,
- NULL);
-
- XtVaSetValues((Widget) m_frameWidget,
- XmNworkWindow, (Widget) m_workArea,
- NULL);
-
-
- XtManageChild((Widget) m_clientArea);
- XtManageChild((Widget) m_workArea);
-
- wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
-
- wxAddWindowToTable((Widget) m_workArea, this);
-
- XtTranslations ptr ;
-
- XtOverrideTranslations((Widget) m_workArea,
- ptr = XtParseTranslationTable("<Configure>: resize()"));
-
- XtFree((char *)ptr);
-
- XtAddCallback((Widget) m_workArea, XmNfocusCallback,
- (XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
-
- /* Part of show-&-hide fix */
- XtAddEventHandler((Widget) m_frameShell, StructureNotifyMask,
- False, (XtEventHandler)wxFrameMapProc,
- (XtPointer)m_workArea);
-
- if (x > -1)
- XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
- if (y > -1)
- XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
- if (width > -1)
- XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL);
-
- m_mainWidget = m_frameWidget;
-
- ChangeFont(FALSE);
-
- // This patch comes from Torsten Liermann lier@lier1.muc.de
- if (XmIsMotifWMRunning( (Widget) m_frameShell ))
- {
- int decor = 0 ;
- if (style & wxRESIZE_BORDER)
- decor |= MWM_DECOR_RESIZEH ;
- if (style & wxSYSTEM_MENU)
- decor |= MWM_DECOR_MENU;
- if ((style & wxCAPTION) ||
- (style & wxTINY_CAPTION_HORIZ) ||
- (style & wxTINY_CAPTION_VERT))
- decor |= MWM_DECOR_TITLE;
- if (style & wxTHICK_FRAME)
- decor |= MWM_DECOR_BORDER;
- if (style & wxTHICK_FRAME)
- decor |= MWM_DECOR_BORDER;
- if (style & wxMINIMIZE_BOX)
- decor |= MWM_DECOR_MINIMIZE;
- if (style & wxMAXIMIZE_BOX)
- decor |= MWM_DECOR_MAXIMIZE;
- XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL) ;
- }
- // This allows non-Motif window managers to support at least the
- // no-decorations case.
- else
- {
- if (style == 0)
- XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL);
- }
- XtRealizeWidget((Widget) m_frameShell);
-
- // Intercept CLOSE messages from the window manager
- Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay((Widget) m_frameShell), "WM_DELETE_WINDOW", False);
+ // Allows menu to resize
+ XmNallowShellResize, True,
+ XmNdeleteResponse, XmDO_NOTHING,
+ XmNmappedWhenManaged, False,
+ XmNiconic, (style & wxICONIZE) ? TRUE : FALSE,
+ NULL);
+
+ if (!title.IsNull())
+ XtVaSetValues((Widget) m_frameShell,
+ XmNtitle, (const char*) title,
+ NULL);
+
+ m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
+ xmMainWindowWidgetClass, (Widget) m_frameShell,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
+
+ m_workArea = (WXWidget) XtVaCreateWidget("form",
+ xmFormWidgetClass, (Widget) m_frameWidget,
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
+
+ m_clientArea = (WXWidget) XtVaCreateWidget("client",
+ xmBulletinBoardWidgetClass, (Widget) m_workArea,
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ XmNrightAttachment, XmATTACH_FORM,
+ XmNleftAttachment, XmATTACH_FORM,
+ XmNtopAttachment, XmATTACH_FORM,
+ XmNbottomAttachment, XmATTACH_FORM,
+ // XmNresizePolicy, XmRESIZE_ANY,
+ NULL);
+
+ XtVaSetValues((Widget) m_frameWidget,
+ XmNworkWindow, (Widget) m_workArea,
+ NULL);
+
+
+ XtManageChild((Widget) m_clientArea);
+ XtManageChild((Widget) m_workArea);
+
+ wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
+
+ wxAddWindowToTable((Widget) m_workArea, this);
+
+ XtTranslations ptr ;
+
+ XtOverrideTranslations((Widget) m_workArea,
+ ptr = XtParseTranslationTable("<Configure>: resize()"));
+
+ XtFree((char *)ptr);
+
+ XtAddCallback((Widget) m_workArea, XmNfocusCallback,
+ (XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
+
+ /* Part of show-&-hide fix */
+ XtAddEventHandler((Widget) m_frameShell, StructureNotifyMask,
+ False, (XtEventHandler)wxFrameMapProc,
+ (XtPointer)m_workArea);
+
+ if (x > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
+ if (y > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
+ if (width > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL);
+
+ m_mainWidget = m_frameWidget;
+
+ ChangeFont(FALSE);
+
+ // This patch comes from Torsten Liermann lier@lier1.muc.de
+ if (XmIsMotifWMRunning( (Widget) m_frameShell ))
+ {
+ int decor = 0 ;
+ if (style & wxRESIZE_BORDER)
+ decor |= MWM_DECOR_RESIZEH ;
+ if (style & wxSYSTEM_MENU)
+ decor |= MWM_DECOR_MENU;
+ if ((style & wxCAPTION) ||
+ (style & wxTINY_CAPTION_HORIZ) ||
+ (style & wxTINY_CAPTION_VERT))
+ decor |= MWM_DECOR_TITLE;
+ if (style & wxTHICK_FRAME)
+ decor |= MWM_DECOR_BORDER;
+ if (style & wxTHICK_FRAME)
+ decor |= MWM_DECOR_BORDER;
+ if (style & wxMINIMIZE_BOX)
+ decor |= MWM_DECOR_MINIMIZE;
+ if (style & wxMAXIMIZE_BOX)
+ decor |= MWM_DECOR_MAXIMIZE;
+ XtVaSetValues((Widget) m_frameShell,XmNmwmDecorations,decor,NULL) ;
+ }
+ // This allows non-Motif window managers to support at least the
+ // no-decorations case.
+ else
+ {
+ if (style == 0)
+ XtVaSetValues((Widget) m_frameShell,XmNoverrideRedirect,TRUE,NULL);
+ }
+ XtRealizeWidget((Widget) m_frameShell);
+
+ // Intercept CLOSE messages from the window manager
+ Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay((Widget) m_frameShell), "WM_DELETE_WINDOW", False);
#if (XmREVISION > 1 || XmVERSION > 1)
- XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (XtPointer)this);
+ XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (XtPointer)this);
#else
#if XmREVISION == 1
- XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (caddr_t)this);
+ XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseFrameCallback, (caddr_t)this);
#else
- XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (void (*)())wxCloseFrameCallback, (caddr_t)this);
+ XmAddWMProtocolCallback((Widget) m_frameShell, WM_DELETE_WINDOW, (void (*)())wxCloseFrameCallback, (caddr_t)this);
#endif
#endif
-
- ChangeBackgroundColour();
-
- PreResize();
-
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-
- return TRUE;
+
+ ChangeBackgroundColour();
+
+ PreResize();
+
+ wxSizeEvent sizeEvent(wxSize(width, height), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+
+ return TRUE;
}
wxFrame::~wxFrame()
{
- if (GetMainWidget())
- Show(FALSE);
-
- if (m_frameMenuBar)
- {
- m_frameMenuBar->DestroyMenuBar();
-
-// Hack to stop core dump on Ultrix, OSF, for some strange reason.
+ if (GetMainWidget())
+ Show(FALSE);
+
+ if (m_frameMenuBar)
+ {
+ m_frameMenuBar->DestroyMenuBar();
+
+ // Hack to stop core dump on Ultrix, OSF, for some strange reason.
#if MOTIF_MENUBAR_DELETE_FIX
- GetMenuBar()->SetMainWidget((WXWidget) NULL);
+ GetMenuBar()->SetMainWidget((WXWidget) NULL);
#endif
- delete m_frameMenuBar;
- m_frameMenuBar = NULL;
- }
-
- wxTopLevelWindows.DeleteObject(this);
- wxModelessWindows.DeleteObject(this);
-
- if (m_frameStatusBar)
- delete m_frameStatusBar;
-
- DestroyChildren();
-
-/*
- int i;
- for (i = 0; i < wxMAX_STATUS; i++)
+ delete m_frameMenuBar;
+ m_frameMenuBar = NULL;
+ }
+
+ wxTopLevelWindows.DeleteObject(this);
+ wxModelessWindows.DeleteObject(this);
+
+ if (m_frameStatusBar)
+ delete m_frameStatusBar;
+
+ DestroyChildren();
+
+ /*
+ int i;
+ for (i = 0; i < wxMAX_STATUS; i++)
if (statusTextWidget[i])
- XtDestroyWidget (statusTextWidget[i]);
-
- if (statusLineForm)
- XtDestroyWidget (statusLineForm);
-
- if (statusLineWidget)
- XtDestroyWidget (statusLineWidget);
- */
-
- if (m_workArea)
- {
- wxDeleteWindowFromTable((Widget) m_workArea);
-
- XtDestroyWidget ((Widget) m_workArea);
- }
-
- if (m_frameWidget)
- {
- wxDeleteWindowFromTable((Widget) m_frameWidget);
- XtDestroyWidget ((Widget) m_frameWidget);
- }
-
- if (m_frameShell)
- XtDestroyWidget ((Widget) m_frameShell);
-
- SetMainWidget((WXWidget) NULL);
-
-/* Check if it's the last top-level window */
-
- if (wxTheApp && (wxTopLevelWindows.Number() == 0))
- {
- wxTheApp->SetTopWindow(NULL);
-
- if (wxTheApp->GetExitOnFrameDelete())
+ XtDestroyWidget (statusTextWidget[i]);
+
+ if (statusLineForm)
+ XtDestroyWidget (statusLineForm);
+
+ if (statusLineWidget)
+ XtDestroyWidget (statusLineWidget);
+ */
+
+ if (m_workArea)
{
- // Signal to the app that we're going to close
- wxTheApp->ExitMainLoop();
+ wxDeleteWindowFromTable((Widget) m_workArea);
+
+ XtDestroyWidget ((Widget) m_workArea);
}
- }
-
+
+ if (m_frameWidget)
+ {
+ wxDeleteWindowFromTable((Widget) m_frameWidget);
+ XtDestroyWidget ((Widget) m_frameWidget);
+ }
+
+ if (m_frameShell)
+ XtDestroyWidget ((Widget) m_frameShell);
+
+ SetMainWidget((WXWidget) NULL);
+
+ /* Check if it's the last top-level window */
+
+ if (wxTheApp && (wxTopLevelWindows.Number() == 0))
+ {
+ wxTheApp->SetTopWindow(NULL);
+
+ if (wxTheApp->GetExitOnFrameDelete())
+ {
+ // Signal to the app that we're going to close
+ wxTheApp->ExitMainLoop();
+ }
+ }
+
}
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
void wxFrame::GetClientSize(int *x, int *y) const
{
- Dimension xx, yy;
- XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL);
-
- if (m_frameStatusBar)
- {
- int sbw, sbh;
- m_frameStatusBar->GetSize(& sbw, & sbh);
- yy -= sbh;
- }
- if (m_frameToolBar)
- {
- int tbw, tbh;
- m_frameToolBar->GetSize(& tbw, & tbh);
- if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
- xx -= tbw;
- else
- yy -= tbh;
- }
-/*
- if (GetMenuBar() != (wxMenuBar*) NULL)
- {
+ Dimension xx, yy;
+ XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL);
+
+ if (m_frameStatusBar)
+ {
+ int sbw, sbh;
+ m_frameStatusBar->GetSize(& sbw, & sbh);
+ yy -= sbh;
+ }
+ if (m_frameToolBar)
+ {
+ int tbw, tbh;
+ m_frameToolBar->GetSize(& tbw, & tbh);
+ if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
+ xx -= tbw;
+ else
+ yy -= tbh;
+ }
+ /*
+ if (GetMenuBar() != (wxMenuBar*) NULL)
+ {
// it seems that if a frame holds a panel, the menu bar size
// gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95
bool hasSubPanel = FALSE;
for(wxNode* node = GetChildren().First(); node; node = node->Next())
{
- wxWindow *win = (wxWindow *)node->Data();
- hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
-
+ wxWindow *win = (wxWindow *)node->Data();
+ hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
+
if (hasSubPanel)
- break;
- }
- if (! hasSubPanel) {
+ break;
+ }
+ if (! hasSubPanel) {
Dimension ys;
XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL);
yy -= ys;
- }
- }
- */
-
- *x = xx; *y = yy;
+ }
+ }
+ */
+
+ *x = xx; *y = yy;
}
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWindows)
void wxFrame::SetClientSize(int width, int height)
{
- // Calculate how large the new main window should be
- // by finding the difference between the client area and the
- // main window area, and adding on to the new client area
- if (width > -1)
- XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL);
-
- if (height > -1)
- {
- if (m_frameStatusBar)
- {
- int sbw, sbh;
- m_frameStatusBar->GetSize(& sbw, & sbh);
- height += sbh;
- }
- if (m_frameToolBar)
+ // Calculate how large the new main window should be
+ // by finding the difference between the client area and the
+ // main window area, and adding on to the new client area
+ if (width > -1)
+ XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL);
+
+ if (height > -1)
{
- int tbw, tbh;
- m_frameToolBar->GetSize(& tbw, & tbh);
- if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
- width += tbw;
- else
- height += tbh;
+ if (m_frameStatusBar)
+ {
+ int sbw, sbh;
+ m_frameStatusBar->GetSize(& sbw, & sbh);
+ height += sbh;
+ }
+ if (m_frameToolBar)
+ {
+ int tbw, tbh;
+ m_frameToolBar->GetSize(& tbw, & tbh);
+ if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
+ width += tbw;
+ else
+ height += tbh;
+ }
+
+ XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL);
}
-
- XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL);
- }
- PreResize();
-
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-
+ PreResize();
+
+ wxSizeEvent sizeEvent(wxSize(width, height), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+
}
void wxFrame::GetSize(int *width, int *height) const
{
- Dimension xx, yy;
- XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL);
- *width = xx; *height = yy;
+ Dimension xx, yy;
+ XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL);
+ *width = xx; *height = yy;
}
void wxFrame::GetPosition(int *x, int *y) const
{
Window parent_window = XtWindow((Widget) m_frameShell),
- next_parent = XtWindow((Widget) m_frameShell),
- root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
-
+ next_parent = XtWindow((Widget) m_frameShell),
+ root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
+
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
- Window *theChildren; unsigned int n;
- parent_window = next_parent;
- XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
+ Window *theChildren; unsigned int n;
+ parent_window = next_parent;
+ XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
}
int xx, yy; unsigned int dummy;
XGetGeometry(XtDisplay((Widget) m_frameShell), parent_window, &root,
- &xx, &yy, &dummy, &dummy, &dummy, &dummy);
+ &xx, &yy, &dummy, &dummy, &dummy, &dummy);
if (x) *x = xx;
if (y) *y = yy;
}
void wxFrame::SetSize(int x, int y, int width, int height, int sizeFlags)
{
- if (x > -1)
- XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
- if (y > -1)
- XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
- if (width > -1)
- XtVaSetValues((Widget) m_frameWidget, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues((Widget) m_frameWidget, XmNheight, height, NULL);
-
- if (!(height == -1 && width == -1))
- {
- PreResize();
-
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
- }
+ if (x > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
+ if (y > -1)
+ XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
+ if (width > -1)
+ XtVaSetValues((Widget) m_frameWidget, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues((Widget) m_frameWidget, XmNheight, height, NULL);
+
+ if (!(height == -1 && width == -1))
+ {
+ PreResize();
+
+ wxSizeEvent sizeEvent(wxSize(width, height), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+ }
}
bool wxFrame::Show(bool show)
{
- if (!m_frameShell)
- return wxWindow::Show(show);
-
- m_visibleStatus = show; /* show-&-hide fix */
-
- m_isShown = show;
- if (show) {
- XtMapWidget((Widget) m_frameShell);
- XRaiseWindow(XtDisplay((Widget) m_frameShell), XtWindow((Widget) m_frameShell));
- } else {
- XtUnmapWidget((Widget) m_frameShell);
-// XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes
- }
- return TRUE;
+ if (!m_frameShell)
+ return wxWindow::Show(show);
+
+ m_visibleStatus = show; /* show-&-hide fix */
+
+ m_isShown = show;
+ if (show) {
+ XtMapWidget((Widget) m_frameShell);
+ XRaiseWindow(XtDisplay((Widget) m_frameShell), XtWindow((Widget) m_frameShell));
+ } else {
+ XtUnmapWidget((Widget) m_frameShell);
+ // XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes
+ }
+ return TRUE;
}
void wxFrame::Iconize(bool iconize)
{
- if (!iconize)
- Show(TRUE);
-
- if (m_frameShell)
- XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL);
+ if (!iconize)
+ Show(TRUE);
+
+ if (m_frameShell)
+ XtVaSetValues((Widget) m_frameShell, XmNiconic, (Boolean)iconize, NULL);
}
// Equivalent to maximize/restore in Windows
void wxFrame::Maximize(bool maximize)
{
- Show(TRUE);
-
- if (maximize && m_frameShell)
- XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL);
+ Show(TRUE);
+
+ if (maximize && m_frameShell)
+ XtVaSetValues((Widget) m_frameShell, XmNiconic, FALSE, NULL);
}
bool wxFrame::IsIconized() const
{
- if (!m_frameShell)
- return FALSE;
-
- Boolean iconic;
- XtVaGetValues((Widget) m_frameShell, XmNiconic, &iconic, NULL);
- return iconic;
+ if (!m_frameShell)
+ return FALSE;
+
+ Boolean iconic;
+ XtVaGetValues((Widget) m_frameShell, XmNiconic, &iconic, NULL);
+ return iconic;
}
// Is it maximized?
void wxFrame::SetTitle(const wxString& title)
{
- if (title == m_title)
- return;
+ if (title == m_title)
+ return;
- m_title = title;
-
- if (!title.IsNull())
- XtVaSetValues((Widget) m_frameShell,
- XmNtitle, (const char*) title,
- XmNiconName, (const char*) title,
- NULL);
+ m_title = title;
+
+ if (!title.IsNull())
+ XtVaSetValues((Widget) m_frameShell,
+ XmNtitle, (const char*) title,
+ XmNiconName, (const char*) title,
+ NULL);
}
void wxFrame::SetIcon(const wxIcon& icon)
{
- m_icon = icon;
-
- if (!m_frameShell)
- return;
-
- if (!icon.Ok() || !icon.GetPixmap())
- return;
-
- XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL);
+ m_icon = icon;
+
+ if (!m_frameShell)
+ return;
+
+ if (!icon.Ok() || !icon.GetPixmap())
+ return;
+
+ XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL);
}
wxStatusBar *wxFrame::OnCreateStatusBar(int number, long style, wxWindowID id,
- const wxString& name)
+ const wxString& name)
{
wxStatusBar *statusBar = NULL;
-
+
statusBar = new wxStatusBar(this, id, wxPoint(0, 0), wxSize(100, 20),
style, name);
-
+
// Set the height according to the font and the border size
wxClientDC dc(statusBar);
dc.SetFont(statusBar->GetFont());
-
+
long x, y;
dc.GetTextExtent("X", &x, &y);
-
+
int height = (int)( (y * 1.1) + 2* statusBar->GetBorderY());
-
+
statusBar->SetSize(-1, -1, 100, height);
-
+
statusBar->SetFieldsCount(number);
return statusBar;
}
wxStatusBar* wxFrame::CreateStatusBar(int number, long style, wxWindowID id,
- const wxString& name)
+ const wxString& name)
{
- // Calling CreateStatusBar twice is an error.
- wxCHECK_MSG( m_frameStatusBar == NULL, FALSE,
- "recreating status bar in wxFrame" );
-
- m_frameStatusBar = OnCreateStatusBar(number, style, id,
- name);
- if ( m_frameStatusBar )
- {
- PositionStatusBar();
- return m_frameStatusBar;
- }
- else
- return NULL;
+ // Calling CreateStatusBar twice is an error.
+ wxCHECK_MSG( m_frameStatusBar == NULL, FALSE,
+ "recreating status bar in wxFrame" );
+
+ m_frameStatusBar = OnCreateStatusBar(number, style, id,
+ name);
+ if ( m_frameStatusBar )
+ {
+ PositionStatusBar();
+ return m_frameStatusBar;
+ }
+ else
+ return NULL;
}
void wxFrame::SetStatusText(const wxString& text, int number)
{
- wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
-
- m_frameStatusBar->SetStatusText(text, number);
+ wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set text for" );
+
+ m_frameStatusBar->SetStatusText(text, number);
}
void wxFrame::SetStatusWidths(int n, const int widths_field[])
{
- wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
-
- m_frameStatusBar->SetStatusWidths(n, widths_field);
- PositionStatusBar();
+ wxCHECK_RET( m_frameStatusBar != NULL, "no statusbar to set widths for" );
+
+ m_frameStatusBar->SetStatusWidths(n, widths_field);
+ PositionStatusBar();
}
void wxFrame::PositionStatusBar()
{
if (!m_frameStatusBar)
- return;
-
+ return;
+
int w, h;
GetClientSize(&w, &h);
int sw, sh;
m_frameStatusBar->GetSize(&sw, &sh);
-
+
// Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
m_frameStatusBar->SetSize(0, h, w, sh);
WXWidget wxFrame::GetMenuBarWidget() const
{
- if (GetMenuBar())
- return GetMenuBar()->GetMainWidget();
- else
- return (WXWidget) NULL;
+ if (GetMenuBar())
+ return GetMenuBar()->GetMainWidget();
+ else
+ return (WXWidget) NULL;
}
void wxFrame::SetMenuBar(wxMenuBar *menuBar)
m_frameMenuBar = NULL;
return;
}
-
+
// Currently can't set it twice
-// wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
-
+ // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
+
if (m_frameMenuBar)
{
m_frameMenuBar->DestroyMenuBar();
delete m_frameMenuBar;
}
-
+
m_frameMenuBar = menuBar;
m_frameMenuBar->CreateMenuBar(this);
}
void wxFrame::Fit()
{
- // Work out max. size
- wxNode *node = GetChildren().First();
- int max_width = 0;
- int max_height = 0;
- while (node)
- {
- // Find a child that's a subwindow, but not a dialog box.
- wxWindow *win = (wxWindow *)node->Data();
-
- if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
- !win->IsKindOf(CLASSINFO(wxDialog)))
+ // Work out max. size
+ wxNode *node = GetChildren().First();
+ int max_width = 0;
+ int max_height = 0;
+ while (node)
{
- int width, height;
- int x, y;
- win->GetSize(&width, &height);
- win->GetPosition(&x, &y);
-
- if ((x + width) > max_width)
- max_width = x + width;
- if ((y + height) > max_height)
- max_height = y + height;
+ // Find a child that's a subwindow, but not a dialog box.
+ wxWindow *win = (wxWindow *)node->Data();
+
+ if (!win->IsKindOf(CLASSINFO(wxFrame)) &&
+ !win->IsKindOf(CLASSINFO(wxDialog)))
+ {
+ int width, height;
+ int x, y;
+ win->GetSize(&width, &height);
+ win->GetPosition(&x, &y);
+
+ if ((x + width) > max_width)
+ max_width = x + width;
+ if ((y + height) > max_height)
+ max_height = y + height;
+ }
+ node = node->Next();
}
- node = node->Next();
- }
- SetClientSize(max_width, max_height);
+ SetClientSize(max_width, max_height);
}
// Responds to colour changes, and passes event on to children.
{
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE));
Refresh();
-
+
if ( m_frameStatusBar )
{
wxSysColourChangedEvent event2;
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->ProcessEvent(event2);
}
-
+
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
// resize to client rectangle size
void wxFrame::OnSize(wxSizeEvent& event)
{
- // if we're using constraints - do use them
- #if wxUSE_CONSTRAINTS
+ // if we're using constraints - do use them
+#if wxUSE_CONSTRAINTS
if ( GetAutoLayout() ) {
- Layout();
- return;
+ Layout();
+ return;
}
- #endif
-
- // do we have _exactly_ one child?
- wxWindow *child = NULL;
- for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
- {
- wxWindow *win = (wxWindow *)node->Data();
- if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
- !win->IsKindOf(CLASSINFO(wxDialog)) &&
- (win != GetStatusBar()) &&
- (win != GetToolBar()) )
+#endif
+
+ // do we have _exactly_ one child?
+ wxWindow *child = NULL;
+ for ( wxNode *node = GetChildren().First(); node; node = node->Next() )
{
- if ( child )
- return; // it's our second subwindow - nothing to do
- child = win;
+ wxWindow *win = (wxWindow *)node->Data();
+ if ( !win->IsKindOf(CLASSINFO(wxFrame)) &&
+ !win->IsKindOf(CLASSINFO(wxDialog)) &&
+ (win != GetStatusBar()) &&
+ (win != GetToolBar()) )
+ {
+ if ( child )
+ return; // it's our second subwindow - nothing to do
+ child = win;
+ }
+ }
+
+ if ( child ) {
+ // we have exactly one child - set it's size to fill the whole frame
+ int clientW, clientH;
+ GetClientSize(&clientW, &clientH);
+
+ int x = 0;
+ int y = 0;
+
+ child->SetSize(x, y, clientW, clientH);
}
- }
-
- if ( child ) {
- // we have exactly one child - set it's size to fill the whole frame
- int clientW, clientH;
- GetClientSize(&clientW, &clientH);
-
- int x = 0;
- int y = 0;
-
- child->SetSize(x, y, clientW, clientH);
- }
}
// Default activation behaviour - set the focus for the first child
// subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event)
{
- for(wxNode *node = GetChildren().First(); node; node = node->Next())
- {
- // Find a child that's a subwindow, but not a dialog box.
- wxWindow *child = (wxWindow *)node->Data();
- if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
- !child->IsKindOf(CLASSINFO(wxDialog)))
+ for(wxNode *node = GetChildren().First(); node; node = node->Next())
{
- child->SetFocus();
- return;
+ // Find a child that's a subwindow, but not a dialog box.
+ wxWindow *child = (wxWindow *)node->Data();
+ if (!child->IsKindOf(CLASSINFO(wxFrame)) &&
+ !child->IsKindOf(CLASSINFO(wxDialog)))
+ {
+ child->SetFocus();
+ return;
+ }
}
- }
}
// The default implementation for the close window event - calls
// Destroy the window (delayed, if a managed window)
bool wxFrame::Destroy()
{
- if (!wxPendingDelete.Member(this))
- wxPendingDelete.Append(this);
- return TRUE;
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+ return TRUE;
}
// Default menu selection behaviour - display a help string
void wxFrame::OnMenuHighlight(wxMenuEvent& event)
{
- if (GetStatusBar())
- {
- if (event.GetMenuId() == -1)
- SetStatusText("");
- else
+ if (GetStatusBar())
{
- wxMenuBar *menuBar = GetMenuBar();
- if (menuBar)
- {
- wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
- if (helpString != "")
- SetStatusText(helpString);
- }
+ if (event.GetMenuId() == -1)
+ SetStatusText("");
+ else
+ {
+ wxMenuBar *menuBar = GetMenuBar();
+ if (menuBar)
+ {
+ wxString helpString(menuBar->GetHelpString(event.GetMenuId()));
+ if (helpString != "")
+ SetStatusText(helpString);
+ }
+ }
}
- }
}
wxMenuBar *wxFrame::GetMenuBar() const
{
- return m_frameMenuBar;
+ return m_frameMenuBar;
}
void wxFrame::Centre(int direction)
{
- int display_width, display_height, width, height, x, y;
- wxDisplaySize(&display_width, &display_height);
-
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- if (direction & wxHORIZONTAL)
- x = (int)((display_width - width)/2);
- if (direction & wxVERTICAL)
- y = (int)((display_height - height)/2);
-
- SetSize(x, y, width, height);
+ int display_width, display_height, width, height, x, y;
+ wxDisplaySize(&display_width, &display_height);
+
+ GetSize(&width, &height);
+ GetPosition(&x, &y);
+
+ if (direction & wxHORIZONTAL)
+ x = (int)((display_width - width)/2);
+ if (direction & wxVERTICAL)
+ y = (int)((display_height - height)/2);
+
+ SetSize(x, y, width, height);
}
// Call this to simulate a menu command
void wxFrame::Command(int id)
{
- ProcessCommand(id);
+ ProcessCommand(id);
}
void wxFrame::ProcessCommand(int id)
{
- wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id);
- commandEvent.SetInt( id );
- commandEvent.SetEventObject( this );
-
- wxMenuBar *bar = GetMenuBar() ;
- if (!bar)
- return;
-
-/* TODO: check the menu item if required
- wxMenuItem *item = bar->FindItemForId(id) ;
- if (item && item->IsCheckable())
- {
- bar->Check(id,!bar->Checked(id)) ;
- }
-*/
-
- GetEventHandler()->ProcessEvent(commandEvent);
+ wxCommandEvent commandEvent(wxEVENT_TYPE_MENU_COMMAND, id);
+ commandEvent.SetInt( id );
+ commandEvent.SetEventObject( this );
+
+ wxMenuBar *bar = GetMenuBar() ;
+ if (!bar)
+ return;
+
+ /* TODO: check the menu item if required
+ wxMenuItem *item = bar->FindItemForId(id) ;
+ if (item && item->IsCheckable())
+ {
+ bar->Check(id,!bar->Checked(id)) ;
+ }
+ */
+
+ GetEventHandler()->ProcessEvent(commandEvent);
}
// Checks if there is a toolbar, and returns the first free client position
{
int w, h;
GetToolBar()->GetSize(& w, & h);
-
+
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
{
pt.x += w;
void wxFrame::ScreenToClient(int *x, int *y) const
{
wxWindow::ScreenToClient(x, y);
-
+
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
wxPoint pt1(GetClientAreaOrigin());
*x += pt1.x;
*y += pt1.y;
-
+
wxWindow::ClientToScreen(x, y);
}
wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name)
{
wxCHECK_MSG( m_frameToolBar == NULL, FALSE,
- "recreating toolbar in wxFrame" );
-
+ "recreating toolbar in wxFrame" );
+
wxToolBar* toolBar = OnCreateToolBar(style, id, name);
if (toolBar)
{
void wxFrame::PositionToolBar()
{
int cw, ch;
-
+
GetClientSize(& cw, &ch);
-
+
if (GetToolBar())
{
int tw, th;
GetToolBar()->GetSize(& tw, & th);
-
+
if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL)
{
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
void wxFrame::CaptureMouse()
{
- if (m_winCaptured)
- return;
+ if (m_winCaptured)
+ return;
- if (GetMainWidget())
- XtAddGrab((Widget) m_frameShell, TRUE, FALSE);
- m_winCaptured = TRUE;
+ if (GetMainWidget())
+ XtAddGrab((Widget) m_frameShell, TRUE, FALSE);
+ m_winCaptured = TRUE;
}
void wxFrame::ReleaseMouse()
{
- if (!m_winCaptured)
- return;
+ if (!m_winCaptured)
+ return;
- if (GetMainWidget())
- XtRemoveGrab((Widget) m_frameShell);
- m_winCaptured = FALSE;
+ if (GetMainWidget())
+ XtRemoveGrab((Widget) m_frameShell);
+ m_winCaptured = FALSE;
}
void wxFrame::Raise(void)
{
Window parent_window = XtWindow((Widget) m_frameShell),
- next_parent = XtWindow((Widget) m_frameShell),
- root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
+ next_parent = XtWindow((Widget) m_frameShell),
+ root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
- Window *theChildren; unsigned int n;
- parent_window = next_parent;
- XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
+ Window *theChildren; unsigned int n;
+ parent_window = next_parent;
+ XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
}
XRaiseWindow(XtDisplay((Widget) m_frameShell), parent_window);
}
void wxFrame::Lower(void)
{
Window parent_window = XtWindow((Widget) m_frameShell),
- next_parent = XtWindow((Widget) m_frameShell),
- root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
+ next_parent = XtWindow((Widget) m_frameShell),
+ root = RootWindowOfScreen(XtScreen((Widget) m_frameShell));
// search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) {
- Window *theChildren; unsigned int n;
- parent_window = next_parent;
- XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
- &next_parent, &theChildren, &n);
- XFree(theChildren); // not needed
+ Window *theChildren; unsigned int n;
+ parent_window = next_parent;
+ XQueryTree(XtDisplay((Widget) m_frameShell), parent_window, &root,
+ &next_parent, &theChildren, &n);
+ XFree(theChildren); // not needed
}
XLowerWindow(XtDisplay((Widget) m_frameShell), parent_window);
}
void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs)
{
- wxFrame *frame = (wxFrame *)clientData;
-
- // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
- // TODO
- // frame->GetEventHandler()->OnSetFocus();
+ wxFrame *frame = (wxFrame *)clientData;
+
+ // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
+ // TODO
+ // frame->GetEventHandler()->OnSetFocus();
}
/* MATTEW: Used to insure that hide-&-show within an event cycle works */
static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
- XCrossingEvent * event)
+ XCrossingEvent * event)
{
- wxFrame *frame = (wxFrame *)wxWidgetHashTable->Get((long)clientData);
-
- if (frame) {
- XEvent *e = (XEvent *)event;
-
- if (e->xany.type == MapNotify)
- {
- // Iconize fix
- XtVaSetValues(frameShell, XmNiconic, (Boolean)False, NULL);
- if (!frame->GetVisibleStatus())
- {
- /* We really wanted this to be hidden! */
- XtUnmapWidget((Widget) frame->GetShellWidget());
- }
+ wxFrame *frame = (wxFrame *)wxWidgetHashTable->Get((long)clientData);
+
+ if (frame) {
+ XEvent *e = (XEvent *)event;
+
+ if (e->xany.type == MapNotify)
+ {
+ // Iconize fix
+ XtVaSetValues(frameShell, XmNiconic, (Boolean)False, NULL);
+ if (!frame->GetVisibleStatus())
+ {
+ /* We really wanted this to be hidden! */
+ XtUnmapWidget((Widget) frame->GetShellWidget());
+ }
+ }
+ else if (e->xany.type == UnmapNotify)
+ // Iconize fix
+ XtVaSetValues(frameShell, XmNiconic, (Boolean)True, NULL);
}
- else if (e->xany.type == UnmapNotify)
- // Iconize fix
- XtVaSetValues(frameShell, XmNiconic, (Boolean)True, NULL);
- }
}
//// Motif-specific
bool wxFrame::PreResize()
{
- PositionToolBar();
- PositionStatusBar();
- return TRUE;
+ PositionToolBar();
+ PositionStatusBar();
+ return TRUE;
}
WXWidget wxFrame::GetClientWidget() const
{
- return m_clientArea;
+ return m_clientArea;
}
void wxFrame::ChangeFont(bool keepOriginalSize)
void wxCloseFrameCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs)
{
- wxFrame *frame = (wxFrame *)client_data;
-
- wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, frame->GetId());
- closeEvent.SetEventObject(frame);
-
- // May delete the frame (with delayed deletion)
- frame->GetEventHandler()->ProcessEvent(closeEvent);
+ wxFrame *frame = (wxFrame *)client_data;
+
+ wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, frame->GetId());
+ closeEvent.SetEventObject(frame);
+
+ // May delete the frame (with delayed deletion)
+ frame->GetEventHandler()->ProcessEvent(closeEvent);
}
// XmGauge copyright notice:
/*
- * Copyright 1994 GROUPE BULL
- *
- * Permission to use, copy, modify, and distribute this software and its
- * documentation for any purpose and without fee is hereby granted, provided
- * that the above copyright notice appear in all copies and that both that
- * copyright notice and this permission notice appear in supporting
- * documentation, and that the name of GROUPE BULL not be used in advertising
- * or publicity pertaining to distribution of the software without specific,
- * written prior permission. GROUPE BULL makes no representations about the
- * suitability of this software for any purpose. It is provided "as is"
- * without express or implied warranty.
- *
- * GROUPE BULL disclaims all warranties with regard to this software,
- * including all implied warranties of merchantability and fitness,
- * in no event shall GROUPE BULL be liable for any special,
- * indirect or consequential damages or any damages
- * whatsoever resulting from loss of use, data or profits,
- * whether in an action of contract, negligence or other tortious
- * action, arising out of or in connection with the use
- * or performance of this software.
- *
- */
+* Copyright 1994 GROUPE BULL
+*
+* Permission to use, copy, modify, and distribute this software and its
+* documentation for any purpose and without fee is hereby granted, provided
+* that the above copyright notice appear in all copies and that both that
+* copyright notice and this permission notice appear in supporting
+* documentation, and that the name of GROUPE BULL not be used in advertising
+* or publicity pertaining to distribution of the software without specific,
+* written prior permission. GROUPE BULL makes no representations about the
+* suitability of this software for any purpose. It is provided "as is"
+* without express or implied warranty.
+*
+* GROUPE BULL disclaims all warranties with regard to this software,
+* including all implied warranties of merchantability and fitness,
+* in no event shall GROUPE BULL be liable for any special,
+* indirect or consequential damages or any damages
+* whatsoever resulting from loss of use, data or profits,
+* whether in an action of contract, negligence or other tortious
+* action, arising out of or in connection with the use
+* or performance of this software.
+*
+*/
//// PUBLIC XMGAUGE DECLARATIONS
typedef struct _XmGaugeClassRec* XmGaugeWidgetClass;
bool wxGauge::Create(wxWindow *parent, wxWindowID id,
- int range,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxValidator& validator,
- const wxString& name)
+ int range,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
Arg args[4];
int count = 4;
if (style & wxHORIZONTAL)
XtSetArg(args[3], XmNmaximum, range);
Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
m_mainWidget = (WXWidget) gaugeWidget ;
-
+
XtManageChild (gaugeWidget);
-
+
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
if (width == -1)
width = 150;
if (height == -1)
height = 80;
-
+
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
-
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
int r;
XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
return (int)r;
-// return m_rangeMax;
+ // return m_rangeMax;
}
int wxGauge::GetValue() const
{
- int pos;
- XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
- return pos;
-// return m_gaugePos;
+ int pos;
+ XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
+ return pos;
+ // return m_gaugePos;
}
void wxGauge::ChangeFont(bool keepOriginalSize)
int maximum;
unsigned char orientation;
unsigned char processingDirection;
-
+
XtCallbackList dragCallback;
XtCallbackList valueChangedCallback;
static char translations[] =
"<Btn1Down>: GaugePick()\n\
- <Btn1Motion>: GaugeDrag()\n\
- <Btn1Up>: GaugeDrop()\n\
-";
+ <Btn1Motion>: GaugeDrag()\n\
+ <Btn1Up>: GaugeDrop()\n\
+ ";
#define THIS gw->gauge
int size, sht;
float ratio;
-/***chubraev
+ /***chubraev
char string[20];
int len;
unsigned long backgr,foregr;
XRectangle rects[1];
-***/
+ ***/
sht = gw->primitive.shadow_thickness;
-
+
ratio = (float)THIS.value/
- (float)(THIS.maximum - THIS.minimum);
-/***chubraev
- sprintf(string,"%-d%%",(int)(ratio*100));
- len=strlen(string);
- XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
-***/
-
+ (float)(THIS.maximum - THIS.minimum);
+ /***chubraev
+ sprintf(string,"%-d%%",(int)(ratio*100));
+ len=strlen(string);
+ XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
+ ***/
+
if(clear) {
- XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
- gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
+ XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
+ gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
}
switch(THIS.orientation) {
case XmHORIZONTAL:
- size = (int) ((gw->core.width - 2 * sht)*ratio);
- /***chubraev
- XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
-gw->core.height - 2 * sht, string, len);
- ***/
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, sht, size, gw->core.height - 2 * sht);
-
- /***chubraev
- rects[0].x = sht; rects[0].y = sht;
- rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
- ***/
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- gw->core.width - size - sht, sht,
- size, gw->core.height - 2 * sht);
+ size = (int) ((gw->core.width - 2 * sht)*ratio);
+ /***chubraev
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
+ gw->core.height - 2 * sht, string, len);
+ ***/
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, size, gw->core.height - 2 * sht);
- /***chubraev
- rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
- rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
- ***/
- break;
- }
+ /***chubraev
+ rects[0].x = sht; rects[0].y = sht;
+ rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
+ ***/
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ gw->core.width - size - sht, sht,
+ size, gw->core.height - 2 * sht);
+
+ /***chubraev
+ rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
+ rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
+ ***/
+ break;
+ }
/***chubraev
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
- XSetForeground(XtDisplay(gw), THIS.gc, backgr);
- XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
-gw->core.height - 2 * sht, string, len);
- ***/
-
- break;
- case XmVERTICAL:
- size = (int) ((gw->core.height - 2 * sht)*ratio);
- /***chubraev
- XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
-sht+gw->core.height/2, string,len);
- ***/
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, sht, gw->core.width - 2 * sht, size);
-
+ XSetForeground(XtDisplay(gw), THIS.gc, backgr);
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
+ gw->core.height - 2 * sht, string, len);
+ ***/
+
+ break;
+ case XmVERTICAL:
+ size = (int) ((gw->core.height - 2 * sht)*ratio);
/***chubraev
- rects[0].x = sht; rects[0].y = sht;
- rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
- ***/
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, gw->core.height - size - sht,
- gw->core.width - 2 * sht, size);
-
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
+ sht+gw->core.height/2, string,len);
+ ***/
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, gw->core.width - 2 * sht, size);
+
+ /***chubraev
+ rects[0].x = sht; rects[0].y = sht;
+ rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
+ ***/
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, gw->core.height - size - sht,
+ gw->core.width - 2 * sht, size);
+
+ /***chubraev
+ rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
+ rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
+ ***/
+ }
/***chubraev
- rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
- rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
- ***/
- }
- /***chubraev
- XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
- XSetForeground(XtDisplay(gw), THIS.gc, backgr);
- XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
-sht+gw->core.height/2, string,len);
- ***/
- break;
+ XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
+ XSetForeground(XtDisplay(gw), THIS.gc, backgr);
+ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
+ sht+gw->core.height/2, string,len);
+ ***/
+ break;
}
/***chubraev
XSetClipMask(XtDisplay(gw), THIS.gc, None);
}
/* Old code
- */
+*/
#if 0
static void
DrawSlider(XmGaugeWidget gw, Boolean clear)
{
#define THIS gw->gauge
int size, sht;
-/* float ratio; */
-
+ /* float ratio; */
+
sht = gw->primitive.shadow_thickness;
-/* See fix comment below: can cause divide by zero error.
+ /* See fix comment below: can cause divide by zero error.
ratio = (float)((float)THIS.maximum -
- (float)THIS.minimum) / (float)THIS.value;
-*/
+ (float)THIS.minimum) / (float)THIS.value;
+ */
if(clear) {
- XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
- gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
+ XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
+ gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
}
switch(THIS.orientation) {
case XmHORIZONTAL:
-/* size = (gw->core.width - 2 * sht) / ratio; */
-/* A fix suggested by Dmitri Chubraev */
+ /* size = (gw->core.width - 2 * sht) / ratio; */
+ /* A fix suggested by Dmitri Chubraev */
size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, sht, size, gw->core.height - 2 * sht);
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- gw->core.width - size - sht, sht,
- size, gw->core.height - 2 * sht);
- break;
- }
- break;
- case XmVERTICAL:
- size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
-/* size = (gw->core.height - 2 * sht)/ ratio; */
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, sht, gw->core.width - 2 * sht, size);
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
- sht, gw->core.height - size - sht,
- gw->core.width - 2 * sht, size);
- }
- break;
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, size, gw->core.height - 2 * sht);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ gw->core.width - size - sht, sht,
+ size, gw->core.height - 2 * sht);
+ break;
+ }
+ break;
+ case XmVERTICAL:
+ size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
+ /* size = (gw->core.height - 2 * sht)/ ratio; */
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, sht, gw->core.width - 2 * sht, size);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
+ sht, gw->core.height - size - sht,
+ gw->core.width - 2 * sht, size);
+ }
+ break;
}
#undef THIS
}
XmGaugeWidget gw = (XmGaugeWidget)new_w;
#define THIS gw->gauge
XGCValues values;
-
+
values.foreground = gw->primitive.foreground;
THIS.gc = XtGetGC(new_w, GCForeground, &values);
-
+
static Boolean
SetValues(
- Widget cw,
- Widget rw,
- Widget nw,
- ArgList args,
- Cardinal *num_args )
+ Widget cw,
+ Widget rw,
+ Widget nw,
+ ArgList args,
+ Cardinal *num_args )
{
XmGaugeWidget cgw = (XmGaugeWidget)cw;
XmGaugeWidget ngw = (XmGaugeWidget)nw;
-
+
Boolean redraw = False;
if(cgw->primitive.foreground != ngw->primitive.foreground) {
- XGCValues values;
-
- redraw = True;
- XtReleaseGC(nw, ngw->gauge.gc);
- values.foreground = ngw->primitive.foreground;
- ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
+ XGCValues values;
+
+ redraw = True;
+ XtReleaseGC(nw, ngw->gauge.gc);
+ values.foreground = ngw->primitive.foreground;
+ ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
}
if(cgw->gauge.value != ngw->gauge.value) {
- redraw = True;
+ redraw = True;
}
return redraw;
}
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
int sht;
-
+
sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w),
- gw->primitive.top_shadow_GC,
- gw->primitive.bottom_shadow_GC,
- 0, 0, w->core.width, w->core.height,
- sht, XmSHADOW_IN);
+ gw->primitive.top_shadow_GC,
+ gw->primitive.bottom_shadow_GC,
+ 0, 0, w->core.width, w->core.height,
+ sht, XmSHADOW_IN);
DrawSlider(gw, False);
#undef THIS
}
static XtResource
resources[] = {
#define offset(field) XtOffset(XmGaugeWidget, gauge.field)
- {XmNvalue, XmCValue, XtRInt, sizeof(int),
- offset(value), XtRImmediate, (caddr_t)10},
-
- {XmNminimum, XmCValue, XtRInt, sizeof(int),
- offset(minimum), XtRImmediate, (caddr_t)0},
-
- {XmNmaximum, XmCValue, XtRInt, sizeof(int),
- offset(maximum), XtRImmediate, (caddr_t)100},
-
- {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
- offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
-
- {XmNprocessingDirection, XmCProcessingDirection,
- XmRProcessingDirection, sizeof(unsigned char),
- offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
-
- {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
- offset(dragCallback), XtRImmediate, (caddr_t)NULL},
-
- {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
- offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
-
-
+ {XmNvalue, XmCValue, XtRInt, sizeof(int),
+ offset(value), XtRImmediate, (caddr_t)10},
+
+ {XmNminimum, XmCValue, XtRInt, sizeof(int),
+ offset(minimum), XtRImmediate, (caddr_t)0},
+
+ {XmNmaximum, XmCValue, XtRInt, sizeof(int),
+ offset(maximum), XtRImmediate, (caddr_t)100},
+
+ {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
+ offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
+
+ {XmNprocessingDirection, XmCProcessingDirection,
+ XmRProcessingDirection, sizeof(unsigned char),
+ offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
+
+ {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
+ offset(dragCallback), XtRImmediate, (caddr_t)NULL},
+
+ {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
+ offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
+
+
#undef offset
};
XmGaugeClassRec xmGaugeClassRec = {
{ /* core fields */
- (WidgetClass) &xmPrimitiveClassRec, /* superclass */
- "XmGauge", /* class_name */
- sizeof(XmGaugeRec), /* widget_size */
- NULL, /* class_initialize */
- NULL, /* class_part_initialize */
- FALSE, /* class_inited */
- Initialize, /* initialize */
- NULL, /* initialize_hook */
- XtInheritRealize, /* realize */
- actions, /* actions */
- XtNumber(actions), /* num_actions */
- resources, /* resources */
- XtNumber(resources), /* num_resources */
- NULLQUARK, /* xrm_class */
- TRUE, /* compress_motion */
- TRUE, /* compress_exposure */
- TRUE, /* compress_enterleave */
- FALSE, /* visible_interest */
- Destroy, /* destroy */
- NULL, /* resize */
- ExposeProc, /* expose */
- SetValues, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- NULL, /* accept_focus */
- XtVersion, /* version */
- NULL, /* callback_private */
- translations, /* tm_table */
- NULL, /* query_geometry */
- NULL, /* display_accelerator */
- NULL /* extension */
+ (WidgetClass) &xmPrimitiveClassRec, /* superclass */
+ "XmGauge", /* class_name */
+ sizeof(XmGaugeRec), /* widget_size */
+ NULL, /* class_initialize */
+ NULL, /* class_part_initialize */
+ FALSE, /* class_inited */
+ Initialize, /* initialize */
+ NULL, /* initialize_hook */
+ XtInheritRealize, /* realize */
+ actions, /* actions */
+ XtNumber(actions), /* num_actions */
+ resources, /* resources */
+ XtNumber(resources), /* num_resources */
+ NULLQUARK, /* xrm_class */
+ TRUE, /* compress_motion */
+ TRUE, /* compress_exposure */
+ TRUE, /* compress_enterleave */
+ FALSE, /* visible_interest */
+ Destroy, /* destroy */
+ NULL, /* resize */
+ ExposeProc, /* expose */
+ SetValues, /* set_values */
+ NULL, /* set_values_hook */
+ XtInheritSetValuesAlmost, /* set_values_almost */
+ NULL, /* get_values_hook */
+ NULL, /* accept_focus */
+ XtVersion, /* version */
+ NULL, /* callback_private */
+ translations, /* tm_table */
+ NULL, /* query_geometry */
+ NULL, /* display_accelerator */
+ NULL /* extension */
},
/* primitive_class fields */
{
- NULL, /* border_highlight */
- NULL, /* border_unhighlight */
- NULL, /* translations */
- NULL, /* arm_and_activate */
- NULL, /* syn_resources */
- 0, /* num_syn_resources */
- NULL /* extension */
- },
- { /* gauge fields */
- 0 /* empty */
- }
+ NULL, /* border_highlight */
+ NULL, /* border_unhighlight */
+ NULL, /* translations */
+ NULL, /* arm_and_activate */
+ NULL, /* syn_resources */
+ 0, /* num_syn_resources */
+ NULL /* extension */
+ },
+ { /* gauge fields */
+ 0 /* empty */
+ }
};
WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
void
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
-/* Commented out for a read-only gauge in wxWindows */
+ /* Commented out for a read-only gauge in wxWindows */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
Boolean dragging = False;
XButtonEvent *event = (XButtonEvent *)e;
int x, y;
-
+
x = event->x;
y = event->y;
sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w),
- gw->primitive.top_shadow_GC,
- gw->primitive.bottom_shadow_GC,
- 0, 0, w->core.width, w->core.height,
- sht, XmSHADOW_IN);
-
-
+ gw->primitive.top_shadow_GC,
+ gw->primitive.bottom_shadow_GC,
+ 0, 0, w->core.width, w->core.height,
+ sht, XmSHADOW_IN);
+
+
ratio = (float)((float)THIS.maximum -
- (float)THIS.minimum) / (float)THIS.value;
+ (float)THIS.minimum) / (float)THIS.value;
switch(THIS.orientation) {
case XmHORIZONTAL:
- size = (w->core.width - 2 * sht) / ratio;
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- dragging = (x > sht) && (y > sht) &&
- (x < sht + size) && (y < w->core.height - sht);
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- dragging = (x > w->core.width - size - sht) && (y > sht) &&
- (x < w->core.width - sht) && (y < w->core.height + sht);
- break;
- }
- break;
- case XmVERTICAL:
- size = (w->core.height - 2 * sht) / ratio;
- switch(THIS.processingDirection) {
- case XmMAX_ON_RIGHT:
- case XmMAX_ON_BOTTOM:
- dragging = (x > sht) && (y > sht) &&
- (x < w->core.width - sht) &&
- (y < w->core.width - 2 * sht + size);
- break;
- case XmMAX_ON_LEFT:
- case XmMAX_ON_TOP:
- dragging = (x > sht) && (y > w->core.height - size - sht) &&
- (x < w->core.width - sht) && (y < w->core.height - sht);
- }
- break;
+ size = (w->core.width - 2 * sht) / ratio;
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ dragging = (x > sht) && (y > sht) &&
+ (x < sht + size) && (y < w->core.height - sht);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ dragging = (x > w->core.width - size - sht) && (y > sht) &&
+ (x < w->core.width - sht) && (y < w->core.height + sht);
+ break;
+ }
+ break;
+ case XmVERTICAL:
+ size = (w->core.height - 2 * sht) / ratio;
+ switch(THIS.processingDirection) {
+ case XmMAX_ON_RIGHT:
+ case XmMAX_ON_BOTTOM:
+ dragging = (x > sht) && (y > sht) &&
+ (x < w->core.width - sht) &&
+ (y < w->core.width - 2 * sht + size);
+ break;
+ case XmMAX_ON_LEFT:
+ case XmMAX_ON_TOP:
+ dragging = (x > sht) && (y > w->core.height - size - sht) &&
+ (x < w->core.width - sht) && (y < w->core.height - sht);
+ }
+ break;
}
THIS.dragging = dragging;
THIS.oldx = x;
void
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
-/* Commented out for a read-only gauge in wxWindows */
+ /* Commented out for a read-only gauge in wxWindows */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
XMotionEvent *event = (XMotionEvent *)e;
if( ! THIS.dragging) return;
-
+
x = event->x;
y = event->y;
sht = gw->primitive.shadow_thickness;
-
+
ratio = (float)THIS.value / (float)((float)THIS.maximum -
- (float)THIS.minimum);
+ (float)THIS.minimum);
switch(THIS.orientation) {
case XmHORIZONTAL:
- max = (w->core.width - 2 * sht);
- size = (float)max * ratio;
- delta = (float)x - (float)THIS.oldx;
- break;
+ max = (w->core.width - 2 * sht);
+ size = (float)max * ratio;
+ delta = (float)x - (float)THIS.oldx;
+ break;
case XmVERTICAL:
- max = (w->core.height - 2 * sht);
- size = (float) max * ratio;
- delta = (float)y - (float)THIS.oldy;
- break;
+ max = (w->core.height - 2 * sht);
+ size = (float) max * ratio;
+ delta = (float)y - (float)THIS.oldy;
+ break;
}
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
- nsize = size + delta;
- break;
+ nsize = size + delta;
+ break;
default:
- nsize = size - delta;
+ nsize = size - delta;
}
if(nsize > (float)max) nsize = (float)max;
if(nsize < (float)0 ) nsize = (float)0;
nratio = nsize / (float)max;
fvalue = (int)((float)THIS.maximum -
- (float)THIS.minimum) * (float)nsize / (float)max;
+ (float)THIS.minimum) * (float)nsize / (float)max;
value = round(fvalue);
-
+
THIS.value = value;
THIS.oldx = x;
THIS.oldy = y;
-
+
/* clear old slider only if it was larger */
DrawSlider(gw, (nsize < size));
{
- XmGaugeCallbackStruct call;
-
- if(NULL != THIS.dragCallback) {
- call.reason = XmCR_DRAG;
- call.event = e;
- call.value = THIS.value;
- XtCallCallbacks(w, XmNdragCallback, &call);
- }
+ XmGaugeCallbackStruct call;
+
+ if(NULL != THIS.dragCallback) {
+ call.reason = XmCR_DRAG;
+ call.event = e;
+ call.value = THIS.value;
+ XtCallCallbacks(w, XmNdragCallback, &call);
+ }
}
#undef THIS
#endif
void
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
-/* Commented out for a read-only gauge in wxWindows */
+ /* Commented out for a read-only gauge in wxWindows */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
if( ! THIS.dragging) return;
-
+
if(NULL != THIS.valueChangedCallback) {
- XmGaugeCallbackStruct call;
- call.reason = XmCR_VALUE_CHANGED;
- call.event = e;
- call.value = THIS.value;
- XtCallCallbacks(w, XmNvalueChangedCallback, &call);
+ XmGaugeCallbackStruct call;
+ call.reason = XmCR_VALUE_CHANGED;
+ call.event = e;
+ call.value = THIS.value;
+ XtCallCallbacks(w, XmNvalueChangedCallback, &call);
}
THIS.dragging = False;
#undef THIS
XmGaugeSetValue(Widget w, int value)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
-
+
gw->gauge.value = value;
DrawSlider(gw, True);
XFlush(XtDisplay(w));
XmGaugeGetValue(Widget w)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
-
+
return gw->gauge.value;
}
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
#endif
-
-// TODO: Nothing to do, unless you want to.
#endif
/*
- * Icons
- */
+* Icons
+*/
wxIcon::wxIcon()
{
}
wxIcon::wxIcon(const wxString& icon_file, long flags,
- int desiredWidth, int desiredHeight)
-
+ int desiredWidth, int desiredHeight)
+
{
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
}
}
bool wxIcon::LoadFile(const wxString& filename, long type,
- int desiredWidth, int desiredHeight)
+ int desiredWidth, int desiredHeight)
{
- UnRef();
-
- m_refData = new wxBitmapRefData;
-
- wxBitmapHandler *handler = FindHandler(type);
-
- if ( handler )
- return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
- else
- return FALSE;
+ UnRef();
+
+ m_refData = new wxBitmapRefData;
+
+ wxBitmapHandler *handler = FindHandler(type);
+
+ if ( handler )
+ return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
+ else
+ return FALSE;
}
#include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY
- IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
#endif
void wxListBoxCallback (Widget w, XtPointer clientData,
- XmListCallbackStruct * cbs);
+ XmListCallbackStruct * cbs);
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs);
// m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour();
-
+
SetName(name);
SetValidator(validator);
-
+
if (parent) parent->AddChild(this);
-
+
m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
-
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
Arg args[3];
int count;
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
}
else
count = 2;
-
+
Widget listWidget = XmCreateScrolledList (parentWidget, (char*) (const char*) name, args, count);
-
+
m_mainWidget = (WXWidget) listWidget;
-
+
Set(n, choices);
-
+
XtManageChild (listWidget);
-
+
long width = size.x;
long height = size.y;
if (width == -1)
width = 150;
if (height == -1)
height = 80;
-
+
XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback,
- (XtPointer) this);
+ (XtPointer) this);
XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback,
- (XtPointer) this);
+ (XtPointer) this);
XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback,
- (XtPointer) this);
-
+ (XtPointer) this);
+
XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc,
- (XtPointer) this);
-
+ (XtPointer) this);
+
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
-
+
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
void wxListBox::SetFirstItem(int N)
{
- int count, length;
-
- if (N < 0)
- return;
- XtVaGetValues ((Widget) m_mainWidget,
- XmNvisibleItemCount, &count,
- XmNitemCount, &length,
- NULL);
- if ((N + count) >= length)
- N = length - count;
- XmListSetPos ((Widget) m_mainWidget, N + 1);
+ int count, length;
+
+ if (N < 0)
+ return;
+ XtVaGetValues ((Widget) m_mainWidget,
+ XmNvisibleItemCount, &count,
+ XmNitemCount, &length,
+ NULL);
+ if ((N + count) >= length)
+ N = length - count;
+ XmListSetPos ((Widget) m_mainWidget, N + 1);
}
void wxListBox::SetFirstItem(const wxString& s)
{
- int N = FindString (s);
-
- if (N >= 0)
- SetFirstItem (N);
+ int N = FindString (s);
+
+ if (N >= 0)
+ SetFirstItem (N);
}
void wxListBox::Delete(int N)
{
- int width1, height1;
- int width2, height2;
- Widget listBox = (Widget) m_mainWidget;
- GetSize (&width1, &height1);
-
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-
- XmListDeletePos (listBox, N + 1);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- // (JDH) need to add code here to take care of clientDataList
- wxNode *node = m_clientDataList.Find((long)N); // get item from list
- if (node) m_clientDataList.DeleteNode(node); // if existed then delete from list
- node = m_clientDataList.First(); // we now have to adjust all keys that
- while (node) // are >=N+1
- { if (node->GetKeyInteger() >= (long)(N+1))
- node->SetKeyInteger(node->GetKeyInteger() - 1);
- node = node->Next();
- }
-
- m_noItems --;
+ int width1, height1;
+ int width2, height2;
+ Widget listBox = (Widget) m_mainWidget;
+ GetSize (&width1, &height1);
+
+ bool managed = XtIsManaged(listBox);
+
+ if (managed)
+ XtUnmanageChild (listBox);
+
+ XmListDeletePos (listBox, N + 1);
+
+ if (managed)
+ XtManageChild (listBox);
+
+ GetSize (&width2, &height2);
+ // Correct for randomly resized listbox - bad boy, Motif!
+ if (width1 != width2 || height1 != height2)
+ SetSize (-1, -1, width1, height1);
+
+ // (JDH) need to add code here to take care of clientDataList
+ wxNode *node = m_clientDataList.Find((long)N); // get item from list
+ if (node) m_clientDataList.DeleteNode(node); // if existed then delete from list
+ node = m_clientDataList.First(); // we now have to adjust all keys that
+ while (node) // are >=N+1
+ { if (node->GetKeyInteger() >= (long)(N+1))
+ node->SetKeyInteger(node->GetKeyInteger() - 1);
+ node = node->Next();
+ }
+
+ m_noItems --;
}
void wxListBox::Append(const wxString& item)
{
- int width1, height1;
- int width2, height2;
-
- Widget listBox = (Widget) m_mainWidget;
- GetSize (&width1, &height1);
-
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
- int n;
- XtVaGetValues (listBox, XmNitemCount, &n, NULL);
- XmString text = XmStringCreateSimple ((char*) (const char*) item);
-// XmListAddItem(listBox, text, n + 1);
- XmListAddItemUnselected (listBox, text, 0);
- XmStringFree (text);
-
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
- XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
- XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
- XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
- m_noItems ++;
+ int width1, height1;
+ int width2, height2;
+
+ Widget listBox = (Widget) m_mainWidget;
+ GetSize (&width1, &height1);
+
+ bool managed = XtIsManaged(listBox);
+
+ if (managed)
+ XtUnmanageChild (listBox);
+ int n;
+ XtVaGetValues (listBox, XmNitemCount, &n, NULL);
+ XmString text = XmStringCreateSimple ((char*) (const char*) item);
+ // XmListAddItem(listBox, text, n + 1);
+ XmListAddItemUnselected (listBox, text, 0);
+ XmStringFree (text);
+
+ // It seems that if the list is cleared, we must re-ask for
+ // selection policy!!
+ Arg args[3];
+ XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
+ if (m_windowStyle & wxLB_MULTIPLE)
+ XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
+ else if (m_windowStyle & wxLB_EXTENDED)
+ XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
+ else
+ XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
+ XtSetValues (listBox, args, 2);
+
+ if (managed)
+ XtManageChild (listBox);
+
+ GetSize (&width2, &height2);
+ // Correct for randomly resized listbox - bad boy, Motif!
+ if (width1 != width2 || height1 != height2)
+ SetSize (-1, -1, width1, height1);
+ m_noItems ++;
}
void wxListBox::Append(const wxString& item, char *clientData)
{
- int width1, height1;
- int width2, height2;
-
- Widget listBox = (Widget) m_mainWidget;
-
- GetSize (&width1, &height1);
- Bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-
- int n;
- XtVaGetValues (listBox, XmNitemCount, &n, NULL);
- XmString text = XmStringCreateSimple ((char*) (const char*) item);
-// XmListAddItem(listBox, text, n + 1);
- XmListAddItemUnselected (listBox, text, 0);
- XmStringFree (text);
-
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
- XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
- XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
- XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-
- m_clientDataList.Append ((long) n, (wxObject *) clientData);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
-
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- m_noItems ++;
+ int width1, height1;
+ int width2, height2;
+
+ Widget listBox = (Widget) m_mainWidget;
+
+ GetSize (&width1, &height1);
+ Bool managed = XtIsManaged(listBox);
+
+ if (managed)
+ XtUnmanageChild (listBox);
+
+ int n;
+ XtVaGetValues (listBox, XmNitemCount, &n, NULL);
+ XmString text = XmStringCreateSimple ((char*) (const char*) item);
+ // XmListAddItem(listBox, text, n + 1);
+ XmListAddItemUnselected (listBox, text, 0);
+ XmStringFree (text);
+
+ // It seems that if the list is cleared, we must re-ask for
+ // selection policy!!
+ Arg args[3];
+ XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
+ if (m_windowStyle & wxLB_MULTIPLE)
+ XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
+ else if (m_windowStyle & wxLB_EXTENDED)
+ XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
+ else
+ XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
+ XtSetValues (listBox, args, 2);
+
+ m_clientDataList.Append ((long) n, (wxObject *) clientData);
+
+ if (managed)
+ XtManageChild (listBox);
+
+ GetSize (&width2, &height2);
+
+ // Correct for randomly resized listbox - bad boy, Motif!
+ if (width1 != width2 || height1 != height2)
+ SetSize (-1, -1, width1, height1);
+
+ m_noItems ++;
}
void wxListBox::Set(int n, const wxString *choices, char** clientData)
{
- m_clientDataList.Clear();
- int width1, height1;
- int width2, height2;
-
- Widget listBox = (Widget) m_mainWidget;
- GetSize (&width1, &height1);
-
- bool managed = XtIsManaged(listBox);
-
- if (managed)
- XtUnmanageChild (listBox);
-/***
- for (int i=0; i<n; i++)
- {
- XmString text = XmStringCreateSimple(choices[i]);
- XmListAddItemUnselected(listBox, text, 0);
- XmStringFree(text);
- }
-***/
- XmString *text = new XmString[n];
- int i;
- for (i = 0; i < n; i++)
- text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
-
- if ( clientData )
+ m_clientDataList.Clear();
+ int width1, height1;
+ int width2, height2;
+
+ Widget listBox = (Widget) m_mainWidget;
+ GetSize (&width1, &height1);
+
+ bool managed = XtIsManaged(listBox);
+
+ if (managed)
+ XtUnmanageChild (listBox);
+ /***
+ for (int i=0; i<n; i++)
+ {
+ XmString text = XmStringCreateSimple(choices[i]);
+ XmListAddItemUnselected(listBox, text, 0);
+ XmStringFree(text);
+ }
+ ***/
+ XmString *text = new XmString[n];
+ int i;
for (i = 0; i < n; i++)
- m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
-
- XmListAddItems (listBox, text, n, 0);
- for (i = 0; i < n; i++)
- XmStringFree (text[i]);
- delete[]text;
-
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
- XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
- XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
- XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-
- if (managed)
- XtManageChild (listBox);
-
- GetSize (&width2, &height2);
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- m_noItems = n;
+ text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
+
+ if ( clientData )
+ for (i = 0; i < n; i++)
+ m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
+
+ XmListAddItems (listBox, text, n, 0);
+ for (i = 0; i < n; i++)
+ XmStringFree (text[i]);
+ delete[]text;
+
+ // It seems that if the list is cleared, we must re-ask for
+ // selection policy!!
+ Arg args[3];
+ XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
+ if (m_windowStyle & wxLB_MULTIPLE)
+ XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
+ else if (m_windowStyle & wxLB_EXTENDED)
+ XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
+ else
+ XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
+ XtSetValues (listBox, args, 2);
+
+ if (managed)
+ XtManageChild (listBox);
+
+ GetSize (&width2, &height2);
+ // Correct for randomly resized listbox - bad boy, Motif!
+ if (width1 != width2 || height1 != height2)
+ SetSize (-1, -1, width1, height1);
+
+ m_noItems = n;
}
int wxListBox::FindString(const wxString& s) const
{
- XmString str = XmStringCreateSimple ((char*) (const char*) s);
- int *positions = NULL;
- int no_positions = 0;
- bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
- XmStringFree (str);
- if (success)
+ XmString str = XmStringCreateSimple ((char*) (const char*) s);
+ int *positions = NULL;
+ int no_positions = 0;
+ bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
+ XmStringFree (str);
+ if (success)
{
- int pos = positions[0];
- if (positions)
- XtFree ((char *) positions);
- return pos - 1;
+ int pos = positions[0];
+ if (positions)
+ XtFree ((char *) positions);
+ return pos - 1;
}
- else
- return -1;
+ else
+ return -1;
}
void wxListBox::Clear()
{
- if (m_noItems <= 0)
- return;
-
- int width1, height1;
- int width2, height2;
-
- Widget listBox = (Widget) m_mainWidget;
- GetSize (&width1, &height1);
-
- XmListDeleteAllItems (listBox);
- m_clientDataList.Clear ();
- GetSize (&width2, &height2);
-
- // Correct for randomly resized listbox - bad boy, Motif!
- if (width1 != width2 || height1 != height2)
- SetSize (-1, -1, width1, height1);
-
- m_noItems = 0;
+ if (m_noItems <= 0)
+ return;
+
+ int width1, height1;
+ int width2, height2;
+
+ Widget listBox = (Widget) m_mainWidget;
+ GetSize (&width1, &height1);
+
+ XmListDeleteAllItems (listBox);
+ m_clientDataList.Clear ();
+ GetSize (&width2, &height2);
+
+ // Correct for randomly resized listbox - bad boy, Motif!
+ if (width1 != width2 || height1 != height2)
+ SetSize (-1, -1, width1, height1);
+
+ m_noItems = 0;
}
void wxListBox::SetSelection(int N, bool select)
{
- m_inSetValue = TRUE;
- if (select)
+ m_inSetValue = TRUE;
+ if (select)
{
-/*
- if (m_windowStyle & wxLB_MULTIPLE)
+ /*
+ if (m_windowStyle & wxLB_MULTIPLE)
{
- int *selections = NULL;
- int n = GetSelections (&selections);
-
+ int *selections = NULL;
+ int n = GetSelections (&selections);
+
// This hack is supposed to work, to make it possible to select more
// than one item, but it DOESN'T under Motif 1.1.
-
- XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
-
- int i;
- for (i = 0; i < n; i++)
- XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
-
- XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
-
- XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
+
+ XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
+
+ int i;
+ for (i = 0; i < n; i++)
+ XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
+
+ XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
+
+ XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
+ }
+ else
+ */
+ XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
+
}
- else
-*/
- XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
-
- }
- else
- XmListDeselectPos ((Widget) m_mainWidget, N + 1);
-
- m_inSetValue = FALSE;
+ else
+ XmListDeselectPos ((Widget) m_mainWidget, N + 1);
+
+ m_inSetValue = FALSE;
}
bool wxListBox::Selected(int N) const
{
- // In Motif, no simple way to determine if the item is selected.
- wxArrayInt theSelections;
- int count = GetSelections (theSelections);
- if (count == 0)
+ // In Motif, no simple way to determine if the item is selected.
+ wxArrayInt theSelections;
+ int count = GetSelections (theSelections);
+ if (count == 0)
+ return FALSE;
+ else
+ {
+ int j;
+ for (j = 0; j < count; j++)
+ if (theSelections[j] == N)
+ return TRUE;
+ }
return FALSE;
- else
- {
- int j;
- for (j = 0; j < count; j++)
- if (theSelections[j] == N)
- return TRUE;
- }
- return FALSE;
}
void wxListBox::Deselect(int N)
// Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const
{
- aSelections.Empty();
-
- Widget listBox = (Widget) m_mainWidget;
- int *posList = NULL;
- int posCnt = 0;
- bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
- if (flag)
- {
- if (posCnt > 0)
- {
- aSelections.Alloc(posCnt);
-
- int i;
- for (i = 0; i < posCnt; i++)
- aSelections.Add(posList[i] - 1);
-
- XtFree ((char *) posList);
- return posCnt;
- }
- else
- return 0;
+ aSelections.Empty();
+
+ Widget listBox = (Widget) m_mainWidget;
+ int *posList = NULL;
+ int posCnt = 0;
+ bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
+ if (flag)
+ {
+ if (posCnt > 0)
+ {
+ aSelections.Alloc(posCnt);
+
+ int i;
+ for (i = 0; i < posCnt; i++)
+ aSelections.Add(posList[i] - 1);
+
+ XtFree ((char *) posList);
+ return posCnt;
+ }
+ else
+ return 0;
}
- else
- return 0;
+ else
+ return 0;
}
// Get single selection, for single choice list items
void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags)
{
wxWindow::SetSize(x, y, width, height, sizeFlags);
-
+
// Check resulting size is correct
int tempW, tempH;
GetSize (&tempW, &tempH);
-
+
/*
if (tempW != width || tempH != height)
{
- cout << "wxListBox::SetSize sizes not set correctly.");
+ cout << "wxListBox::SetSize sizes not set correctly.");
}
*/
}
{
int width1, height1;
int width2, height2;
-
+
Widget listBox = (Widget) m_mainWidget;
-
+
GetSize(&width1, &height1);
-
+
bool managed = XtIsManaged(listBox);
-
+
if (managed)
XtUnmanageChild(listBox);
-
+
XmString *text = new XmString[nItems];
int i;
- // Steve Hammes: Motif 1.1 compatibility
-// #if XmVersion > 1100
-// Corrected by Sergey Krasnov from Steve Hammes' code
+ // Steve Hammes: Motif 1.1 compatibility
+ // #if XmVersion > 1100
+ // Corrected by Sergey Krasnov from Steve Hammes' code
#if XmVersion > 1001
for (i = 0; i < nItems; i++)
text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
for (i = 0; i < nItems; i++)
{
text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
-// XmListAddItemUnselected(listBox, text[i], i);
+ // XmListAddItemUnselected(listBox, text[i], i);
XmListAddItemUnselected(listBox, text[i], pos+i+1); // Another Sergey correction
}
#endif
for (i = 0; i < nItems; i++)
XmStringFree(text[i]);
-
+
delete[] text;
-
+
// It seems that if the list is cleared, we must re-ask for
// selection policy!!
Arg args[3];
XtSetArg(args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
else XtSetArg(args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues(listBox,args,2) ;
-
+
if (managed)
XtManageChild(listBox);
-
+
GetSize(&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 /*|| height1 != height2*/)
SetSize(-1, -1, width1, height1);
-
+
m_noItems += nItems;
}
{
int width1, height1;
int width2, height2;
-
+
Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1);
-
+
XmString text = XmStringCreateSimple ((char*) (const char*) s);
-
+
// WHAT'S THE MOTIF CALL TO SET THE TEXT OF AN EXISTING
// ITEM???
// There isn't one, so delete the item and add it again.
XmListDeletePos (listBox, N+1);
XmListAddItem (listBox, text, N+1);
-
+
XmStringFree(text);
-
-/*
- // It seems that if the list is cleared, we must re-ask for
- // selection policy!!
- Arg args[3];
- XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
- if (m_windowStyle & wxLB_MULTIPLE)
+
+ /*
+ // It seems that if the list is cleared, we must re-ask for
+ // selection policy!!
+ Arg args[3];
+ XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
+ if (m_windowStyle & wxLB_MULTIPLE)
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
- else if (m_windowStyle & wxLB_EXTENDED)
+ else if (m_windowStyle & wxLB_EXTENDED)
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
- else
+ else
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
- XtSetValues (listBox, args, 2);
-*/
-
+ XtSetValues (listBox, args, 2);
+ */
+
GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2)
}
void wxListBoxCallback (Widget w, XtPointer clientData,
- XmListCallbackStruct * cbs)
+ XmListCallbackStruct * cbs)
{
/*
if (cbs->reason == XmCR_EXTENDED_SELECT)
cout << "*** Initial\n";
else if (cbs->selection_type == XmADDITION)
cout << "*** Addition\n";
- */
-
+ */
+
wxListBox *item = (wxListBox *) clientData;
-
+
if (item->InSetValue())
return;
-
+
wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED, item->GetId());
switch (cbs->reason)
{
- case XmCR_MULTIPLE_SELECT:
- case XmCR_BROWSE_SELECT:
+ case XmCR_MULTIPLE_SELECT:
+ case XmCR_BROWSE_SELECT:
{
event.m_clientData = item->GetClientData (cbs->item_position - 1);
//event.commandString = item->GetStringSelection();
//delete[] event.commandString; // Let's not store the command string any more
break;
}
- case XmCR_EXTENDED_SELECT:
+ case XmCR_EXTENDED_SELECT:
{
switch (cbs->selection_type)
{
- case XmINITIAL:
- case XmADDITION:
- case XmMODIFICATION:
+ case XmINITIAL:
+ case XmADDITION:
+ case XmMODIFICATION:
{
event.m_clientData = item->GetClientData (cbs->item_position - 1);
event.m_commandInt = cbs->item_position - 1;
}
/* Respond by getting the
- * designated "default button" in the action area and activate it
- * as if the user had selected it.
- */
+* designated "default button" in the action area and activate it
+* as if the user had selected it.
+*/
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs)
{
wxListBox *lbox = (wxListBox *) client_data;
-
+
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId());
event.SetEventObject( lbox );
lbox->GetEventHandler()->ProcessEvent(event) ;
WXWidget wxListBox::GetTopWidget() const
{
- return (WXWidget) XtParent( (Widget) m_mainWidget );
+ return (WXWidget) XtParent( (Widget) m_mainWidget );
}
void wxListBox::ChangeFont(bool keepOriginalSize)
void wxListBox::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
-
+
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
-
+
XtVaGetValues (parent,
- XmNhorizontalScrollBar, &hsb,
- XmNverticalScrollBar, &vsb,
- NULL);
-
- /* TODO: should scrollbars be affected? Should probably have separate
- * function to change them (by default, taken from wxSystemSettings)
- */
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
+
+ /* TODO: should scrollbars be affected? Should probably have separate
+ * function to change them (by default, taken from wxSystemSettings)
+ */
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
-
+
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
}
void wxListBox::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
-
+
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
-
+
XtVaGetValues (parent,
- XmNhorizontalScrollBar, &hsb,
- XmNverticalScrollBar, &vsb,
- NULL);
- /* TODO: should scrollbars be affected? Should probably have separate
- * function to change them (by default, taken from wxSystemSettings)
- DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
- DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
- DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
+ /* TODO: should scrollbars be affected? Should probably have separate
+ * function to change them (by default, taken from wxSystemSettings)
+ DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
+ DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
+ DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
*/
}
int main(int argc, char* argv[])
{
- return wxEntry(argc, argv);
+ return wxEntry(argc, argv);
}
combobox.cpp \
cursor.cpp \
data.cpp \
+ dataobj.cpp \
dc.cpp \
dcclient.cpp \
dcmemory.cpp \
// Implemented in frame.cpp
extern void wxFrameFocusProc(Widget workArea, XtPointer clientData,
- XmAnyCallbackStruct *cbs);
+ XmAnyCallbackStruct *cbs);
#define wxID_NOTEBOOK_CLIENT_AREA wxID_HIGHEST + 100
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxNotebook)
BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
- EVT_SIZE(wxMDIParentFrame::OnSize)
- EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
- EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
+EVT_SIZE(wxMDIParentFrame::OnSize)
+EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
+EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook)
- EVT_SCROLL(wxMDIClientWindow::OnScroll)
- EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged)
+EVT_SCROLL(wxMDIClientWindow::OnScroll)
+EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged)
END_EVENT_TABLE()
#endif
}
bool wxMDIParentFrame::Create(wxWindow *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
m_clientWindow = (wxMDIClientWindow*) NULL;
m_activeChild = (wxMDIChildFrame*) NULL;
m_activeMenuBar = (wxMenuBar*) NULL;
-
+
bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
if (success)
{
// TODO: app cannot override OnCreateClient since
// wxMDIParentFrame::OnCreateClient will still be called
// (we're in the constructor). How to resolve?
-
+
m_clientWindow = OnCreateClient();
-
+
// Uses own style for client style
m_clientWindow->CreateClient(this, GetWindowStyleFlag());
-
+
int w, h;
GetClientSize(& w, & h);
m_clientWindow->SetSize(0, 0, w, h);
{
// Make sure we delete the client window last of all
RemoveChild(m_clientWindow);
-
+
DestroyChildren();
-
+
delete m_clientWindow;
m_clientWindow = NULL;
}
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
{
m_frameMenuBar = menu_bar;
-
+
SetChildMenuBar((wxMDIChildFrame*) NULL);
}
{
#if wxUSE_CONSTRAINTS
if (GetAutoLayout())
- Layout();
+ Layout();
#endif
int x = 0;
int y = 0;
int width, height;
GetClientSize(&width, &height);
-
+
if ( GetClientWindow() )
GetClientWindow()->SetSize(x, y, width, height);
}
void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
{
- // Do nothing
+ // Do nothing
}
// Returns the active MDI child window
// just return a new class)
wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
{
- return new wxMDIClientWindow ;
+ return new wxMDIClientWindow ;
}
// Set the child's menu into the parent frame
void wxMDIParentFrame::SetChildMenuBar(wxMDIChildFrame* child)
{
wxMenuBar* oldMenuBar = m_activeMenuBar;
-
+
if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame
{
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
{
- // if (m_activeMenuBar)
- // m_activeMenuBar->DestroyMenuBar();
-
+ // if (m_activeMenuBar)
+ // m_activeMenuBar->DestroyMenuBar();
+
m_activeMenuBar = GetMenuBar();
m_activeMenuBar->CreateMenuBar(this);
- /*
+ /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
- XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
- */
+ XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
+ */
if (oldMenuBar && oldMenuBar->GetMainWidget())
- XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
-
+ XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
+
}
}
else if (child->GetMenuBar() == (wxMenuBar*) NULL) // No child menu bar: use parent frame
{
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
{
- // if (m_activeMenuBar)
- // m_activeMenuBar->DestroyMenuBar();
+ // if (m_activeMenuBar)
+ // m_activeMenuBar->DestroyMenuBar();
m_activeMenuBar = GetMenuBar();
m_activeMenuBar->CreateMenuBar(this);
- /*
+ /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
- XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
- */
+ XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
+ */
if (oldMenuBar && oldMenuBar->GetMainWidget())
- XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
+ XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
}
}
else // The child has a menubar
{
if (child->GetMenuBar() != m_activeMenuBar)
{
- // if (m_activeMenuBar)
- // m_activeMenuBar->DestroyMenuBar();
-
+ // if (m_activeMenuBar)
+ // m_activeMenuBar->DestroyMenuBar();
+
m_activeMenuBar = child->GetMenuBar();
m_activeMenuBar->CreateMenuBar(this);
- /*
+ /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
- XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
- */
+ XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
+ */
if (oldMenuBar && oldMenuBar->GetMainWidget())
- XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
+ XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
}
}
}
static wxEventType inEvent = wxEVT_NULL;
if (inEvent == event.GetEventType())
return FALSE;
-
+
inEvent = event.GetEventType();
bool res = FALSE;
if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent)))
{
- res = m_activeChild->GetEventHandler()->ProcessEvent(event);
+ res = m_activeChild->GetEventHandler()->ProcessEvent(event);
}
-
+
if (!res)
- res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
-
+ res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
+
inEvent = wxEVT_NULL;
-
+
return res;
}
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
// TODO
-
+
// Propagate the event to the non-top-level children
wxFrame::OnSysColourChanged(event);
}
}
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
- wxWindowID id,
- const wxString& title,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ wxWindowID id,
+ const wxString& title,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
SetName(name);
-
+
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK;
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
-
+
if ( id > -1 )
m_windowId = id;
else
m_windowId = (int)NewControlId();
-
+
wxMDIClientWindow* clientWindow = parent->GetClientWindow();
-
+
wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window.");
-
+
if (clientWindow) clientWindow->AddChild(this);
-
+
SetMDIParentFrame(parent);
-
+
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
if (width == -1)
width = 200; // TODO: give reasonable default
if (height == -1)
height = 200; // TODO: give reasonable default
-
+
// We're deactivating the old child
wxMDIChildFrame* oldActiveChild = parent->GetActiveChild();
if (oldActiveChild)
event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event);
}
-
+
// This is the currently active child
parent->SetActiveChild((wxMDIChildFrame*) this);
-
+
// This time we'll try a bog-standard bulletin board for
// the 'frame'. A main window doesn't seem to work.
-
+
m_mainWidget = (WXWidget) XtVaCreateWidget("client",
- xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
- XmNmarginWidth, 0,
- XmNmarginHeight, 0,
- /*
- XmNrightAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
- */
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
+ xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
+ XmNmarginWidth, 0,
+ XmNmarginHeight, 0,
+ /*
+ XmNrightAttachment, XmATTACH_FORM,
+ XmNleftAttachment, XmATTACH_FORM,
+ XmNtopAttachment, XmATTACH_FORM,
+ XmNbottomAttachment, XmATTACH_FORM,
+ */
+ XmNresizePolicy, XmRESIZE_NONE,
+ NULL);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
- ChangeBackgroundColour();
-
- // Old stuff
-#if 0
-
- m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
- xmMainWindowWidgetClass, (Widget) clientWindow->GetTopWidget(),
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
-
- // TODO: make sure this doesn't cause problems.
- // I think ~wxFrame will do the right thing since it deletes m_frameWidget,
- // then sets the main widget to NULL.
- m_mainWidget = m_frameWidget;
-
- m_workArea = (WXWidget) XtVaCreateWidget("form",
- xmFormWidgetClass, (Widget) m_frameWidget,
- XmNresizePolicy, XmRESIZE_NONE,
- NULL);
-
- m_clientArea = (WXWidget) XtVaCreateWidget("client",
- xmBulletinBoardWidgetClass, (Widget) m_workArea,
- XmNmarginWidth, 0,
- XmNmarginHeight, 0,
- XmNrightAttachment, XmATTACH_FORM,
- XmNleftAttachment, XmATTACH_FORM,
- XmNtopAttachment, XmATTACH_FORM,
- XmNbottomAttachment, XmATTACH_FORM,
-// XmNresizePolicy, XmRESIZE_ANY,
- NULL);
-
- XtVaSetValues((Widget) m_frameWidget,
- XmNworkWindow, (Widget) m_workArea,
- NULL);
-
- XtManageChild((Widget) m_clientArea);
- XtManageChild((Widget) m_workArea);
-
- wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
-
- wxAddWindowToTable((Widget) m_workArea, this);
-
- XtTranslations ptr ;
-
- XtOverrideTranslations((Widget) m_workArea,
- ptr = XtParseTranslationTable("<Configure>: resize()"));
-
- XtFree((char *)ptr);
-
- XtAddCallback((Widget) m_workArea, XmNfocusCallback,
- (XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
-
- XtManageChild((Widget) m_mainWidget);
-
- if (x > -1)
- XtVaSetValues((Widget) m_mainWidget, XmNx, x, NULL);
- if (y > -1)
- XtVaSetValues((Widget) m_mainWidget, XmNy, y, NULL);
- if (width > -1)
- XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
-
-#endif
-
+
+ ChangeBackgroundColour();
+
XtManageChild((Widget) m_mainWidget);
-
+
SetTitle(title);
-
+
clientWindow->AddPage(this, title, TRUE);
clientWindow->Refresh();
-
+
// Positions the toolbar and status bar -- but we don't have any.
// PreResize();
-
+
wxModelessWindows.Append(this);
return TRUE;
}
if (GetMDIParentFrame())
{
wxMDIParentFrame* parentFrame = GetMDIParentFrame();
-
+
if (parentFrame->GetActiveChild() == this)
parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
-
+
// Remove page if still there
if (clientWindow->RemovePage(this))
- clientWindow->Refresh();
-
+ clientWindow->Refresh();
+
// Set the selection to the first remaining page
if (clientWindow->GetPageCount() > 0)
{
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
parentFrame->SetActiveChild(this);
-
+
if (oldActiveChild)
{
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event);
}
-
+
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
event.SetEventObject( this );
this->GetEventHandler()->ProcessEvent(event);
{
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
-
+
if (oldActiveChild == this)
{
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
// to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height)
{
- wxWindow::SetClientSize(width, height);
+ wxWindow::SetClientSize(width, height);
}
void wxMDIChildFrame::GetClientSize(int* width, int* height) const
void wxMDIChildFrame::SetSize(int x, int y, int width, int height, int sizeFlags)
{
- wxWindow::SetSize(x, y, width, height, sizeFlags);
+ wxWindow::SetSize(x, y, width, height, sizeFlags);
}
void wxMDIChildFrame::GetSize(int* width, int* height) const
// Don't create the underlying menubar yet; need to recreate
// it every time the child is activated.
m_frameMenuBar = menuBar;
-
+
// We make the assumption that if you're setting the menubar,
// this is the currently active child.
GetMDIParentFrame()->SetChildMenuBar(this);
m_icon = icon;
if (m_icon.Ok())
{
- /* TODO: doesn't work yet (crashes in XCopyArea)
- Pixmap pixmap = (Pixmap) m_icon.GetPixmap();
- m_mdiWindow->setPixmap(pixmap);
- */
+ // Not appropriate since there are no icons in
+ // a tabbed window
}
}
void wxMDIChildFrame::Iconize(bool iconize)
{
- // TODO
+ // TODO
}
bool wxMDIChildFrame::IsIconized() const
void wxMDIChildFrame::CaptureMouse()
{
- wxWindow::CaptureMouse();
+ wxWindow::CaptureMouse();
}
void wxMDIChildFrame::ReleaseMouse()
{
- wxWindow::ReleaseMouse();
+ wxWindow::ReleaseMouse();
}
void wxMDIChildFrame::Raise()
{
- wxWindow::Raise();
+ wxWindow::Raise();
}
void wxMDIChildFrame::Lower(void)
{
- wxWindow::Raise();
+ wxWindow::Raise();
}
void wxMDIChildFrame::SetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH))
wxMDIClientWindow::~wxMDIClientWindow()
{
// By the time this destructor is called, the child frames will have been
- // deleted and removed from the notebook/client window.
+ // deleted and removed from the notebook/client window.
DestroyChildren();
-
+
m_mainWidget = (WXWidget) 0;
}
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
{
- // m_windowParent = parent;
+ // m_windowParent = parent;
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
-
+
bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
if (success)
{
return TRUE;
}
else
- return FALSE;
+ return FALSE;
}
void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
}
if (event.GetSelection() != -1)
{
- wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
- if (activeChild)
- {
- wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
- event.SetEventObject( activeChild );
- activeChild->GetEventHandler()->ProcessEvent(event);
-
- if (activeChild->GetMDIParentFrame())
+ wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
+ if (activeChild)
{
- activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
- activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
+ wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
+ event.SetEventObject( activeChild );
+ activeChild->GetEventHandler()->ProcessEvent(event);
+
+ if (activeChild->GetMDIParentFrame())
+ {
+ activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
+ activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
+ }
}
- }
}
event.Skip();
}
m_eventHandler = this;
m_noItems = 0;
m_menuBar = NULL;
-
+
//// Motif-specific members
m_numColumns = 1;
m_menuWidget = (WXWidget) NULL;
m_ownedByMenuBar = FALSE;
m_menuParent = (wxMenu*) NULL;
m_clientData = (void*) NULL;
-
+
if (m_title != "")
{
Append(ID_SEPARATOR, m_title) ;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENU);
m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
-
+
Callback(func);
}
{
if (m_menuWidget)
{
- if (m_menuParent)
- DestroyMenu(TRUE);
- else
- DestroyMenu(FALSE);
+ if (m_menuParent)
+ DestroyMenu(TRUE);
+ else
+ DestroyMenu(FALSE);
}
-
+
// Not sure if this is right
if (m_menuParent && m_menuBar)
{
- m_menuParent = NULL;
- // m_menuBar = NULL;
+ m_menuParent = NULL;
+ // m_menuBar = NULL;
}
-
+
wxNode *node = m_menuItems.First();
while (node)
{
wxMenuItem *item = (wxMenuItem *)node->Data();
-
- /*
+
+ /*
if (item->GetSubMenu())
- item->DeleteSubMenu();
+ item->DeleteSubMenu();
*/
-
+
wxNode *next = node->Next();
delete item;
delete node;
void wxMenu::Append(wxMenuItem *pItem)
{
wxCHECK_RET( pItem != NULL, "can't append NULL item to the menu" );
-
+
m_menuItems.Append(pItem);
-
+
if (m_menuWidget)
- pItem->CreateItem (m_menuWidget, m_menuBar, m_topLevelMenu); // this is a dynamic Append
-
+ pItem->CreateItem (m_menuWidget, m_menuBar, m_topLevelMenu); // this is a dynamic Append
+
m_noItems++;
}
const wxString& helpString)
{
Append(new wxMenuItem(this, id, label, helpString, FALSE, subMenu));
-
+
subMenu->m_topLevelMenu = m_topLevelMenu;
}
void wxMenu::Append(int id, const wxString& label,
const wxString& helpString, bool checkable)
{
- // 'checkable' parameter is useless for Windows.
+ // 'checkable' parameter is useless for Windows.
Append(new wxMenuItem(this, id, label, helpString, checkable));
}
wxNode *node;
wxMenuItem *item;
int pos;
-
+
for (pos = 0, node = m_menuItems.First(); node; node = node->Next(), pos++)
{
- item = (wxMenuItem *)node->Data();
- if (item->GetId() == id)
- break;
+ item = (wxMenuItem *)node->Data();
+ if (item->GetId() == id)
+ break;
}
-
+
if (!node)
- return;
-
+ return;
+
item->DestroyItem(TRUE);
-
+
// See also old code - don't know if this is needed (seems redundant).
/*
- if (item->GetSubMenu()) {
+ if (item->GetSubMenu()) {
item->subMenu->top_level_menu = item->GetSubMenu();
item->subMenu->window_parent = NULL;
children->DeleteObject(item->GetSubMenu());
- }
- */
-
+ }
+ */
+
m_menuItems.DeleteNode(node);
delete item;
}
{
wxMenuItem *item = FindItemForId(id);
wxCHECK_RET( item != NULL, "can't enable non-existing menu item" );
-
+
item->Enable(flag);
}
{
wxMenuItem *item = FindItemForId(Id);
wxCHECK( item != NULL, FALSE );
-
+
return item->IsEnabled();
}
{
wxMenuItem *item = FindItemForId(Id);
wxCHECK_RET( item != NULL, "can't get status of non-existing menu item" );
-
+
item->Check(Flag);
}
{
wxMenuItem *item = FindItemForId(id);
wxCHECK( item != NULL, FALSE );
-
+
return item->IsChecked();
}
void wxMenu::SetTitle(const wxString& label)
{
m_title = label ;
-
+
wxNode *node = m_menuItems.First ();
if (!node)
- return;
-
+ return;
+
wxMenuItem *item = (wxMenuItem *) node->Data ();
Widget widget = (Widget) item->GetButtonWidget();
if (!widget)
- return;
-
+ return;
+
XmString title_str = XmStringCreateSimple ((char*) (const char*) label);
XtVaSetValues (widget,
- XmNlabelString, title_str,
- NULL);
+ XmNlabelString, title_str,
+ NULL);
// TODO: should we delete title_str now?
}
{
wxMenuItem *item = FindItemForId(id);
if (item == (wxMenuItem*) NULL)
- return;
-
+ return;
+
item->SetLabel(label);
}
wxString wxMenu::GetLabel(int id) const
{
- wxMenuItem *it = NULL;
- WXWidget w = FindMenuItem (id, &it);
- if (w)
+ wxMenuItem *it = NULL;
+ WXWidget w = FindMenuItem (id, &it);
+ if (w)
{
- XmString text;
- char *s;
- XtVaGetValues ((Widget) w,
- XmNlabelString, &text,
- NULL);
-
- if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
- {
- wxString str(s);
- XtFree (s);
- return str;
- }
- else
- {
- XmStringFree (text);
- return wxEmptyString;
- }
+ XmString text;
+ char *s;
+ XtVaGetValues ((Widget) w,
+ XmNlabelString, &text,
+ NULL);
+
+ if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
+ {
+ wxString str(s);
+ XtFree (s);
+ return str;
+ }
+ else
+ {
+ XmStringFree (text);
+ return wxEmptyString;
+ }
}
- else
- return wxEmptyString;
+ else
+ return wxEmptyString;
}
// Finds the item id matching the given string, -1 if not found.
char buf1[200];
char buf2[200];
wxStripMenuCodes ((char *)(const char *)itemString, buf1);
-
+
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
- wxMenuItem *item = (wxMenuItem *) node->Data ();
- if (item->GetSubMenu())
- {
- int ans = item->GetSubMenu()->FindItem(itemString);
- if (ans > -1)
- return ans;
- }
- if ( !item->IsSeparator() )
- {
- wxStripMenuCodes((char *)item->GetName().c_str(), buf2);
- if (strcmp(buf1, buf2) == 0)
- return item->GetId();
- }
+ wxMenuItem *item = (wxMenuItem *) node->Data ();
+ if (item->GetSubMenu())
+ {
+ int ans = item->GetSubMenu()->FindItem(itemString);
+ if (ans > -1)
+ return ans;
+ }
+ if ( !item->IsSeparator() )
+ {
+ wxStripMenuCodes((char *)item->GetName().c_str(), buf2);
+ if (strcmp(buf1, buf2) == 0)
+ return item->GetId();
+ }
}
-
+
return -1;
}
for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
wxMenuItem *item = (wxMenuItem *) node->Data ();
-
+
if (item->GetId() == itemId)
{
if (itemMenu)
*itemMenu = (wxMenu *) this;
return item;
}
-
+
if (item->GetSubMenu())
{
wxMenuItem *ans = item->GetSubMenu()->FindItemForId (itemId, itemMenu);
return ans;
}
}
-
+
if (itemMenu)
*itemMenu = NULL;
return NULL;
void wxMenu::ProcessCommand(wxCommandEvent & event)
{
bool processed = FALSE;
-
+
// Try a callback
if (m_callback)
{
- (void) (*(m_callback)) (*this, event);
- processed = TRUE;
+ (void) (*(m_callback)) (*this, event);
+ processed = TRUE;
}
-
+
// Try the menu's event handler
if ( !processed && GetEventHandler())
{
- processed = GetEventHandler()->ProcessEvent(event);
+ processed = GetEventHandler()->ProcessEvent(event);
}
-/* TODO
+ /* TODO
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
- processed = GetInvokingWindow()->ProcessEvent(event);
-*/
+ processed = GetInvokingWindow()->ProcessEvent(event);
+ */
}
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);
- }
-
- wxWindow *parent = this;
-
- menu->SetId(1); /* Mark as popped-up */
- menu->CreateMenu(NULL, widget, menu);
- // 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)))
- {
+ 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);
+ }
+
+ wxWindow *parent = this;
+
+ menu->SetId(1); /* Mark as popped-up */
+ menu->CreateMenu(NULL, widget, menu);
+ // 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;
+ }
+ */
+
+ 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
m_titles = new wxString[n];
int i;
for ( i = 0; i < n; i++ )
- m_titles[i] = titles[i];
+ m_titles[i] = titles[i];
m_menuBarFrame = NULL;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENU);
m_foregroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_MENUTEXT);
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return;
-
+
if (!item->IsCheckable())
return ;
-
+
item->Check(flag);
}
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return FALSE;
-
+
return item->IsChecked();
}
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
if (!item)
return FALSE;
-
+
return item->IsEnabled();
}
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
-
+
if (!item)
return;
-
+
item->SetLabel(label);
}
{
wxMenu *itemMenu = NULL;
wxMenuItem *item = FindItemForId(id, &itemMenu) ;
-
+
if (!item)
return wxString("");
-
+
return item->GetLabel();
}
void wxMenuBar::SetLabelTop(int pos, const wxString& label)
{
- wxASSERT( (pos < m_menuCount) );
-
- Widget w = (Widget) m_menus[pos]->GetButtonWidget();
- if (w)
+ wxASSERT( (pos < m_menuCount) );
+
+ Widget w = (Widget) m_menus[pos]->GetButtonWidget();
+ if (w)
{
- XmString label_str = XmStringCreateSimple ((char*) (const char*) label);
- XtVaSetValues (w,
- XmNlabelString, label_str,
- NULL);
- XmStringFree (label_str);
+ XmString label_str = XmStringCreateSimple ((char*) (const char*) label);
+ XtVaSetValues (w,
+ XmNlabelString, label_str,
+ NULL);
+ XmStringFree (label_str);
}
}
wxString wxMenuBar::GetLabelTop(int pos) const
{
- wxASSERT( (pos < m_menuCount) );
-
- Widget w = (Widget) m_menus[pos]->GetButtonWidget();
- if (w)
+ wxASSERT( (pos < m_menuCount) );
+
+ Widget w = (Widget) m_menus[pos]->GetButtonWidget();
+ if (w)
{
- XmString text;
- char *s;
- XtVaGetValues (w,
- XmNlabelString, &text,
- NULL);
-
- if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
- {
- wxString str(s);
- XtFree (s);
- return str;
- }
- else
- {
- return wxEmptyString;
- }
+ XmString text;
+ char *s;
+ XtVaGetValues (w,
+ XmNlabelString, &text,
+ NULL);
+
+ if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
+ {
+ wxString str(s);
+ XtFree (s);
+ return str;
+ }
+ else
+ {
+ return wxEmptyString;
+ }
}
- else
- return wxEmptyString;
-
+ else
+ return wxEmptyString;
+
}
bool wxMenuBar::OnDelete(wxMenu *menu, int pos)
// Only applies to dynamic deletion (when set in frame)
if (!m_menuBarFrame)
return TRUE;
-
+
menu->DestroyMenu(TRUE);
return TRUE;
}
// Only applies to dynamic append (when set in frame)
if (!m_menuBarFrame)
return TRUE;
-
+
// Probably should be an assert here
if (menu->GetParent())
return FALSE;
-
+
// Has already been appended
if (menu->GetButtonWidget())
return FALSE;
-
+
WXWidget w = menu->CreateMenu(this, GetMainWidget(), menu, title, TRUE);
menu->SetButtonWidget(w);
-
+
return TRUE;
}
{
if (!OnAppend(menu, title))
return;
-
+
m_menuCount ++;
wxMenu **new_menus = new wxMenu *[m_menuCount];
wxString *new_titles = new wxString[m_menuCount];
int i;
-
+
for (i = 0; i < m_menuCount - 1; i++)
- {
+ {
new_menus[i] = m_menus[i];
m_menus[i] = NULL;
new_titles[i] = m_titles[i];
}
m_menus = new_menus;
m_titles = new_titles;
-
+
m_menus[m_menuCount - 1] = (wxMenu *)menu;
m_titles[m_menuCount - 1] = title;
-
+
menu->SetMenuBar(this);
menu->SetParent(this);
}
{
int j;
int ii = (int) i;
-
+
if (menu != 0)
{
- for (ii = 0; ii < m_menuCount; ii++)
+ for (ii = 0; ii < m_menuCount; ii++)
{
if (m_menus[ii] == menu)
- break;
- }
+ break;
+ }
if (ii >= m_menuCount)
return;
} else
return;
menu = m_menus[ii];
}
-
+
if (!OnDelete(menu, ii))
return;
-
+
menu->SetParent((wxEvtHandler*) NULL);
-
+
-- m_menuCount;
for (j = ii; j < m_menuCount; j++)
{
{
if (itemMenu)
*itemMenu = NULL;
-
+
wxMenuItem *item = NULL;
int i;
for (i = 0; i < m_menuCount; i++)
if ((item = m_menus[i]->FindItemForId (id, itemMenu)))
return item;
- return NULL;
+ return NULL;
}
void wxMenuBar::SetHelpString (int id, const wxString& helpString)
// Create menubar
bool wxMenuBar::CreateMenuBar(wxFrame* parent)
{
- if (m_mainWidget)
- {
- XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
- /*
- if (!XtIsManaged((Widget) m_mainWidget))
- XtManageChild((Widget) m_mainWidget);
- */
- XtMapWidget((Widget) m_mainWidget);
- return TRUE;
- }
-
- Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWindowWidget(), "MenuBar", NULL, 0);
- m_mainWidget = (WXWidget) menuBarW;
-
- int i;
- for (i = 0; i < GetMenuCount(); i++)
+ if (m_mainWidget)
{
- wxMenu *menu = GetMenu(i);
- wxString title(m_titles[i]);
- 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);
-
- if (strcmp (wxBuffer, "Help") == 0)
- XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
+ XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
+ /*
+ if (!XtIsManaged((Widget) m_mainWidget))
+ XtManageChild((Widget) m_mainWidget);
+ */
+ XtMapWidget((Widget) m_mainWidget);
+ return TRUE;
}
-
- SetBackgroundColour(m_backgroundColour);
- SetForegroundColour(m_foregroundColour);
- SetFont(m_font);
-
- XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
- XtRealizeWidget ((Widget) menuBarW);
- XtManageChild ((Widget) menuBarW);
- SetMenuBarFrame(parent);
-
- return TRUE;
+
+ Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWindowWidget(), "MenuBar", NULL, 0);
+ m_mainWidget = (WXWidget) menuBarW;
+
+ int i;
+ for (i = 0; i < GetMenuCount(); i++)
+ {
+ wxMenu *menu = GetMenu(i);
+ wxString title(m_titles[i]);
+ 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);
+
+ if (strcmp (wxBuffer, "Help") == 0)
+ XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
+ }
+
+ SetBackgroundColour(m_backgroundColour);
+ SetForegroundColour(m_foregroundColour);
+ SetFont(m_font);
+
+ XtVaSetValues((Widget) parent->GetMainWindowWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
+ XtRealizeWidget ((Widget) menuBarW);
+ XtManageChild ((Widget) menuBarW);
+ SetMenuBarFrame(parent);
+
+ return TRUE;
}
// Destroy menubar, but keep data structures intact so we can recreate it.
bool wxMenuBar::DestroyMenuBar()
{
- if (!m_mainWidget)
- {
- SetMenuBarFrame((wxFrame*) NULL);
- return FALSE;
- }
-
- XtUnmanageChild ((Widget) m_mainWidget);
- XtUnrealizeWidget ((Widget) m_mainWidget);
-
- int i;
- for (i = 0; i < GetMenuCount(); i++)
+ if (!m_mainWidget)
{
- wxMenu *menu = GetMenu(i);
- menu->DestroyMenu(TRUE);
-
+ SetMenuBarFrame((wxFrame*) NULL);
+ return FALSE;
}
- XtDestroyWidget((Widget) m_mainWidget);
- m_mainWidget = (WXWidget) 0;
-
- SetMenuBarFrame((wxFrame*) NULL);
-
- return TRUE;
+
+ XtUnmanageChild ((Widget) m_mainWidget);
+ XtUnrealizeWidget ((Widget) m_mainWidget);
+
+ int i;
+ for (i = 0; i < GetMenuCount(); i++)
+ {
+ wxMenu *menu = GetMenu(i);
+ menu->DestroyMenu(TRUE);
+
+ }
+ XtDestroyWidget((Widget) m_mainWidget);
+ m_mainWidget = (WXWidget) 0;
+
+ SetMenuBarFrame((wxFrame*) NULL);
+
+ return TRUE;
}
//// Motif-specific
static XtWorkProcId WorkProcMenuId;
/* Since PopupMenu under Motif stills grab right mouse button events
- * after it was closed, we need to delete the associated widgets to
- * allow next PopUpMenu to appear...
- */
+* after it was closed, we need to delete the associated widgets to
+* allow next PopUpMenu to appear...
+*/
int PostDeletionOfMenu( XtPointer* clientData )
{
- XtRemoveWorkProc(WorkProcMenuId);
- wxMenu *menu = (wxMenu *)clientData;
-
- if (menu->GetMainWidget()) {
- if (menu->GetParent())
- {
- wxList& list = menu->GetParent()->GetItems();
- list.DeleteObject(menu);
+ XtRemoveWorkProc(WorkProcMenuId);
+ wxMenu *menu = (wxMenu *)clientData;
+
+ if (menu->GetMainWidget()) {
+ if (menu->GetParent())
+ {
+ wxList& list = menu->GetParent()->GetItems();
+ list.DeleteObject(menu);
+ }
+ menu->DestroyMenu(TRUE);
}
- menu->DestroyMenu(TRUE);
- }
- /* Mark as no longer popped up */
- menu->m_menuId = -1;
- return TRUE;
+ /* Mark as no longer popped up */
+ menu->m_menuId = -1;
+ return TRUE;
}
void
wxMenuPopdownCallback(Widget w, XtPointer clientData,
- XtPointer ptr)
+ XtPointer ptr)
{
- wxMenu *menu = (wxMenu *)clientData;
-
- // Added by JOREL Jean-Charles <jjorel@silr.ireste.fr>
- /* Since Callbacks of MenuItems are not yet processed, we put a
- * background job which will be done when system will be idle.
- * What awful hack!! :(
- */
-
- WorkProcMenuId = XtAppAddWorkProc(
- (XtAppContext) wxTheApp->GetAppContext(),
- (XtWorkProc) PostDeletionOfMenu,
- (XtPointer) menu );
- // Apparently not found in Motif headers
- // XtVaSetValues( w, XmNpopupEnabled, XmPOPUP_DISABLED, NULL );
+ wxMenu *menu = (wxMenu *)clientData;
+
+ // Added by JOREL Jean-Charles <jjorel@silr.ireste.fr>
+ /* Since Callbacks of MenuItems are not yet processed, we put a
+ * background job which will be done when system will be idle.
+ * What awful hack!! :(
+ */
+
+ WorkProcMenuId = XtAppAddWorkProc(
+ (XtAppContext) wxTheApp->GetAppContext(),
+ (XtWorkProc) PostDeletionOfMenu,
+ (XtPointer) menu );
+ // Apparently not found in Motif headers
+ // XtVaSetValues( w, XmNpopupEnabled, XmPOPUP_DISABLED, NULL );
}
/*
- * Create a popup or pulldown menu.
- * Submenus of a popup will be pulldown.
- *
- */
+* Create a popup or pulldown menu.
+* Submenus of a popup will be pulldown.
+*
+*/
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topMenu, const wxString& title, bool pullDown)
{
- Widget menu = (Widget) 0;
- Widget buttonWidget = (Widget) 0;
- Arg args[5];
- XtSetArg (args[0], XmNnumColumns, m_numColumns);
- XtSetArg (args[1], XmNpacking, XmPACK_COLUMN);
-
- if (!pullDown)
+ Widget menu = (Widget) 0;
+ Widget buttonWidget = (Widget) 0;
+ Arg args[5];
+ XtSetArg (args[0], XmNnumColumns, m_numColumns);
+ XtSetArg (args[1], XmNpacking, XmPACK_COLUMN);
+
+ if (!pullDown)
{
- menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2);
- XtAddCallback(menu,
- XmNunmapCallback,
- (XtCallbackProc)wxMenuPopdownCallback,
- (XtPointer)this);
+ menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2);
+ XtAddCallback(menu,
+ XmNunmapCallback,
+ (XtCallbackProc)wxMenuPopdownCallback,
+ (XtPointer)this);
}
- else
+ else
{
- char mnem = wxFindMnemonic (title);
- wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
-
- menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
-
- XmString label_str = XmStringCreateSimple (wxBuffer);
- buttonWidget = XtVaCreateManagedWidget (wxBuffer,
+ char mnem = wxFindMnemonic (title);
+ wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
+
+ menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
+
+ XmString label_str = XmStringCreateSimple (wxBuffer);
+ buttonWidget = XtVaCreateManagedWidget (wxBuffer,
#if wxUSE_GADGETS
- xmCascadeButtonGadgetClass, (Widget) parent,
+ xmCascadeButtonGadgetClass, (Widget) parent,
#else
- xmCascadeButtonWidgetClass, (Widget) parent,
+ xmCascadeButtonWidgetClass, (Widget) parent,
#endif
- XmNlabelString, label_str,
- XmNsubMenuId, menu,
- NULL);
-
- if (mnem != 0)
- XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
-
- XmStringFree (label_str);
+ XmNlabelString, label_str,
+ XmNsubMenuId, menu,
+ NULL);
+
+ if (mnem != 0)
+ XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
+
+ XmStringFree (label_str);
}
-
- m_menuWidget = (WXWidget) menu;
-
- m_menuBar = menuBar;
- m_topLevelMenu = topMenu;
-
- for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
+
+ m_menuWidget = (WXWidget) menu;
+
+ m_menuBar = menuBar;
+ m_topLevelMenu = topMenu;
+
+ for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
- wxMenuItem *item = (wxMenuItem *) node->Data ();
- item->CreateItem (menu, menuBar, topMenu);
+ wxMenuItem *item = (wxMenuItem *) node->Data ();
+ item->CreateItem (menu, menuBar, topMenu);
}
-
- SetBackgroundColour(m_backgroundColour);
- SetForegroundColour(m_foregroundColour);
- SetFont(m_font);
-
- return buttonWidget;
+
+ SetBackgroundColour(m_backgroundColour);
+ SetForegroundColour(m_foregroundColour);
+ SetFont(m_font);
+
+ return buttonWidget;
}
// Destroys the Motif implementation of the menu,
// do a CreateMenu again.
void wxMenu::DestroyMenu (bool full)
{
- for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
+ for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
- wxMenuItem *item = (wxMenuItem *) node->Data ();
- item->SetMenuBar((wxMenuBar*) NULL);
-
- item->DestroyItem(full);
+ wxMenuItem *item = (wxMenuItem *) node->Data ();
+ item->SetMenuBar((wxMenuBar*) NULL);
+
+ item->DestroyItem(full);
} // for()
-
- if (m_buttonWidget)
+
+ if (m_buttonWidget)
{
- if (full)
- {
- XtVaSetValues((Widget) m_buttonWidget, XmNsubMenuId, NULL, NULL);
- XtDestroyWidget ((Widget) m_buttonWidget);
- m_buttonWidget = (WXWidget) 0;
- }
+ if (full)
+ {
+ XtVaSetValues((Widget) m_buttonWidget, XmNsubMenuId, NULL, NULL);
+ XtDestroyWidget ((Widget) m_buttonWidget);
+ m_buttonWidget = (WXWidget) 0;
+ }
}
- if (m_menuWidget && full)
+ if (m_menuWidget && full)
{
- XtDestroyWidget((Widget) m_menuWidget);
- m_menuWidget = (WXWidget) NULL;
+ XtDestroyWidget((Widget) m_menuWidget);
+ m_menuWidget = (WXWidget) NULL;
}
}
WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
{
- if (id == m_menuId)
+ if (id == m_menuId)
{
- if (it)
- *it = (wxMenuItem*) NULL;
- return m_buttonWidget;
+ if (it)
+ *it = (wxMenuItem*) NULL;
+ return m_buttonWidget;
}
-
- for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
+
+ for (wxNode * node = m_menuItems.First (); node; node = node->Next ())
{
- wxMenuItem *item = (wxMenuItem *) node->Data ();
- if (item->GetId() == id)
- {
- if (it)
- *it = item;
- return item->GetButtonWidget();
- }
-
- if (item->GetSubMenu())
- {
- WXWidget w = item->GetSubMenu()->FindMenuItem (id, it);
- if (w)
- {
- return w;
- }
- }
+ wxMenuItem *item = (wxMenuItem *) node->Data ();
+ if (item->GetId() == id)
+ {
+ if (it)
+ *it = item;
+ return item->GetButtonWidget();
+ }
+
+ if (item->GetSubMenu())
+ {
+ WXWidget w = item->GetSubMenu()->FindMenuItem (id, it);
+ if (w)
+ {
+ return w;
+ }
+ }
} // for()
-
- if (it)
- *it = (wxMenuItem*) NULL;
- return (WXWidget) NULL;
+
+ if (it)
+ *it = (wxMenuItem*) NULL;
+ return (WXWidget) NULL;
}
void wxMenu::SetBackgroundColour(const wxColour& col)
{
m_backgroundColour = col;
if (m_menuWidget)
- wxDoChangeBackgroundColour(m_menuWidget, (wxColour&) col);
+ wxDoChangeBackgroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
- wxDoChangeBackgroundColour(m_buttonWidget, (wxColour&) col, TRUE);
-
+ wxDoChangeBackgroundColour(m_buttonWidget, (wxColour&) col, TRUE);
+
wxNode* node = m_menuItems.First();
while (node)
{
wxMenuItem* item = (wxMenuItem*) node->Data();
if (item->GetButtonWidget())
{
- // This crashes because it uses gadgets
- // wxDoChangeBackgroundColour(item->GetButtonWidget(), (wxColour&) col, TRUE);
+ // This crashes because it uses gadgets
+ // wxDoChangeBackgroundColour(item->GetButtonWidget(), (wxColour&) col, TRUE);
}
if (item->GetSubMenu())
- item->GetSubMenu()->SetBackgroundColour((wxColour&) col);
+ item->GetSubMenu()->SetBackgroundColour((wxColour&) col);
node = node->Next();
}
}
{
m_foregroundColour = col;
if (m_menuWidget)
- wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col);
+ wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
- wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col);
-
+ wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col);
+
wxNode* node = m_menuItems.First();
while (node)
{
wxMenuItem* item = (wxMenuItem*) node->Data();
if (item->GetButtonWidget())
{
- // This crashes because it uses gadgets
- // wxDoChangeForegroundColour(item->GetButtonWidget(), (wxColour&) col);
+ // This crashes because it uses gadgets
+ // wxDoChangeForegroundColour(item->GetButtonWidget(), (wxColour&) col);
}
if (item->GetSubMenu())
- item->GetSubMenu()->SetForegroundColour((wxColour&) col);
+ item->GetSubMenu()->SetForegroundColour((wxColour&) col);
node = node->Next();
}
}
void wxMenu::ChangeFont(bool keepOriginalSize)
{
-// lesstif 0.87 hangs when setting XmNfontList
+ // lesstif 0.87 hangs when setting XmNfontList
#ifndef LESSTIF_VERSION
if (!m_font.Ok() || !m_menuWidget)
return;
-
+
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_menuWidget));
-
+
XtVaSetValues ((Widget) m_menuWidget,
- XmNfontList, fontList,
- NULL);
+ XmNfontList, fontList,
+ NULL);
if (m_buttonWidget)
{
- XtVaSetValues ((Widget) m_buttonWidget,
- XmNfontList, fontList,
- NULL);
+ XtVaSetValues ((Widget) m_buttonWidget,
+ XmNfontList, fontList,
+ NULL);
}
wxNode* node = m_menuItems.First();
while (node)
wxMenuItem* item = (wxMenuItem*) node->Data();
if (m_menuWidget && item->GetButtonWidget() && m_font.Ok())
{
- XtVaSetValues ((Widget) item->GetButtonWidget(),
- XmNfontList, fontList,
- NULL);
+ XtVaSetValues ((Widget) item->GetButtonWidget(),
+ XmNfontList, fontList,
+ NULL);
}
if (item->GetSubMenu())
- item->GetSubMenu()->ChangeFont(keepOriginalSize);
+ item->GetSubMenu()->ChangeFont(keepOriginalSize);
node = node->Next();
}
#endif
void wxMenuBar::SetBackgroundColour(const wxColour& col)
{
-
+
m_backgroundColour = col;
if (m_mainWidget)
- wxDoChangeBackgroundColour(m_mainWidget, (wxColour&) col);
+ wxDoChangeBackgroundColour(m_mainWidget, (wxColour&) col);
int i;
for (i = 0; i < m_menuCount; i++)
- m_menus[i]->SetBackgroundColour((wxColour&) col);
+ m_menus[i]->SetBackgroundColour((wxColour&) col);
}
void wxMenuBar::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col;
if (m_mainWidget)
- wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col);
-
+ wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col);
+
int i;
for (i = 0; i < m_menuCount; i++)
- m_menus[i]->SetForegroundColour((wxColour&) col);
+ m_menus[i]->SetForegroundColour((wxColour&) col);
}
void wxMenuBar::ChangeFont(bool keepOriginalSize)
{
- // Nothing to do for menubar, fonts are kept in wxMenus
+ // Nothing to do for menubar, fonts are kept in wxMenus
}
void wxMenuBar::SetFont(const wxFont& font)
{
m_font = font;
ChangeFont();
-
+
int i;
for (i = 0; i < m_menuCount; i++)
- m_menus[i]->SetFont(font);
+ m_menus[i]->SetFont(font);
}
#include "wx/motif/private.h"
void wxMenuItemCallback (Widget w, XtPointer clientData,
- XtPointer ptr);
+ XtPointer ptr);
void wxMenuItemArmCallback (Widget w, XtPointer clientData,
- XtPointer ptr);
+ XtPointer ptr);
void wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
- XtPointer ptr);
+ XtPointer ptr);
// ============================================================================
// implementation
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
- IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_SHARED_LIBRARY
// ----------------------------------------------------------------------------
const wxString& strName, const wxString& strHelp,
bool bCheckable,
wxMenu *pSubMenu) :
- m_strHelp(strHelp),
- m_bCheckable(bCheckable),
- m_strName(strName)
+m_strHelp(strHelp),
+m_bCheckable(bCheckable),
+m_strName(strName)
{
- wxASSERT( pParentMenu != NULL );
-
- m_pParentMenu = pParentMenu;
- m_pSubMenu = pSubMenu;
- m_idItem = id;
- m_bEnabled = TRUE;
- m_bChecked = FALSE;
-
- //// Motif-specific
- m_menuBar = NULL;
- m_buttonWidget = (WXWidget) NULL;
- m_topMenu = NULL;
+ wxASSERT( pParentMenu != NULL );
+
+ m_pParentMenu = pParentMenu;
+ m_pSubMenu = pSubMenu;
+ m_idItem = id;
+ m_bEnabled = TRUE;
+ m_bChecked = FALSE;
+
+ //// Motif-specific
+ m_menuBar = NULL;
+ m_buttonWidget = (WXWidget) NULL;
+ m_topMenu = NULL;
}
wxMenuItem::~wxMenuItem()
// delete the sub menu
void wxMenuItem::DeleteSubMenu()
{
- wxASSERT( m_pSubMenu != NULL );
-
- delete m_pSubMenu;
- m_pSubMenu = NULL;
+ wxASSERT( m_pSubMenu != NULL );
+
+ delete m_pSubMenu;
+ m_pSubMenu = NULL;
}
// change item state
void wxMenuItem::Enable(bool bDoEnable)
{
- if ( m_bEnabled != bDoEnable )
- {
- if ( m_pSubMenu == NULL )
- { // normal menu item
- if (m_buttonWidget)
- XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
- }
- else // submenu
+ if ( m_bEnabled != bDoEnable )
{
- // Maybe we should apply this to all items in the submenu?
- // Or perhaps it works anyway.
- if (m_buttonWidget)
- XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
+ if ( m_pSubMenu == NULL )
+ { // normal menu item
+ if (m_buttonWidget)
+ XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
+ }
+ else // submenu
+ {
+ // Maybe we should apply this to all items in the submenu?
+ // Or perhaps it works anyway.
+ if (m_buttonWidget)
+ XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
+ }
+
+ m_bEnabled = bDoEnable;
}
-
- m_bEnabled = bDoEnable;
- }
}
void wxMenuItem::Check(bool bDoCheck)
{
- wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
-
- if ( m_bChecked != bDoCheck )
- {
- if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
+ wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
+
+ if ( m_bChecked != bDoCheck )
{
- XtVaSetValues ( (Widget) m_buttonWidget, XmNset, (Boolean) bDoCheck, NULL);
+ if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
+ {
+ XtVaSetValues ( (Widget) m_buttonWidget, XmNset, (Boolean) bDoCheck, NULL);
+ }
+ m_bChecked = bDoCheck;
}
- m_bChecked = bDoCheck;
- }
}
//// Motif-specific
void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu)
{
- m_menuBar = menuBar;
- m_topMenu = topMenu;
-
- if (GetId() == -2)
+ m_menuBar = menuBar;
+ m_topMenu = topMenu;
+
+ if (GetId() == -2)
{
- // Id=-2 identifies a Title item.
- wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
- xmLabelGadgetClass, (Widget) menu, NULL);
+ // Id=-2 identifies a Title item.
+ wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
+ xmLabelGadgetClass, (Widget) menu, NULL);
}
- else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
+ else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
{
- wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
- if (IsCheckable())
- {
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
- xmToggleButtonGadgetClass, (Widget) menu,
- NULL);
- XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
- }
- else
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
- xmPushButtonGadgetClass, (Widget) menu,
- NULL);
- char mnem = wxFindMnemonic (m_strName);
- if (mnem != 0)
- XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
-
- //// TODO: proper accelerator treatment. What does wxFindAccelerator
- //// look for?
- strcpy(wxBuffer, (char*) (const char*) m_strName);
- char *accel = wxFindAccelerator (wxBuffer);
- if (accel)
- XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
-
- // TODO: What does this do?
- strcpy(wxBuffer, (char*) (const char*) m_strName);
- XmString accel_str = wxFindAcceleratorText (wxBuffer);
- if (accel_str)
- {
- XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
- XmStringFree (accel_str);
- }
-
- if (IsCheckable())
- XtAddCallback ((Widget) m_buttonWidget,
- XmNvalueChangedCallback,
- (XtCallbackProc) wxMenuItemCallback,
- (XtPointer) this);
- else
- XtAddCallback ((Widget) m_buttonWidget,
- XmNactivateCallback,
- (XtCallbackProc) wxMenuItemCallback,
- (XtPointer) this);
- XtAddCallback ((Widget) m_buttonWidget,
- XmNarmCallback,
- (XtCallbackProc) wxMenuItemArmCallback,
- (XtPointer) this);
- XtAddCallback ((Widget) m_buttonWidget,
- XmNdisarmCallback,
- (XtCallbackProc) wxMenuItemDisarmCallback,
- (XtPointer) this);
+ wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
+ if (IsCheckable())
+ {
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
+ xmToggleButtonGadgetClass, (Widget) menu,
+ NULL);
+ XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
+ }
+ else
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
+ xmPushButtonGadgetClass, (Widget) menu,
+ NULL);
+ char mnem = wxFindMnemonic (m_strName);
+ if (mnem != 0)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
+
+ //// TODO: proper accelerator treatment. What does wxFindAccelerator
+ //// look for?
+ strcpy(wxBuffer, (char*) (const char*) m_strName);
+ char *accel = wxFindAccelerator (wxBuffer);
+ if (accel)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
+
+ // TODO: What does this do?
+ strcpy(wxBuffer, (char*) (const char*) m_strName);
+ XmString accel_str = wxFindAcceleratorText (wxBuffer);
+ if (accel_str)
+ {
+ XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
+ XmStringFree (accel_str);
+ }
+
+ if (IsCheckable())
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNvalueChangedCallback,
+ (XtCallbackProc) wxMenuItemCallback,
+ (XtPointer) this);
+ else
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNactivateCallback,
+ (XtCallbackProc) wxMenuItemCallback,
+ (XtPointer) this);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNarmCallback,
+ (XtCallbackProc) wxMenuItemArmCallback,
+ (XtPointer) this);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNdisarmCallback,
+ (XtCallbackProc) wxMenuItemDisarmCallback,
+ (XtPointer) this);
}
- else if (GetId() == -1)
+ else if (GetId() == -1)
{
- m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
- xmSeparatorGadgetClass, (Widget) menu, NULL);
+ m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
+ xmSeparatorGadgetClass, (Widget) menu, NULL);
}
- else if (m_pSubMenu)
+ else if (m_pSubMenu)
{
- m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE);
- m_pSubMenu->SetButtonWidget(m_buttonWidget);
- XtAddCallback ((Widget) m_buttonWidget,
- XmNcascadingCallback,
- (XtCallbackProc) wxMenuItemArmCallback,
- (XtPointer) this);
+ m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE);
+ m_pSubMenu->SetButtonWidget(m_buttonWidget);
+ XtAddCallback ((Widget) m_buttonWidget,
+ XmNcascadingCallback,
+ (XtCallbackProc) wxMenuItemArmCallback,
+ (XtPointer) this);
}
- if (m_buttonWidget)
- XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
+ if (m_buttonWidget)
+ XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
}
void wxMenuItem::DestroyItem(bool full)
{
- if (GetId() == -2)
+ if (GetId() == -2)
{
- ; // Nothing
-
+ ; // Nothing
+
}
- else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
+ else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
{
- if (m_buttonWidget)
- {
- if (IsCheckable())
- XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
- wxMenuItemCallback, (XtPointer) this);
- else
- XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
- wxMenuItemCallback, (XtPointer) this);
- XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
- wxMenuItemArmCallback, (XtPointer) this);
- XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
- wxMenuItemDisarmCallback, (XtPointer) this);
- }
+ if (m_buttonWidget)
+ {
+ if (IsCheckable())
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
+ wxMenuItemCallback, (XtPointer) this);
+ else
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
+ wxMenuItemCallback, (XtPointer) this);
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
+ wxMenuItemArmCallback, (XtPointer) this);
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
+ wxMenuItemDisarmCallback, (XtPointer) this);
+ }
}
- else if (GetId() == -1)
+ else if (GetId() == -1)
{
- ; // Nothing
-
+ ; // Nothing
+
}
- else if (GetSubMenu())
+ else if (GetSubMenu())
{
- if (m_buttonWidget)
- {
- XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
- wxMenuItemArmCallback, (XtPointer) this);
- }
- m_pSubMenu->DestroyMenu(full);
- if (full)
- m_buttonWidget = NULL;
+ if (m_buttonWidget)
+ {
+ XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
+ wxMenuItemArmCallback, (XtPointer) this);
+ }
+ m_pSubMenu->DestroyMenu(full);
+ if (full)
+ m_buttonWidget = NULL;
}
-
- if (m_buttonWidget && full)
+
+ if (m_buttonWidget && full)
{
- XtDestroyWidget ((Widget) m_buttonWidget);
- m_buttonWidget = (WXWidget) 0;
+ XtDestroyWidget ((Widget) m_buttonWidget);
+ m_buttonWidget = (WXWidget) 0;
}
}
void wxMenuItem::SetLabel(const wxString& label)
{
- char mnem = wxFindMnemonic (label);
- wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
-
- m_strName = label;
-
- if (m_buttonWidget)
+ char mnem = wxFindMnemonic (label);
+ wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
+
+ m_strName = label;
+
+ if (m_buttonWidget)
{
- XmString label_str = XmStringCreateSimple (wxBuffer);
- XtVaSetValues ((Widget) m_buttonWidget,
- XmNlabelString, label_str,
- NULL);
- XmStringFree (label_str);
- if (mnem != 0)
- XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
- strcpy(wxBuffer, (char*) (const char*) label);
- char *accel = wxFindAccelerator (wxBuffer);
- if (accel)
- XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
-
- strcpy(wxBuffer, (char*) (const char*) label);
- XmString accel_str = wxFindAcceleratorText (wxBuffer);
- if (accel_str)
+ XmString label_str = XmStringCreateSimple (wxBuffer);
+ XtVaSetValues ((Widget) m_buttonWidget,
+ XmNlabelString, label_str,
+ NULL);
+ XmStringFree (label_str);
+ if (mnem != 0)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
+ strcpy(wxBuffer, (char*) (const char*) label);
+ char *accel = wxFindAccelerator (wxBuffer);
+ if (accel)
+ XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
+
+ strcpy(wxBuffer, (char*) (const char*) label);
+ XmString accel_str = wxFindAcceleratorText (wxBuffer);
+ if (accel_str)
{
- XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
- XmStringFree (accel_str);
+ XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
+ XmStringFree (accel_str);
}
}
}
void wxMenuItemCallback (Widget w, XtPointer clientData,
- XtPointer ptr)
+ XtPointer ptr)
{
- wxMenuItem *item = (wxMenuItem *) clientData;
- if (item)
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
{
- if (item->IsCheckable())
- {
- Boolean isChecked = FALSE;
- XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
- item->SetChecked(isChecked);
- }
- if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
- {
- wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
- commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
- commandEvent.SetInt( item->GetId() );
-
- item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
- }
- else if (item->GetTopMenu())
- {
- wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
- event.SetEventObject(item->GetTopMenu());
- event.SetInt( item->GetId() );
-
- item->GetTopMenu()->ProcessCommand (event);
- }
+ if (item->IsCheckable())
+ {
+ Boolean isChecked = FALSE;
+ XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
+ item->SetChecked(isChecked);
+ }
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
+ commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+ commandEvent.SetInt( item->GetId() );
+
+ item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
+ }
+ else if (item->GetTopMenu())
+ {
+ wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
+ event.SetEventObject(item->GetTopMenu());
+ event.SetInt( item->GetId() );
+
+ item->GetTopMenu()->ProcessCommand (event);
+ }
}
}
-void
-wxMenuItemArmCallback (Widget w, XtPointer clientData,
- XtPointer ptr)
+void wxMenuItemArmCallback (Widget w, XtPointer clientData,
+ XtPointer ptr)
{
- wxMenuItem *item = (wxMenuItem *) clientData;
- if (item)
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
{
- if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
- {
- wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
- menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
-
- item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
- }
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
+ menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+
+ item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
+ }
}
}
void
wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
- XtPointer ptr)
+ XtPointer ptr)
{
- wxMenuItem *item = (wxMenuItem *) clientData;
- if (item)
+ wxMenuItem *item = (wxMenuItem *) clientData;
+ if (item)
{
- if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
- {
- // TODO: not sure this is correct, since -1 means something
- // special to event system
- wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
- menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
-
- item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
- }
+ if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
+ {
+ // TODO: not sure this is correct, since -1 means something
+ // special to event system
+ wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
+ menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
+
+ item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
+ }
}
}
#endif
/*
- * Palette
- *
- */
+* Palette
+*
+*/
wxXPalette::wxXPalette()
{
wxPaletteRefData::~wxPaletteRefData()
{
- XColor xcol;
- Display *display = (Display*) NULL;
-
- wxNode *node, *next;
-
- for (node = m_palettes.First(); node; node = next) {
- wxXPalette *c = (wxXPalette *)node->Data();
- unsigned long *pix_array = c->m_pix_array;
- Colormap cmap = (Colormap) c->m_cmap;
- bool destroyable = c->m_destroyable;
- int pix_array_n = c->m_pix_array_n;
- display = (Display*) c->m_display;
-
- if (pix_array_n > 0)
- {
-// XFreeColors(display, cmap, pix_array, pix_array_n, 0);
- // Be careful not to free '0' pixels...
- int i, j;
- for(i=j=0; i<pix_array_n; i=j) {
- while(j<pix_array_n && pix_array[j]!=0) j++;
- if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
- while(j<pix_array_n && pix_array[j]==0) j++;
- }
- delete [] pix_array;
+ XColor xcol;
+ Display *display = (Display*) NULL;
+
+ wxNode *node, *next;
+
+ for (node = m_palettes.First(); node; node = next) {
+ wxXPalette *c = (wxXPalette *)node->Data();
+ unsigned long *pix_array = c->m_pix_array;
+ Colormap cmap = (Colormap) c->m_cmap;
+ bool destroyable = c->m_destroyable;
+ int pix_array_n = c->m_pix_array_n;
+ display = (Display*) c->m_display;
+
+ if (pix_array_n > 0)
+ {
+ // XFreeColors(display, cmap, pix_array, pix_array_n, 0);
+ // Be careful not to free '0' pixels...
+ int i, j;
+ for(i=j=0; i<pix_array_n; i=j) {
+ while(j<pix_array_n && pix_array[j]!=0) j++;
+ if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
+ while(j<pix_array_n && pix_array[j]==0) j++;
+ }
+ delete [] pix_array;
+ }
+
+ if (destroyable)
+ XFreeColormap(display, cmap);
+
+ next = node->Next();
+ m_palettes.DeleteNode(node);
+ delete c;
}
-
- if (destroyable)
- XFreeColormap(display, cmap);
-
- next = node->Next();
- m_palettes.DeleteNode(node);
- delete c;
- }
}
wxPalette::wxPalette()
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
- UnRef();
-
- if (!n) {
- return FALSE;
- }
-
- m_refData = new wxPaletteRefData;
-
- XColor xcol;
- Display* display = (Display*) wxGetDisplay();
-
- unsigned long *pix_array;
- Colormap cmap;
- int pix_array_n;
-
- cmap = (Colormap) wxTheApp->GetMainColormap(display);
-
- pix_array = new unsigned long[n];
- if (!pix_array)
- return FALSE;
-
- pix_array_n = n;
- xcol.flags = DoRed | DoGreen | DoBlue;
- for(int i = 0; i < n; i++) {
- xcol.red = (unsigned short)red[i] << 8;
- xcol.green = (unsigned short)green[i] << 8;
- xcol.blue = (unsigned short)blue[i] << 8;
- pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
- }
-
- wxXPalette *c = new wxXPalette;
-
- c->m_pix_array_n = pix_array_n;
- c->m_pix_array = pix_array;
- c->m_cmap = (WXColormap) cmap;
- c->m_display = (WXDisplay*) display;
- c->m_destroyable = FALSE;
- M_PALETTEDATA->m_palettes.Append(c);
-
- return TRUE;
+ UnRef();
+
+ if (!n) {
+ return FALSE;
+ }
+
+ m_refData = new wxPaletteRefData;
+
+ XColor xcol;
+ Display* display = (Display*) wxGetDisplay();
+
+ unsigned long *pix_array;
+ Colormap cmap;
+ int pix_array_n;
+
+ cmap = (Colormap) wxTheApp->GetMainColormap(display);
+
+ pix_array = new unsigned long[n];
+ if (!pix_array)
+ return FALSE;
+
+ pix_array_n = n;
+ xcol.flags = DoRed | DoGreen | DoBlue;
+ for(int i = 0; i < n; i++) {
+ xcol.red = (unsigned short)red[i] << 8;
+ xcol.green = (unsigned short)green[i] << 8;
+ xcol.blue = (unsigned short)blue[i] << 8;
+ pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
+ }
+
+ wxXPalette *c = new wxXPalette;
+
+ c->m_pix_array_n = pix_array_n;
+ c->m_pix_array = pix_array;
+ c->m_cmap = (WXColormap) cmap;
+ c->m_display = (WXDisplay*) display;
+ c->m_destroyable = FALSE;
+ M_PALETTEDATA->m_palettes.Append(c);
+
+ return TRUE;
}
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
{
if ( !m_refData )
- return FALSE;
-
+ return FALSE;
+
// TODO
return FALSE;
}
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{
if ( !m_refData )
- return FALSE;
-
+ return FALSE;
+
if (index < 0 || index > 255)
return FALSE;
-
+
// TODO
return FALSE;
}
{
if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0))
return wxTheApp->GetMainColormap(display);
-
+
wxNode* node = M_PALETTEDATA->m_palettes.First();
if (!display && node)
{
wxXPalette* p = (wxXPalette*) node->Data();
if (p->m_display == display)
return p->m_cmap;
-
+
node = node->Next();
}
-
+
/* Make a new one: */
wxXPalette *c = new wxXPalette;
wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data();
XColor xcol;
int pix_array_n = first->m_pix_array_n;
-
+
c->m_pix_array_n = pix_array_n;
c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE;
-
+
xcol.flags = DoRed | DoGreen | DoBlue;
int i;
for (i = 0; i < pix_array_n; i++)
c->m_pix_array[i] =
(XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel;
}
-
+
// wxPalette* nonConstThis = (wxPalette*) this;
-
+
M_PALETTEDATA->m_palettes.Append(c);
-
+
return c->m_cmap;
}
bool wxPalette::TransferBitmap(void *data, int depth, int size)
{
- switch(depth) {
- case 8:
- {
- unsigned char *uptr = (unsigned char *)data;
- int pix_array_n;
- unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
- while(size-- > 0)
- {
- if((int)*uptr < pix_array_n)
- *uptr = (unsigned char)pix_array[*uptr];
- uptr++;
+ switch(depth) {
+ case 8:
+ {
+ unsigned char *uptr = (unsigned char *)data;
+ int pix_array_n;
+ unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
+ while(size-- > 0)
+ {
+ if((int)*uptr < pix_array_n)
+ *uptr = (unsigned char)pix_array[*uptr];
+ uptr++;
+ }
+
+ return TRUE;
+ }
+ default:
+ return FALSE;
}
-
- return TRUE;
- }
- default:
- return FALSE;
- }
}
bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
- void *dest, unsigned int bpp)
+ void *dest, unsigned int bpp)
{
- int pix_array_n;
- unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
+ int pix_array_n;
+ unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
switch(bpp) {
case 8: {
- unsigned char *dptr = (unsigned char *)dest;
- while(sz-- > 0) {
- if((int)*data < pix_array_n)
- *dptr = (unsigned char)pix_array[*data];
- data++;
- dptr++;
- }
- break;
- }
+ unsigned char *dptr = (unsigned char *)dest;
+ while(sz-- > 0) {
+ if((int)*data < pix_array_n)
+ *dptr = (unsigned char)pix_array[*data];
+ data++;
+ dptr++;
+ }
+ break;
+ }
case 16: {
- unsigned short *dptr = (unsigned short *)dest;
- while(sz-- > 0) {
- if((int)*data < pix_array_n)
- *dptr = (unsigned short)pix_array[*data];
- data++;
- dptr++;
- }
- break;
- }
+ unsigned short *dptr = (unsigned short *)dest;
+ while(sz-- > 0) {
+ if((int)*data < pix_array_n)
+ *dptr = (unsigned short)pix_array[*data];
+ data++;
+ dptr++;
+ }
+ break;
+ }
case 24: {
- struct rgb24 { unsigned char r, g, b; } *dptr = (struct rgb24 *)dest;
- while(sz-- > 0) {
- if((int)*data < pix_array_n) {
- dptr->r = pix_array[*data] & 0xFF;
- dptr->g = (pix_array[*data] >> 8) & 0xFF;
- dptr->b = (pix_array[*data] >> 16) & 0xFF;
+ struct rgb24 { unsigned char r, g, b; } *dptr = (struct rgb24 *)dest;
+ while(sz-- > 0) {
+ if((int)*data < pix_array_n) {
+ dptr->r = pix_array[*data] & 0xFF;
+ dptr->g = (pix_array[*data] >> 8) & 0xFF;
+ dptr->b = (pix_array[*data] >> 16) & 0xFF;
+ }
+ data++;
+ dptr++;
}
- data++;
- dptr++;
- }
- break;
- }
+ break;
+ }
case 32: {
- unsigned long *dptr = (unsigned long *)dest;
- while(sz-- > 0) {
- if((int)*data < pix_array_n)
- *dptr = pix_array[*data];
- data++;
- dptr++;
- }
- break;
- }
+ unsigned long *dptr = (unsigned long *)dest;
+ while(sz-- > 0) {
+ if((int)*data < pix_array_n)
+ *dptr = pix_array[*data];
+ data++;
+ dptr++;
+ }
+ break;
+ }
default:
- return FALSE;
+ return FALSE;
}
return TRUE;
}
if (!M_PALETTEDATA)
return (unsigned long*) 0;
wxNode *node;
-
+
for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next())
{
wxXPalette *c = (wxXPalette *)node->Data();
return c->m_pix_array;
}
}
-
+
/* Not found; call GetXColormap, which will create it, then this again */
if (GetXColormap(display))
return GetXPixArray(display, n);
void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp)
{
UnRef();
-
+
m_refData = new wxPaletteRefData;
-
+
wxXPalette *c = new wxXPalette;
-
+
c->m_pix_array_n = 0;
c->m_pix_array = (unsigned long*) NULL;
c->m_display = display;
c->m_cmap = cm;
c->m_destroyable = dp;
-
+
M_PALETTEDATA->m_palettes.Append(c);
}
wxPen::wxPen(const wxColour& col, int Width, int Style)
{
m_refData = new wxPenRefData;
-
+
M_PENDATA->m_colour = col;
M_PENDATA->m_width = Width;
M_PENDATA->m_style = Style;
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ;
-
+
RealizeResource();
-
+
if ( wxThePenList )
wxThePenList->AddPen(this);
}
wxPen::wxPen(const wxBitmap& stipple, int Width)
{
m_refData = new wxPenRefData;
-
+
M_PENDATA->m_stipple = stipple;
M_PENDATA->m_width = Width;
M_PENDATA->m_style = wxSTIPPLE;
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ;
-
+
RealizeResource();
-
+
if ( wxThePenList )
wxThePenList->AddPen(this);
}
void wxPen::Unshare()
{
- // Don't change shared data
- if (!m_refData)
+ // Don't change shared data
+ if (!m_refData)
{
- m_refData = new wxPenRefData();
- }
+ m_refData = new wxPenRefData();
+ }
else
{
- wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
- UnRef();
- m_refData = ref;
- }
+ wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
+ UnRef();
+ m_refData = ref;
+ }
}
void wxPen::SetColour(const wxColour& col)
{
Unshare();
-
+
M_PENDATA->m_colour = col;
-
+
RealizeResource();
}
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
{
Unshare();
-
+
M_PENDATA->m_colour.Set(r, g, b);
-
+
RealizeResource();
}
void wxPen::SetWidth(int Width)
{
Unshare();
-
+
M_PENDATA->m_width = Width;
-
+
RealizeResource();
}
void wxPen::SetStyle(int Style)
{
Unshare();
-
+
M_PENDATA->m_style = Style;
-
+
RealizeResource();
}
void wxPen::SetStipple(const wxBitmap& Stipple)
{
Unshare();
-
+
M_PENDATA->m_stipple = Stipple;
M_PENDATA->m_style = wxSTIPPLE;
-
+
RealizeResource();
}
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
{
Unshare();
-
+
M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxDash *)Dash;
-
+
RealizeResource();
}
void wxPen::SetJoin(int Join)
{
Unshare();
-
+
M_PENDATA->m_join = Join;
-
+
RealizeResource();
}
void wxPen::SetCap(int Cap)
{
Unshare();
-
+
M_PENDATA->m_cap = Cap;
-
+
RealizeResource();
}
#include <wx/motif/private.h>
void wxRadioButtonCallback (Widget w, XtPointer clientData,
- XmToggleButtonCallbackStruct * cbs);
+ XmToggleButtonCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
}
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
- const wxString& label,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxString& label,
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont();
-
+
if (parent) parent->AddChild(this);
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
m_windowStyle = style ;
-
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
wxString label1(wxStripMenuCodes(label));
-
+
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
-
+
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
-
+
Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle",
#if wxUSE_GADGETS
- xmToggleButtonGadgetClass, parentWidget,
+ xmToggleButtonGadgetClass, parentWidget,
#else
- xmToggleButtonWidgetClass, parentWidget,
+ xmToggleButtonWidgetClass, parentWidget,
#endif
- XmNfontList, fontList,
- XmNlabelString, text,
- XmNfillOnSelect, True,
- XmNindicatorType, XmONE_OF_MANY, // diamond-shape
- NULL);
+ XmNfontList, fontList,
+ XmNlabelString, text,
+ XmNfillOnSelect, True,
+ XmNindicatorType, XmONE_OF_MANY, // diamond-shape
+ NULL);
XmStringFree (text);
-
+
XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback,
- (XtCallbackProc) this);
-
+ (XtCallbackProc) this);
+
m_mainWidget = (WXWidget) radioButtonWidget;
-
+
XtManageChild (radioButtonWidget);
-
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
void wxRadioButton::Command (wxCommandEvent & event)
{
- SetValue ( (event.m_commandInt != 0) );
- ProcessCommand (event);
+ SetValue ( (event.m_commandInt != 0) );
+ ProcessCommand (event);
}
void wxRadioButton::ChangeFont(bool keepOriginalSize)
}
void wxRadioButtonCallback (Widget w, XtPointer clientData,
- XmToggleButtonCallbackStruct * cbs)
+ XmToggleButtonCallbackStruct * cbs)
{
- if (!cbs->set)
- return;
-
- wxRadioButton *item = (wxRadioButton *) clientData;
- if (item->InSetValue())
- return;
-
- wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
- event.SetEventObject(item);
-
- item->ProcessCommand (event);
+ if (!cbs->set)
+ return;
+
+ wxRadioButton *item = (wxRadioButton *) clientData;
+ if (item->InSetValue())
+ return;
+
+ wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
+ event.SetEventObject(item);
+
+ item->ProcessCommand (event);
}
// Slider
wxSlider::wxSlider()
{
- m_pageSize = 1;
- m_lineSize = 1;
- m_rangeMax = 0;
- m_rangeMin = 0;
- m_tickFreq = 0;
+ m_pageSize = 1;
+ m_lineSize = 1;
+ m_rangeMax = 0;
+ m_rangeMin = 0;
+ m_tickFreq = 0;
}
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
- int value, int minValue, int maxValue,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ int value, int minValue, int maxValue,
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
SetName(name);
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
-
+
if (parent) parent->AddChild(this);
-
+
m_lineSize = 1;
m_windowStyle = style;
m_tickFreq = 0;
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
m_rangeMax = maxValue;
m_rangeMin = minValue;
-
+
// Not used in Motif, I think
m_pageSize = (int)((maxValue-minValue)/10);
-
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget",
- xmScaleWidgetClass, parentWidget,
- XmNorientation,
- (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL),
- XmNprocessingDirection,
- (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT),
- XmNmaximum, maxValue,
- XmNminimum, minValue,
- XmNvalue, value,
- XmNshowValue, True,
- NULL);
-
+ xmScaleWidgetClass, parentWidget,
+ XmNorientation,
+ (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL),
+ XmNprocessingDirection,
+ (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT),
+ XmNmaximum, maxValue,
+ XmNminimum, minValue,
+ XmNvalue, value,
+ XmNshowValue, True,
+ NULL);
+
m_mainWidget = (WXWidget) sliderWidget;
-
+
if(style & wxSL_NOTIFY_DRAG)
XtAddCallback (sliderWidget, XmNdragCallback,
- (XtCallbackProc) wxSliderCallback, (XtPointer) this);
+ (XtCallbackProc) wxSliderCallback, (XtPointer) this);
else
XtAddCallback (sliderWidget, XmNvalueChangedCallback,
- (XtCallbackProc) wxSliderCallback, (XtPointer) this);
-
+ (XtCallbackProc) wxSliderCallback, (XtPointer) this);
+
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
-
+
m_windowFont = parent->GetFont();
-
+
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags)
{
- Widget widget = (Widget) m_mainWidget;
-
- bool managed = XtIsManaged(widget);
-
- if (managed)
- XtUnmanageChild (widget);
-
- if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
- {
- XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
- }
-
- if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
- {
- XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
- }
-
- int xx = x; int yy = y;
- AdjustForParentClientOrigin(xx, yy, sizeFlags);
-
- if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues (widget, XmNx, xx, NULL);
- if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues (widget, XmNy, yy, NULL);
-
- if (managed)
- XtManageChild (widget);
+ Widget widget = (Widget) m_mainWidget;
+
+ bool managed = XtIsManaged(widget);
+
+ if (managed)
+ XtUnmanageChild (widget);
+
+ if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
+ {
+ XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
+ }
+
+ if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
+ {
+ XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
+ }
+
+ int xx = x; int yy = y;
+ AdjustForParentClientOrigin(xx, yy, sizeFlags);
+
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues (widget, XmNx, xx, NULL);
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues (widget, XmNy, yy, NULL);
+
+ if (managed)
+ XtManageChild (widget);
}
void wxSlider::SetRange(int minValue, int maxValue)
{
m_rangeMin = minValue;
m_rangeMax = maxValue;
-
+
XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL);
}
void wxSlider::Command (wxCommandEvent & event)
{
- SetValue (event.GetInt());
- ProcessCommand (event);
+ SetValue (event.GetInt());
+ ProcessCommand (event);
}
void wxSlider::ChangeFont(bool keepOriginalSize)
wxSlider *slider = (wxSlider *) clientData;
switch (cbs->reason)
{
- case XmCR_VALUE_CHANGED:
- case XmCR_DRAG:
- default:
+ case XmCR_VALUE_CHANGED:
+ case XmCR_DRAG:
+ default:
{
// TODO: the XmCR_VALUE_CHANGED case should be handled
// differently (it's not sent continually as the slider moves).
// In which case we need a similar behaviour for other platforms.
-
+
wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId());
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider);
slider->ProcessCommand(event);
-
+
// Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider);
static void
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
- XmAnyCallbackStruct *ptr);
+ XmAnyCallbackStruct *ptr);
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
- EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
- EVT_CHAR(wxTextCtrl::OnChar)
+EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
+EVT_CHAR(wxTextCtrl::OnChar)
END_EVENT_TABLE()
#endif
// Text item
wxTextCtrl::wxTextCtrl()
#ifndef NO_TEXT_WINDOW_STREAM
- :streambuf()
+:streambuf()
#endif
{
m_fileName = "";
}
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
- const wxString& value,
- const wxPoint& pos,
- const wxSize& size, long style,
- const wxValidator& validator,
- const wxString& name)
+ const wxString& value,
+ const wxPoint& pos,
+ const wxSize& size, long style,
+ const wxValidator& validator,
+ const wxString& name)
{
m_tempCallbackStruct = (void*) NULL;
m_modified = FALSE;
// m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour();
-
+
SetName(name);
SetValidator(validator);
if (parent) parent->AddChild(this);
-
+
m_windowStyle = style;
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
Widget parentWidget = (Widget) parent->GetClientWidget();
-
+
bool wantHorizScrolling = ((m_windowStyle & wxHSCROLL) != 0);
-
+
// If we don't have horizontal scrollbars, we want word wrap.
bool wantWordWrap = !wantHorizScrolling;
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
Arg args[2];
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
-
+
m_mainWidget = (WXWidget) XmCreateScrolledText (parentWidget, (char*) (const char*) name, args, 2);
-
+
XtVaSetValues ((Widget) m_mainWidget,
- XmNeditable, ((style & wxTE_READONLY) ? False : True),
- XmNeditMode, XmMULTI_LINE_EDIT,
- NULL);
+ XmNeditable, ((style & wxTE_READONLY) ? False : True),
+ XmNeditMode, XmMULTI_LINE_EDIT,
+ NULL);
XtManageChild ((Widget) m_mainWidget);
}
else
{
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
- xmTextWidgetClass, parentWidget,
- NULL);
-
+ xmTextWidgetClass, parentWidget,
+ NULL);
+
// TODO: Is this relevant? What does it do?
int noCols = 2;
if (!value.IsNull() && (value.Length() > (unsigned int) noCols))
noCols = value.Length();
XtVaSetValues ((Widget) m_mainWidget,
- XmNcolumns, noCols,
- NULL);
+ XmNcolumns, noCols,
+ NULL);
}
-
+
if (!value.IsNull())
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
-
+
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
-
+
XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this);
-
+
XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this);
-
+
XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this);
-
+
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
-
+
m_windowFont = parent->GetFont();
ChangeFont(FALSE);
-
+
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
-
+
ChangeBackgroundColour();
-
+
return TRUE;
}
char *s = XmTextGetString ((Widget) m_mainWidget);
if (s)
{
- wxString str(s);
+ wxString str(s);
XtFree (s);
- return str;
- }
- else
+ return str;
+ }
+ else
{
return wxEmptyString;
}
void wxTextCtrl::SetValue(const wxString& value)
{
- // This assert is wrong -- means that you can't set an empty
- // string (IsNull == IsEmpty).
- // wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
+ // This assert is wrong -- means that you can't set an empty
+ // string (IsNull == IsEmpty).
+ // wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
m_inSetValue = TRUE;
-
+
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
-
+
m_inSetValue = FALSE;
}
void wxTextCtrl::Replace(long from, long to, const wxString& value)
{
XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
- (char*) (const char*) value);
+ (char*) (const char*) value);
}
void wxTextCtrl::Remove(long from, long to)
{
if (!wxFileExists(file))
return FALSE;
-
+
m_fileName = file;
-
+
Clear();
-
+
Widget textWidget = (Widget) m_mainWidget;
FILE *fp;
-
+
struct stat statb;
if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
- !(fp = fopen ((char*) (const char*) file, "r")))
+ !(fp = fopen ((char*) (const char*) file, "r")))
{
- return FALSE;
+ return FALSE;
}
else
{
- long len = statb.st_size;
- char *text;
- if (!(text = XtMalloc ((unsigned) (len + 1))))
- {
- fclose (fp);
- return FALSE;
- }
- if (fread (text, sizeof (char), len, fp) != (size_t) len)
- {
- }
- fclose (fp);
-
- text[len] = 0;
- XmTextSetString (textWidget, text);
- // m_textPosition = len;
- XtFree (text);
- m_modified = FALSE;
- return TRUE;
+ long len = statb.st_size;
+ char *text;
+ if (!(text = XtMalloc ((unsigned) (len + 1))))
+ {
+ fclose (fp);
+ return FALSE;
+ }
+ if (fread (text, sizeof (char), len, fp) != (size_t) len)
+ {
+ }
+ fclose (fp);
+
+ text[len] = 0;
+ XmTextSetString (textWidget, text);
+ // m_textPosition = len;
+ XtFree (text);
+ m_modified = FALSE;
+ return TRUE;
}
}
if (theFile == "")
return FALSE;
m_fileName = theFile;
-
- Widget textWidget = (Widget) m_mainWidget;
- FILE *fp;
-
- if (!(fp = fopen ((char*) (const char*) theFile, "w")))
+
+ Widget textWidget = (Widget) m_mainWidget;
+ FILE *fp;
+
+ if (!(fp = fopen ((char*) (const char*) theFile, "w")))
{
- return FALSE;
+ return FALSE;
}
- else
+ else
{
- char *text = XmTextGetString (textWidget);
- long len = XmTextGetLastPosition (textWidget);
-
- if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
- {
- // Did not write whole file
- }
- // Make sure newline terminates the file
- if (text[len - 1] != '\n')
- fputc ('\n', fp);
-
- fclose (fp);
- XtFree (text);
- m_modified = FALSE;
- return TRUE;
+ char *text = XmTextGetString (textWidget);
+ long len = XmTextGetLastPosition (textWidget);
+
+ if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
+ {
+ // Did not write whole file
+ }
+ // Make sure newline terminates the file
+ if (text[len - 1] != '\n')
+ fputc ('\n', fp);
+
+ fclose (fp);
+ XtFree (text);
+ m_modified = FALSE;
+ return TRUE;
}
}
char *s = XmTextGetString ((Widget) m_mainWidget);
if (s)
{
- long i = 0;
- int currentLine = 0;
- bool finished = FALSE;
- while (!finished)
- {
- int ch = s[i];
- if (ch == '\n')
- {
- currentLine++;
- i++;
- }
- else if (ch == 0)
- {
- finished = TRUE;
- }
- else
- i++;
- }
-
- XtFree (s);
- return currentLine;
+ long i = 0;
+ int currentLine = 0;
+ bool finished = FALSE;
+ while (!finished)
+ {
+ int ch = s[i];
+ if (ch == '\n')
+ {
+ currentLine++;
+ i++;
+ }
+ else if (ch == 0)
+ {
+ finished = TRUE;
+ }
+ else
+ i++;
+ }
+
+ XtFree (s);
+ return currentLine;
}
return 0;
}
long wxTextCtrl::XYToPosition(long x, long y) const
{
/* It seems, that there is a bug in some versions of the Motif library,
- so the original wxWin-Code doesn't work. */
-/*
- Widget textWidget = (Widget) handle;
- return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y);
-*/
+ so the original wxWin-Code doesn't work. */
+ /*
+ Widget textWidget = (Widget) handle;
+ return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y);
+ */
/* Now a little workaround: */
long r=0;
for (int i=0; i<y; i++) r+=(GetLineLength(i)+1);
{
// HIDEOUSLY inefficient, but we have no choice.
char *s = XmTextGetString ((Widget) m_mainWidget);
-
+
if (s)
{
wxString buf("");
long i;
int currentLine = 0;
for (i = 0; currentLine != lineNo && s[i]; i++ )
- if (s[i] == '\n')
- currentLine++;
- // Now get the text
- int j;
- for (j = 0; s[i] && s[i] != '\n'; i++, j++ )
- buf += s[i];
-
- XtFree(s);
- return buf;
- }
- else
- return wxEmptyString;
+ if (s[i] == '\n')
+ currentLine++;
+ // Now get the text
+ int j;
+ for (j = 0; s[i] && s[i] != '\n'; i++, j++ )
+ buf += s[i];
+
+ XtFree(s);
+ return buf;
+ }
+ else
+ return wxEmptyString;
}
/*
- * Text item
- */
-
+* Text item
+*/
+
void wxTextCtrl::Command(wxCommandEvent & event)
{
SetValue (event.GetString());
#ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow(int c)
{
- // Make sure there is a holding area
- if ( allocate()==EOF )
- {
- wxError("Streambuf allocation failed","Internal error");
- return EOF;
- }
-
- // Verify that there are no characters in get area
- if ( gptr() && gptr() < egptr() )
- {
- wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
- return EOF;
- }
-
- // Reset get area
- setg(0,0,0);
-
- // Make sure there is a put area
- if ( ! pptr() )
- {
-/* This doesn't seem to be fatal so comment out error message */
-// wxError("Put area not opened","Internal error");
- setp( base(), base() );
- }
-
- // Determine how many characters have been inserted but no consumed
- int plen = pptr() - pbase();
-
- // Now Jerry relies on the fact that the buffer is at least 2 chars
- // long, but the holding area "may be as small as 1" ???
- // And we need an additional \0, so let's keep this inefficient but
- // safe copy.
-
- // If c!=EOF, it is a character that must also be comsumed
- int xtra = c==EOF? 0 : 1;
-
- // Write temporary C-string to wxTextWindow
- {
- char *txt = new char[plen+xtra+1];
- memcpy(txt, pbase(), plen);
- txt[plen] = (char)c; // append c
- txt[plen+xtra] = '\0'; // append '\0' or overwrite c
- // If the put area already contained \0, output will be truncated there
- WriteText(txt);
- delete[] txt;
- }
-
- // Reset put area
- setp(pbase(), epptr());
-
+ // Make sure there is a holding area
+ if ( allocate()==EOF )
+ {
+ wxError("Streambuf allocation failed","Internal error");
+ return EOF;
+ }
+
+ // Verify that there are no characters in get area
+ if ( gptr() && gptr() < egptr() )
+ {
+ wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
+ return EOF;
+ }
+
+ // Reset get area
+ setg(0,0,0);
+
+ // Make sure there is a put area
+ if ( ! pptr() )
+ {
+ /* This doesn't seem to be fatal so comment out error message */
+ // wxError("Put area not opened","Internal error");
+ setp( base(), base() );
+ }
+
+ // Determine how many characters have been inserted but no consumed
+ int plen = pptr() - pbase();
+
+ // Now Jerry relies on the fact that the buffer is at least 2 chars
+ // long, but the holding area "may be as small as 1" ???
+ // And we need an additional \0, so let's keep this inefficient but
+ // safe copy.
+
+ // If c!=EOF, it is a character that must also be comsumed
+ int xtra = c==EOF? 0 : 1;
+
+ // Write temporary C-string to wxTextWindow
+ {
+ char *txt = new char[plen+xtra+1];
+ memcpy(txt, pbase(), plen);
+ txt[plen] = (char)c; // append c
+ txt[plen+xtra] = '\0'; // append '\0' or overwrite c
+ // If the put area already contained \0, output will be truncated there
+ WriteText(txt);
+ delete[] txt;
+ }
+
+ // Reset put area
+ setp(pbase(), epptr());
+
#if defined(__WATCOMC__)
- return __NOT_EOF;
+ return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?)
- return zapeof(c);
+ return zapeof(c);
#else
- return c!=EOF ? c : 0; // this should make everybody happy
+ return c!=EOF ? c : 0; // this should make everybody happy
#endif
}
//=========================================================================
int wxTextCtrl::sync()
{
- // Verify that there are no characters in get area
- if ( gptr() && gptr() < egptr() )
- {
- wxError("Who's trespassing my get area?","Internal error");
- return EOF;
- }
-
- if ( pptr() && pptr() > pbase() ) return overflow(EOF);
-
- return 0;
-/* OLD CODE
- int len = pptr() - pbase();
- char *txt = new char[len+1];
- strncpy(txt, pbase(), len);
- txt[len] = '\0';
- (*this) << txt;
- setp(pbase(), epptr());
- delete[] txt;
- return 0;
-*/
+ // Verify that there are no characters in get area
+ if ( gptr() && gptr() < egptr() )
+ {
+ wxError("Who's trespassing my get area?","Internal error");
+ return EOF;
+ }
+
+ if ( pptr() && pptr() > pbase() ) return overflow(EOF);
+
+ return 0;
+ /* OLD CODE
+ int len = pptr() - pbase();
+ char *txt = new char[len+1];
+ strncpy(txt, pbase(), len);
+ txt[len] = '\0';
+ (*this) << txt;
+ setp(pbase(), epptr());
+ delete[] txt;
+ return 0;
+ */
}
//=========================================================================
//=========================================================================
int wxTextCtrl::underflow()
{
- return EOF;
+ return EOF;
}
#endif
wxTextCtrl& wxTextCtrl::operator<<(const char c)
{
char buf[2];
-
+
buf[0] = c;
buf[1] = 0;
WriteText(buf);
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
- // Indicates that we should generate a normal command, because
- // we're letting default behaviour happen (otherwise it's vetoed
- // by virtue of overriding OnChar)
- m_processedDefault = TRUE;
-
- if (m_tempCallbackStruct)
- {
- XmTextVerifyCallbackStruct *textStruct =
- (XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
- textStruct->doit = True;
- if (isascii(event.m_keyCode) && (textStruct->text->length == 1))
+ // Indicates that we should generate a normal command, because
+ // we're letting default behaviour happen (otherwise it's vetoed
+ // by virtue of overriding OnChar)
+ m_processedDefault = TRUE;
+
+ if (m_tempCallbackStruct)
{
- textStruct->text->ptr[0] = ((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
+ XmTextVerifyCallbackStruct *textStruct =
+ (XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
+ textStruct->doit = True;
+ if (isascii(event.m_keyCode) && (textStruct->text->length == 1))
+ {
+ textStruct->text->ptr[0] = ((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
+ }
}
- }
}
void wxTextCtrl::ChangeFont(bool keepOriginalSize)
void wxTextCtrl::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
-
+
/* TODO: should scrollbars be affected? Should probably have separate
- * function to change them (by default, taken from wxSystemSettings)
- */
+ * function to change them (by default, taken from wxSystemSettings)
+ */
if (m_windowStyle & wxTE_MULTILINE)
{
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
-
+
XtVaGetValues (parent,
- XmNhorizontalScrollBar, &hsb,
- XmNverticalScrollBar, &vsb,
- NULL);
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
if (hsb)
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
if (vsb)
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
-
+
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
}
}
void wxTextCtrl::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
-
+
if (m_windowStyle & wxTE_MULTILINE)
{
Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb;
-
+
XtVaGetValues (parent,
- XmNhorizontalScrollBar, &hsb,
- XmNverticalScrollBar, &vsb,
- NULL);
-
- /* TODO: should scrollbars be affected? Should probably have separate
- * function to change them (by default, taken from wxSystemSettings)
- if (hsb)
+ XmNhorizontalScrollBar, &hsb,
+ XmNverticalScrollBar, &vsb,
+ NULL);
+
+ /* TODO: should scrollbars be affected? Should probably have separate
+ * function to change them (by default, taken from wxSystemSettings)
+ if (hsb)
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
- if (vsb)
+ if (vsb)
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
- */
+ */
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
}
}
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)
{
- if (!wxGetWindowFromTable(w))
- // Widget has been deleted!
- return;
-
- wxTextCtrl *tw = (wxTextCtrl *) clientData;
- tw->SetModified(TRUE);
+ if (!wxGetWindowFromTable(w))
+ // Widget has been deleted!
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ tw->SetModified(TRUE);
}
static void
{
wxTextCtrl *tw = (wxTextCtrl *) clientData;
tw->m_processedDefault = FALSE;
-
+
// First, do some stuff if it's a password control.
// (What does this do exactly?)
-
+
if (tw->GetWindowStyleFlag() & wxTE_PASSWORD)
{
- /* _sm_
- * At least on my system (SunOS 4.1.3 + Motif 1.2), you need to think of
- * every event as a replace event. cbs->text->ptr gives the replacement
- * text, cbs->startPos gives the index of the first char affected by the
- * replace, and cbs->endPos gives the index one more than the last char
- * affected by the replace (startPos == endPos implies an empty range).
- * Hence, a deletion is represented by replacing all input text with a
- * blank string ("", *not* NULL!). A simple insertion that does not
- * overwrite any text has startPos == endPos.
- */
-
+ /* _sm_
+ * At least on my system (SunOS 4.1.3 + Motif 1.2), you need to think of
+ * every event as a replace event. cbs->text->ptr gives the replacement
+ * text, cbs->startPos gives the index of the first char affected by the
+ * replace, and cbs->endPos gives the index one more than the last char
+ * affected by the replace (startPos == endPos implies an empty range).
+ * Hence, a deletion is represented by replacing all input text with a
+ * blank string ("", *not* NULL!). A simple insertion that does not
+ * overwrite any text has startPos == endPos.
+ */
+
if (tw->m_value.IsNull())
{
tw->m_value = cbs->text->ptr;
else
{
char * passwd = (char*) (const char*) tw->m_value; // Set up a more convenient alias.
-
+
int len = passwd ? strlen(passwd) : 0; // Enough room for old text
len += strlen(cbs->text->ptr) + 1; // + new text (if any) + NUL
len -= cbs->endPos - cbs->startPos; // - text from affected region.
-
+
char * newS = new char [len];
char * p = passwd, * dest = newS, * insert = cbs->text->ptr;
-
+
// Copy (old) text from passwd, up to the start posn of the change.
int i;
for (i = 0; i < cbs->startPos; ++i)
*dest++ = *p++;
-
+
// Copy the text to be inserted).
while (*insert)
- *dest++ = *insert++;
-
+ *dest++ = *insert++;
+
// Finally, copy into newS any remaining text from passwd[endPos] on.
for (p = passwd + cbs->endPos; *p; )
*dest++ = *p++;
*dest = 0;
-
+
tw->m_value = newS;
-
+
delete[] newS;
}
-
+
if (cbs->text->length>0)
{
int i;
cbs->text->ptr[i] = 0;
}
}
-
+
// If we're already within an OnChar, return: probably
// a programmatic insertion.
if (tw->m_tempCallbackStruct)
return;
-
+
// Check for a backspace
if (cbs->startPos == (cbs->currInsert - 1))
{
tw->m_tempCallbackStruct = (void*) cbs;
-
+
wxKeyEvent event (wxEVT_CHAR);
event.SetId(tw->GetId());
event.m_keyCode = WXK_DELETE;
event.SetEventObject(tw);
-
+
// Only if wxTextCtrl::OnChar is called
// will this be set to True (and the character
// passed through)
cbs->doit = False;
-
+
tw->GetEventHandler()->ProcessEvent(event);
-
+
tw->m_tempCallbackStruct = NULL;
-
+
if (tw->InSetValue())
return;
-
+
if (tw->m_processedDefault)
{
// Can generate a command
wxCommandEvent commandEvent(wxEVT_COMMAND_TEXT_UPDATED, tw->GetId());
- commandEvent.SetEventObject(tw);
+ commandEvent.SetEventObject(tw);
tw->ProcessCommand(commandEvent);
- }
-
+ }
+
return;
}
-
+
// Pasting operation: let it through without
// calling OnChar
if (cbs->text->length > 1)
return;
-
+
// Something other than text
if (cbs->text->ptr == NULL)
return;
-
+
tw->m_tempCallbackStruct = (void*) cbs;
-
+
wxKeyEvent event (wxEVT_CHAR);
event.SetId(tw->GetId());
event.SetEventObject(tw);
event.m_keyCode = (cbs->text->ptr[0] == 10 ? 13 : cbs->text->ptr[0]);
-
+
// Only if wxTextCtrl::OnChar is called
// will this be set to True (and the character
// passed through)
cbs->doit = False;
-
+
tw->GetEventHandler()->ProcessEvent(event);
-
+
tw->m_tempCallbackStruct = NULL;
-
+
if (tw->InSetValue())
return;
static void
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
{
- if (!wxGetWindowFromTable(w))
- return;
-
- wxTextCtrl *tw = (wxTextCtrl *) clientData;
- wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
- event.SetEventObject(tw);
- tw->GetEventHandler()->ProcessEvent(event);
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
+ event.SetEventObject(tw);
+ tw->GetEventHandler()->ProcessEvent(event);
}
static void
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
{
- if (!wxGetWindowFromTable(w))
- return;
-
- wxTextCtrl *tw = (wxTextCtrl *) clientData;
- wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
- event.SetEventObject(tw);
- tw->GetEventHandler()->ProcessEvent(event);
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
+ event.SetEventObject(tw);
+ tw->GetEventHandler()->ProcessEvent(event);
}
static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
- XmAnyCallbackStruct *ptr)
+ XmAnyCallbackStruct *ptr)
{
- if (!wxGetWindowFromTable(w))
- return;
-
- wxTextCtrl *tw = (wxTextCtrl *) clientData;
- /*
- case XmCR_ACTIVATE:
+ if (!wxGetWindowFromTable(w))
+ return;
+
+ wxTextCtrl *tw = (wxTextCtrl *) clientData;
+ /*
+ case XmCR_ACTIVATE:
type_event = wxEVENT_TYPE_TEXT_ENTER_COMMAND ;
break;
- default:
+ default:
type_event = wxEVENT_TYPE_TEXT_COMMAND ;
break;
- }
- */
-
- if (tw->InSetValue())
- return;
+ }
+ */
- wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
- event.SetId(tw->GetId());
- event.SetEventObject(tw);
- tw->ProcessCommand(event);
+ if (tw->InSetValue())
+ return;
+
+ wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
+ event.SetId(tw->GetId());
+ event.SetEventObject(tw);
+ tw->ProcessCommand(event);
}
bool wxGetHostName(char *buf, int maxSize)
{
#if defined(__SVR4__) && !defined(__HPUX__)
- return (sysinfo (SI_HOSTNAME, buf, maxSize) != -1);
+ return (sysinfo (SI_HOSTNAME, buf, maxSize) != -1);
#else /* BSD Sockets */
- char name[255];
- struct hostent *h;
-
- // Get hostname
- if (gethostname (name, sizeof (name) / sizeof (char) - 1) == -1)
- return FALSE;
- // Get official full name of host
- strncpy (buf
- ,(h = gethostbyname (name)) != NULL ? h->h_name : name
- ,maxSize - 1);
- return TRUE;
+ char name[255];
+ struct hostent *h;
+
+ // Get hostname
+ if (gethostname (name, sizeof (name) / sizeof (char) - 1) == -1)
+ return FALSE;
+ // Get official full name of host
+ strncpy (buf
+ ,(h = gethostbyname (name)) != NULL ? h->h_name : name
+ ,maxSize - 1);
+ return TRUE;
#endif
}
bool wxGetUserId(char *buf, int maxSize)
{
#ifdef VMS
- *buf = '\0'; // return empty string
- return FALSE;
+ *buf = '\0'; // return empty string
+ return FALSE;
#else
- struct passwd *who;
-
- if ((who = getpwuid (getuid ())) != NULL)
+ struct passwd *who;
+
+ if ((who = getpwuid (getuid ())) != NULL)
{
- strncpy (buf, who->pw_name, maxSize - 1);
- return TRUE;
+ strncpy (buf, who->pw_name, maxSize - 1);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
#endif
}
bool wxGetUserName(char *buf, int maxSize)
{
#ifdef VMS
- *buf = '\0'; // return empty string
- return FALSE;
+ *buf = '\0'; // return empty string
+ return FALSE;
#else
- struct passwd *who;
-
- if ((who = getpwuid (getuid ())) != NULL)
+ struct passwd *who;
+
+ if ((who = getpwuid (getuid ())) != NULL)
{
- strncpy (buf, who->pw_gecos, maxSize - 1);
- return TRUE;
+ strncpy (buf, who->pw_gecos, maxSize - 1);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
#endif
}
int wxKill(long pid, int sig)
{
- int unixSignal = 0;
- switch (sig)
- {
+ int unixSignal = 0;
+ switch (sig)
+ {
case wxSIGTERM:
default:
- unixSignal = SIGTERM;
- }
- return kill( (int)pid, unixSignal);
+ unixSignal = SIGTERM;
+ }
+ return kill( (int)pid, unixSignal);
}
//
bool wxShell(const wxString& command)
{
#ifdef VMS
- return(FALSE);
+ return(FALSE);
#else
#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
- pid_t pid = vfork ();
+ pid_t pid = vfork ();
#else
- pid_t pid = fork ();
+ pid_t pid = fork ();
#endif
- switch( pid ) {
+ switch( pid ) {
case -1: /* error */
- return(FALSE);
+ return(FALSE);
case 0: /* child */
- // Generic X windows terminal window
- if (command != "")
- execlp("xterm", "-e", (char *) (const char*) command, NULL);
- else
- execlp("xterm", NULL);
- _exit(127);
- }
- return TRUE;
+ // Generic X windows terminal window
+ if (command != "")
+ execlp("xterm", "-e", (char *) (const char*) command, NULL);
+ else
+ execlp("xterm", NULL);
+ _exit(127);
+ }
+ return TRUE;
#endif
- // End VMS
+ // End VMS
}
// Get free memory in bytes, or -1 if cannot determine amount (e.g. on UNIX)
void wxSleep(int nSecs)
{
- sleep(nSecs);
+ sleep(nSecs);
}
// Consume all events until no more left
void wxFlushEvents()
{
- Display *display = (Display*) wxGetDisplay();
-
- XSync (display, FALSE);
- XEvent event;
- // XtAppPending returns availability of events AND timers/inputs, which
- // are processed via callbacks, so XtAppNextEvent will not return if
- // there are no events. So added '& XtIMXEvent' - Sergey.
- while (XtAppPending ((XtAppContext) wxTheApp->GetAppContext()) & XtIMXEvent)
+ Display *display = (Display*) wxGetDisplay();
+
+ XSync (display, FALSE);
+ XEvent event;
+ // XtAppPending returns availability of events AND timers/inputs, which
+ // are processed via callbacks, so XtAppNextEvent will not return if
+ // there are no events. So added '& XtIMXEvent' - Sergey.
+ while (XtAppPending ((XtAppContext) wxTheApp->GetAppContext()) & XtIMXEvent)
{
- XFlush (XtDisplay ((Widget) wxTheApp->GetTopLevelWidget()));
- // Jan Lessner: works better when events are non-X events
- XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMXEvent);
+ XFlush (XtDisplay ((Widget) wxTheApp->GetTopLevelWidget()));
+ // Jan Lessner: works better when events are non-X events
+ XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMXEvent);
}
}
// Output a debug message, in a system dependent fashion.
void wxDebugMsg(const char *fmt ...)
{
- va_list ap;
- char buffer[BUFSIZ];
-
- if (!wxTheApp->GetWantDebugOutput())
- return ;
-
- va_start (ap, fmt);
-
- vsprintf (buffer, fmt, ap);
- cerr << buffer;
-
- va_end (ap);
+ va_list ap;
+ char buffer[BUFSIZ];
+
+ if (!wxTheApp->GetWantDebugOutput())
+ return ;
+
+ va_start (ap, fmt);
+
+ vsprintf (buffer, fmt, ap);
+ cerr << buffer;
+
+ va_end (ap);
}
// Non-fatal error: pop up message box and (possibly) continue
void wxError(const wxString& msg, const wxString& title)
{
- cerr << (const char*) title << ": " << (const char*) msg << "\n";
+ cerr << (const char*) title << ": " << (const char*) msg << "\n";
}
// Fatal error: pop up message box and abort
void wxFatalError(const wxString& msg, const wxString& title)
{
- cerr << (const char*) title << ": " << (const char*) msg << "\n";
- exit (1);
+ cerr << (const char*) title << ": " << (const char*) msg << "\n";
+ exit (1);
}
// Emit a beeeeeep
void wxBell()
{
- // Use current setting for the bell
- XBell ((Display*) wxGetDisplay(), 0);
+ // Use current setting for the bell
+ XBell ((Display*) wxGetDisplay(), 0);
}
int wxGetOsVersion(int *majorVsn, int *minorVsn)
{
// TODO
- // This code is WRONG!! Does NOT return the
- // Motif version of the libs but the X protocol
- // version! @@@@@ Fix ME!!!!!!!!!
- Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
- if (majorVsn)
- *majorVsn = ProtocolVersion (display);
- if (minorVsn)
- *minorVsn = ProtocolRevision (display);
- return wxMOTIF_X;
+ // This code is WRONG!! Does NOT return the
+ // Motif version of the libs but the X protocol
+ // version! @@@@@ Fix ME!!!!!!!!!
+ Display *display = XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
+ if (majorVsn)
+ *majorVsn = ProtocolVersion (display);
+ if (minorVsn)
+ *minorVsn = ProtocolRevision (display);
+ return wxMOTIF_X;
}
// Reading and writing resources (eg WIN.INI, .Xdefaults)
static char *GetResourcePath(char *buf, const char *name, bool create = FALSE)
{
- if (create && wxFileExists (name) ) {
- strcpy(buf, name);
- return buf; // Exists so ...
- }
-
- if (*name == '/')
- strcpy(buf, name);
- else {
- // Put in standard place for resource files if not absolute
- strcpy (buf, DEFAULT_XRESOURCE_DIR);
- strcat (buf, "/");
- strcat (buf, (const char*) wxFileNameFromPath (name));
- }
-
- if (create) {
- // Touch the file to create it
- FILE *fd = fopen (buf, "w");
- if (fd) fclose (fd);
- }
- return buf;
+ if (create && wxFileExists (name) ) {
+ strcpy(buf, name);
+ return buf; // Exists so ...
+ }
+
+ if (*name == '/')
+ strcpy(buf, name);
+ else {
+ // Put in standard place for resource files if not absolute
+ strcpy (buf, DEFAULT_XRESOURCE_DIR);
+ strcat (buf, "/");
+ strcat (buf, (const char*) wxFileNameFromPath (name));
+ }
+
+ if (create) {
+ // Touch the file to create it
+ FILE *fd = fopen (buf, "w");
+ if (fd) fclose (fd);
+ }
+ return buf;
}
/*
- * We have a cache for writing different resource files,
- * which will only get flushed when we call wxFlushResources().
- * Build up a list of resource databases waiting to be written.
- *
- */
+* We have a cache for writing different resource files,
+* which will only get flushed when we call wxFlushResources().
+* Build up a list of resource databases waiting to be written.
+*
+*/
wxList wxResourceCache (wxKEY_STRING);
void
wxFlushResources (void)
{
- char nameBuffer[512];
-
- wxNode *node = wxResourceCache.First ();
- while (node)
+ char nameBuffer[512];
+
+ wxNode *node = wxResourceCache.First ();
+ while (node)
{
- const char *file = node->GetKeyString();
- // If file doesn't exist, create it first.
- (void)GetResourcePath(nameBuffer, file, TRUE);
-
- XrmDatabase database = (XrmDatabase) node->Data ();
- XrmPutFileDatabase (database, nameBuffer);
- XrmDestroyDatabase (database);
- wxNode *next = node->Next ();
- delete node;
- node = next;
+ const char *file = node->GetKeyString();
+ // If file doesn't exist, create it first.
+ (void)GetResourcePath(nameBuffer, file, TRUE);
+
+ XrmDatabase database = (XrmDatabase) node->Data ();
+ XrmPutFileDatabase (database, nameBuffer);
+ XrmDestroyDatabase (database);
+ wxNode *next = node->Next ();
+ delete node;
+ node = next;
}
}
bool wxWriteResource(const wxString& section, const wxString& entry, const wxString& value, const wxString& file)
{
- char buffer[500];
-
- (void) GetIniFile (buffer, file);
-
- XrmDatabase database;
- wxNode *node = wxResourceCache.Find (buffer);
- if (node)
- database = (XrmDatabase) node->Data ();
- else
+ char buffer[500];
+
+ (void) GetIniFile (buffer, file);
+
+ XrmDatabase database;
+ wxNode *node = wxResourceCache.Find (buffer);
+ if (node)
+ database = (XrmDatabase) node->Data ();
+ else
{
- database = XrmGetFileDatabase (buffer);
- wxResourceCache.Append (buffer, (wxObject *) database);
+ database = XrmGetFileDatabase (buffer);
+ wxResourceCache.Append (buffer, (wxObject *) database);
}
-
- char resName[300];
- strcpy (resName, (const char*) section);
- strcat (resName, ".");
- strcat (resName, (const char*) entry);
-
- XrmPutStringResource (&database, resName, value);
- return TRUE;
+
+ char resName[300];
+ strcpy (resName, (const char*) section);
+ strcat (resName, ".");
+ strcat (resName, (const char*) entry);
+
+ XrmPutStringResource (&database, resName, value);
+ return TRUE;
}
bool wxWriteResource(const wxString& section, const wxString& entry, float value, const wxString& file)
{
- char buf[50];
- sprintf(buf, "%.4f", value);
- return wxWriteResource(section, entry, buf, file);
+ char buf[50];
+ sprintf(buf, "%.4f", value);
+ return wxWriteResource(section, entry, buf, file);
}
bool wxWriteResource(const wxString& section, const wxString& entry, long value, const wxString& file)
{
- char buf[50];
- sprintf(buf, "%ld", value);
- return wxWriteResource(section, entry, buf, file);
+ char buf[50];
+ sprintf(buf, "%ld", value);
+ return wxWriteResource(section, entry, buf, file);
}
bool wxWriteResource(const wxString& section, const wxString& entry, int value, const wxString& file)
{
- char buf[50];
- sprintf(buf, "%d", value);
- return wxWriteResource(section, entry, buf, file);
+ char buf[50];
+ sprintf(buf, "%d", value);
+ return wxWriteResource(section, entry, buf, file);
}
bool wxGetResource(const wxString& section, const wxString& entry, char **value, const wxString& file)
{
- if (!wxResourceDatabase)
+ if (!wxResourceDatabase)
{
- Display *display = (Display*) wxGetDisplay();
- wxXMergeDatabases (wxTheApp, display);
+ Display *display = (Display*) wxGetDisplay();
+ wxXMergeDatabases (wxTheApp, display);
}
-
- XrmDatabase database;
-
- if (file != "")
- {
- char buffer[500];
-
- // Is this right? Trying to get it to look in the user's
- // home directory instead of current directory -- JACS
- (void) GetIniFile (buffer, file);
-
- wxNode *node = wxResourceCache.Find (buffer);
- if (node)
- database = (XrmDatabase) node->Data ();
- else
- {
- database = XrmGetFileDatabase (buffer);
- wxResourceCache.Append (buffer, (wxObject *) database);
- }
- }
- else
- database = wxResourceDatabase;
-
- XrmValue xvalue;
- char *str_type[20];
- char buf[150];
- strcpy (buf, section);
- strcat (buf, ".");
- strcat (buf, entry);
-
- Bool success = XrmGetResource (database, buf, "*", str_type,
- &xvalue);
- // Try different combinations of upper/lower case, just in case...
- if (!success)
+
+ XrmDatabase database;
+
+ if (file != "")
{
- buf[0] = (isupper (buf[0]) ? tolower (buf[0]) : toupper (buf[0]));
- success = XrmGetResource (database, buf, "*", str_type,
- &xvalue);
+ char buffer[500];
+
+ // Is this right? Trying to get it to look in the user's
+ // home directory instead of current directory -- JACS
+ (void) GetIniFile (buffer, file);
+
+ wxNode *node = wxResourceCache.Find (buffer);
+ if (node)
+ database = (XrmDatabase) node->Data ();
+ else
+ {
+ database = XrmGetFileDatabase (buffer);
+ wxResourceCache.Append (buffer, (wxObject *) database);
+ }
}
- if (success)
+ else
+ database = wxResourceDatabase;
+
+ XrmValue xvalue;
+ char *str_type[20];
+ char buf[150];
+ strcpy (buf, section);
+ strcat (buf, ".");
+ strcat (buf, entry);
+
+ Bool success = XrmGetResource (database, buf, "*", str_type,
+ &xvalue);
+ // Try different combinations of upper/lower case, just in case...
+ if (!success)
{
- if (*value)
- delete[] *value;
-
- *value = new char[xvalue.size + 1];
- strncpy (*value, xvalue.addr, (int) xvalue.size);
- return TRUE;
+ buf[0] = (isupper (buf[0]) ? tolower (buf[0]) : toupper (buf[0]));
+ success = XrmGetResource (database, buf, "*", str_type,
+ &xvalue);
+ }
+ if (success)
+ {
+ if (*value)
+ delete[] *value;
+
+ *value = new char[xvalue.size + 1];
+ strncpy (*value, xvalue.addr, (int) xvalue.size);
+ return TRUE;
}
- return FALSE;
+ return FALSE;
}
bool wxGetResource(const wxString& section, const wxString& entry, float *value, const wxString& file)
{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- *value = (float)strtod(s, NULL);
- delete[] s;
- return TRUE;
- }
- else return FALSE;
+ char *s = NULL;
+ bool succ = wxGetResource(section, entry, (char **)&s, file);
+ if (succ)
+ {
+ *value = (float)strtod(s, NULL);
+ delete[] s;
+ return TRUE;
+ }
+ else return FALSE;
}
bool wxGetResource(const wxString& section, const wxString& entry, long *value, const wxString& file)
{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- *value = strtol(s, NULL, 10);
- delete[] s;
- return TRUE;
- }
- else return FALSE;
+ char *s = NULL;
+ bool succ = wxGetResource(section, entry, (char **)&s, file);
+ if (succ)
+ {
+ *value = strtol(s, NULL, 10);
+ delete[] s;
+ return TRUE;
+ }
+ else return FALSE;
}
bool wxGetResource(const wxString& section, const wxString& entry, int *value, const wxString& file)
{
- char *s = NULL;
- bool succ = wxGetResource(section, entry, (char **)&s, file);
- if (succ)
- {
- // Handle True, False here
- // True, Yes, Enables, Set or Activated
- if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
- *value = TRUE;
- // False, No, Disabled, Reset, Cleared, Deactivated
- else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C')
- *value = FALSE;
- // Handle as Integer
- else
- *value = (int) strtol (s, NULL, 10);
+ char *s = NULL;
+ bool succ = wxGetResource(section, entry, (char **)&s, file);
+ if (succ)
+ {
+ // Handle True, False here
+ // True, Yes, Enables, Set or Activated
+ if (*s == 'T' || *s == 'Y' || *s == 'E' || *s == 'S' || *s == 'A')
+ *value = TRUE;
+ // False, No, Disabled, Reset, Cleared, Deactivated
+ else if (*s == 'F' || *s == 'N' || *s == 'D' || *s == 'R' || *s == 'C')
+ *value = FALSE;
+ // Handle as Integer
+ else
+ *value = (int) strtol (s, NULL, 10);
delete[] s;
return TRUE;
- }
- else
- return FALSE;
+ }
+ else
+ return FALSE;
}
void wxXMergeDatabases (wxApp * theApp, Display * display)
{
- XrmDatabase homeDB, serverDB, applicationDB;
- char filenamebuf[1024];
-
- char *filename = &filenamebuf[0];
- char *environment;
- wxString classname = theApp->GetClassName();
- char name[256];
- (void) strcpy (name, "/usr/lib/X11/app-defaults/");
- (void) strcat (name, (const char*) classname);
-
- /* Get application defaults file, if any */
- applicationDB = XrmGetFileDatabase (name);
- (void) XrmMergeDatabases (applicationDB, &wxResourceDatabase);
-
- /* Merge server defaults, created by xrdb, loaded as a property of the root
- * window when the server initializes and loaded into the display
- * structure on XOpenDisplay;
- * if not defined, use .Xdefaults
- */
-
- if (XResourceManagerString (display) != NULL)
+ XrmDatabase homeDB, serverDB, applicationDB;
+ char filenamebuf[1024];
+
+ char *filename = &filenamebuf[0];
+ char *environment;
+ wxString classname = theApp->GetClassName();
+ char name[256];
+ (void) strcpy (name, "/usr/lib/X11/app-defaults/");
+ (void) strcat (name, (const char*) classname);
+
+ /* Get application defaults file, if any */
+ applicationDB = XrmGetFileDatabase (name);
+ (void) XrmMergeDatabases (applicationDB, &wxResourceDatabase);
+
+ /* Merge server defaults, created by xrdb, loaded as a property of the root
+ * window when the server initializes and loaded into the display
+ * structure on XOpenDisplay;
+ * if not defined, use .Xdefaults
+ */
+
+ if (XResourceManagerString (display) != NULL)
{
- serverDB = XrmGetStringDatabase (XResourceManagerString (display));
+ serverDB = XrmGetStringDatabase (XResourceManagerString (display));
}
- else
+ else
{
- (void) GetIniFile (filename, NULL);
- serverDB = XrmGetFileDatabase (filename);
+ (void) GetIniFile (filename, NULL);
+ serverDB = XrmGetFileDatabase (filename);
}
- XrmMergeDatabases (serverDB, &wxResourceDatabase);
-
- /* Open XENVIRONMENT file, or if not defined, the .Xdefaults,
- * and merge into existing database
- */
-
- if ((environment = getenv ("XENVIRONMENT")) == NULL)
+ XrmMergeDatabases (serverDB, &wxResourceDatabase);
+
+ /* Open XENVIRONMENT file, or if not defined, the .Xdefaults,
+ * and merge into existing database
+ */
+
+ if ((environment = getenv ("XENVIRONMENT")) == NULL)
{
- size_t len;
- environment = GetIniFile (filename, NULL);
- len = strlen (environment);
+ size_t len;
+ environment = GetIniFile (filename, NULL);
+ len = strlen (environment);
#if defined(__SVR4__) && !defined(__HPUX__)
- (void) sysinfo (SI_HOSTNAME, environment + len, 1024 - len);
+ (void) sysinfo (SI_HOSTNAME, environment + len, 1024 - len);
#else
- (void) gethostname (environment + len, 1024 - len);
+ (void) gethostname (environment + len, 1024 - len);
#endif
}
- homeDB = XrmGetFileDatabase (environment);
- XrmMergeDatabases (homeDB, &wxResourceDatabase);
+ homeDB = XrmGetFileDatabase (environment);
+ XrmMergeDatabases (homeDB, &wxResourceDatabase);
}
#if 0
/*
- * Not yet used but may be useful.
- *
- */
+* Not yet used but may be useful.
+*
+*/
void
wxSetDefaultResources (const Widget w, const char **resourceSpec, const char *name)
{
- int i;
- Display *dpy = XtDisplay (w); // Retrieve the display pointer
-
- XrmDatabase rdb = NULL; // A resource data base
-
- // Create an empty resource database
- rdb = XrmGetStringDatabase ("");
-
- // Add the Component resources, prepending the name of the component
-
- i = 0;
- while (resourceSpec[i] != NULL)
+ int i;
+ Display *dpy = XtDisplay (w); // Retrieve the display pointer
+
+ XrmDatabase rdb = NULL; // A resource data base
+
+ // Create an empty resource database
+ rdb = XrmGetStringDatabase ("");
+
+ // Add the Component resources, prepending the name of the component
+
+ i = 0;
+ while (resourceSpec[i] != NULL)
{
- char buf[1000];
-
- sprintf (buf, "*%s%s", name, resourceSpec[i++]);
- XrmPutLineResource (&rdb, buf);
+ char buf[1000];
+
+ sprintf (buf, "*%s%s", name, resourceSpec[i++]);
+ XrmPutLineResource (&rdb, buf);
}
-
- // Merge them into the Xt database, with lowest precendence
-
- if (rdb)
+
+ // Merge them into the Xt database, with lowest precendence
+
+ if (rdb)
{
#if (XlibSpecificationRelease>=5)
- XrmDatabase db = XtDatabase (dpy);
- XrmCombineDatabase (rdb, &db, FALSE);
+ XrmDatabase db = XtDatabase (dpy);
+ XrmCombineDatabase (rdb, &db, FALSE);
#else
- XrmMergeDatabases (dpy->db, &rdb);
- dpy->db = rdb;
+ XrmMergeDatabases (dpy->db, &rdb);
+ dpy->db = rdb;
#endif
}
}
#endif
- // 0
+// 0
#endif // wxUSE_RESOURCES
static void
wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
{
- Display *display = (Display*) win->GetXDisplay();
-
- Window xwin = (Window) win->GetXWindow();
- XSetWindowAttributes attrs;
-
- if (cursor)
+ Display *display = (Display*) win->GetXDisplay();
+
+ Window xwin = (Window) win->GetXWindow();
+ XSetWindowAttributes attrs;
+
+ if (cursor)
{
- attrs.cursor = (Cursor) cursor->GetXCursor(display);
+ attrs.cursor = (Cursor) cursor->GetXCursor(display);
}
- else
+ else
{
- // Restore old cursor
- if (win->GetCursor()->Ok())
- attrs.cursor = (Cursor) win->GetCursor()->GetXCursor(display);
- else
- attrs.cursor = None;
+ // Restore old cursor
+ if (win->GetCursor()->Ok())
+ attrs.cursor = (Cursor) win->GetCursor()->GetXCursor(display);
+ else
+ attrs.cursor = None;
}
- if (xwin)
- XChangeWindowAttributes (display, xwin, CWCursor, &attrs);
-
- XFlush (display);
-
- for(wxNode *node = win->GetChildren().First (); node; node = node->Next())
- {
+ if (xwin)
+ XChangeWindowAttributes (display, xwin, CWCursor, &attrs);
+
+ XFlush (display);
+
+ for(wxNode *node = win->GetChildren().First (); node; node = node->Next())
+ {
wxWindow *child = (wxWindow *) node->Data ();
- wxXSetBusyCursor (child, cursor);
- }
+ wxXSetBusyCursor (child, cursor);
+ }
}
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(wxCursor *cursor)
{
- wxBusyCursorCount++;
- if (wxBusyCursorCount == 1)
- {
- for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
+ wxBusyCursorCount++;
+ if (wxBusyCursorCount == 1)
{
- wxWindow *win = (wxWindow *) node->Data ();
- wxXSetBusyCursor (win, cursor);
+ for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxXSetBusyCursor (win, cursor);
+ }
}
- }
}
// Restore cursor to normal
void wxEndBusyCursor()
{
- if (wxBusyCursorCount == 0)
- return;
-
- wxBusyCursorCount--;
- if (wxBusyCursorCount == 0)
- {
- for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
- {
- wxWindow *win = (wxWindow *) node->Data ();
- wxXSetBusyCursor (win, NULL);
- }
- }
+ if (wxBusyCursorCount == 0)
+ return;
+
+ wxBusyCursorCount--;
+ if (wxBusyCursorCount == 0)
+ {
+ for(wxNode *node = wxTopLevelWindows.First (); node; node = node->Next())
+ {
+ wxWindow *win = (wxWindow *) node->Data ();
+ wxXSetBusyCursor (win, NULL);
+ }
+ }
}
// TRUE if we're between the above two calls
bool wxIsBusy()
{
- return (wxBusyCursorCount > 0);
+ return (wxBusyCursorCount > 0);
}
const char* wxGetHomeDir( wxString *home )
{
- *home = wxGetUserHome( wxString() );
- if (home->IsNull()) *home = "/";
- return *home;
+ *home = wxGetUserHome( wxString() );
+ if (home->IsNull()) *home = "/";
+ return *home;
};
char *wxGetUserHome (const wxString& user)
{
#ifdef VMS
- return(NULL);
+ return(NULL);
#else
- struct passwd *who = NULL;
-
- if (user == "") {
- register char *ptr;
-
- if ((ptr = getenv("HOME")) != NULL)
- return ptr;
- if ((ptr = getenv("USER")) != NULL ||
- (ptr = getenv("LOGNAME")) != NULL)
- {
- who = getpwnam( ptr );
- }
- // We now make sure the the user exists!
- if (who == NULL)
- who = getpwuid( getuid() );
- } else
- who = getpwnam ((const char*) user);
-
- return who ? who->pw_dir : (char*) NULL;
+ struct passwd *who = NULL;
+
+ if (user == "") {
+ register char *ptr;
+
+ if ((ptr = getenv("HOME")) != NULL)
+ return ptr;
+ if ((ptr = getenv("USER")) != NULL ||
+ (ptr = getenv("LOGNAME")) != NULL)
+ {
+ who = getpwnam( ptr );
+ }
+ // We now make sure the the user exists!
+ if (who == NULL)
+ who = getpwuid( getuid() );
+ } else
+ who = getpwnam ((const char*) user);
+
+ return who ? who->pw_dir : (char*) NULL;
#endif
- // ifdef VMS
+ // ifdef VMS
}
// Check whether this window wants to process messages, e.g. Stop button
// in long calculations.
bool wxCheckForInterrupt(wxWindow *wnd)
{
- if(wnd){
- Display *dpy=(Display*) wnd->GetXDisplay();
- Window win=(Window) wnd->GetXWindow();
- XEvent event;
- XFlush(dpy);
- if(wnd->GetMainWidget()){
- XmUpdateDisplay((Widget)(wnd->GetMainWidget()));
- }
- while(XCheckMaskEvent(dpy,
- ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
- PointerMotionMask|KeyPressMask|KeyReleaseMask,
- &event)){
- if(event.xany.window==win)
- XtDispatchEvent(&event);
- // else
- // XBell(dpy,50);
- }
- return TRUE;//*** temporary?
- }
- else{
- wxMessageBox("wnd==NULL !!!");
- return FALSE;//*** temporary?
- }
+ if(wnd){
+ Display *dpy=(Display*) wnd->GetXDisplay();
+ Window win=(Window) wnd->GetXWindow();
+ XEvent event;
+ XFlush(dpy);
+ if(wnd->GetMainWidget()){
+ XmUpdateDisplay((Widget)(wnd->GetMainWidget()));
+ }
+ while(XCheckMaskEvent(dpy,
+ ButtonPressMask|ButtonReleaseMask|ButtonMotionMask|
+ PointerMotionMask|KeyPressMask|KeyReleaseMask,
+ &event)){
+ if(event.xany.window==win)
+ XtDispatchEvent(&event);
+ // else
+ // XBell(dpy,50);
+ }
+ return TRUE;//*** temporary?
+ }
+ else{
+ wxMessageBox("wnd==NULL !!!");
+ return FALSE;//*** temporary?
+ }
}
void wxGetMousePosition( int* x, int* y )
XMotionEvent xev;
Window root, child;
XQueryPointer((Display*) wxGetDisplay(),
- DefaultRootWindow((Display*) wxGetDisplay()), &root, &child,
- &(xev.x_root), &(xev.y_root),
- &(xev.x), &(xev.y),
- &(xev.state));
+ DefaultRootWindow((Display*) wxGetDisplay()), &root, &child,
+ &(xev.x_root), &(xev.y_root),
+ &(xev.x), &(xev.y),
+ &(xev.state));
*x = xev.x_root;
*y = xev.y_root;
};
bool wxColourDisplay()
{
Display *dpy = (Display*) wxGetDisplay();
-
+
if (DefaultDepth (dpy, DefaultScreen (dpy)) < 2)
- return FALSE;
+ return FALSE;
else
- return TRUE;
+ return TRUE;
}
// Returns depth of screen
// Get size of display
void wxDisplaySize(int *width, int *height)
{
- Display *dpy = (Display*) wxGetDisplay();
-
- *width = DisplayWidth (dpy, DefaultScreen (dpy));
- *height = DisplayHeight (dpy, DefaultScreen (dpy));
+ Display *dpy = (Display*) wxGetDisplay();
+
+ *width = DisplayWidth (dpy, DefaultScreen (dpy));
+ *height = DisplayHeight (dpy, DefaultScreen (dpy));
}
/* Configurable display in Motif */
WXDisplay *wxGetDisplay()
{
- if (gs_currentDisplay)
- return gs_currentDisplay;
-
- if (wxTheApp && wxTheApp->GetTopLevelWidget())
- return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
- else if (wxTheApp)
- return wxTheApp->GetInitialDisplay();
- else
- return (WXDisplay*) NULL;
+ if (gs_currentDisplay)
+ return gs_currentDisplay;
+
+ if (wxTheApp && wxTheApp->GetTopLevelWidget())
+ return XtDisplay ((Widget) wxTheApp->GetTopLevelWidget());
+ else if (wxTheApp)
+ return wxTheApp->GetInitialDisplay();
+ else
+ return (WXDisplay*) NULL;
}
bool wxSetDisplay(const wxString& display_name)
{
- gs_displayName = display_name;
-
- if (display_name.IsNull() || display_name.IsEmpty())
- {
- gs_currentDisplay = NULL;
- return TRUE;
- }
- else
- {
- Cardinal argc = 0;
-
- Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
- (const char*) display_name,
- (const char*) wxTheApp->GetAppName(),
- (const char*) wxTheApp->GetClassName(),
- NULL,
+ gs_displayName = display_name;
+
+ if (display_name.IsNull() || display_name.IsEmpty())
+ {
+ gs_currentDisplay = NULL;
+ return TRUE;
+ }
+ else
+ {
+ Cardinal argc = 0;
+
+ Display *display = XtOpenDisplay((XtAppContext) wxTheApp->GetAppContext(),
+ (const char*) display_name,
+ (const char*) wxTheApp->GetAppName(),
+ (const char*) wxTheApp->GetClassName(),
+ NULL,
# if XtSpecificationRelease < 5
- 0, &argc, NULL);
+ 0, &argc, NULL);
# else
- 0, (int *)&argc, NULL);
+ 0, (int *)&argc, NULL);
# endif
-
- if (display)
- {
- gs_currentDisplay = (WXDisplay*) display;
- return TRUE;
- } else
- return FALSE;
- }
- return FALSE;
+
+ if (display)
+ {
+ gs_currentDisplay = (WXDisplay*) display;
+ return TRUE;
+ } else
+ return FALSE;
+ }
+ return FALSE;
}
wxString wxGetDisplayName()
{
- return gs_displayName;
+ return gs_displayName;
}
// Find the letter corresponding to the mnemonic, for Motif
char wxFindMnemonic (const char *s)
{
- char mnem = 0;
- int len = strlen (s);
- int i;
- for (i = 0; i < len; i++)
+ char mnem = 0;
+ int len = strlen (s);
+ int i;
+ for (i = 0; i < len; i++)
{
- if (s[i] == '&')
- {
- // Carefully handle &&
- if ((i + 1) <= len && s[i + 1] == '&')
- i++;
- else
- {
- mnem = s[i + 1];
- break;
- }
- }
+ if (s[i] == '&')
+ {
+ // Carefully handle &&
+ if ((i + 1) <= len && s[i + 1] == '&')
+ i++;
+ else
+ {
+ mnem = s[i + 1];
+ break;
+ }
+ }
}
- return mnem;
+ return mnem;
}
char * wxFindAccelerator (char *s)
{
-// The accelerator text is after the \t char.
- while (*s && *s != '\t')
+ // The accelerator text is after the \t char.
+ while (*s && *s != '\t')
+ s++;
+ if (*s == '\0')
+ return (NULL);
s++;
- if (*s == '\0')
- return (NULL);
- s++;
-/*
- Now we need to format it as X standard:
-
- input output
-
- F7 --> <Key>F7
- Ctrl+N --> Ctrl<Key>N
- Alt+k --> Meta<Key>k
- Ctrl+Shift+A --> Ctrl Shift<Key>A
-
- */
-
- wxBuffer[0] = '\0';
- char *tmp = copystring (s);
- s = tmp;
- char *p = s;
-
- while (1)
+ /*
+ Now we need to format it as X standard:
+
+ input output
+
+ F7 --> <Key>F7
+ Ctrl+N --> Ctrl<Key>N
+ Alt+k --> Meta<Key>k
+ Ctrl+Shift+A --> Ctrl Shift<Key>A
+
+ */
+
+ wxBuffer[0] = '\0';
+ char *tmp = copystring (s);
+ s = tmp;
+ char *p = s;
+
+ while (1)
{
- while (*p && *p != '+')
- p++;
- if (*p)
- {
- *p = '\0';
- if (wxBuffer[0])
- strcat (wxBuffer, " ");
- if (strcmp (s, "Alt"))
- strcat (wxBuffer, s);
- else
- strcat (wxBuffer, "Meta");
- s = p + 1;
- p = s;
- }
- else
- {
- strcat (wxBuffer, "<Key>");
- strcat (wxBuffer, s);
- break;
- }
+ while (*p && *p != '+')
+ p++;
+ if (*p)
+ {
+ *p = '\0';
+ if (wxBuffer[0])
+ strcat (wxBuffer, " ");
+ if (strcmp (s, "Alt"))
+ strcat (wxBuffer, s);
+ else
+ strcat (wxBuffer, "Meta");
+ s = p + 1;
+ p = s;
+ }
+ else
+ {
+ strcat (wxBuffer, "<Key>");
+ strcat (wxBuffer, s);
+ break;
+ }
}
- delete[]tmp;
- return wxBuffer;
+ delete[]tmp;
+ return wxBuffer;
}
XmString wxFindAcceleratorText (char *s)
{
-// The accelerator text is after the \t char.
- while (*s && *s != '\t')
+ // The accelerator text is after the \t char.
+ while (*s && *s != '\t')
+ s++;
+ if (*s == '\0')
+ return (NULL);
s++;
- if (*s == '\0')
- return (NULL);
- s++;
- XmString text = XmStringCreateSimple (s);
- return text;
+ XmString text = XmStringCreateSimple (s);
+ return text;
}
#include <X11/keysym.h>
int wxCharCodeXToWX(KeySym keySym)
{
- int id;
- switch (keySym) {
+ int id;
+ switch (keySym) {
case XK_Shift_L:
case XK_Shift_R:
- id = WXK_SHIFT; break;
+ id = WXK_SHIFT; break;
case XK_Control_L:
case XK_Control_R:
- id = WXK_CONTROL; break;
+ id = WXK_CONTROL; break;
case XK_BackSpace:
- id = WXK_BACK; break;
+ id = WXK_BACK; break;
case XK_Delete:
- id = WXK_DELETE; break;
+ id = WXK_DELETE; break;
case XK_Clear:
- id = WXK_CLEAR; break;
+ id = WXK_CLEAR; break;
case XK_Tab:
- id = WXK_TAB; break;
+ id = WXK_TAB; break;
case XK_numbersign:
- id = '#'; break;
+ id = '#'; break;
case XK_Return:
- id = WXK_RETURN; break;
+ id = WXK_RETURN; break;
case XK_Escape:
- id = WXK_ESCAPE; break;
+ id = WXK_ESCAPE; break;
case XK_Pause:
case XK_Break:
- id = WXK_PAUSE; break;
+ id = WXK_PAUSE; break;
case XK_Num_Lock:
- id = WXK_NUMLOCK; break;
+ id = WXK_NUMLOCK; break;
case XK_Scroll_Lock:
- id = WXK_SCROLL; break;
-
+ id = WXK_SCROLL; break;
+
case XK_Home:
- id = WXK_HOME; break;
+ id = WXK_HOME; break;
case XK_End:
- id = WXK_END; break;
+ id = WXK_END; break;
case XK_Left:
- id = WXK_LEFT; break;
+ id = WXK_LEFT; break;
case XK_Right:
- id = WXK_RIGHT; break;
+ id = WXK_RIGHT; break;
case XK_Up:
- id = WXK_UP; break;
+ id = WXK_UP; break;
case XK_Down:
- id = WXK_DOWN; break;
+ id = WXK_DOWN; break;
case XK_Next:
- id = WXK_NEXT; break;
+ id = WXK_NEXT; break;
case XK_Prior:
- id = WXK_PRIOR; break;
+ id = WXK_PRIOR; break;
case XK_Menu:
- id = WXK_MENU; break;
+ id = WXK_MENU; break;
case XK_Select:
- id = WXK_SELECT; break;
+ id = WXK_SELECT; break;
case XK_Cancel:
- id = WXK_CANCEL; break;
+ id = WXK_CANCEL; break;
case XK_Print:
- id = WXK_PRINT; break;
+ id = WXK_PRINT; break;
case XK_Execute:
- id = WXK_EXECUTE; break;
+ id = WXK_EXECUTE; break;
case XK_Insert:
- id = WXK_INSERT; break;
+ id = WXK_INSERT; break;
case XK_Help:
- id = WXK_HELP; break;
-
+ id = WXK_HELP; break;
+
case XK_KP_Multiply:
- id = WXK_MULTIPLY; break;
+ id = WXK_MULTIPLY; break;
case XK_KP_Add:
- id = WXK_ADD; break;
+ id = WXK_ADD; break;
case XK_KP_Subtract:
- id = WXK_SUBTRACT; break;
+ id = WXK_SUBTRACT; break;
case XK_KP_Divide:
- id = WXK_DIVIDE; break;
+ id = WXK_DIVIDE; break;
case XK_KP_Decimal:
- id = WXK_DECIMAL; break;
+ id = WXK_DECIMAL; break;
case XK_KP_Equal:
- id = '='; break;
+ id = '='; break;
case XK_KP_Space:
- id = ' '; break;
+ id = ' '; break;
case XK_KP_Tab:
- id = WXK_TAB; break;
+ id = WXK_TAB; break;
case XK_KP_Enter:
- id = WXK_RETURN; break;
+ id = WXK_RETURN; break;
case XK_KP_0:
- id = WXK_NUMPAD0; break;
+ id = WXK_NUMPAD0; break;
case XK_KP_1:
- id = WXK_NUMPAD1; break;
+ id = WXK_NUMPAD1; break;
case XK_KP_2:
- id = WXK_NUMPAD2; break;
+ id = WXK_NUMPAD2; break;
case XK_KP_3:
- id = WXK_NUMPAD3; break;
+ id = WXK_NUMPAD3; break;
case XK_KP_4:
- id = WXK_NUMPAD4; break;
+ id = WXK_NUMPAD4; break;
case XK_KP_5:
- id = WXK_NUMPAD5; break;
+ id = WXK_NUMPAD5; break;
case XK_KP_6:
- id = WXK_NUMPAD6; break;
+ id = WXK_NUMPAD6; break;
case XK_KP_7:
- id = WXK_NUMPAD7; break;
+ id = WXK_NUMPAD7; break;
case XK_KP_8:
- id = WXK_NUMPAD8; break;
+ id = WXK_NUMPAD8; break;
case XK_KP_9:
- id = WXK_NUMPAD9; break;
+ id = WXK_NUMPAD9; break;
case XK_F1:
- id = WXK_F1; break;
+ id = WXK_F1; break;
case XK_F2:
- id = WXK_F2; break;
+ id = WXK_F2; break;
case XK_F3:
- id = WXK_F3; break;
+ id = WXK_F3; break;
case XK_F4:
- id = WXK_F4; break;
+ id = WXK_F4; break;
case XK_F5:
- id = WXK_F5; break;
+ id = WXK_F5; break;
case XK_F6:
- id = WXK_F6; break;
+ id = WXK_F6; break;
case XK_F7:
- id = WXK_F7; break;
+ id = WXK_F7; break;
case XK_F8:
- id = WXK_F8; break;
+ id = WXK_F8; break;
case XK_F9:
- id = WXK_F9; break;
+ id = WXK_F9; break;
case XK_F10:
- id = WXK_F10; break;
+ id = WXK_F10; break;
case XK_F11:
- id = WXK_F11; break;
+ id = WXK_F11; break;
case XK_F12:
- id = WXK_F12; break;
+ id = WXK_F12; break;
case XK_F13:
- id = WXK_F13; break;
+ id = WXK_F13; break;
case XK_F14:
- id = WXK_F14; break;
+ id = WXK_F14; break;
case XK_F15:
- id = WXK_F15; break;
+ id = WXK_F15; break;
case XK_F16:
- id = WXK_F16; break;
+ id = WXK_F16; break;
case XK_F17:
- id = WXK_F17; break;
+ id = WXK_F17; break;
case XK_F18:
- id = WXK_F18; break;
+ id = WXK_F18; break;
case XK_F19:
- id = WXK_F19; break;
+ id = WXK_F19; break;
case XK_F20:
- id = WXK_F20; break;
+ id = WXK_F20; break;
case XK_F21:
- id = WXK_F21; break;
+ id = WXK_F21; break;
case XK_F22:
- id = WXK_F22; break;
+ id = WXK_F22; break;
case XK_F23:
- id = WXK_F23; break;
+ id = WXK_F23; break;
case XK_F24:
- id = WXK_F24; break;
+ id = WXK_F24; break;
default:
- id = (keySym <= 255) ? (int)keySym : -1;
+ id = (keySym <= 255) ? (int)keySym : -1;
} // switch
return id;
}
KeySym wxCharCodeWXToX(int id)
{
- KeySym keySym;
-
- switch (id) {
+ KeySym keySym;
+
+ switch (id) {
case WXK_CANCEL: keySym = XK_Cancel; break;
case WXK_BACK: keySym = XK_BackSpace; break;
case WXK_TAB: keySym = XK_Tab; break;
case WXK_NUMLOCK: keySym = XK_Num_Lock; break;
case WXK_SCROLL: keySym = XK_Scroll_Lock; break;
default: keySym = id <= 255 ? (KeySym)id : 0;
- } // switch
- return keySym;
+ } // switch
+ return keySym;
}
// Read $HOME for what it says is home, if not
// the Real User, then determine the Real home dir.
static char * GetIniFile (char *dest, const char *filename)
{
- char *home = NULL;
- if (filename && wxIsAbsolutePath(filename))
- {
- strcpy(dest, filename);
- }
- else if ((home = wxGetUserHome("")) != NULL)
- {
- strcpy(dest, home);
- if (dest[strlen(dest) - 1] != '/')
- strcat (dest, "/");
- if (filename == NULL)
- {
- if ((filename = getenv ("XENVIRONMENT")) == NULL)
- filename = ".Xdefaults";
- }
- else if (*filename != '.')
- strcat (dest, ".");
- strcat (dest, filename);
- } else
- {
- dest[0] = '\0';
- }
- return dest;
+ char *home = NULL;
+ if (filename && wxIsAbsolutePath(filename))
+ {
+ strcpy(dest, filename);
+ }
+ else if ((home = wxGetUserHome("")) != NULL)
+ {
+ strcpy(dest, home);
+ if (dest[strlen(dest) - 1] != '/')
+ strcat (dest, "/");
+ if (filename == NULL)
+ {
+ if ((filename = getenv ("XENVIRONMENT")) == NULL)
+ filename = ".Xdefaults";
+ }
+ else if (*filename != '.')
+ strcat (dest, ".");
+ strcat (dest, filename);
+ } else
+ {
+ dest[0] = '\0';
+ }
+ return dest;
}
/*
- * Some colour manipulation routines
- */
-
+* Some colour manipulation routines
+*/
+
void wxHSVToXColor(wxHSV *hsv,XColor *rgb)
- {
- int h = hsv->h;
- int s = hsv->s;
- int v = hsv->v;
- int r, g, b;
- int i, f;
- int p, q, t;
- s = (s * wxMAX_RGB) / wxMAX_SV;
- v = (v * wxMAX_RGB) / wxMAX_SV;
- if (h == 360) h = 0;
- if (s == 0) { h = 0; r = g = b = v; }
- i = h / 60;
- f = h % 60;
- p = v * (wxMAX_RGB - s) / wxMAX_RGB;
- q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB;
- t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB;
- switch (i)
- {
- case 0: r = v, g = t, b = p; break;
- case 1: r = q, g = v, b = p; break;
- case 2: r = p, g = v, b = t; break;
- case 3: r = p, g = q, b = v; break;
- case 4: r = t, g = p, b = v; break;
- case 5: r = v, g = p, b = q; break;
- }
- rgb->red = r << 8;
- rgb->green = g << 8;
- rgb->blue = b << 8;
- }
+{
+ int h = hsv->h;
+ int s = hsv->s;
+ int v = hsv->v;
+ int r, g, b;
+ int i, f;
+ int p, q, t;
+ s = (s * wxMAX_RGB) / wxMAX_SV;
+ v = (v * wxMAX_RGB) / wxMAX_SV;
+ if (h == 360) h = 0;
+ if (s == 0) { h = 0; r = g = b = v; }
+ i = h / 60;
+ f = h % 60;
+ p = v * (wxMAX_RGB - s) / wxMAX_RGB;
+ q = v * (wxMAX_RGB - s * f / 60) / wxMAX_RGB;
+ t = v * (wxMAX_RGB - s * (60 - f) / 60) / wxMAX_RGB;
+ switch (i)
+ {
+ case 0: r = v, g = t, b = p; break;
+ case 1: r = q, g = v, b = p; break;
+ case 2: r = p, g = v, b = t; break;
+ case 3: r = p, g = q, b = v; break;
+ case 4: r = t, g = p, b = v; break;
+ case 5: r = v, g = p, b = q; break;
+ }
+ rgb->red = r << 8;
+ rgb->green = g << 8;
+ rgb->blue = b << 8;
+}
void wxXColorToHSV(wxHSV *hsv,XColor *rgb)
- {
- int r = rgb->red >> 8;
- int g = rgb->green >> 8;
- int b = rgb->blue >> 8;
- int maxv = wxMax3(r, g, b);
- int minv = wxMin3(r, g, b);
- int h, s, v;
- v = maxv;
- if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv;
- else s = 0;
- if (s == 0) h = 0;
- else
- {
- int rc, gc, bc, hex;
- rc = (maxv - r) * wxMAX_RGB / (maxv - minv);
- gc = (maxv - g) * wxMAX_RGB / (maxv - minv);
- bc = (maxv - b) * wxMAX_RGB / (maxv - minv);
- if (r == maxv) { h = bc - gc, hex = 0; }
- else if (g == maxv) { h = rc - bc, hex = 2; }
- else if (b == maxv) { h = gc - rc, hex = 4; }
- h = hex * 60 + (h * 60 / wxMAX_RGB);
- if (h < 0) h += 360;
- }
- hsv->h = h;
- hsv->s = (s * wxMAX_SV) / wxMAX_RGB;
- hsv->v = (v * wxMAX_SV) / wxMAX_RGB;
- }
+{
+ int r = rgb->red >> 8;
+ int g = rgb->green >> 8;
+ int b = rgb->blue >> 8;
+ int maxv = wxMax3(r, g, b);
+ int minv = wxMin3(r, g, b);
+ int h, s, v;
+ v = maxv;
+ if (maxv) s = (maxv - minv) * wxMAX_RGB / maxv;
+ else s = 0;
+ if (s == 0) h = 0;
+ else
+ {
+ int rc, gc, bc, hex;
+ rc = (maxv - r) * wxMAX_RGB / (maxv - minv);
+ gc = (maxv - g) * wxMAX_RGB / (maxv - minv);
+ bc = (maxv - b) * wxMAX_RGB / (maxv - minv);
+ if (r == maxv) { h = bc - gc, hex = 0; }
+ else if (g == maxv) { h = rc - bc, hex = 2; }
+ else if (b == maxv) { h = gc - rc, hex = 4; }
+ h = hex * 60 + (h * 60 / wxMAX_RGB);
+ if (h < 0) h += 360;
+ }
+ hsv->h = h;
+ hsv->s = (s * wxMAX_SV) / wxMAX_RGB;
+ hsv->v = (v * wxMAX_SV) / wxMAX_RGB;
+}
void wxAllocNearestColor(Display *d,Colormap cmp,XColor *xc)
- {
- int llp;
-
- int screen = DefaultScreen(d);
- int num_colors = DisplayCells(d,screen);
-
- XColor *color_defs = new XColor[num_colors];
- for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp;
- XQueryColors(d,cmp,color_defs,num_colors);
-
- wxHSV hsv_defs, hsv;
- wxXColorToHSV(&hsv,xc);
-
- int diff, min_diff, pixel = 0;
-
- for(llp = 0;llp < num_colors;llp++)
- {
- wxXColorToHSV(&hsv_defs,&color_defs[llp]);
- diff = wxSIGN(wxH_WEIGHT * (hsv.h - hsv_defs.h)) +
- wxSIGN(wxS_WEIGHT * (hsv.s - hsv_defs.s)) +
- wxSIGN(wxV_WEIGHT * (hsv.v - hsv_defs.v));
- if (llp == 0) min_diff = diff;
- if (min_diff > diff) { min_diff = diff; pixel = llp; }
- if (min_diff == 0) break;
- }
-
- xc -> red = color_defs[pixel].red;
- xc -> green = color_defs[pixel].green;
- xc -> blue = color_defs[pixel].blue;
- xc -> flags = DoRed | DoGreen | DoBlue;
- if (!XAllocColor(d,cmp,xc))
+{
+ int llp;
+
+ int screen = DefaultScreen(d);
+ int num_colors = DisplayCells(d,screen);
+
+ XColor *color_defs = new XColor[num_colors];
+ for(llp = 0;llp < num_colors;llp++) color_defs[llp].pixel = llp;
+ XQueryColors(d,cmp,color_defs,num_colors);
+
+ wxHSV hsv_defs, hsv;
+ wxXColorToHSV(&hsv,xc);
+
+ int diff, min_diff, pixel = 0;
+
+ for(llp = 0;llp < num_colors;llp++)
+ {
+ wxXColorToHSV(&hsv_defs,&color_defs[llp]);
+ diff = wxSIGN(wxH_WEIGHT * (hsv.h - hsv_defs.h)) +
+ wxSIGN(wxS_WEIGHT * (hsv.s - hsv_defs.s)) +
+ wxSIGN(wxV_WEIGHT * (hsv.v - hsv_defs.v));
+ if (llp == 0) min_diff = diff;
+ if (min_diff > diff) { min_diff = diff; pixel = llp; }
+ if (min_diff == 0) break;
+ }
+
+ xc -> red = color_defs[pixel].red;
+ xc -> green = color_defs[pixel].green;
+ xc -> blue = color_defs[pixel].blue;
+ xc -> flags = DoRed | DoGreen | DoBlue;
+ if (!XAllocColor(d,cmp,xc))
cout << "wxAllocNearestColor : Warning : Cannot find nearest color !\n";
-
- delete[] color_defs;
- }
+
+ delete[] color_defs;
+}
void wxAllocColor(Display *d,Colormap cmp,XColor *xc)
- {
- if (!XAllocColor(d,cmp,xc))
- {
-// cout << "wxAllocColor : Warning : Can not allocate color, attempt find nearest !\n";
- wxAllocNearestColor(d,cmp,xc);
- }
- }
+{
+ if (!XAllocColor(d,cmp,xc))
+ {
+ // cout << "wxAllocColor : Warning : Can not allocate color, attempt find nearest !\n";
+ wxAllocNearestColor(d,cmp,xc);
+ }
+}
// These functions duplicate those in wxWindow, but are needed
void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
{
- // When should we specify the foreground, if it's calculated
- // by wxComputeColours?
- // Solution: say we start with the default (computed) foreground colour.
- // If we call SetForegroundColour explicitly for a control or window,
- // then the foreground is changed.
- // Therefore SetBackgroundColour computes the foreground colour, and
- // SetForegroundColour changes the foreground colour. The ordering is
- // important.
-
- XtVaSetValues ((Widget) widget,
- XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
- NULL);
+ // When should we specify the foreground, if it's calculated
+ // by wxComputeColours?
+ // Solution: say we start with the default (computed) foreground colour.
+ // If we call SetForegroundColour explicitly for a control or window,
+ // then the foreground is changed.
+ // Therefore SetBackgroundColour computes the foreground colour, and
+ // SetForegroundColour changes the foreground colour. The ordering is
+ // important.
+
+ XtVaSetValues ((Widget) widget,
+ XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
+ NULL);
}
void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
{
- wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
- (wxColour*) NULL);
-
- XtVaSetValues ((Widget) widget,
- XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
- XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
- XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
- XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
- NULL);
-
- if (changeArmColour)
+ wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
+ (wxColour*) NULL);
+
XtVaSetValues ((Widget) widget,
- XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
- NULL);
+ XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
+ XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
+ XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
+ XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
+ NULL);
+
+ if (changeArmColour)
+ XtVaSetValues ((Widget) widget,
+ XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
+ NULL);
}
#endif
#ifdef __SVR4__
- #include <sys/systeminfo.h>
+#include <sys/systeminfo.h>
#endif
#ifdef __SOLARIS__
// somehow missing from sys/wait.h but in the system's docs
extern "C"
{
- pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
- *rusage);
+ pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
+ *rusage);
}
#endif
struct wxLocalProcessData
{
- int pid, end_process;
- wxProcess *process;
+ int pid, end_process;
+ wxProcess *process;
};
#ifdef __SOLARIS__
// somehow missing from sys/wait.h but in the system's docs
extern "C"
{
- pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
- *rusage);
+ pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
+ *rusage);
}
#endif
void xt_notify_end_process(XtPointer client, int *fid,
- XtInputId *id)
+ XtInputId *id)
{
- wxLocalProcessData *process_data = (wxLocalProcessData *)client;
-
- int pid;
-
- pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid);
-
- /* wait4 is not part of any standard, use at own risk
- * not sure what wait4 does, but wait3 seems to be closest, whats a digit ;-)
- * --- offer@sgi.com */
+ wxLocalProcessData *process_data = (wxLocalProcessData *)client;
+
+ int pid;
+
+ pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid);
+
+ /* wait4 is not part of any standard, use at own risk
+ * not sure what wait4 does, but wait3 seems to be closest, whats a digit ;-)
+ * --- offer@sgi.com */
#if !defined(__sgi) && !defined(__SGI__) && !defined(__ALPHA__) && !defined(__SUNCC__)
- wait4(process_data->pid, NULL, 0, NULL);
+ wait4(process_data->pid, NULL, 0, NULL);
#else
- wait3((int *) NULL, 0, (rusage *) NULL);
+ wait3((int *) NULL, 0, (rusage *) NULL);
#endif
-
- XtRemoveInput(*id);
- if (process_data->process)
- process_data->process->OnTerminate(process_data->pid);
-
- process_data->end_process = TRUE;
-
- if (process_data->pid > 0)
- delete process_data;
- else
- process_data->pid = 0;
+
+ XtRemoveInput(*id);
+ if (process_data->process)
+ process_data->process->OnTerminate(process_data->pid);
+
+ process_data->end_process = TRUE;
+
+ if (process_data->pid > 0)
+ delete process_data;
+ else
+ process_data->pid = 0;
}
long wxExecute(char **argv, bool sync, wxProcess *handler)
{
#ifdef VMS
- return(0);
+ return(0);
#else
- if (*argv == NULL)
- return 0; // Nothing???
-
- int proc_link[2];
- if (pipe(proc_link))
- return 0;
-
- /* fork the process */
+ if (*argv == NULL)
+ return 0; // Nothing???
+
+ int proc_link[2];
+ if (pipe(proc_link))
+ return 0;
+
+ /* fork the process */
#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
- pid_t pid = vfork ();
+ pid_t pid = vfork ();
#else
- pid_t pid = fork ();
+ pid_t pid = fork ();
#endif
-
- if (pid == -1)
+
+ if (pid == -1)
{
- return 0;
+ return 0;
}
- else if (pid == 0)
+ else if (pid == 0)
{
-/* GUILHEM: Close all fds when sync == 0 */
- if (sync == 0)
- for (int fd=0;fd<FD_SETSIZE;fd++) {
- if (proc_link[1] != fd)
- close(fd);
- }
- /* child */
+ /* GUILHEM: Close all fds when sync == 0 */
+ if (sync == 0)
+ for (int fd=0;fd<FD_SETSIZE;fd++) {
+ if (proc_link[1] != fd)
+ close(fd);
+ }
+ /* child */
#ifdef _AIX
- execvp ((const char *)*argv, (const char **)argv);
+ execvp ((const char *)*argv, (const char **)argv);
#else
- execvp (*argv, argv);
+ execvp (*argv, argv);
#endif
-/* GUILHEM: Reopen output stream */
-// open("/dev/console", O_WRONLY);
-/* GUILHEM: End */
- if (errno == ENOENT)
- printf ("%s: command not found\n", *argv);
- else
- perror (*argv);
- printf ("wxWindows: could not execute '%s'\n", *argv);
- _exit (-1);
+ /* GUILHEM: Reopen output stream */
+ // open("/dev/console", O_WRONLY);
+ /* GUILHEM: End */
+ if (errno == ENOENT)
+ printf ("%s: command not found\n", *argv);
+ else
+ perror (*argv);
+ printf ("wxWindows: could not execute '%s'\n", *argv);
+ _exit (-1);
}
-
- wxLocalProcessData *process_data = new wxLocalProcessData;
-
- process_data->end_process = 0;
- process_data->process = handler;
- process_data->pid = (sync) ? pid : -pid;
-
- close(proc_link[1]);
- XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0],
- (XtPointer *) XtInputReadMask,
- (XtInputCallbackProc) xt_notify_end_process,
- (XtPointer) process_data);
-
- if (sync) {
- while (!process_data->end_process)
- XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
-
- if (WIFEXITED(process_data->end_process) != 0)
- return WEXITSTATUS(process_data->end_process);
- }
-
- delete process_data;
-
- return pid;
+
+ wxLocalProcessData *process_data = new wxLocalProcessData;
+
+ process_data->end_process = 0;
+ process_data->process = handler;
+ process_data->pid = (sync) ? pid : -pid;
+
+ close(proc_link[1]);
+ XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0],
+ (XtPointer *) XtInputReadMask,
+ (XtInputCallbackProc) xt_notify_end_process,
+ (XtPointer) process_data);
+
+ if (sync) {
+ while (!process_data->end_process)
+ XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
+
+ if (WIFEXITED(process_data->end_process) != 0)
+ return WEXITSTATUS(process_data->end_process);
+ }
+
+ delete process_data;
+
+ return pid;
#endif
- // end VMS
+ // end VMS
}
long wxExecute (const wxString& command, bool sync, wxProcess* handler)
{
#ifdef VMS
- return(0);
+ return(0);
#else
- if (command.IsNull() || command == "")
- return 0; // Nothing to do
-
- // Run a program the recomended way under X (XView)
- int argc = 0;
- char *argv[127];
- char tmp[1024];
- const char *IFS = " \t\n";
-
- // Build argument vector
- strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1);
- tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
- argv[argc++] = strtok (tmp, IFS);
- while ((argv[argc++] = strtok (NULL, IFS)) != NULL)
- /* loop */ ;
-
- return wxExecute(argv, sync, handler);
+ if (command.IsNull() || command == "")
+ return 0; // Nothing to do
+
+ // Run a program the recomended way under X (XView)
+ int argc = 0;
+ char *argv[127];
+ char tmp[1024];
+ const char *IFS = " \t\n";
+
+ // Build argument vector
+ strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1);
+ tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
+ argv[argc++] = strtok (tmp, IFS);
+ while ((argv[argc++] = strtok (NULL, IFS)) != NULL)
+ /* loop */ ;
+
+ return wxExecute(argv, sync, handler);
#endif
- // VMS
+ // VMS
}
void wxCanvasMotionEvent (Widget, XButtonEvent * event);
void wxCanvasEnterLeave (Widget drawingArea, XtPointer clientData, XCrossingEvent * event);
static void wxScrollBarCallback(Widget widget, XtPointer clientData,
- XmScaleCallbackStruct *cbs);
+ XmScaleCallbackStruct *cbs);
void wxPanelItemEventHandler (Widget wid,
XtPointer client_data,
XEvent* event,
IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxEvtHandler)
BEGIN_EVENT_TABLE(wxWindow, wxEvtHandler)
- EVT_CHAR(wxWindow::OnChar)
- EVT_KEY_DOWN(wxWindow::OnKeyDown)
- EVT_KEY_UP(wxWindow::OnKeyUp)
- EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
- EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
- EVT_INIT_DIALOG(wxWindow::OnInitDialog)
- EVT_IDLE(wxWindow::OnIdle)
+EVT_CHAR(wxWindow::OnChar)
+EVT_KEY_DOWN(wxWindow::OnKeyDown)
+EVT_KEY_UP(wxWindow::OnKeyUp)
+EVT_ERASE_BACKGROUND(wxWindow::OnEraseBackground)
+EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged)
+EVT_INIT_DIALOG(wxWindow::OnInitDialog)
+EVT_IDLE(wxWindow::OnIdle)
END_EVENT_TABLE()
#endif
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
m_foregroundColour = *wxBLACK;
-
+
#if wxUSE_DRAG_AND_DROP
m_pDropTarget = NULL;
#endif
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
-
+
/// Motif-specific
m_mainWidget = (WXWidget) 0;
m_button1Pressed = FALSE;
wxWindow::~wxWindow()
{
//// Motif-specific
-
+
if (GetMainWidget())
DetachWidget(GetMainWidget()); // Removes event handlers
-
+
// If m_drawingArea, we're a fully-fledged window with drawing area, scrollbars etc. (what wxCanvas used to be)
if (m_drawingArea)
{
// Destroy children before destroying self
DestroyChildren();
-
+
if (m_backingPixmap)
- XFreePixmap (XtDisplay ((Widget) GetMainWidget()), (Pixmap) m_backingPixmap);
-
+ XFreePixmap (XtDisplay ((Widget) GetMainWidget()), (Pixmap) m_backingPixmap);
+
Widget w = (Widget) m_drawingArea;
wxDeleteWindowFromTable(w);
-
+
if (w)
XtDestroyWidget(w);
m_mainWidget = (WXWidget) 0;
-
+
// Only if we're _really_ a canvas (not a dialog box/panel)
if (m_scrolledWindow)
{
wxDeleteWindowFromTable((Widget) m_scrolledWindow);
}
-
+
if (m_hScrollBar)
{
XtUnmanageChild ((Widget) m_hScrollBar);
XtUnmanageChild ((Widget) m_scrolledWindow);
XtDestroyWidget ((Widget) m_scrolledWindow);
}
-
+
if (m_borderWidget)
{
XtDestroyWidget ((Widget) m_borderWidget);
m_borderWidget = (WXWidget) 0;
}
}
-
+
//// Generic stuff
-
- // Have to delete constraints/sizer FIRST otherwise
- // sizers may try to look at deleted windows as they
- // delete themselves.
+
+ // Have to delete constraints/sizer FIRST otherwise
+ // sizers may try to look at deleted windows as they
+ // delete themselves.
#if wxUSE_CONSTRAINTS
DeleteRelatedConstraints();
if (m_constraints)
if (m_sizerParent)
m_sizerParent->RemoveChild((wxWindow *)this);
#endif
-
+
if (m_windowParent)
m_windowParent->RemoveChild(this);
-
+
DestroyChildren();
-
+
// Destroy the window
if (GetMainWidget())
{
- wxDeleteWindowFromTable((Widget) GetMainWidget());
- XtDestroyWidget((Widget) GetMainWidget());
- SetMainWidget((WXWidget) NULL);
+ wxDeleteWindowFromTable((Widget) GetMainWidget());
+ XtDestroyWidget((Widget) GetMainWidget());
+ SetMainWidget((WXWidget) NULL);
}
-
+
delete m_children;
m_children = NULL;
-
+
// Just in case the window has been Closed, but
// we're then deleting immediately: don't leave
// dangling pointers.
wxPendingDelete.DeleteObject(this);
-
+
if ( m_windowValidator ) delete m_windowValidator;
if (m_clientObject) delete m_clientObject;
-
+
ClearUpdateRects();
}
// Constructor
bool wxWindow::Create(wxWindow *parent, wxWindowID id,
- const wxPoint& pos,
- const wxSize& size,
- long style,
- const wxString& name)
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString& name)
{
// Generic
m_windowId = 0;
m_windowParent = NULL;
m_clientObject = (wxClientData*) NULL;
m_clientData = NULL;
-
+
// Motif-specific
m_canAddEventHandler = FALSE;
m_mainWidget = (WXWidget) 0;
m_pixmapOffsetY = 0;
m_scrollPosX = 0;
m_scrollPosY = 0;
-
+
if (!parent)
return FALSE;
-
+
if (parent) parent->AddChild(this);
-
+
m_returnCode = 0;
-
+
SetName(name);
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW) ; ;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
m_foregroundColour = *wxBLACK;
-
+
m_windowStyle = style;
-
+
if ( id == -1 )
- m_windowId = (int)NewControlId();
+ m_windowId = (int)NewControlId();
else
- m_windowId = id;
-
+ m_windowId = id;
+
//// TODO: we should probably optimize by only creating a
//// a drawing area if we have one or more scrollbars (wxVSCROLL/wxHSCROLL).
//// But for now, let's simplify things by always creating the
//// drawing area, since otherwise the translations are different.
-
- // New translations for getting mouse motion feedback
- String translations =
- "<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <BtnMotion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
- <Btn1Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn2Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn3Down>: DrawingAreaInput() ManagerGadgetArm()\n\
- <Btn1Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Btn2Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Btn3Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
- <Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
- <Key>: DrawingAreaInput()";
-
- XtActionsRec actions[1];
- actions[0].string = "wxCanvasMotionEvent";
- actions[0].proc = (XtActionProc) wxCanvasMotionEvent;
- XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1);
-
- Widget parentWidget = (Widget) parent->GetClientWidget();
- if (style & wxBORDER)
- m_borderWidget = (WXWidget) XtVaCreateManagedWidget ("canvasBorder",
- xmFrameWidgetClass, parentWidget,
- XmNshadowType, XmSHADOW_IN,
- NULL);
-
- m_scrolledWindow = (WXWidget) XtVaCreateManagedWidget ("scrolledWindow",
- xmScrolledWindowWidgetClass, m_borderWidget ? (Widget) m_borderWidget : parentWidget,
- XmNresizePolicy, XmRESIZE_NONE,
- XmNspacing, 0,
- XmNscrollingPolicy, XmAPPLICATION_DEFINED,
- // XmNscrollBarDisplayPolicy, XmAS_NEEDED,
- NULL);
-
- XtTranslations ptr;
- m_drawingArea = (WXWidget) XtVaCreateWidget ((char*) (const char*) name,
- xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow,
- XmNunitType, XmPIXELS,
-// XmNresizePolicy, XmRESIZE_ANY,
- XmNresizePolicy, XmRESIZE_NONE,
- XmNmarginHeight, 0,
- XmNmarginWidth, 0,
- XmNtranslations, ptr = XtParseTranslationTable (translations),
- NULL);
- /*
- if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS)
- {
- XtFree ((char *) ptr);
- ptr = XtParseTranslationTable ("<Key>: DrawingAreaInput()");
- XtOverrideTranslations ((Widget) m_drawingArea, ptr);
+
+ // New translations for getting mouse motion feedback
+ String translations =
+ "<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
+<Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
+<Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
+<BtnMotion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
+<Btn1Down>: DrawingAreaInput() ManagerGadgetArm()\n\
+<Btn2Down>: DrawingAreaInput() ManagerGadgetArm()\n\
+<Btn3Down>: DrawingAreaInput() ManagerGadgetArm()\n\
+<Btn1Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
+<Btn2Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
+<Btn3Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
+<Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\
+<EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
+<LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
+<Key>: DrawingAreaInput()";
+
+ XtActionsRec actions[1];
+ actions[0].string = "wxCanvasMotionEvent";
+ actions[0].proc = (XtActionProc) wxCanvasMotionEvent;
+ XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1);
+
+ Widget parentWidget = (Widget) parent->GetClientWidget();
+ if (style & wxBORDER)
+ m_borderWidget = (WXWidget) XtVaCreateManagedWidget ("canvasBorder",
+ xmFrameWidgetClass, parentWidget,
+ XmNshadowType, XmSHADOW_IN,
+ NULL);
+
+ m_scrolledWindow = (WXWidget) XtVaCreateManagedWidget ("scrolledWindow",
+ xmScrolledWindowWidgetClass, m_borderWidget ? (Widget) m_borderWidget : parentWidget,
+ XmNresizePolicy, XmRESIZE_NONE,
+ XmNspacing, 0,
+ XmNscrollingPolicy, XmAPPLICATION_DEFINED,
+ // XmNscrollBarDisplayPolicy, XmAS_NEEDED,
+ NULL);
+
+ XtTranslations ptr;
+ m_drawingArea = (WXWidget) XtVaCreateWidget ((char*) (const char*) name,
+ xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow,
+ XmNunitType, XmPIXELS,
+ // XmNresizePolicy, XmRESIZE_ANY,
+ XmNresizePolicy, XmRESIZE_NONE,
+ XmNmarginHeight, 0,
+ XmNmarginWidth, 0,
+ XmNtranslations, ptr = XtParseTranslationTable (translations),
+ NULL);
+ /*
+ if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS)
+ {
+ XtFree ((char *) ptr);
+ ptr = XtParseTranslationTable ("<Key>: DrawingAreaInput()");
+ XtOverrideTranslations ((Widget) m_drawingArea, ptr);
+ XtFree ((char *) ptr);
+ }
+ */
+
+ wxAddWindowToTable((Widget) m_drawingArea, this);
+ wxAddWindowToTable((Widget) m_scrolledWindow, this);
+
+ /*
+ * This order is very important in Motif 1.2.1
+ *
+ */
+
+ XtRealizeWidget ((Widget) m_scrolledWindow);
+ XtRealizeWidget ((Widget) m_drawingArea);
+ XtManageChild ((Widget) m_drawingArea);
+
+ XtOverrideTranslations ((Widget) m_drawingArea,
+ ptr = XtParseTranslationTable ("<Configure>: resize()"));
XtFree ((char *) ptr);
- }
- */
-
- wxAddWindowToTable((Widget) m_drawingArea, this);
- wxAddWindowToTable((Widget) m_scrolledWindow, this);
-
- /*
- * This order is very important in Motif 1.2.1
- *
- */
-
- XtRealizeWidget ((Widget) m_scrolledWindow);
- XtRealizeWidget ((Widget) m_drawingArea);
- XtManageChild ((Widget) m_drawingArea);
-
- XtOverrideTranslations ((Widget) m_drawingArea,
- ptr = XtParseTranslationTable ("<Configure>: resize()"));
- XtFree ((char *) ptr);
-
- XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this);
- XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this);
-
- /* TODO?
- display = XtDisplay (scrolledWindow);
- xwindow = XtWindow (drawingArea);
- */
-
- XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
- False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
-
- // Scrolled widget needs to have its colour changed or we get
- // a little blue square where the scrollbars abutt
- wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
- DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
- DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE);
-
- XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) 0, (Widget) 0, (Widget) m_drawingArea);
-
- /*
- if (m_hScrollBar)
- XtRealizeWidget ((Widget) m_hScrollBar);
- if (m_vScrollBar)
- XtRealizeWidget ((Widget) m_vScrollBar);
- */
-
- // Without this, the cursor may not be restored properly
- // (e.g. in splitter sample).
- SetCursor(*wxSTANDARD_CURSOR);
- SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
- SetSize(pos.x, pos.y, size.x, size.y);
-
- return TRUE;
+
+ XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this);
+ XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this);
+
+ /* TODO?
+ display = XtDisplay (scrolledWindow);
+ xwindow = XtWindow (drawingArea);
+ */
+
+ XtAddEventHandler ((Widget) m_drawingArea, PointerMotionHintMask | EnterWindowMask | LeaveWindowMask | FocusChangeMask,
+ False, (XtEventHandler) wxCanvasEnterLeave, (XtPointer) this);
+
+ // Scrolled widget needs to have its colour changed or we get
+ // a little blue square where the scrollbars abutt
+ wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE);
+ DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE);
+
+ XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) 0, (Widget) 0, (Widget) m_drawingArea);
+
+ /*
+ if (m_hScrollBar)
+ XtRealizeWidget ((Widget) m_hScrollBar);
+ if (m_vScrollBar)
+ XtRealizeWidget ((Widget) m_vScrollBar);
+ */
+
+ // Without this, the cursor may not be restored properly
+ // (e.g. in splitter sample).
+ SetCursor(*wxSTANDARD_CURSOR);
+ SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
+ SetSize(pos.x, pos.y, size.x, size.y);
+
+ return TRUE;
}
// Helper function
void wxWindow::CreateScrollbar(int orientation)
{
- if (!m_drawingArea)
- return;
-
- XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
- // Add scrollbars if required
- if (orientation == wxHORIZONTAL)
- {
- Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
- xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
- XmNorientation, XmHORIZONTAL,
- NULL);
- // XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
- XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
-
- XtVaSetValues (hScrollBar,
- XmNincrement, 1,
- XmNvalue, 0,
- NULL);
-
- m_hScrollBar = (WXWidget) hScrollBar;
-
- wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
- DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE);
-
- XtRealizeWidget(hScrollBar);
-
- XtVaSetValues((Widget) m_scrolledWindow,
- XmNhorizontalScrollBar, (Widget) m_hScrollBar,
- NULL);
-
- m_hScroll = TRUE;
- }
-
- if (orientation == wxVERTICAL)
- {
- Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
- xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
- XmNorientation, XmVERTICAL,
- NULL);
- // XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
- XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
-
- XtVaSetValues (vScrollBar,
- XmNincrement, 1,
- XmNvalue, 0,
- NULL);
-
- m_vScrollBar = (WXWidget) vScrollBar;
- wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
- DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE);
-
- XtRealizeWidget(vScrollBar);
-
- XtVaSetValues((Widget) m_scrolledWindow,
- XmNverticalScrollBar, (Widget) m_vScrollBar,
- NULL);
-
- m_vScroll = TRUE;
- }
-
- XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
+ if (!m_drawingArea)
+ return;
+
+ XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ // Add scrollbars if required
+ if (orientation == wxHORIZONTAL)
+ {
+ Widget hScrollBar = XtVaCreateManagedWidget ("hsb",
+ xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+ XmNorientation, XmHORIZONTAL,
+ NULL);
+ // XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+ XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL);
+
+ XtVaSetValues (hScrollBar,
+ XmNincrement, 1,
+ XmNvalue, 0,
+ NULL);
+
+ m_hScrollBar = (WXWidget) hScrollBar;
+
+ wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE);
+
+ XtRealizeWidget(hScrollBar);
+
+ XtVaSetValues((Widget) m_scrolledWindow,
+ XmNhorizontalScrollBar, (Widget) m_hScrollBar,
+ NULL);
+
+ m_hScroll = TRUE;
+ }
+
+ if (orientation == wxVERTICAL)
+ {
+ Widget vScrollBar = XtVaCreateManagedWidget ("vsb",
+ xmScrollBarWidgetClass, (Widget) m_scrolledWindow,
+ XmNorientation, XmVERTICAL,
+ NULL);
+ // XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+ XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL);
+
+ XtVaSetValues (vScrollBar,
+ XmNincrement, 1,
+ XmNvalue, 0,
+ NULL);
+
+ m_vScrollBar = (WXWidget) vScrollBar;
+ wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
+ DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE);
+
+ XtRealizeWidget(vScrollBar);
+
+ XtVaSetValues((Widget) m_scrolledWindow,
+ XmNverticalScrollBar, (Widget) m_vScrollBar,
+ NULL);
+
+ m_vScroll = TRUE;
+ }
+
+ XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
}
void wxWindow::DestroyScrollbar(int orientation)
{
- if (!m_drawingArea)
- return;
-
- XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
- // Add scrollbars if required
- if (orientation == wxHORIZONTAL)
- {
- if (m_hScrollBar)
- {
- XtDestroyWidget((Widget) m_hScrollBar);
- }
- m_hScrollBar = (WXWidget) 0;
- m_hScroll = FALSE;
-
- XtVaSetValues((Widget) m_scrolledWindow,
- XmNhorizontalScrollBar, (Widget) 0,
- NULL);
-
- }
-
- if (orientation == wxVERTICAL)
- {
- if (m_vScrollBar)
- {
- XtDestroyWidget((Widget) m_vScrollBar);
- }
- m_vScrollBar = (WXWidget) 0;
- m_vScroll = TRUE;
-
- XtVaSetValues((Widget) m_scrolledWindow,
- XmNverticalScrollBar, (Widget) 0,
- NULL);
-
- }
- XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
+ if (!m_drawingArea)
+ return;
+
+ XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL);
+ // Add scrollbars if required
+ if (orientation == wxHORIZONTAL)
+ {
+ if (m_hScrollBar)
+ {
+ XtDestroyWidget((Widget) m_hScrollBar);
+ }
+ m_hScrollBar = (WXWidget) 0;
+ m_hScroll = FALSE;
+
+ XtVaSetValues((Widget) m_scrolledWindow,
+ XmNhorizontalScrollBar, (Widget) 0,
+ NULL);
+
+ }
+
+ if (orientation == wxVERTICAL)
+ {
+ if (m_vScrollBar)
+ {
+ XtDestroyWidget((Widget) m_vScrollBar);
+ }
+ m_vScrollBar = (WXWidget) 0;
+ m_vScroll = TRUE;
+
+ XtVaSetValues((Widget) m_scrolledWindow,
+ XmNverticalScrollBar, (Widget) 0,
+ NULL);
+
+ }
+ XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL);
}
void wxWindow::SetFocus()
{
- XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
- XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
+ XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
+ XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT);
}
void wxWindow::Enable(bool enable)
{
- if (GetMainWidget())
- {
- XtSetSensitive((Widget) GetMainWidget(), enable);
- XmUpdateDisplay((Widget) GetMainWidget());
- }
+ if (GetMainWidget())
+ {
+ XtSetSensitive((Widget) GetMainWidget(), enable);
+ XmUpdateDisplay((Widget) GetMainWidget());
+ }
}
void wxWindow::CaptureMouse()
{
- if (m_winCaptured)
- return;
+ if (m_winCaptured)
+ return;
- if (GetMainWidget())
- XtAddGrab((Widget) GetMainWidget(), TRUE, FALSE);
-
- m_winCaptured = TRUE;
+ if (GetMainWidget())
+ XtAddGrab((Widget) GetMainWidget(), TRUE, FALSE);
+
+ m_winCaptured = TRUE;
}
void wxWindow::ReleaseMouse()
{
- if (!m_winCaptured)
- return;
+ if (!m_winCaptured)
+ return;
- if (GetMainWidget())
- XtRemoveGrab((Widget) GetMainWidget());
- m_winCaptured = FALSE;
+ if (GetMainWidget())
+ XtRemoveGrab((Widget) GetMainWidget());
+ m_winCaptured = FALSE;
}
// Push/pop event handler (i.e. allow a chain of event handlers
// be searched)
void wxWindow::PushEventHandler(wxEvtHandler *handler)
{
- handler->SetNextHandler(GetEventHandler());
- SetEventHandler(handler);
+ handler->SetNextHandler(GetEventHandler());
+ SetEventHandler(handler);
}
wxEvtHandler *wxWindow::PopEventHandler(bool deleteHandler)
{
- if ( GetEventHandler() )
- {
- wxEvtHandler *handlerA = GetEventHandler();
- wxEvtHandler *handlerB = handlerA->GetNextHandler();
- handlerA->SetNextHandler(NULL);
- SetEventHandler(handlerB);
- if ( deleteHandler )
- {
- delete handlerA;
- return NULL;
- }
- else
- return handlerA;
- }
- else
- return NULL;
+ if ( GetEventHandler() )
+ {
+ wxEvtHandler *handlerA = GetEventHandler();
+ wxEvtHandler *handlerB = handlerA->GetNextHandler();
+ handlerA->SetNextHandler(NULL);
+ SetEventHandler(handlerB);
+ if ( deleteHandler )
+ {
+ delete handlerA;
+ return NULL;
+ }
+ else
+ return handlerA;
+ }
+ else
+ return NULL;
}
#if wxUSE_DRAG_AND_DROP
void wxWindow::SetDropTarget(wxDropTarget *pDropTarget)
{
- if ( m_pDropTarget != 0 ) {
- delete m_pDropTarget;
- }
-
- m_pDropTarget = pDropTarget;
- if ( m_pDropTarget != 0 )
- {
- // TODO
- }
+ if ( m_pDropTarget != 0 ) {
+ delete m_pDropTarget;
+ }
+
+ m_pDropTarget = pDropTarget;
+ if ( m_pDropTarget != 0 )
+ {
+ // TODO
+ }
}
#endif
// Get total size
void wxWindow::GetSize(int *x, int *y) const
{
- if (m_drawingArea)
- {
- CanvasGetSize(x, y);
- return;
- }
-
- Widget widget = (Widget) GetTopWidget();
- Dimension xx, yy;
- XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
- *x = xx; *y = yy;
+ if (m_drawingArea)
+ {
+ CanvasGetSize(x, y);
+ return;
+ }
+
+ Widget widget = (Widget) GetTopWidget();
+ Dimension xx, yy;
+ XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
+ *x = xx; *y = yy;
}
void wxWindow::GetPosition(int *x, int *y) const
Widget widget = (Widget) GetTopWidget();
Position xx, yy;
XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL);
-
+
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
xx -= pt.x;
yy -= pt.y;
}
-
+
*x = xx; *y = yy;
}
void wxWindow::ScreenToClient(int *x, int *y) const
{
- Widget widget = (Widget) GetClientWidget();
- Display *display = XtDisplay((Widget) GetMainWidget());
- Window rootWindow = RootWindowOfScreen(XtScreen(widget));
- Window thisWindow = XtWindow(widget);
-
- Window childWindow;
- int xx = *x;
- int yy = *y;
- XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
+ Widget widget = (Widget) GetClientWidget();
+ Display *display = XtDisplay((Widget) GetMainWidget());
+ Window rootWindow = RootWindowOfScreen(XtScreen(widget));
+ Window thisWindow = XtWindow(widget);
+
+ Window childWindow;
+ int xx = *x;
+ int yy = *y;
+ XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow);
}
void wxWindow::ClientToScreen(int *x, int *y) const
{
- Widget widget = (Widget) GetClientWidget();
- Display *display = XtDisplay(widget);
- Window rootWindow = RootWindowOfScreen(XtScreen(widget));
- Window thisWindow = XtWindow(widget);
-
- Window childWindow;
- int xx = *x;
- int yy = *y;
- XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow);
+ Widget widget = (Widget) GetClientWidget();
+ Display *display = XtDisplay(widget);
+ Window rootWindow = RootWindowOfScreen(XtScreen(widget));
+ Window thisWindow = XtWindow(widget);
+
+ Window childWindow;
+ int xx = *x;
+ int yy = *y;
+ XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow);
}
void wxWindow::SetCursor(const wxCursor& cursor)
{
- m_windowCursor = cursor;
- if (m_windowCursor.Ok())
- {
- WXDisplay *dpy = GetXDisplay();
- WXCursor x_cursor = ((wxCursor&)cursor).GetXCursor(dpy);
-
- Widget w = (Widget) GetMainWidget();
- Window win = XtWindow(w);
- XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
- }
+ m_windowCursor = cursor;
+ if (m_windowCursor.Ok())
+ {
+ WXDisplay *dpy = GetXDisplay();
+ WXCursor x_cursor = ((wxCursor&)cursor).GetXCursor(dpy);
+
+ Widget w = (Widget) GetMainWidget();
+ Window win = XtWindow(w);
+ XDefineCursor((Display*) dpy, win, (Cursor) x_cursor);
+ }
}
// Get size *available for subwindows* i.e. excluding menu bar etc.
void wxWindow::GetClientSize(int *x, int *y) const
{
- Widget widget = (Widget) GetClientWidget();
- Dimension xx, yy;
- XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
- *x = xx; *y = yy;
+ Widget widget = (Widget) GetClientWidget();
+ Dimension xx, yy;
+ XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL);
+ *x = xx; *y = yy;
}
void wxWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
{
- // A bit of optimization to help sort out the flickers.
- int oldX, oldY, oldW, oldH;
- GetSize(& oldW, & oldH);
- GetPosition(& oldX, & oldY);
-
- bool useOldPos = FALSE;
- bool useOldSize = FALSE;
+ // A bit of optimization to help sort out the flickers.
+ int oldX, oldY, oldW, oldH;
+ GetSize(& oldW, & oldH);
+ GetPosition(& oldX, & oldY);
+
+ bool useOldPos = FALSE;
+ bool useOldSize = FALSE;
+
+ if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
+ useOldPos = TRUE;
+ else if (x == oldX && y == oldY)
+ useOldPos = TRUE;
+
+ if ((width == -1) && (height == -1))
+ useOldSize = TRUE;
+ else if (width == oldW && height == oldH)
+ useOldSize = TRUE;
+
+ if (!wxNoOptimize::CanOptimize())
+ {
+ useOldSize = FALSE; useOldPos = FALSE;
+ }
+
+ if (useOldPos && useOldSize)
+ return;
+
+ if (m_drawingArea)
+ {
+ CanvasSetSize(x, y, width, height, sizeFlags);
+ return;
+ }
+ Widget widget = (Widget) GetTopWidget();
+ if (!widget)
+ return;
+
+ bool managed = XtIsManaged( widget );
+ if (managed)
+ XtUnmanageChild(widget);
+
+ int xx = x; int yy = y;
+ AdjustForParentClientOrigin(xx, yy, sizeFlags);
+
+ if (!useOldPos)
+ {
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues(widget, XmNx, xx, NULL);
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ XtVaSetValues(widget, XmNy, yy, NULL);
+ }
+ if (!useOldSize)
+ {
+ if (width > -1)
+ XtVaSetValues(widget, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues(widget, XmNheight, height, NULL);
+ }
+
+ if (managed)
+ XtManageChild(widget);
+
+ // How about this bit. Maybe we don't need to generate size events
+ // all the time -- they'll be generated when the window is sized anyway.
+ /*
+ wxSizeEvent sizeEvent(wxSize(width, height), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+ */
+}
- if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
- useOldPos = TRUE;
- else if (x == oldX && y == oldY)
- useOldPos = TRUE;
-
- if ((width == -1) && (height == -1))
- useOldSize = TRUE;
- else if (width == oldW && height == oldH)
- useOldSize = TRUE;
-
- if (!wxNoOptimize::CanOptimize())
- {
- useOldSize = FALSE; useOldPos = FALSE;
- }
-
- if (useOldPos && useOldSize)
- return;
-
- if (m_drawingArea)
- {
- CanvasSetSize(x, y, width, height, sizeFlags);
- return;
- }
- Widget widget = (Widget) GetTopWidget();
- if (!widget)
- return;
-
- bool managed = XtIsManaged( widget );
- if (managed)
- XtUnmanageChild(widget);
-
- int xx = x; int yy = y;
- AdjustForParentClientOrigin(xx, yy, sizeFlags);
-
- if (!useOldPos)
- {
- if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues(widget, XmNx, xx, NULL);
- if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
- XtVaSetValues(widget, XmNy, yy, NULL);
- }
- if (!useOldSize)
- {
- if (width > -1)
- XtVaSetValues(widget, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues(widget, XmNheight, height, NULL);
- }
-
- if (managed)
- XtManageChild(widget);
-
- // How about this bit. Maybe we don't need to generate size events
- // all the time -- they'll be generated when the window is sized anyway.
- /*
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
- */
-}
-
-void wxWindow::SetClientSize(int width, int height)
-{
- if (m_drawingArea)
- {
- CanvasSetClientSize(width, height);
- return;
- }
-
- Widget widget = (Widget) GetTopWidget();
-
- if (width > -1)
- XtVaSetValues(widget, XmNwidth, width, NULL);
- if (height > -1)
- XtVaSetValues(widget, XmNheight, height, NULL);
-
- wxSizeEvent sizeEvent(wxSize(width, height), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
-}
+void wxWindow::SetClientSize(int width, int height)
+{
+ if (m_drawingArea)
+ {
+ CanvasSetClientSize(width, height);
+ return;
+ }
+
+ Widget widget = (Widget) GetTopWidget();
+
+ if (width > -1)
+ XtVaSetValues(widget, XmNwidth, width, NULL);
+ if (height > -1)
+ XtVaSetValues(widget, XmNheight, height, NULL);
+
+ wxSizeEvent sizeEvent(wxSize(width, height), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+}
// For implementation purposes - sometimes decorations make the client area
// smaller
{
if (show)
{
- if (m_borderWidget || m_scrolledWindow)
- {
- if (m_drawingArea)
- XtMapWidget((Widget) m_drawingArea);
- XtMapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- }
- else
- {
- WXWidget topWidget = GetTopWidget();
- if (GetTopWidget())
- XtMapWidget((Widget) GetTopWidget());
- else if (GetMainWidget())
- XtMapWidget((Widget) GetMainWidget());
- }
+ if (m_borderWidget || m_scrolledWindow)
+ {
+ if (m_drawingArea)
+ XtMapWidget((Widget) m_drawingArea);
+ XtMapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ }
+ else
+ {
+ WXWidget topWidget = GetTopWidget();
+ if (GetTopWidget())
+ XtMapWidget((Widget) GetTopWidget());
+ else if (GetMainWidget())
+ XtMapWidget((Widget) GetMainWidget());
+ }
}
else
{
- if (m_borderWidget || m_scrolledWindow)
- {
- if (m_drawingArea)
- XtUnmapWidget((Widget) m_drawingArea);
- XtUnmapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- }
- else
- {
- if (GetTopWidget())
- XtUnmapWidget((Widget) GetTopWidget());
- else if (GetMainWidget())
- XtUnmapWidget((Widget) GetMainWidget());
- }
+ if (m_borderWidget || m_scrolledWindow)
+ {
+ if (m_drawingArea)
+ XtUnmapWidget((Widget) m_drawingArea);
+ XtUnmapWidget(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ }
+ else
+ {
+ if (GetTopWidget())
+ XtUnmapWidget((Widget) GetTopWidget());
+ else if (GetMainWidget())
+ XtUnmapWidget((Widget) GetMainWidget());
+ }
}
-
- /*
+
+ /*
Window xwin = (Window) GetXWindow();
Display *xdisp = (Display*) GetXDisplay();
if (show)
- XMapWindow(xdisp, xwin);
+ XMapWindow(xdisp, xwin);
else
- XUnmapWindow(xdisp, xwin);
- */
-
+ XUnmapWindow(xdisp, xwin);
+ */
+
m_isShown = show;
-
+
return TRUE;
}
int wxWindow::GetCharHeight() const
{
- if (!m_windowFont.Ok())
- return 0;
-
- WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
-
- int direction, ascent, descent;
- XCharStruct overall;
- XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+ if (!m_windowFont.Ok())
+ return 0;
+
+ WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+
+ int direction, ascent, descent;
+ XCharStruct overall;
+ XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
-// return (overall.ascent + overall.descent);
- return (ascent + descent);
+ // return (overall.ascent + overall.descent);
+ return (ascent + descent);
}
int wxWindow::GetCharWidth() const
{
- if (!m_windowFont.Ok())
- return 0;
-
- WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
-
- int direction, ascent, descent;
- XCharStruct overall;
- XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
+ if (!m_windowFont.Ok())
+ return 0;
+
+ WXFontStructPtr pFontStruct = m_windowFont.GetFontStruct(1.0, GetXDisplay());
+
+ int direction, ascent, descent;
+ XCharStruct overall;
+ XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent,
&descent, &overall);
- return overall.width;
+ return overall.width;
}
/* Helper function for 16-bit fonts */
static int str16len(const char *s)
{
- int count = 0;
-
- while (s[0] && s[1]) {
- count++;
- s += 2;
- }
-
- return count;
+ int count = 0;
+
+ while (s[0] && s[1]) {
+ count++;
+ s += 2;
+ }
+
+ return count;
}
void wxWindow::GetTextExtent(const wxString& string, int *x, int *y,
- int *descent, int *externalLeading, const wxFont *theFont, bool use16) const
+ int *descent, int *externalLeading, const wxFont *theFont, bool use16) const
{
- wxFont *fontToUse = (wxFont *)theFont;
- if (!fontToUse)
- fontToUse = (wxFont *) & m_windowFont;
-
- if (!fontToUse->Ok())
- return;
-
- WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
-
- int direction, ascent, descent2;
- XCharStruct overall;
- int slen;
-
- if (use16) slen = str16len(string); else slen = strlen(string);
-
- if (use16)
- XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
- &ascent, &descent2, &overall);
- else
- XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
- &ascent, &descent2, &overall);
-
- *x = (overall.width);
- *y = (ascent + descent2);
- if (descent)
- *descent = descent2;
- if (externalLeading)
- *externalLeading = 0;
+ wxFont *fontToUse = (wxFont *)theFont;
+ if (!fontToUse)
+ fontToUse = (wxFont *) & m_windowFont;
+
+ if (!fontToUse->Ok())
+ return;
+
+ WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay());
+
+ int direction, ascent, descent2;
+ XCharStruct overall;
+ int slen;
+
+ if (use16) slen = str16len(string); else slen = strlen(string);
+
+ if (use16)
+ XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction,
+ &ascent, &descent2, &overall);
+ else
+ XTextExtents((XFontStruct*) pFontStruct, (char*) (const char*) string, slen, &direction,
+ &ascent, &descent2, &overall);
+
+ *x = (overall.width);
+ *y = (ascent + descent2);
+ if (descent)
+ *descent = descent2;
+ if (externalLeading)
+ *externalLeading = 0;
}
void wxWindow::Refresh(bool eraseBack, const wxRect *rect)
{
Display *display = XtDisplay((Widget) GetMainWidget());
Window thisWindow = XtWindow((Widget) GetMainWidget());
-
+
XExposeEvent dummyEvent;
int width, height;
GetSize(&width, &height);
-
+
dummyEvent.type = Expose;
dummyEvent.display = display;
dummyEvent.send_event = True;
dummyEvent.window = thisWindow;
if (rect)
{
- dummyEvent.x = rect->x;
- dummyEvent.y = rect->y;
- dummyEvent.width = rect->width;
- dummyEvent.height = rect->height;
+ dummyEvent.x = rect->x;
+ dummyEvent.y = rect->y;
+ dummyEvent.width = rect->width;
+ dummyEvent.height = rect->height;
}
else
{
- dummyEvent.x = 0;
- dummyEvent.y = 0;
- dummyEvent.width = width;
- dummyEvent.height = height;
+ dummyEvent.x = 0;
+ dummyEvent.y = 0;
+ dummyEvent.width = width;
+ dummyEvent.height = height;
}
dummyEvent.count = 0;
-
+
if (eraseBack)
{
wxClientDC dc(this);
wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID);
dc.SetBackground(backgroundBrush);
if (rect)
- dc.Clear(*rect);
+ dc.Clear(*rect);
else
- dc.Clear();
+ dc.Clear();
}
-
+
XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent);
}
event.m_eventObject = win;
win->GetEventHandler()->ProcessEvent(event2);
}
-
+
node = node->Next();
}
}
void wxWindow::InitDialog()
{
- wxInitDialogEvent event(GetId());
- event.SetEventObject( this );
- GetEventHandler()->ProcessEvent(event);
+ wxInitDialogEvent event(GetId());
+ event.SetEventObject( this );
+ GetEventHandler()->ProcessEvent(event);
}
// Default init dialog behaviour is to transfer data to window
void wxWindow::OnInitDialog(wxInitDialogEvent& event)
{
- TransferDataToWindow();
+ TransferDataToWindow();
}
// Caret manipulation
void wxWindow::CreateCaret(int w, int h)
{
- m_caretWidth = w;
- m_caretHeight = h;
- m_caretEnabled = TRUE;
+ m_caretWidth = w;
+ m_caretHeight = h;
+ m_caretEnabled = TRUE;
}
void wxWindow::CreateCaret(const wxBitmap *WXUNUSED(bitmap))
m_minSizeY = minH;
m_maxSizeX = maxW;
m_maxSizeY = maxH;
-
+
if (!this->IsKindOf(CLASSINFO(wxFrame)))
- return;
-
+ return;
+
wxFrame *frame = (wxFrame *)this;
Widget widget = (Widget) frame->GetShellWidget();
-
+
if (minW > -1)
- XtVaSetValues(widget, XmNminWidth, minW, NULL);
+ XtVaSetValues(widget, XmNminWidth, minW, NULL);
if (minH > -1)
- XtVaSetValues(widget, XmNminHeight, minH, NULL);
+ XtVaSetValues(widget, XmNminHeight, minH, NULL);
if (maxW > -1)
- XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
+ XtVaSetValues(widget, XmNmaxWidth, maxW, NULL);
if (maxH > -1)
- XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
+ XtVaSetValues(widget, XmNmaxHeight, maxH, NULL);
if (incW > -1)
- XtVaSetValues(widget, XmNwidthInc, incW, NULL);
+ XtVaSetValues(widget, XmNwidthInc, incW, NULL);
if (incH > -1)
- XtVaSetValues(widget, XmNheightInc, incH, NULL);
+ XtVaSetValues(widget, XmNheightInc, incH, NULL);
}
void wxWindow::Centre(int direction)
{
- int x, y, width, height, panel_width, panel_height, new_x, new_y;
-
- wxWindow *father = (wxWindow *)GetParent();
- if (!father)
- return;
-
- father->GetClientSize(&panel_width, &panel_height);
- GetSize(&width, &height);
- GetPosition(&x, &y);
-
- new_x = -1;
- new_y = -1;
-
- if (direction & wxHORIZONTAL)
- new_x = (int)((panel_width - width)/2);
-
- if (direction & wxVERTICAL)
- new_y = (int)((panel_height - height)/2);
-
- SetSize(new_x, new_y, -1, -1);
-
+ int x, y, width, height, panel_width, panel_height, new_x, new_y;
+
+ wxWindow *father = (wxWindow *)GetParent();
+ if (!father)
+ return;
+
+ father->GetClientSize(&panel_width, &panel_height);
+ GetSize(&width, &height);
+ GetPosition(&x, &y);
+
+ new_x = -1;
+ new_y = -1;
+
+ if (direction & wxHORIZONTAL)
+ new_x = (int)((panel_width - width)/2);
+
+ if (direction & wxVERTICAL)
+ new_y = (int)((panel_height - height)/2);
+
+ SetSize(new_x, new_y, -1, -1);
+
}
// Coordinates relative to the window
void wxWindow::WarpPointer (int x, int y)
{
- XWarpPointer (XtDisplay((Widget) GetClientWidget()), None, XtWindow((Widget) GetClientWidget()), 0, 0, 0, 0, x, y);
+ XWarpPointer (XtDisplay((Widget) GetClientWidget()), None, XtWindow((Widget) GetClientWidget()), 0, 0, 0, 0, x, y);
}
void wxWindow::OnEraseBackground(wxEraseEvent& event)
return m_scrollPosX;
else
return m_scrollPosY;
-/*
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
+ /*
+ Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+ if (scrollBar)
+ {
int pos;
XtVaGetValues(scrollBar,
- XmNvalue, &pos, NULL);
+ XmNvalue, &pos, NULL);
return pos;
- }
- else
+ }
+ else
return 0;
-*/
+ */
}
// This now returns the whole range, not just the number
// of positions that we can scroll.
int wxWindow::GetScrollRange(int orient) const
{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
+ Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+ if (scrollBar)
+ {
int range;
XtVaGetValues(scrollBar,
XmNmaximum, &range, NULL);
int wxWindow::GetScrollThumb(int orient) const
{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
+ Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+ if (scrollBar)
+ {
int thumb;
XtVaGetValues(scrollBar,
XmNsliderSize, &thumb, NULL);
void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh))
{
- Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
- if (scrollBar)
- {
- XtVaSetValues (scrollBar,
- XmNvalue, pos,
- NULL);
- }
- if (orient == wxHORIZONTAL)
- m_scrollPosX = pos;
- else
- m_scrollPosY = pos;
-
+ Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar);
+ if (scrollBar)
+ {
+ XtVaSetValues (scrollBar,
+ XmNvalue, pos,
+ NULL);
+ }
+ if (orient == wxHORIZONTAL)
+ m_scrollPosX = pos;
+ else
+ m_scrollPosY = pos;
+
}
// New function that will replace some of the above.
void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible,
- int range, bool WXUNUSED(refresh))
+ int range, bool WXUNUSED(refresh))
{
int oldW, oldH;
GetSize(& oldW, & oldH);
-
+
if (range == 0)
- range = 1;
+ range = 1;
if (thumbVisible == 0)
- thumbVisible = 1;
-
+ thumbVisible = 1;
+
if (thumbVisible > range)
- thumbVisible = range;
-
+ thumbVisible = range;
+
// Save the old state to see if it changed
WXWidget oldScrollBar = ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
-
+
if (orient == wxHORIZONTAL)
{
if (thumbVisible == range)
{
if (m_hScrollBar)
- DestroyScrollbar(wxHORIZONTAL);
- }
+ DestroyScrollbar(wxHORIZONTAL);
+ }
else
{
if (!m_hScrollBar)
- CreateScrollbar(wxHORIZONTAL);
+ CreateScrollbar(wxHORIZONTAL);
}
}
if (orient == wxVERTICAL)
if (thumbVisible == range)
{
if (m_vScrollBar)
- DestroyScrollbar(wxVERTICAL);
- }
+ DestroyScrollbar(wxVERTICAL);
+ }
else
{
if (!m_vScrollBar)
- CreateScrollbar(wxVERTICAL);
+ CreateScrollbar(wxVERTICAL);
}
}
WXWidget newScrollBar = ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar );
-
+
if (oldScrollBar != newScrollBar)
{
- // This is important! Without it, scrollbars misbehave
- // badly.
- XtUnrealizeWidget((Widget) m_scrolledWindow);
- XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
- XtRealizeWidget((Widget) m_scrolledWindow);
- XtManageChild((Widget) m_scrolledWindow);
+ // This is important! Without it, scrollbars misbehave
+ // badly.
+ XtUnrealizeWidget((Widget) m_scrolledWindow);
+ XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea);
+ XtRealizeWidget((Widget) m_scrolledWindow);
+ XtManageChild((Widget) m_scrolledWindow);
}
-
+
if (newScrollBar)
- XtVaSetValues((Widget) newScrollBar,
- XmNvalue, pos,
- XmNminimum, 0,
- XmNmaximum, range,
- XmNsliderSize, thumbVisible,
- NULL);
-
+ XtVaSetValues((Widget) newScrollBar,
+ XmNvalue, pos,
+ XmNminimum, 0,
+ XmNmaximum, range,
+ XmNsliderSize, thumbVisible,
+ NULL);
+
if (orient == wxHORIZONTAL)
m_scrollPosX = pos;
else
m_scrollPosY = pos;
-
+
int newW, newH;
GetSize(& newW, & newH);
-
+
// Adjusting scrollbars can resize the canvas accidentally
if (newW != oldW || newH != oldH)
SetSize(-1, -1, oldW, oldH);
// Does a physical scroll
void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect)
{
-// cerr << "Scrolling. delta = " << dx << ", " << dy << endl;
- int x, y, w, h;
- if (rect)
- {
- // Use specified rectangle
- x = rect->x; y = rect->y; w = rect->width; h = rect->height;
- }
- else
- {
- // Use whole client area
- x = 0; y = 0;
- GetClientSize(& w, & h);
- }
-
- int x1 = (dx >= 0) ? x : x - dx ;
- int y1 = (dy >= 0) ? y : y - dy;
- int w1 = w - abs(dx);
- int h1 = h - abs(dy);
- int x2 = (dx >= 0) ? x + dx : x;
- int y2 = (dy >= 0) ? y + dy : y;
-
- wxClientDC dc(this);
-
- dc.SetLogicalFunction (wxCOPY);
-
- Widget widget = (Widget) GetMainWidget();
- Window window = XtWindow(widget);
- Display* display = XtDisplay(widget);
-
- XCopyArea(display, window,
- window, (GC) dc.GetGC(),
- x1, y1,
- w1, h1,
- x2, y2);
-
- dc.SetAutoSetting(TRUE);
- wxBrush brush(GetBackgroundColour(), wxSOLID);
- dc.SetBrush(brush); // ??
-
- // We'll add rectangles to the list of update rectangles
- // according to which bits we've exposed.
- wxList updateRects;
-
- if (dx > 0)
- {
- wxRect *rect = new wxRect;
- rect->x = x;
- rect->y = y;
- rect->width = dx;
- rect->height = h;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- else if (dx < 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x + w + dx;
- rect->y = y;
- rect->width = -dx;
- rect->height = h;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width,
- rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- if (dy > 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x;
- rect->y = y;
- rect->width = w;
- rect->height = dy;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- else if (dy < 0)
- {
- wxRect *rect = new wxRect;
-
- rect->x = x;
- rect->y = y + h + dy;
- rect->width = w;
- rect->height = -dy;
-
- XFillRectangle(display, window,
- (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
-
- rect->x = rect->x;
- rect->y = rect->y;
- rect->width = rect->width;
- rect->height = rect->height;
-
- updateRects.Append((wxObject*) rect);
- }
- dc.SetBrush(wxNullBrush);
-
- // Now send expose events
-
- wxNode* node = updateRects.First();
- while (node)
- {
- wxRect* rect = (wxRect*) node->Data();
- XExposeEvent event;
-
- event.type = Expose;
- event.display = display;
- event.send_event = True;
- event.window = window;
-
- event.x = rect->x;
- event.y = rect->y;
- event.width = rect->width;
- event.height = rect->height;
-
- event.count = 0;
-
- XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
-
- node = node->Next();
-
- }
-
- // Delete the update rects
- node = updateRects.First();
- while (node)
- {
- wxRect* rect = (wxRect*) node->Data();
- delete rect;
- node = node->Next();
- }
-
+ // cerr << "Scrolling. delta = " << dx << ", " << dy << endl;
+ int x, y, w, h;
+ if (rect)
+ {
+ // Use specified rectangle
+ x = rect->x; y = rect->y; w = rect->width; h = rect->height;
+ }
+ else
+ {
+ // Use whole client area
+ x = 0; y = 0;
+ GetClientSize(& w, & h);
+ }
+
+ int x1 = (dx >= 0) ? x : x - dx ;
+ int y1 = (dy >= 0) ? y : y - dy;
+ int w1 = w - abs(dx);
+ int h1 = h - abs(dy);
+ int x2 = (dx >= 0) ? x + dx : x;
+ int y2 = (dy >= 0) ? y + dy : y;
+
+ wxClientDC dc(this);
+
+ dc.SetLogicalFunction (wxCOPY);
+
+ Widget widget = (Widget) GetMainWidget();
+ Window window = XtWindow(widget);
+ Display* display = XtDisplay(widget);
+
+ XCopyArea(display, window,
+ window, (GC) dc.GetGC(),
+ x1, y1,
+ w1, h1,
+ x2, y2);
+
+ dc.SetAutoSetting(TRUE);
+ wxBrush brush(GetBackgroundColour(), wxSOLID);
+ dc.SetBrush(brush); // ??
+
+ // We'll add rectangles to the list of update rectangles
+ // according to which bits we've exposed.
+ wxList updateRects;
+
+ if (dx > 0)
+ {
+ wxRect *rect = new wxRect;
+ rect->x = x;
+ rect->y = y;
+ rect->width = dx;
+ rect->height = h;
+
+ XFillRectangle(display, window,
+ (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+ rect->x = rect->x;
+ rect->y = rect->y;
+ rect->width = rect->width;
+ rect->height = rect->height;
+
+ updateRects.Append((wxObject*) rect);
+ }
+ else if (dx < 0)
+ {
+ wxRect *rect = new wxRect;
+
+ rect->x = x + w + dx;
+ rect->y = y;
+ rect->width = -dx;
+ rect->height = h;
+
+ XFillRectangle(display, window,
+ (GC) dc.GetGC(), rect->x, rect->y, rect->width,
+ rect->height);
+
+ rect->x = rect->x;
+ rect->y = rect->y;
+ rect->width = rect->width;
+ rect->height = rect->height;
+
+ updateRects.Append((wxObject*) rect);
+ }
+ if (dy > 0)
+ {
+ wxRect *rect = new wxRect;
+
+ rect->x = x;
+ rect->y = y;
+ rect->width = w;
+ rect->height = dy;
+
+ XFillRectangle(display, window,
+ (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+ rect->x = rect->x;
+ rect->y = rect->y;
+ rect->width = rect->width;
+ rect->height = rect->height;
+
+ updateRects.Append((wxObject*) rect);
+ }
+ else if (dy < 0)
+ {
+ wxRect *rect = new wxRect;
+
+ rect->x = x;
+ rect->y = y + h + dy;
+ rect->width = w;
+ rect->height = -dy;
+
+ XFillRectangle(display, window,
+ (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height);
+
+ rect->x = rect->x;
+ rect->y = rect->y;
+ rect->width = rect->width;
+ rect->height = rect->height;
+
+ updateRects.Append((wxObject*) rect);
+ }
+ dc.SetBrush(wxNullBrush);
+
+ // Now send expose events
+
+ wxNode* node = updateRects.First();
+ while (node)
+ {
+ wxRect* rect = (wxRect*) node->Data();
+ XExposeEvent event;
+
+ event.type = Expose;
+ event.display = display;
+ event.send_event = True;
+ event.window = window;
+
+ event.x = rect->x;
+ event.y = rect->y;
+ event.width = rect->width;
+ event.height = rect->height;
+
+ event.count = 0;
+
+ XSendEvent(display, window, False, ExposureMask, (XEvent *)&event);
+
+ node = node->Next();
+
+ }
+
+ // Delete the update rects
+ node = updateRects.First();
+ while (node)
+ {
+ wxRect* rect = (wxRect*) node->Data();
+ delete rect;
+ node = node->Next();
+ }
+
}
void wxWindow::OnChar(wxKeyEvent& event)
{
/* ??
- if ( event.KeyCode() == WXK_TAB ) {
- // propagate the TABs to the parent - it's up to it to decide what
- // to do with it
- if ( GetParent() ) {
- if ( GetParent()->ProcessEvent(event) )
- return;
- }
- }
-*/
+if ( event.KeyCode() == WXK_TAB ) {
+// propagate the TABs to the parent - it's up to it to decide what
+// to do with it
+if ( GetParent() ) {
+if ( GetParent()->ProcessEvent(event) )
+return;
+}
+}
+ */
}
void wxWindow::OnKeyDown(wxKeyEvent& event)
void wxWindow::OnPaint(wxPaintEvent& event)
{
- Default();
+ Default();
}
bool wxWindow::IsEnabled() const
// it's an application error (pops up a dialog)
bool wxWindow::TransferDataToWindow()
{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() &&
- !child->GetValidator()->TransferToWindow() )
- {
- wxMessageBox("Application Error", "Could not transfer data to window", wxOK|wxICON_EXCLAMATION);
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ if ( child->GetValidator() &&
+ !child->GetValidator()->TransferToWindow() )
+ {
+ wxLogError("Could not transfer data to window.");
+ return FALSE;
+ }
+
+ node = node->Next();
+ }
+ return TRUE;
}
// Transfer values from controls. If returns FALSE,
// validation failed: don't quit
bool wxWindow::TransferDataFromWindow()
{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && !child->GetValidator()->TransferFromWindow() )
- {
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ if ( child->GetValidator() && !child->GetValidator()->TransferFromWindow() )
+ {
+ return FALSE;
+ }
+
+ node = node->Next();
+ }
+ return TRUE;
}
bool wxWindow::Validate()
{
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) )
- {
- return FALSE;
- }
-
- node = node->Next();
- }
- return TRUE;
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ if ( child->GetValidator() && /* child->GetValidator()->Ok() && */ !child->GetValidator()->Validate(this) )
+ {
+ return FALSE;
+ }
+
+ node = node->Next();
+ }
+ return TRUE;
}
// Get the window with the focus
wxNode *node = GetChildren().First();
while (node)
{
- wxNode* next = node->Next();
- wxWindow* child = (wxWindow*) node->Data();
- delete child;
- node = next;
+ wxNode* next = node->Next();
+ wxWindow* child = (wxWindow*) node->Data();
+ delete child;
+ node = next;
}
GetChildren().Clear();
#if 0
wxNode *node;
while ((node = GetChildren().First()) != (wxNode *)NULL) {
- wxWindow *child;
- if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
- delete child;
- if ( GetChildren().Member(child) )
- delete node;
- }
+ wxWindow *child;
+ if ((child = (wxWindow *)node->Data()) != (wxWindow *)NULL) {
+ delete child;
+ if ( GetChildren().Member(child) )
+ delete node;
+ }
} /* while */
#endif
}
void wxWindow::MakeModal(bool modal)
{
- // Disable all other windows
- if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
- {
- wxNode *node = wxTopLevelWindows.First();
- while (node)
+ // Disable all other windows
+ if (this->IsKindOf(CLASSINFO(wxDialog)) || this->IsKindOf(CLASSINFO(wxFrame)))
{
- wxWindow *win = (wxWindow *)node->Data();
- if (win != this)
- win->Enable(!modal);
-
- node = node->Next();
+ wxNode *node = wxTopLevelWindows.First();
+ while (node)
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ if (win != this)
+ win->Enable(!modal);
+
+ node = node->Next();
+ }
}
- }
}
// If nothing defined for this, try the parent.
// defined.
void wxWindow::OnCommand(wxWindow& win, wxCommandEvent& event)
{
- if (GetEventHandler()->ProcessEvent(event) )
- return;
- if (m_windowParent)
- m_windowParent->GetEventHandler()->OnCommand(win, event);
+ if (GetEventHandler()->ProcessEvent(event) )
+ return;
+ if (m_windowParent)
+ m_windowParent->GetEventHandler()->OnCommand(win, event);
}
void wxWindow::SetConstraints(wxLayoutConstraints *c)
{
- if (m_constraints)
- {
- UnsetConstraints(m_constraints);
- delete m_constraints;
- }
- m_constraints = c;
- if (m_constraints)
- {
- // Make sure other windows know they're part of a 'meaningful relationship'
- if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
- m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
- m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
- m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
- m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
- m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
- m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
- m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
- m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
- }
+ if (m_constraints)
+ {
+ UnsetConstraints(m_constraints);
+ delete m_constraints;
+ }
+ m_constraints = c;
+ if (m_constraints)
+ {
+ // Make sure other windows know they're part of a 'meaningful relationship'
+ if (m_constraints->left.GetOtherWindow() && (m_constraints->left.GetOtherWindow() != this))
+ m_constraints->left.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->top.GetOtherWindow() && (m_constraints->top.GetOtherWindow() != this))
+ m_constraints->top.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->right.GetOtherWindow() && (m_constraints->right.GetOtherWindow() != this))
+ m_constraints->right.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->bottom.GetOtherWindow() && (m_constraints->bottom.GetOtherWindow() != this))
+ m_constraints->bottom.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->width.GetOtherWindow() && (m_constraints->width.GetOtherWindow() != this))
+ m_constraints->width.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->height.GetOtherWindow() && (m_constraints->height.GetOtherWindow() != this))
+ m_constraints->height.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->centreX.GetOtherWindow() && (m_constraints->centreX.GetOtherWindow() != this))
+ m_constraints->centreX.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ if (m_constraints->centreY.GetOtherWindow() && (m_constraints->centreY.GetOtherWindow() != this))
+ m_constraints->centreY.GetOtherWindow()->AddConstraintReference((wxWindow *)this);
+ }
}
// This removes any dangling pointers to this window
// in other windows' constraintsInvolvedIn lists.
void wxWindow::UnsetConstraints(wxLayoutConstraints *c)
{
- if (c)
- {
- if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
- c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
- c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
- c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
- c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
- c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
- c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
- c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
- }
+ if (c)
+ {
+ if (c->left.GetOtherWindow() && (c->top.GetOtherWindow() != this))
+ c->left.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->top.GetOtherWindow() && (c->top.GetOtherWindow() != this))
+ c->top.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->right.GetOtherWindow() && (c->right.GetOtherWindow() != this))
+ c->right.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->bottom.GetOtherWindow() && (c->bottom.GetOtherWindow() != this))
+ c->bottom.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->width.GetOtherWindow() && (c->width.GetOtherWindow() != this))
+ c->width.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->height.GetOtherWindow() && (c->height.GetOtherWindow() != this))
+ c->height.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->centreX.GetOtherWindow() && (c->centreX.GetOtherWindow() != this))
+ c->centreX.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ if (c->centreY.GetOtherWindow() && (c->centreY.GetOtherWindow() != this))
+ c->centreY.GetOtherWindow()->RemoveConstraintReference((wxWindow *)this);
+ }
}
// Back-pointer to other windows we're involved with, so if we delete
// this window, we must delete any constraints we're involved with.
void wxWindow::AddConstraintReference(wxWindow *otherWin)
{
- if (!m_constraintsInvolvedIn)
- m_constraintsInvolvedIn = new wxList;
- if (!m_constraintsInvolvedIn->Member(otherWin))
- m_constraintsInvolvedIn->Append(otherWin);
+ if (!m_constraintsInvolvedIn)
+ m_constraintsInvolvedIn = new wxList;
+ if (!m_constraintsInvolvedIn->Member(otherWin))
+ m_constraintsInvolvedIn->Append(otherWin);
}
// REMOVE back-pointer to other windows we're involved with.
void wxWindow::RemoveConstraintReference(wxWindow *otherWin)
{
- if (m_constraintsInvolvedIn)
- m_constraintsInvolvedIn->DeleteObject(otherWin);
+ if (m_constraintsInvolvedIn)
+ m_constraintsInvolvedIn->DeleteObject(otherWin);
}
// Reset any constraints that mention this window
void wxWindow::DeleteRelatedConstraints()
{
- if (m_constraintsInvolvedIn)
- {
- wxNode *node = m_constraintsInvolvedIn->First();
- while (node)
+ if (m_constraintsInvolvedIn)
{
- wxWindow *win = (wxWindow *)node->Data();
- wxNode *next = node->Next();
- wxLayoutConstraints *constr = win->GetConstraints();
-
- // Reset any constraints involving this window
- if (constr)
- {
- constr->left.ResetIfWin((wxWindow *)this);
- constr->top.ResetIfWin((wxWindow *)this);
- constr->right.ResetIfWin((wxWindow *)this);
- constr->bottom.ResetIfWin((wxWindow *)this);
- constr->width.ResetIfWin((wxWindow *)this);
- constr->height.ResetIfWin((wxWindow *)this);
- constr->centreX.ResetIfWin((wxWindow *)this);
- constr->centreY.ResetIfWin((wxWindow *)this);
- }
- delete node;
- node = next;
+ wxNode *node = m_constraintsInvolvedIn->First();
+ while (node)
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ wxNode *next = node->Next();
+ wxLayoutConstraints *constr = win->GetConstraints();
+
+ // Reset any constraints involving this window
+ if (constr)
+ {
+ constr->left.ResetIfWin((wxWindow *)this);
+ constr->top.ResetIfWin((wxWindow *)this);
+ constr->right.ResetIfWin((wxWindow *)this);
+ constr->bottom.ResetIfWin((wxWindow *)this);
+ constr->width.ResetIfWin((wxWindow *)this);
+ constr->height.ResetIfWin((wxWindow *)this);
+ constr->centreX.ResetIfWin((wxWindow *)this);
+ constr->centreY.ResetIfWin((wxWindow *)this);
+ }
+ delete node;
+ node = next;
+ }
+ delete m_constraintsInvolvedIn;
+ m_constraintsInvolvedIn = NULL;
}
- delete m_constraintsInvolvedIn;
- m_constraintsInvolvedIn = NULL;
- }
}
void wxWindow::SetSizer(wxSizer *sizer)
{
- m_windowSizer = sizer;
- if (sizer)
- sizer->SetSizerParent((wxWindow *)this);
+ m_windowSizer = sizer;
+ if (sizer)
+ sizer->SetSizerParent((wxWindow *)this);
}
/*
- * New version
- */
+* New version
+*/
bool wxWindow::Layout()
{
- if (GetConstraints())
- {
- int w, h;
- GetClientSize(&w, &h);
- GetConstraints()->width.SetValue(w);
- GetConstraints()->height.SetValue(h);
- }
-
- // If top level (one sizer), evaluate the sizer's constraints.
- if (GetSizer())
- {
- int noChanges;
- GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
- GetSizer()->LayoutPhase1(&noChanges);
- GetSizer()->LayoutPhase2(&noChanges);
- GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
- return TRUE;
- }
- else
- {
- // Otherwise, evaluate child constraints
- ResetConstraints(); // Mark all constraints as unevaluated
- DoPhase(1); // Just one phase need if no sizers involved
- DoPhase(2);
- SetConstraintSizes(); // Recursively set the real window sizes
- }
- return TRUE;
+ if (GetConstraints())
+ {
+ int w, h;
+ GetClientSize(&w, &h);
+ GetConstraints()->width.SetValue(w);
+ GetConstraints()->height.SetValue(h);
+ }
+
+ // If top level (one sizer), evaluate the sizer's constraints.
+ if (GetSizer())
+ {
+ int noChanges;
+ GetSizer()->ResetConstraints(); // Mark all constraints as unevaluated
+ GetSizer()->LayoutPhase1(&noChanges);
+ GetSizer()->LayoutPhase2(&noChanges);
+ GetSizer()->SetConstraintSizes(); // Recursively set the real window sizes
+ return TRUE;
+ }
+ else
+ {
+ // Otherwise, evaluate child constraints
+ ResetConstraints(); // Mark all constraints as unevaluated
+ DoPhase(1); // Just one phase need if no sizers involved
+ DoPhase(2);
+ SetConstraintSizes(); // Recursively set the real window sizes
+ }
+ return TRUE;
}
// and order the evaluation differently.
bool wxWindow::LayoutPhase1(int *noChanges)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- return constr->SatisfyConstraints((wxWindow *)this, noChanges);
- }
- else
- return TRUE;
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ return constr->SatisfyConstraints((wxWindow *)this, noChanges);
+ }
+ else
+ return TRUE;
}
bool wxWindow::LayoutPhase2(int *noChanges)
{
- *noChanges = 0;
-
- // Layout children
- DoPhase(1);
- DoPhase(2);
- return TRUE;
+ *noChanges = 0;
+
+ // Layout children
+ DoPhase(1);
+ DoPhase(2);
+ return TRUE;
}
// Do a phase of evaluating child constraints
bool wxWindow::DoPhase(int phase)
{
- int noIterations = 0;
- int maxIterations = 500;
- int noChanges = 1;
- int noFailures = 0;
- wxList succeeded;
- while ((noChanges > 0) && (noIterations < maxIterations))
- {
- noChanges = 0;
- noFailures = 0;
- wxNode *node = GetChildren().First();
- while (node)
+ int noIterations = 0;
+ int maxIterations = 500;
+ int noChanges = 1;
+ int noFailures = 0;
+ wxList succeeded;
+ while ((noChanges > 0) && (noIterations < maxIterations))
{
- wxWindow *child = (wxWindow *)node->Data();
- if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
- {
- wxLayoutConstraints *constr = child->GetConstraints();
- if (constr)
+ noChanges = 0;
+ noFailures = 0;
+ wxNode *node = GetChildren().First();
+ while (node)
{
- if (succeeded.Member(child))
- {
- }
- else
- {
- int tempNoChanges = 0;
- bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
- noChanges += tempNoChanges;
- if (success)
+ wxWindow *child = (wxWindow *)node->Data();
+ if (!child->IsKindOf(CLASSINFO(wxFrame)) && !child->IsKindOf(CLASSINFO(wxDialog)))
{
- succeeded.Append(child);
+ wxLayoutConstraints *constr = child->GetConstraints();
+ if (constr)
+ {
+ if (succeeded.Member(child))
+ {
+ }
+ else
+ {
+ int tempNoChanges = 0;
+ bool success = ( (phase == 1) ? child->LayoutPhase1(&tempNoChanges) : child->LayoutPhase2(&tempNoChanges) ) ;
+ noChanges += tempNoChanges;
+ if (success)
+ {
+ succeeded.Append(child);
+ }
+ }
+ }
}
- }
+ node = node->Next();
}
- }
- node = node->Next();
+ noIterations ++;
}
- noIterations ++;
- }
- return TRUE;
+ return TRUE;
}
void wxWindow::ResetConstraints()
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- constr->left.SetDone(FALSE);
- constr->top.SetDone(FALSE);
- constr->right.SetDone(FALSE);
- constr->bottom.SetDone(FALSE);
- constr->width.SetDone(FALSE);
- constr->height.SetDone(FALSE);
- constr->centreX.SetDone(FALSE);
- constr->centreY.SetDone(FALSE);
- }
- wxNode *node = GetChildren().First();
- while (node)
- {
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->ResetConstraints();
- node = node->Next();
- }
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ constr->left.SetDone(FALSE);
+ constr->top.SetDone(FALSE);
+ constr->right.SetDone(FALSE);
+ constr->bottom.SetDone(FALSE);
+ constr->width.SetDone(FALSE);
+ constr->height.SetDone(FALSE);
+ constr->centreX.SetDone(FALSE);
+ constr->centreY.SetDone(FALSE);
+ }
+ wxNode *node = GetChildren().First();
+ while (node)
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
+ win->ResetConstraints();
+ node = node->Next();
+ }
}
// Need to distinguish between setting the 'fake' size for
// windows and sizers, and setting the real values.
void wxWindow::SetConstraintSizes(bool recurse)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr && constr->left.GetDone() && constr->right.GetDone() &&
- constr->width.GetDone() && constr->height.GetDone())
- {
- int x = constr->left.GetValue();
- int y = constr->top.GetValue();
- int w = constr->width.GetValue();
- int h = constr->height.GetValue();
-
- // If we don't want to resize this window, just move it...
- if ((constr->width.GetRelationship() != wxAsIs) ||
- (constr->height.GetRelationship() != wxAsIs))
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr && constr->left.GetDone() && constr->right.GetDone() &&
+ constr->width.GetDone() && constr->height.GetDone())
{
- // Calls Layout() recursively. AAAGH. How can we stop that.
- // Simply take Layout() out of non-top level OnSizes.
- SizerSetSize(x, y, w, h);
+ int x = constr->left.GetValue();
+ int y = constr->top.GetValue();
+ int w = constr->width.GetValue();
+ int h = constr->height.GetValue();
+
+ // If we don't want to resize this window, just move it...
+ if ((constr->width.GetRelationship() != wxAsIs) ||
+ (constr->height.GetRelationship() != wxAsIs))
+ {
+ // Calls Layout() recursively. AAAGH. How can we stop that.
+ // Simply take Layout() out of non-top level OnSizes.
+ SizerSetSize(x, y, w, h);
+ }
+ else
+ {
+ SizerMove(x, y);
+ }
}
- else
+ else if (constr)
{
- SizerMove(x, y);
+ char *windowClass = this->GetClassInfo()->GetClassName();
+
+ wxString winName;
+ if (GetName() == "")
+ winName = "unnamed";
+ else
+ winName = GetName();
+ wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName);
+ if (!constr->left.GetDone())
+ wxDebugMsg(" unsatisfied 'left' constraint.\n");
+ if (!constr->right.GetDone())
+ wxDebugMsg(" unsatisfied 'right' constraint.\n");
+ if (!constr->width.GetDone())
+ wxDebugMsg(" unsatisfied 'width' constraint.\n");
+ if (!constr->height.GetDone())
+ wxDebugMsg(" unsatisfied 'height' constraint.\n");
+ wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
}
- }
- else if (constr)
- {
- char *windowClass = this->GetClassInfo()->GetClassName();
-
- wxString winName;
- if (GetName() == "")
- winName = "unnamed";
- else
- winName = GetName();
- wxDebugMsg("Constraint(s) not satisfied for window of type %s, name %s:\n", (const char *)windowClass, (const char *)winName);
- if (!constr->left.GetDone())
- wxDebugMsg(" unsatisfied 'left' constraint.\n");
- if (!constr->right.GetDone())
- wxDebugMsg(" unsatisfied 'right' constraint.\n");
- if (!constr->width.GetDone())
- wxDebugMsg(" unsatisfied 'width' constraint.\n");
- if (!constr->height.GetDone())
- wxDebugMsg(" unsatisfied 'height' constraint.\n");
- wxDebugMsg("Please check constraints: try adding AsIs() constraints.\n");
- }
-
- if (recurse)
- {
- wxNode *node = GetChildren().First();
- while (node)
+
+ if (recurse)
{
- wxWindow *win = (wxWindow *)node->Data();
- if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
- win->SetConstraintSizes();
- node = node->Next();
+ wxNode *node = GetChildren().First();
+ while (node)
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ if (!win->IsKindOf(CLASSINFO(wxFrame)) && !win->IsKindOf(CLASSINFO(wxDialog)))
+ win->SetConstraintSizes();
+ node = node->Next();
+ }
}
- }
}
// This assumes that all sizers are 'on' the same
// window, i.e. the parent of this window.
void wxWindow::TransformSizerToActual(int *x, int *y) const
{
- if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
- m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
- return;
+ if (!m_sizerParent || m_sizerParent->IsKindOf(CLASSINFO(wxDialog)) ||
+ m_sizerParent->IsKindOf(CLASSINFO(wxFrame)) )
+ return;
- int xp, yp;
- m_sizerParent->GetPosition(&xp, &yp);
- m_sizerParent->TransformSizerToActual(&xp, &yp);
- *x += xp;
- *y += yp;
+ int xp, yp;
+ m_sizerParent->GetPosition(&xp, &yp);
+ m_sizerParent->TransformSizerToActual(&xp, &yp);
+ *x += xp;
+ *y += yp;
}
void wxWindow::SizerSetSize(int x, int y, int w, int h)
{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- SetSize(xx, yy, w, h);
+ int xx = x;
+ int yy = y;
+ TransformSizerToActual(&xx, &yy);
+ SetSize(xx, yy, w, h);
}
void wxWindow::SizerMove(int x, int y)
{
- int xx = x;
- int yy = y;
- TransformSizerToActual(&xx, &yy);
- Move(xx, yy);
+ int xx = x;
+ int yy = y;
+ TransformSizerToActual(&xx, &yy);
+ Move(xx, yy);
}
// Only set the size/position of the constraint (if any)
void wxWindow::SetSizeConstraint(int x, int y, int w, int h)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
{
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
- }
- if (w != -1)
- {
- constr->width.SetValue(w);
- constr->width.SetDone(TRUE);
- }
- if (h != -1)
- {
- constr->height.SetValue(h);
- constr->height.SetDone(TRUE);
+ if (x != -1)
+ {
+ constr->left.SetValue(x);
+ constr->left.SetDone(TRUE);
+ }
+ if (y != -1)
+ {
+ constr->top.SetValue(y);
+ constr->top.SetDone(TRUE);
+ }
+ if (w != -1)
+ {
+ constr->width.SetValue(w);
+ constr->width.SetDone(TRUE);
+ }
+ if (h != -1)
+ {
+ constr->height.SetValue(h);
+ constr->height.SetDone(TRUE);
+ }
}
- }
}
void wxWindow::MoveConstraint(int x, int y)
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- if (x != -1)
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
{
- constr->left.SetValue(x);
- constr->left.SetDone(TRUE);
- }
- if (y != -1)
- {
- constr->top.SetValue(y);
- constr->top.SetDone(TRUE);
+ if (x != -1)
+ {
+ constr->left.SetValue(x);
+ constr->left.SetDone(TRUE);
+ }
+ if (y != -1)
+ {
+ constr->top.SetValue(y);
+ constr->top.SetDone(TRUE);
+ }
}
- }
}
void wxWindow::GetSizeConstraint(int *w, int *h) const
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetSize(w, h);
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ *w = constr->width.GetValue();
+ *h = constr->height.GetValue();
+ }
+ else
+ GetSize(w, h);
}
void wxWindow::GetClientSizeConstraint(int *w, int *h) const
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *w = constr->width.GetValue();
- *h = constr->height.GetValue();
- }
- else
- GetClientSize(w, h);
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ *w = constr->width.GetValue();
+ *h = constr->height.GetValue();
+ }
+ else
+ GetClientSize(w, h);
}
void wxWindow::GetPositionConstraint(int *x, int *y) const
{
- wxLayoutConstraints *constr = GetConstraints();
- if (constr)
- {
- *x = constr->left.GetValue();
- *y = constr->top.GetValue();
- }
- else
- GetPosition(x, y);
+ wxLayoutConstraints *constr = GetConstraints();
+ if (constr)
+ {
+ *x = constr->left.GetValue();
+ *y = constr->top.GetValue();
+ }
+ else
+ GetPosition(x, y);
}
bool wxWindow::Close(bool force)
{
- wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
- event.SetEventObject(this);
- event.SetForce(force);
-
- return GetEventHandler()->ProcessEvent(event);
+ wxCloseEvent event(wxEVT_CLOSE_WINDOW, m_windowId);
+ event.SetEventObject(this);
+ event.SetForce(force);
+
+ return GetEventHandler()->ProcessEvent(event);
}
wxObject* wxWindow::GetChild(int number) const
{
- // Return a pointer to the Nth object in the window
- wxNode *node = GetChildren().First();
- int n = number;
- while (node && n--)
- node = node->Next() ;
- if (node)
- {
- wxObject *obj = (wxObject *)node->Data();
- return(obj) ;
- }
- else
- return NULL ;
+ // Return a pointer to the Nth object in the window
+ wxNode *node = GetChildren().First();
+ int n = number;
+ while (node && n--)
+ node = node->Next() ;
+ if (node)
+ {
+ wxObject *obj = (wxObject *)node->Data();
+ return(obj) ;
+ }
+ else
+ return NULL ;
}
void wxWindow::OnDefaultAction(wxControl *initiatingItem)
// Fits the panel around the items
void wxWindow::Fit()
{
- int maxX = 0;
- int maxY = 0;
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *win = (wxWindow *)node->Data();
- int wx, wy, ww, wh;
- win->GetPosition(&wx, &wy);
- win->GetSize(&ww, &wh);
- if ( wx + ww > maxX )
- maxX = wx + ww;
- if ( wy + wh > maxY )
- maxY = wy + wh;
-
- node = node->Next();
- }
- SetClientSize(maxX + 5, maxY + 5);
+ int maxX = 0;
+ int maxY = 0;
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *win = (wxWindow *)node->Data();
+ int wx, wy, ww, wh;
+ win->GetPosition(&wx, &wy);
+ win->GetSize(&ww, &wh);
+ if ( wx + ww > maxX )
+ maxX = wx + ww;
+ if ( wy + wh > maxY )
+ maxY = wy + wh;
+
+ node = node->Next();
+ }
+ SetClientSize(maxX + 5, maxY + 5);
}
void wxWindow::SetValidator(const wxValidator& validator)
{
- if ( m_windowValidator )
- delete m_windowValidator;
- m_windowValidator = validator.Clone();
-
- if ( m_windowValidator )
- m_windowValidator->SetWindow(this) ;
+ if ( m_windowValidator )
+ delete m_windowValidator;
+ m_windowValidator = validator.Clone();
+
+ if ( m_windowValidator )
+ m_windowValidator->SetWindow(this) ;
}
void wxWindow::SetClientObject( wxClientData *data )
{
- if (m_clientObject) delete m_clientObject;
- m_clientObject = data;
+ if (m_clientObject) delete m_clientObject;
+ m_clientObject = data;
}
wxClientData *wxWindow::GetClientObject()
{
- return m_clientObject;
+ return m_clientObject;
}
void wxWindow::SetClientData( void *data )
{
- m_clientData = data;
+ m_clientData = data;
}
void *wxWindow::GetClientData()
{
- return m_clientData;
+ return m_clientData;
}
// Find a window by id or name
wxWindow *wxWindow::FindWindow(long id)
{
- if ( GetId() == id)
- return this;
-
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- wxWindow *found = child->FindWindow(id);
- if ( found )
- return found;
- node = node->Next();
- }
- return NULL;
+ if ( GetId() == id)
+ return this;
+
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ wxWindow *found = child->FindWindow(id);
+ if ( found )
+ return found;
+ node = node->Next();
+ }
+ return NULL;
}
wxWindow *wxWindow::FindWindow(const wxString& name)
{
- if ( GetName() == name)
- return this;
-
- wxNode *node = GetChildren().First();
- while ( node )
- {
- wxWindow *child = (wxWindow *)node->Data();
- wxWindow *found = child->FindWindow(name);
- if ( found )
- return found;
- node = node->Next();
- }
- return NULL;
+ if ( GetName() == name)
+ return this;
+
+ wxNode *node = GetChildren().First();
+ while ( node )
+ {
+ wxWindow *child = (wxWindow *)node->Data();
+ wxWindow *found = child->FindWindow(name);
+ if ( found )
+ return found;
+ node = node->Next();
+ }
+ return NULL;
}
void wxWindow::OnIdle(wxIdleEvent& event)
bool wxWindow::AcceptsFocus() const
{
- return IsShown() && IsEnabled();
+ return IsShown() && IsEnabled();
}
// Update region access
}
/*
- * Allocates control IDs
- */
+* Allocates control IDs
+*/
int wxWindow::NewControlId()
{
wxWindow *win = (wxWindow *)wxWidgetHashTable->Get((long)w);
if (!win)
return;
-
+
if (win->PreResize())
{
int width, height;
bool wxAddWindowToTable(Widget w, wxWindow *win)
{
- wxWindow *oldItem = NULL;
-// printf("Adding widget %ld, name = %s\n", w, win->GetClassInfo()->GetClassName());
- if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w)))
- {
- wxLogError("Widget table clash: new widget is %ld, %s", (long)w, win->GetClassInfo()->GetClassName());
- return FALSE;
- }
-
- wxWidgetHashTable->Put ((long) w, win);
- return TRUE;
+ wxWindow *oldItem = NULL;
+ // printf("Adding widget %ld, name = %s\n", w, win->GetClassInfo()->GetClassName());
+ if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w)))
+ {
+ wxLogError("Widget table clash: new widget is %ld, %s", (long)w, win->GetClassInfo()->GetClassName());
+ return FALSE;
+ }
+
+ wxWidgetHashTable->Put ((long) w, win);
+ return TRUE;
}
wxWindow *wxGetWindowFromTable(Widget w)
{
- return (wxWindow *)wxWidgetHashTable->Get ((long) w);
+ return (wxWindow *)wxWidgetHashTable->Get ((long) w);
}
void wxDeleteWindowFromTable(Widget w)
{
- wxWidgetHashTable->Delete((long)w);
+ wxWidgetHashTable->Delete((long)w);
}
-
+
// Get the underlying X window and display
WXWindow wxWindow::GetXWindow() const
{
WXWidget wxWindow::GetMainWidget() const
{
if (m_drawingArea)
- return m_drawingArea;
+ return m_drawingArea;
else
- return m_mainWidget;
+ return m_mainWidget;
}
WXWidget wxWindow::GetClientWidget() const
}
void wxCanvasRepaintProc (Widget drawingArea, XtPointer clientData,
- XmDrawingAreaCallbackStruct * cbs)
+ XmDrawingAreaCallbackStruct * cbs)
{
if (!wxWidgetHashTable->Get ((long) (Widget) drawingArea))
- return;
-
+ return;
+
XEvent * event = cbs->event;
wxWindow * win = (wxWindow *) clientData;
Display * display = (Display *) win->GetXDisplay();
-
+
switch (event->type)
{
- case Expose:
+ case Expose:
{
wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
- event->xexpose.width, event->xexpose.height);
- /*
- cout << "Expose proc. wxRect: " << rect->x << ", " << rect->y << ", ";
- cout << rect->width << ", " << rect->height << "\n\n";
- */
-
+ event->xexpose.width, event->xexpose.height);
+ /*
+ cout << "Expose proc. wxRect: " << rect->x << ", " << rect->y << ", ";
+ cout << rect->width << ", " << rect->height << "\n\n";
+ */
+
win->m_updateRects.Append((wxObject*) rect);
-
+
if (event -> xexpose.count == 0)
{
wxPaintEvent event(win->GetId());
event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event);
-
+
win->ClearUpdateRects();
}
break;
}
- default:
+ default:
{
- cout << "\n\nNew Event ! is = " << event -> type << "\n";
- break;
+ cout << "\n\nNew Event ! is = " << event -> type << "\n";
+ break;
}
}
}
void
wxCanvasEnterLeave (Widget drawingArea, XtPointer clientData, XCrossingEvent * event)
{
- XmDrawingAreaCallbackStruct cbs;
- XEvent ev;
-
- //if (event->mode!=NotifyNormal)
- // return ;
-
-// ev = *((XEvent *) event); // Causes Purify error (copying too many bytes)
- ((XCrossingEvent &) ev) = *event;
-
- cbs.reason = XmCR_INPUT;
- cbs.event = &ev;
-
- wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs);
+ XmDrawingAreaCallbackStruct cbs;
+ XEvent ev;
+
+ //if (event->mode!=NotifyNormal)
+ // return ;
+
+ // ev = *((XEvent *) event); // Causes Purify error (copying too many bytes)
+ ((XCrossingEvent &) ev) = *event;
+
+ cbs.reason = XmCR_INPUT;
+ cbs.event = &ev;
+
+ wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs);
}
// Fix to make it work under Motif 1.0 (!)
void wxCanvasMotionEvent (Widget drawingArea, XButtonEvent * event)
{
#if XmVersion<=1000
-
- XmDrawingAreaCallbackStruct cbs;
- XEvent ev;
-
- //ev.xbutton = *event;
- ev = *((XEvent *) event);
- cbs.reason = XmCR_INPUT;
- cbs.event = &ev;
-
- wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs);
+
+ XmDrawingAreaCallbackStruct cbs;
+ XEvent ev;
+
+ //ev.xbutton = *event;
+ ev = *((XEvent *) event);
+ cbs.reason = XmCR_INPUT;
+ cbs.event = &ev;
+
+ wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs);
#endif
}
void wxCanvasInputEvent (Widget drawingArea, XtPointer data, XmDrawingAreaCallbackStruct * cbs)
{
- wxWindow *canvas = (wxWindow *) wxWidgetHashTable->Get ((long) (Widget) drawingArea);
- XEvent local_event;
-
- if (canvas==NULL)
- return ;
-
- if (cbs->reason != XmCR_INPUT)
- return;
-
- local_event = *(cbs->event); // We must keep a copy!
-
+ wxWindow *canvas = (wxWindow *) wxWidgetHashTable->Get ((long) (Widget) drawingArea);
+ XEvent local_event;
+
+ if (canvas==NULL)
+ return ;
+
+ if (cbs->reason != XmCR_INPUT)
+ return;
+
+ local_event = *(cbs->event); // We must keep a copy!
+
/*
switch (local_event.xany.type)
- {
- case EnterNotify:
- cout << "EnterNotify\n";
- break;
- case LeaveNotify:
- cout << "LeaveNotify\n";
- break;
- case ButtonPress:
- cout << "ButtonPress\n";
- break;
- case ButtonRelease:
- cout << "ButtonRelease\n";
- break;
- case MotionNotify:
- cout << "MotionNotify\n";
- break;
- default:
- cout << "Something else\n";
- break;
+ {
+ case EnterNotify:
+ cout << "EnterNotify\n";
+ break;
+ case LeaveNotify:
+ cout << "LeaveNotify\n";
+ break;
+ case ButtonPress:
+ cout << "ButtonPress\n";
+ break;
+ case ButtonRelease:
+ cout << "ButtonRelease\n";
+ break;
+ case MotionNotify:
+ cout << "MotionNotify\n";
+ break;
+ default:
+ cout << "Something else\n";
+ break;
}
- */
-
- switch (local_event.xany.type)
+ */
+
+ switch (local_event.xany.type)
{
case EnterNotify:
case LeaveNotify:
case ButtonPress:
case ButtonRelease:
case MotionNotify:
- {
- wxEventType eventType = wxEVT_NULL;
-
- if (local_event.xany.type == EnterNotify)
- {
- //if (local_event.xcrossing.mode!=NotifyNormal)
- // return ; // Ignore grab events
- eventType = wxEVT_ENTER_WINDOW;
-// canvas->GetEventHandler()->OnSetFocus();
- }
- else if (local_event.xany.type == LeaveNotify)
- {
- //if (local_event.xcrossing.mode!=NotifyNormal)
- // return ; // Ignore grab events
- eventType = wxEVT_LEAVE_WINDOW;
-// canvas->GetEventHandler()->OnKillFocus();
- }
- else if (local_event.xany.type == MotionNotify)
- {
- eventType = wxEVT_MOTION;
- if (local_event.xmotion.is_hint == NotifyHint)
- {
- Window root, child;
- Display *dpy = XtDisplay (drawingArea);
-
- XQueryPointer (dpy, XtWindow (drawingArea),
- &root, &child,
- &local_event.xmotion.x_root,
- &local_event.xmotion.y_root,
- &local_event.xmotion.x,
- &local_event.xmotion.y,
- &local_event.xmotion.state);
- }
- else
- {
- }
- }
-
- else if (local_event.xany.type == ButtonPress)
- {
- if (local_event.xbutton.button == Button1)
- {
- eventType = wxEVT_LEFT_DOWN;
- canvas->m_button1Pressed = TRUE;
- }
- else if (local_event.xbutton.button == Button2)
- {
- eventType = wxEVT_MIDDLE_DOWN;
- canvas->m_button2Pressed = TRUE;
- }
- else if (local_event.xbutton.button == Button3)
- {
- eventType = wxEVT_RIGHT_DOWN;
- canvas->m_button3Pressed = TRUE;
- }
- }
- else if (local_event.xany.type == ButtonRelease)
- {
- if (local_event.xbutton.button == Button1)
- {
- eventType = wxEVT_LEFT_UP;
- canvas->m_button1Pressed = FALSE;
- }
- else if (local_event.xbutton.button == Button2)
- {
- eventType = wxEVT_MIDDLE_UP;
- canvas->m_button2Pressed = FALSE;
- }
- else if (local_event.xbutton.button == Button3)
- {
- eventType = wxEVT_RIGHT_UP;
- canvas->m_button3Pressed = FALSE;
- }
- }
-
- wxMouseEvent wxevent (eventType);
- wxevent.m_eventHandle = (char *) &local_event;
-
- wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
- || (event_left_is_down (&local_event)
- && (eventType != wxEVT_LEFT_UP)));
- wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN)
- || (event_middle_is_down (&local_event)
- && (eventType != wxEVT_MIDDLE_UP)));
- wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN)
- || (event_right_is_down (&local_event)
- && (eventType != wxEVT_RIGHT_UP)));
-
- wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask;
- wxevent.m_controlDown = local_event.xbutton.state & ControlMask;
- wxevent.m_altDown = local_event.xbutton.state & Mod3Mask;
- wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask;
- wxevent.SetTimestamp(local_event.xbutton.time);
-
- // Now check if we need to translate this event into a double click
- if (TRUE) // canvas->doubleClickAllowed)
- {
- if (wxevent.ButtonDown())
- {
- long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()) ;
-
- // get button and time-stamp
- int button = 0;
- if (wxevent.LeftDown()) button = 1;
- else if (wxevent.MiddleDown()) button = 2;
- else if (wxevent.RightDown()) button = 3;
- long ts = wxevent.GetTimestamp();
- // check, if single or double click
- if (canvas->m_lastButton && canvas->m_lastButton==button && (ts - canvas->m_lastTS) < dclickTime)
- {
- // I have a dclick
- canvas->m_lastButton = 0;
- switch ( eventType )
- {
- case wxEVT_LEFT_DOWN:
- wxevent.SetEventType(wxEVT_LEFT_DCLICK);
- break;
- case wxEVT_MIDDLE_DOWN:
- wxevent.SetEventType(wxEVT_MIDDLE_DCLICK);
- break;
- case wxEVT_RIGHT_DOWN:
- wxevent.SetEventType(wxEVT_RIGHT_DCLICK);
- break;
-
- default :
- break;
- }
-
- }
- else
- {
- // not fast enough or different button
- canvas->m_lastTS = ts;
- canvas->m_lastButton = button;
- }
- }
- }
-
- wxevent.SetId(canvas->GetId());
- wxevent.SetEventObject(canvas);
- wxevent.m_x = local_event.xbutton.x;
- wxevent.m_y = local_event.xbutton.y;
- canvas->GetEventHandler()->ProcessEvent (wxevent);
- /*
- if (eventType == wxEVT_ENTER_WINDOW ||
- eventType == wxEVT_LEAVE_WINDOW ||
- eventType == wxEVT_MOTION
- )
- return;
- */
- break;
+ {
+ wxEventType eventType = wxEVT_NULL;
+
+ if (local_event.xany.type == EnterNotify)
+ {
+ //if (local_event.xcrossing.mode!=NotifyNormal)
+ // return ; // Ignore grab events
+ eventType = wxEVT_ENTER_WINDOW;
+ // canvas->GetEventHandler()->OnSetFocus();
+ }
+ else if (local_event.xany.type == LeaveNotify)
+ {
+ //if (local_event.xcrossing.mode!=NotifyNormal)
+ // return ; // Ignore grab events
+ eventType = wxEVT_LEAVE_WINDOW;
+ // canvas->GetEventHandler()->OnKillFocus();
+ }
+ else if (local_event.xany.type == MotionNotify)
+ {
+ eventType = wxEVT_MOTION;
+ if (local_event.xmotion.is_hint == NotifyHint)
+ {
+ Window root, child;
+ Display *dpy = XtDisplay (drawingArea);
+
+ XQueryPointer (dpy, XtWindow (drawingArea),
+ &root, &child,
+ &local_event.xmotion.x_root,
+ &local_event.xmotion.y_root,
+ &local_event.xmotion.x,
+ &local_event.xmotion.y,
+ &local_event.xmotion.state);
+ }
+ else
+ {
+ }
+ }
+
+ else if (local_event.xany.type == ButtonPress)
+ {
+ if (local_event.xbutton.button == Button1)
+ {
+ eventType = wxEVT_LEFT_DOWN;
+ canvas->m_button1Pressed = TRUE;
+ }
+ else if (local_event.xbutton.button == Button2)
+ {
+ eventType = wxEVT_MIDDLE_DOWN;
+ canvas->m_button2Pressed = TRUE;
+ }
+ else if (local_event.xbutton.button == Button3)
+ {
+ eventType = wxEVT_RIGHT_DOWN;
+ canvas->m_button3Pressed = TRUE;
+ }
+ }
+ else if (local_event.xany.type == ButtonRelease)
+ {
+ if (local_event.xbutton.button == Button1)
+ {
+ eventType = wxEVT_LEFT_UP;
+ canvas->m_button1Pressed = FALSE;
+ }
+ else if (local_event.xbutton.button == Button2)
+ {
+ eventType = wxEVT_MIDDLE_UP;
+ canvas->m_button2Pressed = FALSE;
+ }
+ else if (local_event.xbutton.button == Button3)
+ {
+ eventType = wxEVT_RIGHT_UP;
+ canvas->m_button3Pressed = FALSE;
+ }
+ }
+
+ wxMouseEvent wxevent (eventType);
+ wxevent.m_eventHandle = (char *) &local_event;
+
+ wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
+ || (event_left_is_down (&local_event)
+ && (eventType != wxEVT_LEFT_UP)));
+ wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN)
+ || (event_middle_is_down (&local_event)
+ && (eventType != wxEVT_MIDDLE_UP)));
+ wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN)
+ || (event_right_is_down (&local_event)
+ && (eventType != wxEVT_RIGHT_UP)));
+
+ wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask;
+ wxevent.m_controlDown = local_event.xbutton.state & ControlMask;
+ wxevent.m_altDown = local_event.xbutton.state & Mod3Mask;
+ wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask;
+ wxevent.SetTimestamp(local_event.xbutton.time);
+
+ // Now check if we need to translate this event into a double click
+ if (TRUE) // canvas->doubleClickAllowed)
+ {
+ if (wxevent.ButtonDown())
+ {
+ long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()) ;
+
+ // get button and time-stamp
+ int button = 0;
+ if (wxevent.LeftDown()) button = 1;
+ else if (wxevent.MiddleDown()) button = 2;
+ else if (wxevent.RightDown()) button = 3;
+ long ts = wxevent.GetTimestamp();
+ // check, if single or double click
+ if (canvas->m_lastButton && canvas->m_lastButton==button && (ts - canvas->m_lastTS) < dclickTime)
+ {
+ // I have a dclick
+ canvas->m_lastButton = 0;
+ switch ( eventType )
+ {
+ case wxEVT_LEFT_DOWN:
+ wxevent.SetEventType(wxEVT_LEFT_DCLICK);
+ break;
+ case wxEVT_MIDDLE_DOWN:
+ wxevent.SetEventType(wxEVT_MIDDLE_DCLICK);
+ break;
+ case wxEVT_RIGHT_DOWN:
+ wxevent.SetEventType(wxEVT_RIGHT_DCLICK);
+ break;
+
+ default :
+ break;
+ }
+
+ }
+ else
+ {
+ // not fast enough or different button
+ canvas->m_lastTS = ts;
+ canvas->m_lastButton = button;
+ }
+ }
+ }
+
+ wxevent.SetId(canvas->GetId());
+ wxevent.SetEventObject(canvas);
+ wxevent.m_x = local_event.xbutton.x;
+ wxevent.m_y = local_event.xbutton.y;
+ canvas->GetEventHandler()->ProcessEvent (wxevent);
+ /*
+ if (eventType == wxEVT_ENTER_WINDOW ||
+ eventType == wxEVT_LEAVE_WINDOW ||
+ eventType == wxEVT_MOTION
+ )
+ return;
+ */
+ break;
}
case KeyPress:
- {
- KeySym keySym;
-// XComposeStatus compose;
-// (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, &compose);
- (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL);
- int id = wxCharCodeXToWX (keySym);
-
- wxKeyEvent event (wxEVT_CHAR);
-
- if (local_event.xkey.state & ShiftMask)
- event.m_shiftDown = TRUE;
- if (local_event.xkey.state & ControlMask)
- event.m_controlDown = TRUE;
- if (local_event.xkey.state & Mod3Mask)
- event.m_altDown = TRUE;
- if (local_event.xkey.state & Mod1Mask)
- event.m_metaDown = TRUE;
- event.SetEventObject(canvas);
- event.m_keyCode = id;
- event.SetTimestamp(local_event.xkey.time);
-
- if (id > -1)
{
- // Implement wxFrame::OnCharHook by checking ancestor.
- wxWindow *parent = canvas->GetParent();
- while (parent && !parent->IsKindOf(CLASSINFO(wxFrame)))
- parent = parent->GetParent();
-
- if (parent)
- {
- event.SetEventType(wxEVT_CHAR_HOOK);
- if (parent->GetEventHandler()->ProcessEvent(event))
- return;
- event.SetEventType(wxEVT_CHAR);
- }
+ KeySym keySym;
+ // XComposeStatus compose;
+ // (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, &compose);
+ (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL);
+ int id = wxCharCodeXToWX (keySym);
+
+ wxEventType eventType = wxEVT_CHAR;
- canvas->GetEventHandler()->ProcessEvent (event);
+ // TODO: Is this the correct criterion for wxEVT_KEY_DOWN down versus wxEVT_CHAR?
+ if (id > WXK_START) // Non-ASCII values
+ eventType = wxEVT_KEY_DOWN;
+
+ wxKeyEvent event (eventType);
+
+ if (local_event.xkey.state & ShiftMask)
+ event.m_shiftDown = TRUE;
+ if (local_event.xkey.state & ControlMask)
+ event.m_controlDown = TRUE;
+ if (local_event.xkey.state & Mod3Mask)
+ event.m_altDown = TRUE;
+ if (local_event.xkey.state & Mod1Mask)
+ event.m_metaDown = TRUE;
+ event.SetEventObject(canvas);
+ event.m_keyCode = id;
+ event.SetTimestamp(local_event.xkey.time);
+
+ if (id > -1)
+ {
+ // Implement wxFrame::OnCharHook by checking ancestor.
+ wxWindow *parent = canvas->GetParent();
+ while (parent && !parent->IsKindOf(CLASSINFO(wxFrame)))
+ parent = parent->GetParent();
+
+ if (parent)
+ {
+ event.SetEventType(wxEVT_CHAR_HOOK);
+ if (parent->GetEventHandler()->ProcessEvent(event))
+ return;
+ event.SetEventType(wxEVT_CHAR);
+ }
+
+ canvas->GetEventHandler()->ProcessEvent (event);
+ }
+ break;
+ }
+ case KeyRelease:
+ {
+ KeySym keySym;
+ (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL);
+ int id = wxCharCodeXToWX (keySym);
+
+ wxKeyEvent event (wxEVT_KEY_UP);
+
+ if (local_event.xkey.state & ShiftMask)
+ event.m_shiftDown = TRUE;
+ if (local_event.xkey.state & ControlMask)
+ event.m_controlDown = TRUE;
+ if (local_event.xkey.state & Mod3Mask)
+ event.m_altDown = TRUE;
+ if (local_event.xkey.state & Mod1Mask)
+ event.m_metaDown = TRUE;
+ event.SetEventObject(canvas);
+ event.m_keyCode = id;
+ event.SetTimestamp(local_event.xkey.time);
+
+ if (id > -1)
+ {
+ canvas->GetEventHandler()->ProcessEvent (event);
+ }
+ break;
}
- break;
- }
case FocusIn:
- {
- if (local_event.xfocus.detail != NotifyPointer)
- {
- wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
- event.SetEventObject(canvas);
- canvas->GetEventHandler()->ProcessEvent(event);
+ {
+ if (local_event.xfocus.detail != NotifyPointer)
+ {
+ wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId());
+ event.SetEventObject(canvas);
+ canvas->GetEventHandler()->ProcessEvent(event);
+ }
+ break;
}
- break;
- }
case FocusOut:
- {
- if (local_event.xfocus.detail != NotifyPointer)
- {
- wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
- event.SetEventObject(canvas);
- canvas->GetEventHandler()->ProcessEvent(event);
- }
- break;
- }
+ {
+ if (local_event.xfocus.detail != NotifyPointer)
+ {
+ wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId());
+ event.SetEventObject(canvas);
+ canvas->GetEventHandler()->ProcessEvent(event);
+ }
+ break;
+ }
default:
- break;
+ break;
}
}
void wxWindow::DoPaint()
{
- //TODO : make a temporary gc so we can do the XCopyArea below
- if (0) // m_backingPixmap)
+ //TODO : make a temporary gc so we can do the XCopyArea below
+ if (0) // m_backingPixmap)
{
- /*
- Widget drawingArea = (Widget) m_drawingArea;
- // int orig = GetDC()->GetLogicalFunction();
- // GetDC()->SetLogicalFunction (wxCOPY);
-
+ /*
+ Widget drawingArea = (Widget) m_drawingArea;
+ // int orig = GetDC()->GetLogicalFunction();
+ // GetDC()->SetLogicalFunction (wxCOPY);
+
// TODO: it may not be necessary to store m_pixmapOffsetX/Y; we
// should be able to calculate them.
XCopyArea (XtDisplay (drawingArea), m_backingPixmap, XtWindow (drawingArea), GetDC ()->gc,
- m_pixmapOffsetX, m_pixmapOffsetY,
- m_pixmapWidth, m_pixmapHeight,
- 0, 0);
-
- // GetDC()->SetLogicalFunction (orig);
- */
+ m_pixmapOffsetX, m_pixmapOffsetY,
+ m_pixmapWidth, m_pixmapHeight,
+ 0, 0);
+
+ // GetDC()->SetLogicalFunction (orig);
+ */
}
- else
+ else
{
wxPaintEvent event(GetId());
event.SetEventObject(this);
// SetSize, but as per old wxCanvas (with drawing widget etc.)
void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags)
{
- // A bit of optimization to help sort out the flickers.
- int oldX, oldY, oldW, oldH;
- GetSize(& oldW, & oldH);
- GetPosition(& oldX, & oldY);
-
- bool useOldPos = FALSE;
- bool useOldSize = FALSE;
-
- if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
- useOldPos = TRUE;
- else if (x == oldX && y == oldY)
- useOldPos = TRUE;
-
- if ((w == -1) && (h == -1))
- useOldSize = TRUE;
- else if (w == oldW && h == oldH)
- useOldSize = TRUE;
-
- if (!wxNoOptimize::CanOptimize())
- {
- useOldSize = FALSE; useOldPos = FALSE;
- }
-
- if (useOldPos && useOldSize)
- return;
-
- Widget drawingArea = (Widget) m_drawingArea;
- bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
-
- if (managed)
- XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
-
- int xx = x; int yy = y;
- AdjustForParentClientOrigin(xx, yy, sizeFlags);
-
- if (!useOldPos)
- {
- if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ // A bit of optimization to help sort out the flickers.
+ int oldX, oldY, oldW, oldH;
+ GetSize(& oldW, & oldH);
+ GetPosition(& oldX, & oldY);
+
+ bool useOldPos = FALSE;
+ bool useOldSize = FALSE;
+
+ if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0))
+ useOldPos = TRUE;
+ else if (x == oldX && y == oldY)
+ useOldPos = TRUE;
+
+ if ((w == -1) && (h == -1))
+ useOldSize = TRUE;
+ else if (w == oldW && h == oldH)
+ useOldSize = TRUE;
+
+ if (!wxNoOptimize::CanOptimize())
{
- XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
- XmNx, xx, NULL);
+ useOldSize = FALSE; useOldPos = FALSE;
}
-
- if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+
+ if (useOldPos && useOldSize)
+ return;
+
+ Widget drawingArea = (Widget) m_drawingArea;
+ bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+
+ if (managed)
+ XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+
+ int xx = x; int yy = y;
+ AdjustForParentClientOrigin(xx, yy, sizeFlags);
+
+ if (!useOldPos)
{
- XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
- XmNy, yy, NULL);
+ if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
+ XmNx, xx, NULL);
+ }
+
+ if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
+ {
+ XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow,
+ XmNy, yy, NULL);
+ }
}
- }
-
- if (!useOldSize)
- {
-
- if (w > -1)
+
+ if (!useOldSize)
{
- if (m_borderWidget)
- {
- XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL);
- short thick, margin;
- XtVaGetValues ((Widget) m_borderWidget,
- XmNshadowThickness, &thick,
- XmNmarginWidth, &margin,
- NULL);
- w -= 2 * (thick + margin);
- }
-
- XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
-
- Dimension spacing;
- Widget sbar;
- XtVaGetValues ((Widget) m_scrolledWindow,
- XmNspacing, &spacing,
- XmNverticalScrollBar, &sbar,
- NULL);
- Dimension wsbar;
- if (sbar)
- XtVaGetValues (sbar, XmNwidth, &wsbar, NULL);
- else
- wsbar = 0;
-
- w -= (spacing + wsbar);
-
- // XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
- }
- if (h > -1)
- {
- if (m_borderWidget)
- {
- XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL);
- short thick, margin;
- XtVaGetValues ((Widget) m_borderWidget,
- XmNshadowThickness, &thick,
- XmNmarginHeight, &margin,
- NULL);
- h -= 2 * (thick + margin);
- }
-
- XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
-
- Dimension spacing;
- Widget sbar;
- XtVaGetValues ((Widget) m_scrolledWindow,
- XmNspacing, &spacing,
- XmNhorizontalScrollBar, &sbar,
- NULL);
- Dimension wsbar;
- if (sbar)
- XtVaGetValues (sbar, XmNheight, &wsbar, NULL);
- else
- wsbar = 0;
-
- h -= (spacing + wsbar);
-
- // XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
-
+
+ if (w > -1)
+ {
+ if (m_borderWidget)
+ {
+ XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL);
+ short thick, margin;
+ XtVaGetValues ((Widget) m_borderWidget,
+ XmNshadowThickness, &thick,
+ XmNmarginWidth, &margin,
+ NULL);
+ w -= 2 * (thick + margin);
+ }
+
+ XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL);
+
+ Dimension spacing;
+ Widget sbar;
+ XtVaGetValues ((Widget) m_scrolledWindow,
+ XmNspacing, &spacing,
+ XmNverticalScrollBar, &sbar,
+ NULL);
+ Dimension wsbar;
+ if (sbar)
+ XtVaGetValues (sbar, XmNwidth, &wsbar, NULL);
+ else
+ wsbar = 0;
+
+ w -= (spacing + wsbar);
+
+ // XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+ }
+ if (h > -1)
+ {
+ if (m_borderWidget)
+ {
+ XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL);
+ short thick, margin;
+ XtVaGetValues ((Widget) m_borderWidget,
+ XmNshadowThickness, &thick,
+ XmNmarginHeight, &margin,
+ NULL);
+ h -= 2 * (thick + margin);
+ }
+
+ XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL);
+
+ Dimension spacing;
+ Widget sbar;
+ XtVaGetValues ((Widget) m_scrolledWindow,
+ XmNspacing, &spacing,
+ XmNhorizontalScrollBar, &sbar,
+ NULL);
+ Dimension wsbar;
+ if (sbar)
+ XtVaGetValues (sbar, XmNheight, &wsbar, NULL);
+ else
+ wsbar = 0;
+
+ h -= (spacing + wsbar);
+
+ // XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+
+ }
}
- }
-
- if (managed)
- XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
- /*
- int ww, hh;
- GetClientSize (&ww, &hh);
- wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
- */
-
+
+ if (managed)
+ XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow);
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ /*
+ int ww, hh;
+ GetClientSize (&ww, &hh);
+ wxSizeEvent sizeEvent(wxSize(ww, hh), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
+ */
+
}
void wxWindow::CanvasSetClientSize (int w, int h)
{
- Widget drawingArea = (Widget) m_drawingArea;
-
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
-
- if (w > -1)
- XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
- if (h > -1)
- XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
- /* TODO: is this necessary?
- allowRepainting = FALSE;
-
- XSync (XtDisplay (drawingArea), FALSE);
- XEvent event;
- while (XtAppPending (wxTheApp->appContext))
- {
- XFlush (XtDisplay (drawingArea));
- XtAppNextEvent (wxTheApp->appContext, &event);
- XtDispatchEvent (&event);
- }
+ Widget drawingArea = (Widget) m_drawingArea;
+
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL);
+
+ if (w > -1)
+ XtVaSetValues ((Widget) m_drawingArea, XmNwidth, w, NULL);
+ if (h > -1)
+ XtVaSetValues ((Widget) m_drawingArea, XmNheight, h, NULL);
+ /* TODO: is this necessary?
+ allowRepainting = FALSE;
+
+ XSync (XtDisplay (drawingArea), FALSE);
+ XEvent event;
+ while (XtAppPending (wxTheApp->appContext))
+ {
+ XFlush (XtDisplay (drawingArea));
+ XtAppNextEvent (wxTheApp->appContext, &event);
+ XtDispatchEvent (&event);
+ }
+ */
+
+ XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
+
+ /* TODO
+ allowRepainting = TRUE;
+ DoRefresh ();
+ */
+
+ /*
+ wxSizeEvent sizeEvent(wxSize(w, h), GetId());
+ sizeEvent.SetEventObject(this);
+
+ GetEventHandler()->ProcessEvent(sizeEvent);
*/
-
- XtVaSetValues((Widget) m_drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL);
-
- /* TODO
- allowRepainting = TRUE;
- DoRefresh ();
- */
-
- /*
- wxSizeEvent sizeEvent(wxSize(w, h), GetId());
- sizeEvent.SetEventObject(this);
-
- GetEventHandler()->ProcessEvent(sizeEvent);
- */
}
void wxWindow::CanvasGetClientSize (int *w, int *h) const
{
- // Must return the same thing that was set via SetClientSize
- Dimension xx, yy;
- XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
- *w = xx;
- *h = yy;
+ // Must return the same thing that was set via SetClientSize
+ Dimension xx, yy;
+ XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
+ *w = xx;
+ *h = yy;
}
void wxWindow::CanvasGetSize (int *w, int *h) const
{
- Dimension xx, yy;
- if ((Widget) m_borderWidget)
- XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
- else if ((Widget) m_scrolledWindow)
- XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL);
- else
- XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
-
- *w = xx;
- *h = yy;
+ Dimension xx, yy;
+ if ((Widget) m_borderWidget)
+ XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL);
+ else if ((Widget) m_scrolledWindow)
+ XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL);
+ else
+ XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL);
+
+ *w = xx;
+ *h = yy;
}
void wxWindow::CanvasGetPosition (int *x, int *y) const
{
Position xx, yy;
XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL);
-
+
// We may be faking the client origin.
// So a window that's really at (0, 30) may appear
// (to wxWin apps) to be at (0, 0).
xx -= pt.x;
yy -= pt.y;
}
-
+
*x = xx;
*y = yy;
}
// Add to hash table, add event handler
bool wxWindow::AttachWidget (wxWindow* parent, WXWidget mainWidget,
- WXWidget formWidget, int x, int y, int width, int height)
+ WXWidget formWidget, int x, int y, int width, int height)
{
wxAddWindowToTable((Widget) mainWidget, this);
if (CanAddEventHandler())
{
XtAddEventHandler((Widget) mainWidget,
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
- False,
- wxPanelItemEventHandler,
- (XtPointer) this);
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
+ False,
+ wxPanelItemEventHandler,
+ (XtPointer) this);
}
-
+
if (!formWidget)
{
XtTranslations ptr;
XtOverrideTranslations ((Widget) mainWidget,
- ptr = XtParseTranslationTable ("<Configure>: resize()"));
+ ptr = XtParseTranslationTable ("<Configure>: resize()"));
XtFree ((char *) ptr);
}
-
+
// Some widgets have a parent form widget, e.g. wxRadioBox
if (formWidget)
{
- if (!wxAddWindowToTable((Widget) formWidget, this))
- return FALSE;
-
- XtTranslations ptr;
- XtOverrideTranslations ((Widget) formWidget,
- ptr = XtParseTranslationTable ("<Configure>: resize()"));
- XtFree ((char *) ptr);
+ if (!wxAddWindowToTable((Widget) formWidget, this))
+ return FALSE;
+
+ XtTranslations ptr;
+ XtOverrideTranslations ((Widget) formWidget,
+ ptr = XtParseTranslationTable ("<Configure>: resize()"));
+ XtFree ((char *) ptr);
}
-
+
if (x == -1)
- x = 0;
+ x = 0;
if (y == -1)
- y = 0;
+ y = 0;
SetSize (x, y, width, height);
-
+
return TRUE;
}
{
if (CanAddEventHandler())
{
- XtRemoveEventHandler((Widget) widget,
- ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
- False,
- wxPanelItemEventHandler,
- (XtPointer)this);
+ XtRemoveEventHandler((Widget) widget,
+ ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask,
+ False,
+ wxPanelItemEventHandler,
+ (XtPointer)this);
}
-
+
wxDeleteWindowFromTable((Widget) widget);
return TRUE;
}
XEvent* event,
Boolean *continueToDispatch)
{
- // Widget can be a label or the actual widget.
-
- wxWindow *window = (wxWindow *)wxWidgetHashTable->Get((long)wid);
- if (window)
- {
- wxMouseEvent wxevent(0);
- if (wxTranslateMouseEvent(wxevent, window, wid, event))
+ // Widget can be a label or the actual widget.
+
+ wxWindow *window = (wxWindow *)wxWidgetHashTable->Get((long)wid);
+ if (window)
{
- window->GetEventHandler()->ProcessEvent(wxevent);
+ wxMouseEvent wxevent(0);
+ if (wxTranslateMouseEvent(wxevent, window, wid, event))
+ {
+ window->GetEventHandler()->ProcessEvent(wxevent);
+ }
}
- }
- // TODO: probably the key to allowing default behaviour
- // to happen.
- // Say we set a m_doDefault flag to FALSE at the start of this
- // function. Then in e.g. wxWindow::OnMouseEvent we can
- // call Default() which sets this flag to TRUE, indicating
- // that default processing can happen. Thus, behaviour can appear
- // to be overridden just by adding an event handler and not calling
- // wxWindow::OnWhatever.
- // ALSO, maybe we can use this instead of the current way of handling
- // drawing area events, to simplify things.
- *continueToDispatch = True;
+ // TODO: probably the key to allowing default behaviour
+ // to happen.
+ // Say we set a m_doDefault flag to FALSE at the start of this
+ // function. Then in e.g. wxWindow::OnMouseEvent we can
+ // call Default() which sets this flag to TRUE, indicating
+ // that default processing can happen. Thus, behaviour can appear
+ // to be overridden just by adding an event handler and not calling
+ // wxWindow::OnWhatever.
+ // ALSO, maybe we can use this instead of the current way of handling
+ // drawing area events, to simplify things.
+ *continueToDispatch = True;
}
static void wxScrollBarCallback(Widget scrollbar, XtPointer clientData,
- XmScaleCallbackStruct *cbs)
+ XmScaleCallbackStruct *cbs)
{
Widget scrolledWindow = XtParent (scrollbar);
wxWindow *win = (wxWindow *) wxWidgetHashTable->Get ((long) scrolledWindow);
int orientation = (int) clientData;
-
+
wxEventType eventType = wxEVT_NULL;
switch (cbs->reason)
{
- case XmCR_INCREMENT:
+ case XmCR_INCREMENT:
{
eventType = wxEVT_SCROLL_LINEDOWN;
break;
}
- case XmCR_DECREMENT:
+ case XmCR_DECREMENT:
{
eventType = wxEVT_SCROLL_LINEUP;
break;
}
- case XmCR_DRAG:
+ case XmCR_DRAG:
{
eventType = wxEVT_SCROLL_THUMBTRACK;
break;
}
- case XmCR_VALUE_CHANGED:
+ case XmCR_VALUE_CHANGED:
{
// TODO: Should this be intercepted too, or will it cause
// duplicate events?
eventType = wxEVT_SCROLL_THUMBTRACK;
break;
}
- case XmCR_PAGE_INCREMENT:
+ case XmCR_PAGE_INCREMENT:
{
eventType = wxEVT_SCROLL_PAGEDOWN;
break;
}
- case XmCR_PAGE_DECREMENT:
+ case XmCR_PAGE_DECREMENT:
{
eventType = wxEVT_SCROLL_PAGEUP;
break;
}
- case XmCR_TO_TOP:
+ case XmCR_TO_TOP:
{
eventType = wxEVT_SCROLL_TOP;
break;
}
- case XmCR_TO_BOTTOM:
+ case XmCR_TO_BOTTOM:
{
eventType = wxEVT_SCROLL_BOTTOM;
break;
}
- default:
+ default:
{
// Should never get here
wxFAIL_MSG("Unknown scroll event.");
break;
}
}
-
+
wxScrollEvent event(eventType, win->GetId());
event.SetEventObject(win);
event.SetPosition(cbs->value);
event.SetOrientation( (orientation == XmHORIZONTAL) ? wxHORIZONTAL : wxVERTICAL );
-
+
win->GetEventHandler()->ProcessEvent(event);
}
bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent)
{
- switch (xevent->xany.type)
- {
+ switch (xevent->xany.type)
+ {
case EnterNotify:
case LeaveNotify:
case ButtonPress:
case ButtonRelease:
case MotionNotify:
- {
- wxEventType eventType = wxEVT_NULL;
-
- if (xevent->xany.type == LeaveNotify)
- {
- win->m_button1Pressed = FALSE;
- win->m_button2Pressed = FALSE;
- win->m_button3Pressed = FALSE;
- return FALSE;
- }
- else if (xevent->xany.type == MotionNotify)
- {
- eventType = wxEVT_MOTION;
- }
- else if (xevent->xany.type == ButtonPress)
- {
- if (xevent->xbutton.button == Button1)
- {
- eventType = wxEVT_LEFT_DOWN;
- win->m_button1Pressed = TRUE;
- }
- else if (xevent->xbutton.button == Button2)
- {
- eventType = wxEVT_MIDDLE_DOWN;
- win->m_button2Pressed = TRUE;
- }
- else if (xevent->xbutton.button == Button3)
- {
- eventType = wxEVT_RIGHT_DOWN;
- win->m_button3Pressed = TRUE;
- }
- }
- else if (xevent->xany.type == ButtonRelease)
- {
- if (xevent->xbutton.button == Button1)
- {
- eventType = wxEVT_LEFT_UP;
- win->m_button1Pressed = FALSE;
- }
- else if (xevent->xbutton.button == Button2)
- {
- eventType = wxEVT_MIDDLE_UP;
- win->m_button2Pressed = FALSE;
- }
- else if (xevent->xbutton.button == Button3)
- {
- eventType = wxEVT_RIGHT_UP;
- win->m_button3Pressed = FALSE;
- }
- else return FALSE;
- }
- else return FALSE;
-
- wxevent.m_eventHandle = (char *)xevent;
- wxevent.SetEventType(eventType);
-
- Position x1, y1;
- XtVaGetValues(widget, XmNx, &x1, XmNy, &y1, NULL);
-
- int x2, y2;
- win->GetPosition(&x2, &y2);
-
- // The button x/y must be translated to wxWindows
- // window space - the widget might be a label or button,
- // within a form.
- int dx = 0;
- int dy = 0;
- if (widget != (Widget)win->GetMainWidget())
{
- dx = x1;
- dy = y1;
- }
-
- wxevent.m_x = xevent->xbutton.x + dx;
- wxevent.m_y = xevent->xbutton.y + dy;
-
- wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
- || (event_left_is_down (xevent)
- && (eventType != wxEVT_LEFT_UP)));
- wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN)
- || (event_middle_is_down (xevent)
- && (eventType != wxEVT_MIDDLE_UP)));
- wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN)
- || (event_right_is_down (xevent)
- && (eventType != wxEVT_RIGHT_UP)));
-
- wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask;
- wxevent.m_controlDown = xevent->xbutton.state & ControlMask;
- return TRUE;
+ wxEventType eventType = wxEVT_NULL;
+
+ if (xevent->xany.type == LeaveNotify)
+ {
+ win->m_button1Pressed = FALSE;
+ win->m_button2Pressed = FALSE;
+ win->m_button3Pressed = FALSE;
+ return FALSE;
+ }
+ else if (xevent->xany.type == MotionNotify)
+ {
+ eventType = wxEVT_MOTION;
+ }
+ else if (xevent->xany.type == ButtonPress)
+ {
+ if (xevent->xbutton.button == Button1)
+ {
+ eventType = wxEVT_LEFT_DOWN;
+ win->m_button1Pressed = TRUE;
+ }
+ else if (xevent->xbutton.button == Button2)
+ {
+ eventType = wxEVT_MIDDLE_DOWN;
+ win->m_button2Pressed = TRUE;
+ }
+ else if (xevent->xbutton.button == Button3)
+ {
+ eventType = wxEVT_RIGHT_DOWN;
+ win->m_button3Pressed = TRUE;
+ }
+ }
+ else if (xevent->xany.type == ButtonRelease)
+ {
+ if (xevent->xbutton.button == Button1)
+ {
+ eventType = wxEVT_LEFT_UP;
+ win->m_button1Pressed = FALSE;
+ }
+ else if (xevent->xbutton.button == Button2)
+ {
+ eventType = wxEVT_MIDDLE_UP;
+ win->m_button2Pressed = FALSE;
+ }
+ else if (xevent->xbutton.button == Button3)
+ {
+ eventType = wxEVT_RIGHT_UP;
+ win->m_button3Pressed = FALSE;
+ }
+ else return FALSE;
+ }
+ else return FALSE;
+
+ wxevent.m_eventHandle = (char *)xevent;
+ wxevent.SetEventType(eventType);
+
+ Position x1, y1;
+ XtVaGetValues(widget, XmNx, &x1, XmNy, &y1, NULL);
+
+ int x2, y2;
+ win->GetPosition(&x2, &y2);
+
+ // The button x/y must be translated to wxWindows
+ // window space - the widget might be a label or button,
+ // within a form.
+ int dx = 0;
+ int dy = 0;
+ if (widget != (Widget)win->GetMainWidget())
+ {
+ dx = x1;
+ dy = y1;
+ }
+
+ wxevent.m_x = xevent->xbutton.x + dx;
+ wxevent.m_y = xevent->xbutton.y + dy;
+
+ wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN)
+ || (event_left_is_down (xevent)
+ && (eventType != wxEVT_LEFT_UP)));
+ wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN)
+ || (event_middle_is_down (xevent)
+ && (eventType != wxEVT_MIDDLE_UP)));
+ wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN)
+ || (event_right_is_down (xevent)
+ && (eventType != wxEVT_RIGHT_UP)));
+
+ wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask;
+ wxevent.m_controlDown = xevent->xbutton.state & ControlMask;
+ return TRUE;
+ }
}
- }
- return FALSE;
+ return FALSE;
}
bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent)
{
- switch (xevent->xany.type)
- {
+ switch (xevent->xany.type)
+ {
case KeyPress:
- {
- char buf[20];
-
- KeySym keySym;
-// XComposeStatus compose;
-// (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, &compose);
- (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL);
- int id = wxCharCodeXToWX (keySym);
-
- if (xevent->xkey.state & ShiftMask)
- wxevent.m_shiftDown = TRUE;
- if (xevent->xkey.state & ControlMask)
- wxevent.m_controlDown = TRUE;
- if (xevent->xkey.state & Mod3Mask)
- wxevent.m_altDown = TRUE;
- if (xevent->xkey.state & Mod1Mask)
- wxevent.m_metaDown = TRUE;
- wxevent.SetEventObject(win);
- wxevent.m_keyCode = id;
- wxevent.SetTimestamp(xevent->xkey.time);
-
- wxevent.m_x = xevent->xbutton.x;
- wxevent.m_y = xevent->xbutton.y;
-
- if (id > -1)
- return TRUE;
- else
- return FALSE;
- break;
- }
+ {
+ char buf[20];
+
+ KeySym keySym;
+ // XComposeStatus compose;
+ // (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, &compose);
+ (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL);
+ int id = wxCharCodeXToWX (keySym);
+
+ if (xevent->xkey.state & ShiftMask)
+ wxevent.m_shiftDown = TRUE;
+ if (xevent->xkey.state & ControlMask)
+ wxevent.m_controlDown = TRUE;
+ if (xevent->xkey.state & Mod3Mask)
+ wxevent.m_altDown = TRUE;
+ if (xevent->xkey.state & Mod1Mask)
+ wxevent.m_metaDown = TRUE;
+ wxevent.SetEventObject(win);
+ wxevent.m_keyCode = id;
+ wxevent.SetTimestamp(xevent->xkey.time);
+
+ wxevent.m_x = xevent->xbutton.x;
+ wxevent.m_y = xevent->xbutton.y;
+
+ if (id > -1)
+ return TRUE;
+ else
+ return FALSE;
+ break;
+ }
default:
- break;
- }
- return FALSE;
+ break;
+ }
+ return FALSE;
}
#define YAllocColor XAllocColor
XColor g_itemColors[5];
int wxComputeColours (Display *display, wxColour * back, wxColour * fore)
{
- int result;
- static XmColorProc colorProc;
-
- result = wxNO_COLORS;
-
- if (back)
+ int result;
+ static XmColorProc colorProc;
+
+ result = wxNO_COLORS;
+
+ if (back)
{
- g_itemColors[0].red = (((long) back->Red ()) << 8);
- g_itemColors[0].green = (((long) back->Green ()) << 8);
- g_itemColors[0].blue = (((long) back->Blue ()) << 8);
- g_itemColors[0].flags = DoRed | DoGreen | DoBlue;
- if (colorProc == (XmColorProc) NULL)
- {
- // Get a ptr to the actual function
- colorProc = XmSetColorCalculation ((XmColorProc) NULL);
- // And set it back to motif.
- XmSetColorCalculation (colorProc);
- }
- (*colorProc) (&g_itemColors[wxBACK_INDEX],
- &g_itemColors[wxFORE_INDEX],
- &g_itemColors[wxSELE_INDEX],
- &g_itemColors[wxTOPS_INDEX],
- &g_itemColors[wxBOTS_INDEX]);
- result = wxBACK_COLORS;
+ g_itemColors[0].red = (((long) back->Red ()) << 8);
+ g_itemColors[0].green = (((long) back->Green ()) << 8);
+ g_itemColors[0].blue = (((long) back->Blue ()) << 8);
+ g_itemColors[0].flags = DoRed | DoGreen | DoBlue;
+ if (colorProc == (XmColorProc) NULL)
+ {
+ // Get a ptr to the actual function
+ colorProc = XmSetColorCalculation ((XmColorProc) NULL);
+ // And set it back to motif.
+ XmSetColorCalculation (colorProc);
+ }
+ (*colorProc) (&g_itemColors[wxBACK_INDEX],
+ &g_itemColors[wxFORE_INDEX],
+ &g_itemColors[wxSELE_INDEX],
+ &g_itemColors[wxTOPS_INDEX],
+ &g_itemColors[wxBOTS_INDEX]);
+ result = wxBACK_COLORS;
}
- if (fore)
+ if (fore)
{
- g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
- g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
- g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
- g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
- if (result == wxNO_COLORS)
- result = wxFORE_COLORS;
+ g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8);
+ g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8);
+ g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8);
+ g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue;
+ if (result == wxNO_COLORS)
+ result = wxFORE_COLORS;
}
-
- Display *dpy = display;
- Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
-
- if (back)
+
+ Display *dpy = display;
+ Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
+
+ if (back)
{
- /* 5 Colours to allocate */
- for (int i = 0; i < 5; i++)
- if (!YAllocColor (dpy, cmap, &g_itemColors[i]))
- result = wxNO_COLORS;
+ /* 5 Colours to allocate */
+ for (int i = 0; i < 5; i++)
+ if (!YAllocColor (dpy, cmap, &g_itemColors[i]))
+ result = wxNO_COLORS;
}
- else if (fore)
+ else if (fore)
{
- /* Only 1 colour to allocate */
- if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX]))
- result = wxNO_COLORS;
+ /* Only 1 colour to allocate */
+ if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX]))
+ result = wxNO_COLORS;
}
-
- return (result);
-
+
+ return (result);
+
}
// Changes the foreground and background colours to be derived
{
if (GetMainWidget())
DoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
-
+
// This not necessary
#if 0
-
+
if (m_scrolledWindow && (GetMainWidget() != m_scrolledWindow))
{
DoChangeBackgroundColour(m_scrolledWindow, m_backgroundColour);
// Have to set the scrollbar colours back since
// the scrolled window seemed to change them
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE) ;
-
+
if (m_hScrollBar)
- DoChangeBackgroundColour(m_hScrollBar, backgroundColour);
+ DoChangeBackgroundColour(m_hScrollBar, backgroundColour);
if (m_vScrollBar)
- DoChangeBackgroundColour(m_vScrollBar, backgroundColour);
+ DoChangeBackgroundColour(m_vScrollBar, backgroundColour);
}
#endif
}
void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour)
{
- // When should we specify the foreground, if it's calculated
- // by wxComputeColours?
- // Solution: say we start with the default (computed) foreground colour.
- // If we call SetForegroundColour explicitly for a control or window,
- // then the foreground is changed.
- // Therefore SetBackgroundColour computes the foreground colour, and
- // SetForegroundColour changes the foreground colour. The ordering is
- // important.
-
- XtVaSetValues ((Widget) widget,
- XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
- NULL);
+ // When should we specify the foreground, if it's calculated
+ // by wxComputeColours?
+ // Solution: say we start with the default (computed) foreground colour.
+ // If we call SetForegroundColour explicitly for a control or window,
+ // then the foreground is changed.
+ // Therefore SetBackgroundColour computes the foreground colour, and
+ // SetForegroundColour changes the foreground colour. The ordering is
+ // important.
+
+ XtVaSetValues ((Widget) widget,
+ XmNforeground, foregroundColour.AllocColour(XtDisplay((Widget) widget)),
+ NULL);
}
void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour)
{
- wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
- (wxColour*) NULL);
-
- XtVaSetValues ((Widget) widget,
- XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
- XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
- XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
- XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
- NULL);
-
- if (changeArmColour)
+ wxComputeColours (XtDisplay((Widget) widget), & backgroundColour,
+ (wxColour*) NULL);
+
XtVaSetValues ((Widget) widget,
- XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
- NULL);
+ XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
+ XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
+ XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
+ XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
+ NULL);
+
+ if (changeArmColour)
+ XtVaSetValues ((Widget) widget,
+ XmNarmColor, g_itemColors[wxSELE_INDEX].pixel,
+ NULL);
}
void wxWindow::SetBackgroundColour(const wxColour& col)
{
int width, height, width1, height1;
GetSize(& width, & height);
-
-// lesstif 0.87 hangs here
+
+ // lesstif 0.87 hangs here
#ifndef LESSTIF_VERSION
XtVaSetValues (w,
- XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
- NULL);
+ XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(w)),
+ NULL);
#endif
-
+
GetSize(& width1, & height1);
if (keepOriginalSize && (width != width1 || height != height1))
{
{
if (!m_acceleratorTable.Ok())
return FALSE;
-
+
int count = m_acceleratorTable.GetCount();
wxAcceleratorEntry* entries = m_acceleratorTable.GetEntries();
int i;
{
// Bingo, we have a match. Now find a control
// that matches the entry command id.
-
+
// Need to go up to the top of the window hierarchy,
// since it might be e.g. a menu item
wxWindow* parent = this;
while (parent && !parent->IsKindOf(CLASSINFO(wxFrame)) && !parent->IsKindOf(CLASSINFO(wxDialog)))
parent = parent->GetParent();
-
+
if (!parent)
return FALSE;
-
+
if (parent->IsKindOf(CLASSINFO(wxFrame)))
{
// Try for a menu command
{
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, entry->GetCommand());
commandEvent.SetEventObject(frame);
-
+
// If ProcessEvent returns TRUE (it was handled), then
// the calling code will skip the event handling.
return frame->GetEventHandler()->ProcessEvent(commandEvent);
}
}
}
-
+
// Find a child matching the command id
wxWindow* child = parent->FindWindow(entry->GetCommand());
-
+
// No such child
if (!child)
return FALSE;
-
+
// Now we process those kinds of windows that we can.
// For now, only buttons.
if (child->IsKindOf(CLASSINFO(wxButton)))
commandEvent.SetEventObject(child);
return child->GetEventHandler()->ProcessEvent(commandEvent);
}
-
+
return FALSE;
} // matches event
}// for
-
+
// We didn't match the key event against an accelerator.
return FALSE;
}
/*
- * wxNoOptimize: switch off size optimization
- */
+* wxNoOptimize: switch off size optimization
+*/
int wxNoOptimize::m_count = 0;
wxNoOptimize::wxNoOptimize()
{
- m_count ++;
+ m_count ++;
}
wxNoOptimize::~wxNoOptimize()
{
- m_count --;
+ m_count --;
}
bool wxNoOptimize::CanOptimize()
{
- return (m_count == 0);
+ return (m_count == 0);
}
return (::GetClipboardFormatName((int) dataFormat, formatName, maxCount) > 0);
}
-/*
- * wxClipboard
- */
-
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------