Added some tentative wxMotif clipboard code; did some file formatting

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1408 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
1999-01-14 15:15:39 +00:00
parent 8de2e39c17
commit 2d120f8391
46 changed files with 9903 additions and 9564 deletions

View File

@@ -41,10 +41,6 @@ High Priority
- Get wxGLCanvas from 1.68 working. - Get wxGLCanvas from 1.68 working.
- wxClipboard
- EVT_KEY_DOWN, EVT_KEY_UP events.
Low Priority Low Priority
------------ ------------

View File

@@ -16,6 +16,8 @@ Please see also:
- Documentation: mention include files with each class. - Documentation: mention include files with each class.
- Document wxTime.
- Get Karsten to remove trashed CVS files: - Get Karsten to remove trashed CVS files:
include/wx/msw/magnif1.cur include/wx/msw/magnif1.cur

View File

@@ -4,7 +4,7 @@
#if defined(__WXMSW__) #if defined(__WXMSW__)
#include "wx/msw/ole/dataobj.h" #include "wx/msw/ole/dataobj.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
#include "wx/motif/dnd.h" #include "wx/motif/dataobj.h"
#elif defined(__WXGTK__) #elif defined(__WXGTK__)
#include "wx/gtk/dataobj.h" #include "wx/gtk/dataobj.h"
#elif defined(__WXQT__) #elif defined(__WXQT__)

View File

@@ -23,17 +23,77 @@
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/list.h" #include "wx/list.h"
#include "wx/module.h"
bool WXDLLEXPORT wxOpenClipboard(); bool WXDLLEXPORT wxOpenClipboard();
bool WXDLLEXPORT wxClipboardOpen(); bool WXDLLEXPORT wxClipboardOpen();
bool WXDLLEXPORT wxCloseClipboard(); bool WXDLLEXPORT wxCloseClipboard();
bool WXDLLEXPORT wxEmptyClipboard(); bool WXDLLEXPORT wxEmptyClipboard();
bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat); bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0); bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL); wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
int WXDLLEXPORT wxEnumClipboardFormats(int dataFormat); wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat);
int WXDLLEXPORT wxRegisterClipboardFormat(char *formatName); wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount); 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. /* A clipboard client holds data belonging to the clipboard.
For plain text, a client is not necessary. */ For plain text, a client is not necessary. */
@@ -100,5 +160,8 @@ void WXDLLEXPORT wxInitClipboard();
/* The clipboard */ /* The clipboard */
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard; WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
#endif
// Old clipboard class
#endif #endif
// _WX_CLIPBRD_H_ // _WX_CLIPBRD_H_

View File

@@ -1,22 +1,27 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: dnd.h // Name: dnd.h
// Purpose: Declaration of the wxDropTarget, wxDropSource class etc. // Purpose: declaration of wxDropTarget, wxDropSource classes
// Author: Julian Smart // Author: Julian Smart
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DND_H_ #ifndef _WX_DND_H_
#define _WX_DND_H_ #define _WX_DND_H_
#ifdef __GNUG__ #ifdef __GNUG__
#pragma interface "dnd.h" #pragma interface
#endif #endif
#include "wx/defs.h" #include "wx/defs.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/object.h" #include "wx/object.h"
#include "wx/string.h" #include "wx/string.h"
#include "wx/dataobj.h"
#include "wx/cursor.h" #include "wx/cursor.h"
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -25,119 +30,13 @@
class WXDLLEXPORT wxWindow; class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxDataObject;
class WXDLLEXPORT wxTextDataObject;
class WXDLLEXPORT wxFileDataObject;
class WXDLLEXPORT wxDropTarget; class WXDLLEXPORT wxDropTarget;
class WXDLLEXPORT wxTextDropTarget; class WXDLLEXPORT wxTextDropTarget;
class WXDLLEXPORT wxFileDropTarget; class WXDLLEXPORT wxFileDropTarget;
class WXDLLEXPORT wxPrivateDropTarget;
class WXDLLEXPORT wxDropSource; 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 // wxDropTarget
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -151,16 +50,14 @@ class WXDLLEXPORT wxDropTarget: public wxObject
virtual void OnEnter() { } virtual void OnEnter() { }
virtual void OnLeave() { } 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: // Override these to indicate what kind of data you support:
virtual size_t GetFormatCount() const = 0; virtual size_t GetFormatCount() const = 0;
virtual wxDataFormat GetFormat(size_t n) const = 0; virtual wxDataFormat GetFormat(size_t n) const = 0;
// implementation
}; };
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
@@ -172,7 +69,7 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
public: public:
wxTextDropTarget() {}; 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 ); virtual bool OnDropText( long x, long y, const char *psz );
protected: protected:
@@ -181,6 +78,36 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
virtual wxDataFormat GetFormat(size_t n) const; 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) // A drop target which accepts files (dragged from File Manager or Explorer)
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -191,9 +118,9 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
wxFileDropTarget() {}; 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, virtual bool OnDropFiles( long x, long y,
size_t nFiles, const char * const aszFiles[]); size_t nFiles, const char * const aszFiles[] );
protected: protected:
@@ -205,14 +132,14 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
// wxDropSource // wxDropSource
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
enum wxDragResult enum wxDragResult
{ {
wxDragError, // error prevented the d&d operation from completing wxDragError, // error prevented the d&d operation from completing
wxDragNone, // drag target didn't accept the data wxDragNone, // drag target didn't accept the data
wxDragCopy, // the data was successfully copied wxDragCopy, // the data was successfully copied
wxDragMove, // the data was successfully moved wxDragMove, // the data was successfully moved
wxDragCancel // the operation was cancelled by user (not an error) wxDragCancel // the operation was cancelled by user (not an error)
}; };
class WXDLLEXPORT wxDropSource: public wxObject class WXDLLEXPORT wxDropSource: public wxObject
{ {
@@ -227,12 +154,25 @@ class WXDLLEXPORT wxDropSource: public wxObject
wxDragResult DoDragDrop( bool bAllowMove = FALSE ); wxDragResult DoDragDrop( bool bAllowMove = FALSE );
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; }; 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; wxDataObject *m_data;
wxCursor m_defaultCursor;
wxCursor m_goaheadCursor;
#endif
}; };
#endif
// wxUSE_DRAG_AND_DROP
#endif #endif
//_WX_DND_H_ //_WX_DND_H_

View File

@@ -418,7 +418,6 @@ public:
void OnChar(wxKeyEvent& event); void OnChar(wxKeyEvent& event);
void OnKeyDown(wxKeyEvent& event); void OnKeyDown(wxKeyEvent& event);
void OnKeyUp(wxKeyEvent& event); void OnKeyUp(wxKeyEvent& event);
void OnChar(wxKeyEvent& event);
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnIdle(wxIdleEvent& event); void OnIdle(wxIdleEvent& event);

View File

@@ -29,7 +29,7 @@ class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
public: public:
wxAcceleratorRefData(); wxAcceleratorRefData();
~wxAcceleratorRefData(); ~wxAcceleratorRefData();
public: public:
int m_count; int m_count;
wxAcceleratorEntry* m_entries; wxAcceleratorEntry* m_entries;
@@ -71,13 +71,13 @@ wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[])
{ {
wxAcceleratorRefData* data = new wxAcceleratorRefData; wxAcceleratorRefData* data = new wxAcceleratorRefData;
m_refData = data; m_refData = data;
data->m_count = n; data->m_count = n;
data->m_entries = new wxAcceleratorEntry[n]; data->m_entries = new wxAcceleratorEntry[n];
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
data->m_entries[i] = entries[i]; data->m_entries[i] = entries[i];
} }
bool wxAcceleratorTable::Ok() const bool wxAcceleratorTable::Ok() const
@@ -102,17 +102,17 @@ bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
bool eventCtrlDown = event.ControlDown(); bool eventCtrlDown = event.ControlDown();
bool eventShiftDown = event.ShiftDown(); bool eventShiftDown = event.ShiftDown();
int eventKeyCode = event.KeyCode(); int eventKeyCode = event.KeyCode();
bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT); bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT);
bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL); bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL);
bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT); bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
int accKeyCode = GetKeyCode(); int accKeyCode = GetKeyCode();
int accKeyCode2 = GetKeyCode(); int accKeyCode2 = GetKeyCode();
if (isascii(accKeyCode2)) if (isascii(accKeyCode2))
accKeyCode2 = wxToLower(accKeyCode2); accKeyCode2 = wxToLower(accKeyCode2);
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) && return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
(eventShiftDown == accShiftDown) && (eventShiftDown == accShiftDown) &&
((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ; ((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
} }

View File

@@ -57,7 +57,7 @@ wxHashTable *wxWidgetHashTable = NULL;
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler) IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler) BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle) EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #endif
@@ -70,35 +70,35 @@ bool wxApp::Initialize()
#else #else
wxBuffer = new char[BUFSIZ + 512]; wxBuffer = new char[BUFSIZ + 512];
#endif #endif
wxClassInfo::InitializeClasses(); wxClassInfo::InitializeClasses();
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING); wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize(); wxTheColourDatabase->Initialize();
wxInitializeStockLists(); wxInitializeStockLists();
wxInitializeStockObjects(); wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
wxInitializeResourceSystem(); wxInitializeResourceSystem();
#endif #endif
// For PostScript printing // For PostScript printing
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
/* Done using wxModule now /* Done using wxModule now
wxInitializePrintSetupData(); wxInitializePrintSetupData();
wxThePrintPaperDatabase = new wxPrintPaperDatabase; wxThePrintPaperDatabase = new wxPrintPaperDatabase;
wxThePrintPaperDatabase->CreateDatabase(); wxThePrintPaperDatabase->CreateDatabase();
*/ */
#endif #endif
wxBitmap::InitStandardHandlers(); wxBitmap::InitStandardHandlers();
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER); wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
wxModule::RegisterModules(); wxModule::RegisterModules();
if (!wxModule::InitializeModules()) return FALSE; if (!wxModule::InitializeModules()) return FALSE;
return TRUE; return TRUE;
} }
@@ -106,50 +106,50 @@ void wxApp::CleanUp()
{ {
delete wxWidgetHashTable; delete wxWidgetHashTable;
wxWidgetHashTable = NULL; wxWidgetHashTable = NULL;
wxModule::CleanUpModules(); wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES #if wxUSE_WX_RESOURCES
wxCleanUpResourceSystem(); wxCleanUpResourceSystem();
#endif #endif
wxDeleteStockObjects() ; wxDeleteStockObjects() ;
// Destroy all GDI lists, etc. // Destroy all GDI lists, etc.
delete wxTheBrushList; delete wxTheBrushList;
wxTheBrushList = NULL; wxTheBrushList = NULL;
delete wxThePenList; delete wxThePenList;
wxThePenList = NULL; wxThePenList = NULL;
delete wxTheFontList; delete wxTheFontList;
wxTheFontList = NULL; wxTheFontList = NULL;
delete wxTheBitmapList; delete wxTheBitmapList;
wxTheBitmapList = NULL; wxTheBitmapList = NULL;
delete wxTheColourDatabase; delete wxTheColourDatabase;
wxTheColourDatabase = NULL; wxTheColourDatabase = NULL;
#if wxUSE_POSTSCRIPT #if wxUSE_POSTSCRIPT
/* Done using wxModule now /* Done using wxModule now
wxInitializePrintSetupData(FALSE); wxInitializePrintSetupData(FALSE);
delete wxThePrintPaperDatabase; delete wxThePrintPaperDatabase;
wxThePrintPaperDatabase = NULL; wxThePrintPaperDatabase = NULL;
*/ */
#endif #endif
wxBitmap::CleanUpHandlers(); wxBitmap::CleanUpHandlers();
delete[] wxBuffer; delete[] wxBuffer;
wxBuffer = NULL; wxBuffer = NULL;
wxClassInfo::CleanUpClasses(); wxClassInfo::CleanUpClasses();
delete wxTheApp; delete wxTheApp;
wxTheApp = NULL; wxTheApp = NULL;
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT #if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// At this point we want to check if there are any memory // At this point we want to check if there are any memory
// blocks that aren't part of the wxDebugContext itself, // blocks that aren't part of the wxDebugContext itself,
@@ -157,12 +157,12 @@ void wxApp::CleanUp()
// wxDebugContext, too. // wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft(TRUE) > 0) if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{ {
wxLogDebug("There were memory leaks.\n"); wxLogDebug("There were memory leaks.\n");
wxDebugContext::Dump(); wxDebugContext::Dump();
wxDebugContext::PrintStatistics(); wxDebugContext::PrintStatistics();
} }
#endif #endif
// do it as the very last thing because everything else can log messages // do it as the very last thing because everything else can log messages
wxLog::DontCreateOnDemand(); wxLog::DontCreateOnDemand();
// do it as the very last thing because everything else can log messages // do it as the very last thing because everything else can log messages
@@ -180,66 +180,66 @@ int wxEntry( int argc, char *argv[] )
// checked, but this is a reasonable compromise. // checked, but this is a reasonable compromise.
wxDebugContext::SetCheckpoint(); wxDebugContext::SetCheckpoint();
#endif #endif
if (!wxApp::Initialize())
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::Initialize())
}; return FALSE;
if (!wxTheApp) if (!wxTheApp)
{ {
printf( "wxWindows error: wxTheApp == NULL\n" ); if (!wxApp::GetInitializerFunction())
return 0; {
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;
};
wxTheApp->SetClassName(wxFileNameFromPath(argv[0])); wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
wxTheApp->SetAppName(wxFileNameFromPath(argv[0])); wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
wxTheApp->argc = argc; wxTheApp->argc = argc;
wxTheApp->argv = argv; wxTheApp->argv = argv;
// GUI-specific initialization, such as creating an app context. // GUI-specific initialization, such as creating an app context.
wxTheApp->OnInitGui(); wxTheApp->OnInitGui();
// Here frames insert themselves automatically // Here frames insert themselves automatically
// into wxTopLevelWindows by getting created // into wxTopLevelWindows by getting created
// in OnInit(). // in OnInit().
int retValue = 0; int retValue = 0;
if (wxTheApp->OnInit()) if (wxTheApp->OnInit())
{ {
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun(); if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
} }
// flush the logged messages if any // flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget(); wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() ) if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush(); pLog->Flush();
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
// for further messages // for further messages
if (wxTheApp->GetTopWindow()) if (wxTheApp->GetTopWindow())
{ {
delete wxTheApp->GetTopWindow(); delete wxTheApp->GetTopWindow();
wxTheApp->SetTopWindow(NULL); wxTheApp->SetTopWindow(NULL);
} }
wxTheApp->DeletePendingObjects(); wxTheApp->DeletePendingObjects();
wxTheApp->OnExit(); wxTheApp->OnExit();
wxApp::CleanUp(); wxApp::CleanUp();
return retValue; return retValue;
}; };
@@ -258,7 +258,7 @@ wxApp::wxApp()
m_printMode = wxPRINT_POSTSCRIPT; m_printMode = wxPRINT_POSTSCRIPT;
m_exitOnFrameDelete = TRUE; m_exitOnFrameDelete = TRUE;
m_auto3D = TRUE; m_auto3D = TRUE;
m_mainColormap = (WXColormap) NULL; m_mainColormap = (WXColormap) NULL;
m_appContext = (WXAppContext) NULL; m_appContext = (WXAppContext) NULL;
m_topLevelWidget = (WXWidget) NULL; m_topLevelWidget = (WXWidget) NULL;
@@ -269,50 +269,50 @@ wxApp::wxApp()
bool wxApp::Initialized() bool wxApp::Initialized()
{ {
if (GetTopWindow()) if (GetTopWindow())
return TRUE; return TRUE;
else else
return FALSE; return FALSE;
} }
int wxApp::MainLoop() int wxApp::MainLoop()
{ {
m_keepGoing = TRUE; m_keepGoing = TRUE;
/* /*
* Sit around forever waiting to process X-events. Property Change * Sit around forever waiting to process X-events. Property Change
* event are handled special, because they have to refer to * event are handled special, because they have to refer to
* the root window rather than to a widget. therefore we can't * the root window rather than to a widget. therefore we can't
* use an Xt-eventhandler. * use an Xt-eventhandler.
*/ */
XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()),
XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())), XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
PropertyChangeMask); PropertyChangeMask);
XEvent event; XEvent event;
// Use this flag to allow breaking the loop via wxApp::ExitMainLoop() // Use this flag to allow breaking the loop via wxApp::ExitMainLoop()
while (m_keepGoing) while (m_keepGoing)
{ {
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event); ProcessXEvent((WXEvent*) & event);
if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0) if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
{ {
if (!ProcessIdle()) if (!ProcessIdle())
{ {
// TODO: Robert, what's this for? // TODO: Robert, what's this for?
#if wxUSE_THREADS #if wxUSE_THREADS
wxMutexGuiLeave(); wxMutexGuiLeave();
usleep(20); usleep(20);
wxMutexGuiEnter(); wxMutexGuiEnter();
#endif #endif
} }
} }
} }
return 0; return 0;
} }
@@ -320,7 +320,7 @@ int wxApp::MainLoop()
void wxApp::ProcessXEvent(WXEvent* _event) void wxApp::ProcessXEvent(WXEvent* _event)
{ {
XEvent* event = (XEvent*) _event; XEvent* event = (XEvent*) _event;
if ((event->type == KeyPress) && CheckForAccelerator(_event)) if ((event->type == KeyPress) && CheckForAccelerator(_event))
{ {
// Do nothing! We intercepted and processed the event as an accelerator. // Do nothing! We intercepted and processed the event as an accelerator.
@@ -333,22 +333,22 @@ void wxApp::ProcessXEvent(WXEvent* _event)
} }
else if (event->type == ResizeRequest) else if (event->type == ResizeRequest)
{ {
/* Terry Gitnick <terryg@scientech.com> - 1/21/98 /* Terry Gitnick <terryg@scientech.com> - 1/21/98
* If resize event, don't resize until the last resize event for this * If resize event, don't resize until the last resize event for this
* window is recieved. Prevents flicker as windows are resized. * window is recieved. Prevents flicker as windows are resized.
*/ */
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget()); Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
Window win = event->xany.window; Window win = event->xany.window;
XEvent report; XEvent report;
// to avoid flicker // to avoid flicker
report = * event; report = * event;
while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report)); while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report));
// TODO: when implementing refresh optimization, we can use // TODO: when implementing refresh optimization, we can use
// XtAddExposureToRegion to expand the window's paint region. // XtAddExposureToRegion to expand the window's paint region.
XtDispatchEvent(event); XtDispatchEvent(event);
} }
else else
@@ -363,7 +363,7 @@ bool wxApp::ProcessIdle()
wxIdleEvent event; wxIdleEvent event;
event.SetEventObject(this); event.SetEventObject(this);
ProcessEvent(event); ProcessEvent(event);
return event.MoreRequested(); return event.MoreRequested();
} }
@@ -376,7 +376,7 @@ void wxApp::ExitMainLoop()
bool wxApp::Pending() bool wxApp::Pending()
{ {
XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() )); XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
// Fix by Doug from STI, to prevent a stall if non-X event // Fix by Doug from STI, to prevent a stall if non-X event
// is found. // is found.
return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ; return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
@@ -385,8 +385,8 @@ bool wxApp::Pending()
// Dispatch a message. // Dispatch a message.
void wxApp::Dispatch() void wxApp::Dispatch()
{ {
// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll); // XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
XEvent event; XEvent event;
XtAppNextEvent((XtAppContext) GetAppContext(), &event); XtAppNextEvent((XtAppContext) GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event); ProcessXEvent((WXEvent*) & event);
@@ -403,27 +403,27 @@ void wxApp::HandlePropertyChange(WXEvent *event)
void wxApp::OnIdle(wxIdleEvent& event) void wxApp::OnIdle(wxIdleEvent& event)
{ {
static bool inOnIdle = FALSE; static bool inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case) // Avoid recursion (via ProcessEvent default case)
if (inOnIdle) if (inOnIdle)
return; return;
inOnIdle = TRUE; inOnIdle = TRUE;
// 'Garbage' collection of windows deleted with Close(). // 'Garbage' collection of windows deleted with Close().
DeletePendingObjects(); DeletePendingObjects();
// flush the logged messages if any // flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget(); wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() ) if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush(); pLog->Flush();
// Send OnIdle events to all windows // Send OnIdle events to all windows
bool needMore = SendIdleEvents(); bool needMore = SendIdleEvents();
if (needMore) if (needMore)
event.RequestMore(TRUE); event.RequestMore(TRUE);
inOnIdle = FALSE; inOnIdle = FALSE;
} }
@@ -431,15 +431,15 @@ void wxApp::OnIdle(wxIdleEvent& event)
bool wxApp::SendIdleEvents() bool wxApp::SendIdleEvents()
{ {
bool needMore = FALSE; bool needMore = FALSE;
wxNode* node = wxTopLevelWindows.First(); wxNode* node = wxTopLevelWindows.First();
while (node) while (node)
{ {
wxWindow* win = (wxWindow*) node->Data(); wxWindow* win = (wxWindow*) node->Data();
if (SendIdleEvents(win)) if (SendIdleEvents(win))
needMore = TRUE; needMore = TRUE;
node = node->Next(); node = node->Next();
} }
return needMore; return needMore;
} }
@@ -447,23 +447,23 @@ bool wxApp::SendIdleEvents()
bool wxApp::SendIdleEvents(wxWindow* win) bool wxApp::SendIdleEvents(wxWindow* win)
{ {
bool needMore = FALSE; bool needMore = FALSE;
wxIdleEvent event; wxIdleEvent event;
event.SetEventObject(win); event.SetEventObject(win);
win->ProcessEvent(event); win->ProcessEvent(event);
if (event.MoreRequested()) if (event.MoreRequested())
needMore = TRUE; needMore = TRUE;
wxNode* node = win->GetChildren().First(); wxNode* node = win->GetChildren().First();
while (node) while (node)
{ {
wxWindow* win = (wxWindow*) node->Data(); wxWindow* win = (wxWindow*) node->Data();
if (SendIdleEvents(win)) if (SendIdleEvents(win))
needMore = TRUE; needMore = TRUE;
node = node->Next(); node = node->Next();
} }
return needMore ; return needMore ;
} }
@@ -472,16 +472,16 @@ void wxApp::DeletePendingObjects()
wxNode *node = wxPendingDelete.First(); wxNode *node = wxPendingDelete.First();
while (node) while (node)
{ {
wxObject *obj = (wxObject *)node->Data(); wxObject *obj = (wxObject *)node->Data();
delete obj; delete obj;
if (wxPendingDelete.Member(obj)) if (wxPendingDelete.Member(obj))
delete node; delete node;
// Deleting one object may have deleted other pending // Deleting one object may have deleted other pending
// objects, so start from beginning of list again. // objects, so start from beginning of list again.
node = wxPendingDelete.First(); node = wxPendingDelete.First();
} }
} }
@@ -506,46 +506,46 @@ bool wxApp::OnInitGui()
XtToolkitInitialize() ; XtToolkitInitialize() ;
wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ; wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ;
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL, Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
(const char*) wxTheApp->GetClassName(), NULL, (const char*) wxTheApp->GetClassName(), NULL,
# if XtSpecificationRelease < 5 # if XtSpecificationRelease < 5
0,(Cardinal*) &argc,argv) ; 0,(Cardinal*) &argc,argv) ;
# else # else
0,&argc,argv) ; 0,&argc,argv) ;
# endif # endif
if (!dpy) { if (!dpy) {
cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n"; cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
exit(-1); exit(-1);
} }
m_initialDisplay = (WXDisplay*) dpy; m_initialDisplay = (WXDisplay*) dpy;
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(), wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
applicationShellWidgetClass,dpy, applicationShellWidgetClass,dpy,
NULL,0) ; NULL,0) ;
// Add general resize proc // Add general resize proc
XtActionsRec rec; XtActionsRec rec;
rec.string = "resize"; rec.string = "resize";
rec.proc = (XtActionProc)wxWidgetResizeProc; rec.proc = (XtActionProc)wxWidgetResizeProc;
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1); XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
GetMainColormap(dpy); GetMainColormap(dpy);
m_maxRequestSize = XMaxRequestSize((Display*) dpy); m_maxRequestSize = XMaxRequestSize((Display*) dpy);
return TRUE; return TRUE;
} }
WXColormap wxApp::GetMainColormap(WXDisplay* display) WXColormap wxApp::GetMainColormap(WXDisplay* display)
{ {
if (!display) /* Must be called first with non-NULL display */ if (!display) /* Must be called first with non-NULL display */
return m_mainColormap; return m_mainColormap;
Colormap c = Colormap c =
DefaultColormapOfScreen(XScreenOfDisplay((Display*) display, DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
DefaultScreen((Display*) display))); DefaultScreen((Display*) display)));
if (!m_mainColormap) if (!m_mainColormap)
m_mainColormap = (WXColormap) c; m_mainColormap = (WXColormap) c;
return (WXColormap) c; return (WXColormap) c;
} }
@@ -559,17 +559,17 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
// TODO: should get display for the window, not the current display // TODO: should get display for the window, not the current display
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window); Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window);
wxWindow* win = NULL; wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window // Find the first wxWindow that corresponds to this event window
while (widget && !(win = wxGetWindowFromTable(widget))) while (widget && !(win = wxGetWindowFromTable(widget)))
widget = XtParent(widget); widget = XtParent(widget);
if (!widget || !win) if (!widget || !win)
return FALSE; return FALSE;
wxKeyEvent keyEvent(wxEVT_CHAR); wxKeyEvent keyEvent(wxEVT_CHAR);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent); wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
// Now we have a wxKeyEvent and we have a wxWindow. // Now we have a wxKeyEvent and we have a wxWindow.
// Go up the hierarchy until we find a matching accelerator, // Go up the hierarchy until we find a matching accelerator,
// or we get to the top. // or we get to the top.
@@ -588,13 +588,13 @@ void wxExit()
{ {
int retValue = 0; int retValue = 0;
if (wxTheApp) if (wxTheApp)
retValue = wxTheApp->OnExit(); retValue = wxTheApp->OnExit();
wxApp::CleanUp(); wxApp::CleanUp();
/* /*
* Exit in some platform-specific way. Not recommended that the app calls this: * Exit in some platform-specific way. Not recommended that the app calls this:
* only for emergencies. * only for emergencies.
*/ */
exit(retValue); exit(retValue);
} }
@@ -602,7 +602,7 @@ void wxExit()
bool wxYield() bool wxYield()
{ {
while (wxTheApp && wxTheApp->Pending()) while (wxTheApp && wxTheApp->Pending())
wxTheApp->Dispatch(); wxTheApp->Dispatch();
return TRUE; return TRUE;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -36,82 +36,82 @@ wxBitmapButton::wxBitmapButton()
} }
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap, bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_buttonBitmap = bitmap; m_buttonBitmap = bitmap;
m_buttonBitmapOriginal = bitmap; m_buttonBitmapOriginal = bitmap;
m_buttonBitmapSelected = bitmap; m_buttonBitmapSelected = bitmap;
m_buttonBitmapSelectedOriginal = bitmap; m_buttonBitmapSelectedOriginal = bitmap;
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
parent->AddChild(this); parent->AddChild(this);
m_backgroundColour = parent->GetBackgroundColour() ; m_backgroundColour = parent->GetBackgroundColour() ;
m_foregroundColour = parent->GetForegroundColour() ; m_foregroundColour = parent->GetForegroundColour() ;
m_windowStyle = style; m_windowStyle = style;
m_marginX = 0; m_marginX = 0;
m_marginY = 0; m_marginY = 0;
/* /*
int x = pos.x; int x = pos.x;
int y = pos.y; int y = pos.y;
int width = size.x; int width = size.x;
int height = size.y; int height = size.y;
*/ */
if (id == -1) if (id == -1)
m_windowId = NewControlId(); m_windowId = NewControlId();
else else
m_windowId = id; m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
/* /*
* Patch Note (important) * Patch Note (important)
* There is no major reason to put a defaultButtonThickness here. * There is no major reason to put a defaultButtonThickness here.
* Not requesting it give the ability to put wxButton with a spacing * Not requesting it give the ability to put wxButton with a spacing
* as small as requested. However, if some button become a DefaultButton, * as small as requested. However, if some button become a DefaultButton,
* other buttons are no more aligned -- This is why we set * other buttons are no more aligned -- This is why we set
* defaultButtonThickness of ALL buttons belonging to the same wxPanel, * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
* in the ::SetDefaultButton method. * in the ::SetDefaultButton method.
*/ */
Widget buttonWidget = XtVaCreateManagedWidget ("button", Widget buttonWidget = XtVaCreateManagedWidget ("button",
// Gadget causes problems for default button operation. // Gadget causes problems for default button operation.
#if wxUSE_GADGETS #if wxUSE_GADGETS
xmPushButtonGadgetClass, parentWidget, xmPushButtonGadgetClass, parentWidget,
#else #else
xmPushButtonWidgetClass, parentWidget, xmPushButtonWidgetClass, parentWidget,
#endif #endif
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault // XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
NULL); NULL);
m_mainWidget = (WXWidget) buttonWidget; m_mainWidget = (WXWidget) buttonWidget;
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
ChangeBackgroundColour (); ChangeBackgroundColour ();
DoSetBitmap(); DoSetBitmap();
XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this); (XtPointer) this);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
return TRUE; return TRUE;
} }
wxBitmapButton::~wxBitmapButton() wxBitmapButton::~wxBitmapButton()
{ {
SetBitmapLabel(wxNullBitmap); SetBitmapLabel(wxNullBitmap);
if (m_insensPixmap) if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()), (Pixmap) m_insensPixmap); XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()), (Pixmap) m_insensPixmap);
} }
@@ -120,7 +120,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
{ {
m_buttonBitmapOriginal = bitmap; m_buttonBitmapOriginal = bitmap;
m_buttonBitmap = bitmap; m_buttonBitmap = bitmap;
DoSetBitmap(); DoSetBitmap();
} }
@@ -128,7 +128,7 @@ void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel)
{ {
m_buttonBitmapSelected = sel; m_buttonBitmapSelected = sel;
m_buttonBitmapSelectedOriginal = sel; m_buttonBitmapSelectedOriginal = sel;
DoSetBitmap(); DoSetBitmap();
}; };
@@ -142,7 +142,7 @@ void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled)
{ {
m_buttonBitmapDisabled = disabled; m_buttonBitmapDisabled = disabled;
m_buttonBitmapDisabledOriginal = disabled; m_buttonBitmapDisabledOriginal = disabled;
DoSetBitmap(); DoSetBitmap();
}; };
@@ -153,40 +153,40 @@ void wxBitmapButton::DoSetBitmap()
Pixmap pixmap = 0; Pixmap pixmap = 0;
Pixmap insensPixmap = 0; Pixmap insensPixmap = 0;
Pixmap armPixmap = 0; Pixmap armPixmap = 0;
// Must re-make the bitmap to have its transparent areas drawn // Must re-make the bitmap to have its transparent areas drawn
// in the current widget background colour. // in the current widget background colour.
if (m_buttonBitmapOriginal.GetMask()) if (m_buttonBitmapOriginal.GetMask())
{ {
int backgroundPixel; int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel, XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
NULL); NULL);
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapOriginal, col); wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapOriginal, col);
m_buttonBitmap = newBitmap; m_buttonBitmap = newBitmap;
pixmap = (Pixmap) m_buttonBitmap.GetPixmap(); pixmap = (Pixmap) m_buttonBitmap.GetPixmap();
} }
else else
pixmap = (Pixmap) m_buttonBitmap.GetLabelPixmap(m_mainWidget); pixmap = (Pixmap) m_buttonBitmap.GetLabelPixmap(m_mainWidget);
if (m_buttonBitmapDisabledOriginal.Ok()) if (m_buttonBitmapDisabledOriginal.Ok())
{ {
if (m_buttonBitmapDisabledOriginal.GetMask()) if (m_buttonBitmapDisabledOriginal.GetMask())
{ {
int backgroundPixel; int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel, XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
NULL); NULL);
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapDisabledOriginal, col); wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapDisabledOriginal, col);
m_buttonBitmapDisabled = newBitmap; m_buttonBitmapDisabled = newBitmap;
insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetPixmap(); insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetPixmap();
} }
else else
@@ -194,7 +194,7 @@ void wxBitmapButton::DoSetBitmap()
} }
else else
insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget); insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget);
// Now make the bitmap representing the armed state // Now make the bitmap representing the armed state
if (m_buttonBitmapSelectedOriginal.Ok()) if (m_buttonBitmapSelectedOriginal.Ok())
{ {
@@ -202,29 +202,29 @@ void wxBitmapButton::DoSetBitmap()
{ {
int backgroundPixel; int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget, XmNarmColor, &backgroundPixel, XtVaGetValues((Widget) m_mainWidget, XmNarmColor, &backgroundPixel,
NULL); NULL);
wxColour col; wxColour col;
col.SetPixel(backgroundPixel); col.SetPixel(backgroundPixel);
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapSelectedOriginal, col); wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapSelectedOriginal, col);
m_buttonBitmapSelected = newBitmap; m_buttonBitmapSelected = newBitmap;
armPixmap = (Pixmap) m_buttonBitmapSelected.GetPixmap(); armPixmap = (Pixmap) m_buttonBitmapSelected.GetPixmap();
} }
else else
armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget); armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
} }
else 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! if (insensPixmap == pixmap) // <- the Get...Pixmap()-functions return the same pixmap!
{ {
insensPixmap = insensPixmap =
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap); XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
m_insensPixmap = (WXPixmap) insensPixmap; m_insensPixmap = (WXPixmap) insensPixmap;
} }
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNlabelPixmap, pixmap, XmNlabelPixmap, pixmap,
XmNlabelInsensitivePixmap, insensPixmap, XmNlabelInsensitivePixmap, insensPixmap,
@@ -239,7 +239,7 @@ void wxBitmapButton::DoSetBitmap()
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNlabelType, XmSTRING, XmNlabelType, XmSTRING,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP, XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP, XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
XmNarmPixmap, XmUNSPECIFIED_PIXMAP, XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
NULL); NULL);
} }
@@ -248,7 +248,7 @@ void wxBitmapButton::DoSetBitmap()
void wxBitmapButton::ChangeBackgroundColour() void wxBitmapButton::ChangeBackgroundColour()
{ {
DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE); DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE);
// Must reset the bitmaps since the colours have changed. // Must reset the bitmaps since the colours have changed.
DoSetBitmap(); DoSetBitmap();
} }

View File

@@ -28,9 +28,9 @@ wxBrushRefData::wxBrushRefData()
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data) wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
{ {
m_style = data.m_style; m_style = data.m_style;
m_stipple = data.m_stipple; m_stipple = data.m_stipple;
m_colour = data.m_colour; m_colour = data.m_colour;
} }
wxBrushRefData::~wxBrushRefData() wxBrushRefData::~wxBrushRefData()
@@ -53,12 +53,12 @@ wxBrush::~wxBrush()
wxBrush::wxBrush(const wxColour& col, int Style) wxBrush::wxBrush(const wxColour& col, int Style)
{ {
m_refData = new wxBrushRefData; m_refData = new wxBrushRefData;
M_BRUSHDATA->m_colour = col; M_BRUSHDATA->m_colour = col;
M_BRUSHDATA->m_style = Style; M_BRUSHDATA->m_style = Style;
RealizeResource(); RealizeResource();
if ( wxTheBrushList ) if ( wxTheBrushList )
wxTheBrushList->AddBrush(this); wxTheBrushList->AddBrush(this);
} }
@@ -66,64 +66,64 @@ wxBrush::wxBrush(const wxColour& col, int Style)
wxBrush::wxBrush(const wxBitmap& stipple) wxBrush::wxBrush(const wxBitmap& stipple)
{ {
m_refData = new wxBrushRefData; m_refData = new wxBrushRefData;
M_BRUSHDATA->m_style = wxSTIPPLE; M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_stipple = stipple; M_BRUSHDATA->m_stipple = stipple;
RealizeResource(); RealizeResource();
if ( wxTheBrushList ) if ( wxTheBrushList )
wxTheBrushList->AddBrush(this); wxTheBrushList->AddBrush(this);
} }
void wxBrush::Unshare() void wxBrush::Unshare()
{ {
// Don't change shared data // Don't change shared data
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxBrushRefData(); m_refData = new wxBrushRefData();
} }
else else
{ {
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData); wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
UnRef(); UnRef();
m_refData = ref; m_refData = ref;
} }
} }
void wxBrush::SetColour(const wxColour& col) void wxBrush::SetColour(const wxColour& col)
{ {
Unshare(); Unshare();
M_BRUSHDATA->m_colour = col; M_BRUSHDATA->m_colour = col;
RealizeResource(); RealizeResource();
} }
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b) void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
{ {
Unshare(); Unshare();
M_BRUSHDATA->m_colour.Set(r, g, b); M_BRUSHDATA->m_colour.Set(r, g, b);
RealizeResource(); RealizeResource();
} }
void wxBrush::SetStyle(int Style) void wxBrush::SetStyle(int Style)
{ {
Unshare(); Unshare();
M_BRUSHDATA->m_style = Style; M_BRUSHDATA->m_style = Style;
RealizeResource(); RealizeResource();
} }
void wxBrush::SetStipple(const wxBitmap& Stipple) void wxBrush::SetStipple(const wxBitmap& Stipple)
{ {
Unshare(); Unshare();
M_BRUSHDATA->m_stipple = Stipple; M_BRUSHDATA->m_stipple = Stipple;
RealizeResource(); RealizeResource();
} }

View File

@@ -30,10 +30,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
// Button // Button
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label, bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -41,48 +41,48 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
parent->AddChild((wxButton *)this); parent->AddChild((wxButton *)this);
if (id == -1) if (id == -1)
m_windowId = NewControlId(); m_windowId = NewControlId();
else else
m_windowId = id; m_windowId = id;
wxString label1(wxStripMenuCodes(label)); wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1); XmString text = XmStringCreateSimple ((char*) (const char*) label1);
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget)); XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
/* /*
* Patch Note (important) * Patch Note (important)
* There is no major reason to put a defaultButtonThickness here. * There is no major reason to put a defaultButtonThickness here.
* Not requesting it give the ability to put wxButton with a spacing * Not requesting it give the ability to put wxButton with a spacing
* as small as requested. However, if some button become a DefaultButton, * as small as requested. However, if some button become a DefaultButton,
* other buttons are no more aligned -- This is why we set * other buttons are no more aligned -- This is why we set
* defaultButtonThickness of ALL buttons belonging to the same wxPanel, * defaultButtonThickness of ALL buttons belonging to the same wxPanel,
* in the ::SetDefaultButton method. * in the ::SetDefaultButton method.
*/ */
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button", m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
xmPushButtonWidgetClass, xmPushButtonWidgetClass,
parentWidget, parentWidget,
XmNfontList, fontList, XmNfontList, fontList,
XmNlabelString, text, XmNlabelString, text,
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault // XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
NULL); NULL);
XmStringFree (text); XmStringFree (text);
XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback, XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this); (XtPointer) this);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -91,33 +91,33 @@ void wxButton::SetDefault()
wxWindow *parent = (wxWindow *)GetParent(); wxWindow *parent = (wxWindow *)GetParent();
if (parent) if (parent)
parent->SetDefaultItem(this); parent->SetDefaultItem(this);
// We initially do not set XmNdefaultShadowThickness, to have small buttons. // We initially do not set XmNdefaultShadowThickness, to have small buttons.
// Unfortunately, buttons are now mis-aligned. We try to correct this // Unfortunately, buttons are now mis-aligned. We try to correct this
// now -- setting this ressource to 1 for each button in the same row. // 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, // Because it's very hard to find wxButton in the same row,
// correction is straighforward: we set resource for all wxButton // correction is straighforward: we set resource for all wxButton
// in this parent (but not sub panels) // in this parent (but not sub panels)
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ()) for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
{ {
wxButton *item = (wxButton *) node->Data (); wxButton *item = (wxButton *) node->Data ();
if (item->IsKindOf(CLASSINFO(wxButton))) if (item->IsKindOf(CLASSINFO(wxButton)))
{ {
bool managed = XtIsManaged((Widget) item->GetMainWidget()); bool managed = XtIsManaged((Widget) item->GetMainWidget());
if (managed) if (managed)
XtUnmanageChild ((Widget) item->GetMainWidget()); XtUnmanageChild ((Widget) item->GetMainWidget());
XtVaSetValues ((Widget) item->GetMainWidget(), XtVaSetValues ((Widget) item->GetMainWidget(),
XmNdefaultButtonShadowThickness, 1, XmNdefaultButtonShadowThickness, 1,
NULL); NULL);
if (managed) if (managed)
XtManageChild ((Widget) item->GetMainWidget()); XtManageChild ((Widget) item->GetMainWidget());
} }
} // while } // while
// XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL); // XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL); XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
} }
void wxButton::Command (wxCommandEvent & event) void wxButton::Command (wxCommandEvent & event)
@@ -127,14 +127,14 @@ void wxButton::Command (wxCommandEvent & event)
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr)) void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
{ {
if (!wxGetWindowFromTable(w)) if (!wxGetWindowFromTable(w))
// Widget has been deleted! // Widget has been deleted!
return; return;
wxButton *item = (wxButton *) clientData; wxButton *item = (wxButton *) clientData;
wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
event.SetEventObject(item); event.SetEventObject(item);
item->ProcessCommand (event); item->ProcessCommand (event);
} }
void wxButton::ChangeFont(bool keepOriginalSize) void wxButton::ChangeFont(bool keepOriginalSize)

View File

@@ -23,7 +23,7 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
void wxCheckBoxCallback (Widget w, XtPointer clientData, void wxCheckBoxCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
@@ -32,10 +32,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
// Single check box item // Single check box item
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label, bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -43,35 +43,35 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = NewControlId(); m_windowId = NewControlId();
else else
m_windowId = id; m_windowId = id;
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label); char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
XmString text = XmStringCreateSimple (label1); XmString text = XmStringCreateSimple (label1);
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget)); XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle", m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
xmToggleButtonWidgetClass, parentWidget, xmToggleButtonWidgetClass, parentWidget,
XmNfontList, fontList, XmNfontList, fontList,
XmNlabelString, text, XmNlabelString, text,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
XtAddCallback ((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc) wxCheckBoxCallback, XtAddCallback ((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc) wxCheckBoxCallback,
(XtPointer) this); (XtPointer) this);
XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE); XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -96,24 +96,24 @@ void wxCheckBox::Command (wxCommandEvent & event)
// Bitmap checkbox // Bitmap checkbox
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label, bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
m_windowStyle = style; m_windowStyle = style;
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = NewControlId(); m_windowId = NewControlId();
else else
m_windowId = id; m_windowId = id;
// TODO: Create the bitmap checkbox // TODO: Create the bitmap checkbox
return FALSE; return FALSE;
} }
@@ -139,17 +139,17 @@ bool wxBitmapCheckBox::GetValue() const
} }
void wxCheckBoxCallback (Widget w, XtPointer clientData, void wxCheckBoxCallback (Widget w, XtPointer clientData,
XtPointer ptr) XtPointer ptr)
{ {
wxCheckBox *item = (wxCheckBox *) clientData; wxCheckBox *item = (wxCheckBox *) clientData;
if (item->InSetValue())
return;
wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId()); if (item->InSetValue())
event.SetInt((int) item->GetValue ()); return;
event.SetEventObject(item);
item->ProcessCommand (event); 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::ChangeFont(bool keepOriginalSize)
@@ -159,19 +159,19 @@ void wxCheckBox::ChangeFont(bool keepOriginalSize)
void wxCheckBox::ChangeBackgroundColour() void wxCheckBox::ChangeBackgroundColour()
{ {
wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour, wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
(wxColour*) NULL); (wxColour*) NULL);
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNbackground, g_itemColors[wxBACK_INDEX].pixel, XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel, XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel, XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
XmNforeground, g_itemColors[wxFORE_INDEX].pixel, XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
NULL); NULL);
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNselectColor, g_itemColors[wxSELE_INDEX].pixel, XmNselectColor, g_itemColors[wxSELE_INDEX].pixel,
NULL); NULL);
} }
void wxCheckBox::ChangeForegroundColour() void wxCheckBox::ChangeForegroundColour()

View File

@@ -24,7 +24,7 @@
// ============================================================================ // ============================================================================
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox) IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -50,7 +50,7 @@ wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
int nStrings, const wxString choices[], int nStrings, const wxString choices[],
long style, const wxValidator& val, long style, const wxValidator& val,
const wxString& name) const wxString& name)
: wxListBox() : wxListBox()
{ {
// TODO: you'll probably need a separate Create instead of using // TODO: you'll probably need a separate Create instead of using
// the wxListBox one as here. // the wxListBox one as here.

View File

@@ -29,7 +29,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
#endif #endif
void wxChoiceCallback (Widget w, XtPointer clientData, void wxChoiceCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
wxChoice::wxChoice() wxChoice::wxChoice()
{ {
@@ -41,12 +41,12 @@ wxChoice::wxChoice()
} }
bool wxChoice::Create(wxWindow *parent, wxWindowID id, bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -56,49 +56,49 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
m_menuWidget = (WXWidget) 0; m_menuWidget = (WXWidget) 0;
m_widgetList = (WXWidget*) 0; m_widgetList = (WXWidget*) 0;
m_formWidget = (WXWidget) 0; m_formWidget = (WXWidget) 0;
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
xmRowColumnWidgetClass, parentWidget, xmRowColumnWidgetClass, parentWidget,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
XmNpacking, XmPACK_TIGHT, XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL, XmNorientation, XmHORIZONTAL,
NULL); NULL);
XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL); XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL);
/* /*
* Create the popup menu * Create the popup menu
*/ */
m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, "choiceMenu", NULL, 0); m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, "choiceMenu", NULL, 0);
// int i; // int i;
if (n > 0) if (n > 0)
{ {
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
Append (choices[i]); Append (choices[i]);
} }
/* /*
* Create button * Create button
*/ */
Arg args[10]; Arg args[10];
Cardinal argcnt = 0; Cardinal argcnt = 0;
XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget); XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget);
argcnt++; argcnt++;
XtSetArg (args[argcnt], XmNmarginWidth, 0); XtSetArg (args[argcnt], XmNmarginWidth, 0);
@@ -108,11 +108,11 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT); XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT);
argcnt++; argcnt++;
m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, "choiceButton", args, argcnt); m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, "choiceButton", args, argcnt);
m_mainWidget = m_buttonWidget; m_mainWidget = m_buttonWidget;
XtManageChild ((Widget) m_buttonWidget); XtManageChild ((Widget) m_buttonWidget);
// New code from Roland Haenel (roland_haenel@ac.cybercity.de) // New code from Roland Haenel (roland_haenel@ac.cybercity.de)
// Some time ago, I reported a problem with wxChoice-items under // Some time ago, I reported a problem with wxChoice-items under
// Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems // Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems
@@ -123,36 +123,36 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
XtUnmanageChild (optionLabel); XtUnmanageChild (optionLabel);
#endif #endif
#endif #endif
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
ChangeFont(FALSE); ChangeFont(FALSE);
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
wxChoice::~wxChoice() wxChoice::~wxChoice()
{ {
// For some reason destroying the menuWidget // For some reason destroying the menuWidget
// can cause crashes on some machines. It will // can cause crashes on some machines. It will
// be deleted implicitly by deleting the parent form // be deleted implicitly by deleting the parent form
// anyway. // anyway.
// XtDestroyWidget (menuWidget); // XtDestroyWidget (menuWidget);
if (m_widgetList) if (m_widgetList)
delete[] m_widgetList; delete[] m_widgetList;
if (GetMainWidget()) if (GetMainWidget())
{ {
DetachWidget(GetMainWidget()); // Removes event handlers DetachWidget(GetMainWidget()); // Removes event handlers
DetachWidget(m_formWidget); DetachWidget(m_formWidget);
XtDestroyWidget((Widget) m_formWidget); XtDestroyWidget((Widget) m_formWidget);
m_formWidget = (WXWidget) 0; m_formWidget = (WXWidget) 0;
// Presumably the other widgets have been deleted now, via the form // Presumably the other widgets have been deleted now, via the form
m_mainWidget = (WXWidget) 0; m_mainWidget = (WXWidget) 0;
m_buttonWidget = (WXWidget) 0; m_buttonWidget = (WXWidget) 0;
@@ -161,64 +161,64 @@ wxChoice::~wxChoice()
void wxChoice::Append(const wxString& item) void wxChoice::Append(const wxString& item)
{ {
wxStripMenuCodes ((char *)(const char *)item, wxBuffer); wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
Widget w = XtVaCreateManagedWidget (wxBuffer, Widget w = XtVaCreateManagedWidget (wxBuffer,
#if USE_GADGETS #if USE_GADGETS
xmPushButtonGadgetClass, (Widget) m_menuWidget, xmPushButtonGadgetClass, (Widget) m_menuWidget,
#else #else
xmPushButtonWidgetClass, (Widget) m_menuWidget, xmPushButtonWidgetClass, (Widget) m_menuWidget,
#endif #endif
NULL); NULL);
DoChangeBackgroundColour((WXWidget) w, m_backgroundColour); DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
if (m_windowFont.Ok()) if (m_windowFont.Ok())
XtVaSetValues (w, XtVaSetValues (w,
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)), XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
NULL); NULL);
WXWidget *new_widgetList = new WXWidget[m_noStrings + 1]; WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
int i; int i;
if (m_widgetList) if (m_widgetList)
for (i = 0; i < m_noStrings; i++) for (i = 0; i < m_noStrings; i++)
new_widgetList[i] = m_widgetList[i]; new_widgetList[i] = m_widgetList[i];
new_widgetList[m_noStrings] = (WXWidget) w; new_widgetList[m_noStrings] = (WXWidget) w;
if (m_widgetList) if (m_widgetList)
delete[] m_widgetList; delete[] m_widgetList;
m_widgetList = new_widgetList; m_widgetList = new_widgetList;
char mnem = wxFindMnemonic ((char*) (const char*) item); char mnem = wxFindMnemonic ((char*) (const char*) item);
if (mnem != 0) if (mnem != 0)
XtVaSetValues (w, XmNmnemonic, mnem, NULL); XtVaSetValues (w, XmNmnemonic, mnem, NULL);
XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this); XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
if (m_noStrings == 0 && m_buttonWidget) if (m_noStrings == 0 && m_buttonWidget)
{ {
XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
XmString text = XmStringCreateSimple ((char*) (const char*) item); XmString text = XmStringCreateSimple ((char*) (const char*) item);
XtVaSetValues (label, XtVaSetValues (label,
XmNlabelString, text, XmNlabelString, text,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
} }
wxNode *node = m_stringList.Add (item); wxNode *node = m_stringList.Add (item);
XtVaSetValues (w, XmNuserData, node->Data (), NULL); XtVaSetValues (w, XmNuserData, node->Data (), NULL);
m_noStrings ++; m_noStrings ++;
} }
void wxChoice::Delete(int WXUNUSED(n)) void wxChoice::Delete(int WXUNUSED(n))
{ {
wxFAIL_MSG( "Sorry, wxChoice::Delete isn't implemented yet. Maybe you'd like to volunteer? :-)" ); 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, // 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 // delete the m_stringList entry, delete the button widget, construct a new widget list
// (see Append) // (see Append)
// TODO // TODO
m_noStrings --; m_noStrings --;
} }
@@ -242,59 +242,59 @@ void wxChoice::Clear()
int wxChoice::GetSelection() const int wxChoice::GetSelection() const
{ {
XmString text; XmString text;
char *s; char *s;
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
XtVaGetValues (label, XtVaGetValues (label,
XmNlabelString, &text, XmNlabelString, &text,
NULL); NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{ {
int i = 0; int i = 0;
for (wxNode * node = m_stringList.First (); node; node = node->Next ()) for (wxNode * node = m_stringList.First (); node; node = node->Next ())
{
char *s1 = (char *) node->Data ();
if (s1 == s || strcmp (s1, s) == 0)
{ {
XmStringFree(text) ; char *s1 = (char *) node->Data ();
XtFree (s); if (s1 == s || strcmp (s1, s) == 0)
return i; {
} XmStringFree(text) ;
else XtFree (s);
i++; return i;
} // for() }
else
XmStringFree(text) ; i++;
XtFree (s); } // for()
return -1;
} XmStringFree(text) ;
XmStringFree(text) ; XtFree (s);
return -1; return -1;
}
XmStringFree(text) ;
return -1;
} }
void wxChoice::SetSelection(int n) void wxChoice::SetSelection(int n)
{ {
m_inSetValue = TRUE; m_inSetValue = TRUE;
wxNode *node = m_stringList.Nth (n); wxNode *node = m_stringList.Nth (n);
if (node) if (node)
{ {
Dimension selectionWidth, selectionHeight; Dimension selectionWidth, selectionHeight;
char *s = (char *) node->Data (); char *s = (char *) node->Data ();
XmString text = XmStringCreateSimple (s); XmString text = XmStringCreateSimple (s);
XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL); XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget); Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
XtVaSetValues (label, XtVaSetValues (label,
XmNlabelString, text, XmNlabelString, text,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
XtVaSetValues ((Widget) m_buttonWidget, XtVaSetValues ((Widget) m_buttonWidget,
XmNwidth, selectionWidth, XmNheight, selectionHeight, XmNwidth, selectionWidth, XmNheight, selectionHeight,
XmNmenuHistory, (Widget) m_widgetList[n], NULL); XmNmenuHistory, (Widget) m_widgetList[n], NULL);
} }
m_inSetValue = FALSE; m_inSetValue = FALSE;
} }
int wxChoice::FindString(const wxString& s) const int wxChoice::FindString(const wxString& s) const
@@ -315,55 +315,55 @@ int wxChoice::FindString(const wxString& s) const
wxString wxChoice::GetString(int n) const wxString wxChoice::GetString(int n) const
{ {
wxNode *node = m_stringList.Nth (n); wxNode *node = m_stringList.Nth (n);
if (node) if (node)
return wxString((char *) node->Data ()); return wxString((char *) node->Data ());
else else
return wxEmptyString; return wxEmptyString;
} }
void wxChoice::SetColumns(int n) void wxChoice::SetColumns(int n)
{ {
if (n<1) n = 1 ; if (n<1) n = 1 ;
short numColumns = n ; short numColumns = n ;
Arg args[3]; Arg args[3];
XtSetArg(args[0], XmNnumColumns, numColumns); XtSetArg(args[0], XmNnumColumns, numColumns);
XtSetArg(args[1], XmNpacking, XmPACK_COLUMN); XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
XtSetValues((Widget) m_menuWidget,args,2) ; XtSetValues((Widget) m_menuWidget,args,2) ;
} }
int wxChoice::GetColumns(void) const int wxChoice::GetColumns(void) const
{ {
short numColumns ; short numColumns ;
XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ; XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
return numColumns ; return numColumns ;
} }
void wxChoice::SetFocus() 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) void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
{ {
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_ANY, NULL); XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
bool managed = XtIsManaged((Widget) m_formWidget); bool managed = XtIsManaged((Widget) m_formWidget);
if (managed) if (managed)
XtUnmanageChild ((Widget) m_formWidget); XtUnmanageChild ((Widget) m_formWidget);
int actualWidth = width, actualHeight = height; int actualWidth = width, actualHeight = height;
if (width > -1) if (width > -1)
{ {
int i; int i;
for (i = 0; i < m_noStrings; i++) for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetList[i], XmNwidth, actualWidth, NULL); XtVaSetValues ((Widget) m_widgetList[i], XmNwidth, actualWidth, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNwidth, actualWidth, XtVaSetValues ((Widget) m_buttonWidget, XmNwidth, actualWidth,
NULL); NULL);
} }
if (height > -1) if (height > -1)
{ {
@@ -371,13 +371,13 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
for (i = 0; i < m_noStrings; i++) for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetList[i], XmNheight, actualHeight, NULL); XtVaSetValues ((Widget) m_widgetList[i], XmNheight, actualHeight, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNheight, actualHeight, XtVaSetValues ((Widget) m_buttonWidget, XmNheight, actualHeight,
NULL); NULL);
} }
if (managed) if (managed)
XtManageChild ((Widget) m_formWidget); XtManageChild ((Widget) m_formWidget);
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL); XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
wxControl::SetSize (x, y, width, height, sizeFlags); wxControl::SetSize (x, y, width, height, sizeFlags);
} }
@@ -394,10 +394,10 @@ bool wxChoice::SetStringSelection (const wxString& s)
{ {
int sel = FindString (s); int sel = FindString (s);
if (sel > -1) if (sel > -1)
{ {
SetSelection (sel); SetSelection (sel);
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} }
@@ -423,7 +423,7 @@ void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
event.SetEventObject(item); event.SetEventObject(item);
event.m_commandInt = item->FindString (s); event.m_commandInt = item->FindString (s);
// event.m_commandString = s; // event.m_commandString = s;
item->ProcessCommand (event); item->ProcessCommand (event);
} }
} }
@@ -438,15 +438,15 @@ void wxChoice::ChangeFont(bool keepOriginalSize)
{ {
int width, height, width1, height1; int width, height, width1, height1;
GetSize(& width, & height); GetSize(& width, & height);
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget)); XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget));
XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
/* TODO: why does this cause a crash in XtWidgetToApplicationContext? /* TODO: why does this cause a crash in XtWidgetToApplicationContext?
int i; int i;
for (i = 0; i < m_noStrings; 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); GetSize(& width1, & height1);
if (keepOriginalSize && (width != width1 || height != height1)) if (keepOriginalSize && (width != width1 || height != height1))

View File

@@ -20,218 +20,508 @@
#include "wx/utils.h" #include "wx/utils.h"
#include "wx/metafile.h" #include "wx/metafile.h"
#include "wx/clipbrd.h" #include "wx/clipbrd.h"
#include "wx/dataobj.h"
#include <Xm/Xm.h>
#include <Xm/CutPaste.h>
#include <string.h> #include <string.h>
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject) // IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject) // IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
#endif #endif
static bool gs_clipboardIsOpen = FALSE;
bool wxOpenClipboard() bool wxOpenClipboard()
{ {
// TODO if (!gs_clipboardIsOpen)
return FALSE; {
gs_clipboardIsOpen = TRUE;
return TRUE;
}
else
return FALSE;
} }
bool wxCloseClipboard() bool wxCloseClipboard()
{ {
// TODO if (gs_clipboardIsOpen)
return FALSE; {
gs_clipboardIsOpen = FALSE;
return TRUE;
}
else
return FALSE;
} }
bool wxEmptyClipboard() bool wxEmptyClipboard()
{ {
// TODO // No equivalent in Motif
return FALSE; return TRUE;
} }
bool wxClipboardOpen() bool wxClipboardOpen()
{ {
// TODO return gs_clipboardIsOpen;
return FALSE;
} }
bool wxIsClipboardFormatAvailable(int dataFormat) bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{ {
// TODO // Only text is supported.
return FALSE; 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 if (dataFormat != wxDF_TEXT)
return FALSE; 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; return NULL;
} }
int wxEnumClipboardFormats(int dataFormat) wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{ {
// TODO // Only wxDF_TEXT supported
return 0; if (dataFormat == (wxDataFormat) 0)
return wxDF_TEXT;
else
return (wxDataFormat) 0;
} }
int wxRegisterClipboardFormat(char *formatName) wxDataFormat wxRegisterClipboardFormat(char *formatName)
{ {
// TODO // Not supported
return 0; return (wxDataFormat) 0;
} }
bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount) bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount)
{ {
// TODO // Only wxDF_TEXT supported
if (dataFormat == wxDF_TEXT)
{
strcpy(formatName, "TEXT");
return TRUE;
}
else
return FALSE;
}
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
wxClipboard* wxTheClipboard = (wxClipboard*) NULL;
wxClipboard::wxClipboard()
{
m_open = FALSE;
}
wxClipboard::~wxClipboard()
{
Clear();
}
void wxClipboard::Clear()
{
wxNode* node = m_data.First();
while (node)
{
wxDataObject* data = (wxDataObject*) node->Data();
delete data;
node = node->Next();
}
m_data.Clear();
}
bool wxClipboard::Open()
{
wxCHECK_MSG( !m_open, FALSE, "clipboard already open" );
m_open = TRUE;
return wxOpenClipboard();
}
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;
}
}
return FALSE; return FALSE;
} }
void wxClipboard::Close()
{
wxCHECK_RET( m_open, "clipboard not open" );
m_open = FALSE;
wxCloseClipboard();
}
bool wxClipboard::IsSupportedFormat( wxDataFormat format, const wxString& WXUNUSED(id) )
{
return wxIsClipboardFormatAvailable(format);
}
bool wxClipboard::GetData( wxDataObject *data )
{
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;
}
//-----------------------------------------------------------------------------
// wxClipboardModule
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClipboardModule,wxModule)
bool wxClipboardModule::OnInit()
{
wxTheClipboard = new wxClipboard();
return TRUE;
}
void wxClipboardModule::OnExit()
{
if (wxTheClipboard) delete wxTheClipboard;
wxTheClipboard = (wxClipboard*) NULL;
}
#if 0
/* /*
* Generalized clipboard implementation by Matthew Flatt * Old clipboard implementation by Matthew Flatt
*/ */
wxClipboard *wxTheClipboard = NULL; wxClipboard *wxTheClipboard = NULL;
void wxInitClipboard() void wxInitClipboard()
{ {
if (!wxTheClipboard) if (!wxTheClipboard)
wxTheClipboard = new wxClipboard; wxTheClipboard = new wxClipboard;
} }
wxClipboard::wxClipboard() wxClipboard::wxClipboard()
{ {
clipOwner = NULL; clipOwner = NULL;
cbString = NULL; cbString = NULL;
} }
wxClipboard::~wxClipboard() wxClipboard::~wxClipboard()
{ {
if (clipOwner) if (clipOwner)
clipOwner->BeingReplaced(); clipOwner->BeingReplaced();
if (cbString) if (cbString)
delete[] cbString; delete[] cbString;
} }
static int FormatStringToID(char *str) static int FormatStringToID(char *str)
{ {
if (!strcmp(str, "TEXT")) if (!strcmp(str, "TEXT"))
return wxDF_TEXT; return wxDF_TEXT;
return wxRegisterClipboardFormat(str); return wxRegisterClipboardFormat(str);
} }
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time) void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
{ {
bool got_selection; bool got_selection;
if (clipOwner) if (clipOwner)
clipOwner->BeingReplaced(); clipOwner->BeingReplaced();
clipOwner = client; clipOwner = client;
if (cbString) { if (cbString) {
delete[] cbString; delete[] cbString;
cbString = NULL; cbString = NULL;
} }
if (wxOpenClipboard()) { if (wxOpenClipboard()) {
char **formats, *data; char **formats, *data;
int i; int i;
int ftype; int ftype;
long size; long size;
formats = clipOwner->formats.ListToArray(FALSE); formats = clipOwner->formats.ListToArray(FALSE);
for (i = clipOwner->formats.Number(); i--; ) { for (i = clipOwner->formats.Number(); i--; ) {
ftype = FormatStringToID(formats[i]); ftype = FormatStringToID(formats[i]);
data = clipOwner->GetData(formats[i], &size); data = clipOwner->GetData(formats[i], &size);
if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) { if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
got_selection = FALSE; got_selection = FALSE;
break; 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;
} }
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;
}
} }
wxClipboardClient *wxClipboard::GetClipboardClient() wxClipboardClient *wxClipboard::GetClipboardClient()
{ {
return clipOwner; return clipOwner;
} }
void wxClipboard::SetClipboardString(char *str, long time) void wxClipboard::SetClipboardString(char *str, long time)
{ {
bool got_selection; bool got_selection;
if (clipOwner) { if (clipOwner) {
clipOwner->BeingReplaced(); clipOwner->BeingReplaced();
clipOwner = NULL; clipOwner = NULL;
} }
if (cbString) if (cbString)
delete[] cbString; delete[] cbString;
cbString = str; cbString = str;
if (wxOpenClipboard()) { if (wxOpenClipboard()) {
if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str)) if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
got_selection = FALSE; got_selection = FALSE;
else else
got_selection = wxCloseClipboard(); got_selection = wxCloseClipboard();
} else } else
got_selection = FALSE; got_selection = FALSE;
got_selection = FALSE; // Assume another process takes over got_selection = FALSE; // Assume another process takes over
if (!got_selection) { if (!got_selection) {
delete[] cbString; delete[] cbString;
cbString = NULL; cbString = NULL;
} }
} }
char *wxClipboard::GetClipboardString(long time) char *wxClipboard::GetClipboardString(long time)
{ {
char *str; char *str;
long length; long length;
str = GetClipboardData("TEXT", &length, time); str = GetClipboardData("TEXT", &length, time);
if (!str) { if (!str) {
str = new char[1]; str = new char[1];
*str = 0; *str = 0;
} }
return str; return str;
} }
char *wxClipboard::GetClipboardData(char *format, long *length, long time) char *wxClipboard::GetClipboardData(char *format, long *length, long time)
{ {
if (clipOwner) { if (clipOwner) {
if (clipOwner->formats.Member(format)) if (clipOwner->formats.Member(format))
return clipOwner->GetData(format, length); return clipOwner->GetData(format, length);
else else
return NULL; return NULL;
} else if (cbString) { } else if (cbString) {
if (!strcmp(format, "TEXT")) if (!strcmp(format, "TEXT"))
return copystring(cbString); return copystring(cbString);
else else
return NULL; return NULL;
} else { } else {
if (wxOpenClipboard()) { if (wxOpenClipboard()) {
receivedString = (char *)wxGetClipboardData(FormatStringToID(format), receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
length); length);
wxCloseClipboard(); wxCloseClipboard();
} else } else
receivedString = NULL; receivedString = NULL;
return receivedString; return receivedString;
} }
} }
#endif

View File

@@ -57,12 +57,12 @@ wxColour::wxColour (const wxColour& col)
wxColour& wxColour::operator =(const wxColour& col) wxColour& wxColour::operator =(const wxColour& col)
{ {
m_red = col.m_red; m_red = col.m_red;
m_green = col.m_green; m_green = col.m_green;
m_blue = col.m_blue; m_blue = col.m_blue;
m_isInit = col.m_isInit; m_isInit = col.m_isInit;
m_pixel = col.m_pixel; m_pixel = col.m_pixel;
return *this; return *this;
} }
void wxColour::InitFromName(const wxString& col) void wxColour::InitFromName(const wxString& col)
@@ -109,8 +109,8 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
int wxColour::AllocColour(WXDisplay* display, bool realloc) int wxColour::AllocColour(WXDisplay* display, bool realloc)
{ {
if ((m_pixel != -1) && !realloc) if ((m_pixel != -1) && !realloc)
return m_pixel; return m_pixel;
XColor color; XColor color;
color.red = (unsigned short) Red (); color.red = (unsigned short) Red ();
color.red |= color.red << 8; color.red |= color.red << 8;
@@ -118,20 +118,20 @@ int wxColour::AllocColour(WXDisplay* display, bool realloc)
color.green |= color.green << 8; color.green |= color.green << 8;
color.blue = (unsigned short) Blue (); color.blue = (unsigned short) Blue ();
color.blue |= color.blue << 8; color.blue |= color.blue << 8;
color.flags = DoRed | DoGreen | DoBlue; color.flags = DoRed | DoGreen | DoBlue;
WXColormap cmap = wxTheApp->GetMainColormap(display); WXColormap cmap = wxTheApp->GetMainColormap(display);
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color)) if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
{ {
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap); m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
return m_pixel; return m_pixel;
} }
else else
{ {
m_pixel = (int) color.pixel; m_pixel = (int) color.pixel;
return m_pixel; return m_pixel;
} }
} }
@@ -146,30 +146,30 @@ But in many cases, that is still better than always using black.
Chris Breeze <chris@hel.co.uk> Chris Breeze <chris@hel.co.uk>
Improvements: Improvements:
1) More efficient calculation of RGB distance of colour cell from 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 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 since we are only interested in the top 8-bits of R, G and B we
can perform integer arithmetic. can perform integer arithmetic.
2) Attempt to allocate a read-only colour when a close match is found. 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. 3) Fall back to the closest match if no read-only colours are available.
Possible further improvements: Possible further improvements:
1) Scan the lookup table and sort the colour cells in order of 1) Scan the lookup table and sort the colour cells in order of
increasing increasing
distance from the desired colour. Then attempt to allocate a distance from the desired colour. Then attempt to allocate a
read-only read-only
colour starting from the nearest match. colour starting from the nearest match.
2) Linear RGB distance is not a particularly good method of colour 2) Linear RGB distance is not a particularly good method of colour
matching matching
(though it is quick). Converting the colour to HLS and then comparing (though it is quick). Converting the colour to HLS and then comparing
may give better matching. may give better matching.
-------------------------------------------*/ -------------------------------------------*/
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap) int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap)
{ {
if (cmap == (Colormap) NULL) if (cmap == (Colormap) NULL)
cmap = (Colormap) wxTheApp->GetMainColormap(display); cmap = (Colormap) wxTheApp->GetMainColormap(display);
int numPixVals = XDisplayCells(display, DefaultScreen (display)); int numPixVals = XDisplayCells(display, DefaultScreen (display));
int mindist = 256 * 256 * 3; int mindist = 256 * 256 * 3;
int bestpixel = (int) BlackPixel (display, DefaultScreen (display)); int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
@@ -177,21 +177,21 @@ int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap
int green = desiredColor->green >> 8; int green = desiredColor->green >> 8;
int blue = desiredColor->blue >> 8; int blue = desiredColor->blue >> 8;
const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B
for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++) for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++)
{ {
XColor matching_color; XColor matching_color;
matching_color.pixel = pixelcount; matching_color.pixel = pixelcount;
XQueryColor(display,cmap,&matching_color); XQueryColor(display,cmap,&matching_color);
int delta_red = red - (matching_color.red >> 8); int delta_red = red - (matching_color.red >> 8);
int delta_green = green - (matching_color.green >> 8); int delta_green = green - (matching_color.green >> 8);
int delta_blue = blue - (matching_color.blue >> 8); int delta_blue = blue - (matching_color.blue >> 8);
int dist = delta_red * delta_red + int dist = delta_red * delta_red +
delta_green * delta_green + delta_green * delta_green +
delta_blue * delta_blue; delta_blue * delta_blue;
if (dist <= threshold) if (dist <= threshold)
{ {
// try to allocate a read-only colour... // try to allocate a read-only colour...

View File

@@ -21,20 +21,20 @@
#include "xmcombo/xmcombo.h" #include "xmcombo/xmcombo.h"
void wxComboBoxCallback (Widget w, XtPointer clientData, void wxComboBoxCallback (Widget w, XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs); XmComboBoxSelectionCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
#endif #endif
bool wxComboBox::Create(wxWindow *parent, wxWindowID id, bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value, const wxString& value,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
int n, const wxString choices[], int n, const wxString choices[],
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -43,31 +43,31 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
// m_backgroundColour = parent->GetBackgroundColour(); // m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE; m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name, Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name,
xmComboBoxWidgetClass, parentWidget, xmComboBoxWidgetClass, parentWidget,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
XmNshowLabel, False, XmNshowLabel, False,
XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY), XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
XmNsorted, ((style & wxCB_SORT) == wxCB_SORT), XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE), XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
NULL); NULL);
XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback, XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback, XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this); (XtPointer) this);
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
{ {
@@ -77,21 +77,21 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
m_stringList.Add(choices[i]); m_stringList.Add(choices[i]);
} }
m_noStrings = n; m_noStrings = n;
m_mainWidget = (Widget) buttonWidget; m_mainWidget = (Widget) buttonWidget;
XtManageChild (buttonWidget); XtManageChild (buttonWidget);
SetValue(value); SetValue(value);
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -144,8 +144,8 @@ void wxComboBox::Delete(int n)
wxNode *node = m_stringList.Nth(n); wxNode *node = m_stringList.Nth(n);
if (node) if (node)
{ {
delete[] (char *)node->Data(); delete[] (char *)node->Data();
delete node; delete node;
} }
m_noStrings--; m_noStrings--;
} }
@@ -163,20 +163,20 @@ void wxComboBox::SetSelection (int n)
int wxComboBox::GetSelection (void) const int wxComboBox::GetSelection (void) const
{ {
int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget); int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
if (sel == 0) if (sel == 0)
return -1; return -1;
else else
return sel - 1; return sel - 1;
} }
wxString wxComboBox::GetString(int n) const wxString wxComboBox::GetString(int n) const
{ {
wxNode *node = m_stringList.Nth (n); wxNode *node = m_stringList.Nth (n);
if (node) if (node)
return wxString((char *) node->Data ()); return wxString((char *) node->Data ());
else else
return wxEmptyString; return wxEmptyString;
} }
wxString wxComboBox::GetStringSelection() const wxString wxComboBox::GetStringSelection() const
@@ -202,22 +202,22 @@ bool wxComboBox::SetStringSelection(const wxString& sel)
int wxComboBox::FindString(const wxString& s) const int wxComboBox::FindString(const wxString& s) const
{ {
int *pos_list = NULL; int *pos_list = NULL;
int count = 0; int count = 0;
XmString text = XmStringCreateSimple ((char*) (const char*) s); XmString text = XmStringCreateSimple ((char*) (const char*) s);
bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget, bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
text, &pos_list, &count) != 0); text, &pos_list, &count) != 0);
XmStringFree(text); XmStringFree(text);
if (found && count > 0) if (found && count > 0)
{ {
int pos = pos_list[0] - 1; int pos = pos_list[0] - 1;
free(pos_list); free(pos_list);
return pos; return pos;
} }
return -1; return -1;
} }
// Clipboard operations // Clipboard operations
@@ -265,7 +265,7 @@ long wxComboBox::GetLastPosition() const
void wxComboBox::Replace(long from, long to, const wxString& value) void wxComboBox::Replace(long from, long to, const wxString& value)
{ {
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to, XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(char*) (const char*) value); (char*) (const char*) value);
} }
void wxComboBox::Remove(long from, long to) void wxComboBox::Remove(long from, long to)
@@ -282,35 +282,35 @@ void wxComboBox::SetSelection(long from, long to)
} }
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData, void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs) XmComboBoxSelectionCallbackStruct * cbs)
{ {
wxComboBox *item = (wxComboBox *) clientData; wxComboBox *item = (wxComboBox *) clientData;
switch (cbs->reason) switch (cbs->reason)
{ {
case XmCR_SINGLE_SELECT: case XmCR_SINGLE_SELECT:
case XmCR_BROWSE_SELECT: case XmCR_BROWSE_SELECT:
{ {
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId());
event.m_commandInt = cbs->index - 1; event.m_commandInt = cbs->index - 1;
// event.m_commandString = item->GetString (event.m_commandInt); // event.m_commandString = item->GetString (event.m_commandInt);
event.m_extraLong = TRUE; event.m_extraLong = TRUE;
event.SetEventObject(item); event.SetEventObject(item);
item->ProcessCommand (event); item->ProcessCommand (event);
break; break;
} }
case XmCR_VALUE_CHANGED: case XmCR_VALUE_CHANGED:
{ {
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
event.m_commandInt = -1; event.m_commandInt = -1;
// event.m_commandString = item->GetValue(); // event.m_commandString = item->GetValue();
event.m_extraLong = TRUE; event.m_extraLong = TRUE;
event.SetEventObject(item); event.SetEventObject(item);
item->ProcessCommand (event); item->ProcessCommand (event);
break; break;
} }
default: default:
break; break;
} }
} }

View File

@@ -51,14 +51,14 @@ void wxControl::SetLabel(const wxString& label)
Widget widget = (Widget) GetLabelWidget() ; Widget widget = (Widget) GetLabelWidget() ;
if (!widget) if (!widget)
return; return;
wxStripMenuCodes((char*) (const char*) label, wxBuffer); wxStripMenuCodes((char*) (const char*) label, wxBuffer);
XmString text = XmStringCreateSimple (wxBuffer); XmString text = XmStringCreateSimple (wxBuffer);
XtVaSetValues (widget, XtVaSetValues (widget,
XmNlabelString, text, XmNlabelString, text,
XmNlabelType, XmSTRING, XmNlabelType, XmSTRING,
NULL); NULL);
XmStringFree (text); XmStringFree (text);
} }
@@ -67,13 +67,13 @@ wxString wxControl::GetLabel() const
Widget widget = (Widget) GetLabelWidget() ; Widget widget = (Widget) GetLabelWidget() ;
if (!widget) if (!widget)
return wxEmptyString; return wxEmptyString;
XmString text; XmString text;
char *s; char *s;
XtVaGetValues (widget, XtVaGetValues (widget,
XmNlabelString, &text, XmNlabelString, &text,
NULL); NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s)) if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{ {
wxString str(s); wxString str(s);
@@ -90,41 +90,41 @@ wxString wxControl::GetLabel() const
void wxControl::ProcessCommand (wxCommandEvent & event) void wxControl::ProcessCommand (wxCommandEvent & event)
{ {
// Tries: // Tries:
// 1) A callback function (to become obsolete) // 1) A callback function (to become obsolete)
// 2) OnCommand, starting at this window and working up parent hierarchy // 2) OnCommand, starting at this window and working up parent hierarchy
// 3) OnCommand then calls ProcessEvent to search the event tables. // 3) OnCommand then calls ProcessEvent to search the event tables.
if (m_callback) if (m_callback)
{ {
(void) (*(m_callback)) (*this, event); (void) (*(m_callback)) (*this, event);
} }
else else
{ {
GetEventHandler()->OnCommand(*this, event); GetEventHandler()->OnCommand(*this, event);
} }
} }
void wxControl::Centre (int direction) void wxControl::Centre (int direction)
{ {
int x, y, width, height, panel_width, panel_height, new_x, new_y; int x, y, width, height, panel_width, panel_height, new_x, new_y;
wxWindow *parent = (wxWindow *) GetParent (); wxWindow *parent = (wxWindow *) GetParent ();
if (!parent) if (!parent)
return; return;
parent->GetClientSize (&panel_width, &panel_height); parent->GetClientSize (&panel_width, &panel_height);
GetSize (&width, &height); GetSize (&width, &height);
GetPosition (&x, &y); GetPosition (&x, &y);
new_x = x; new_x = x;
new_y = y; new_y = y;
if (direction & wxHORIZONTAL) if (direction & wxHORIZONTAL)
new_x = (int) ((panel_width - width) / 2); new_x = (int) ((panel_width - width) / 2);
if (direction & wxVERTICAL) if (direction & wxVERTICAL)
new_y = (int) ((panel_height - height) / 2); new_y = (int) ((panel_height - height) / 2);
SetSize (new_x, new_y, width, height); SetSize (new_x, new_y, width, height);
} }

View File

@@ -37,54 +37,54 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
wxDC::wxDC(void) wxDC::wxDC(void)
{ {
m_ok = FALSE; m_ok = FALSE;
m_optimize = FALSE; m_optimize = FALSE;
m_colour = TRUE; m_colour = TRUE;
m_clipping = FALSE; m_clipping = FALSE;
m_mm_to_pix_x = 1.0; m_mm_to_pix_x = 1.0;
m_mm_to_pix_y = 1.0; m_mm_to_pix_y = 1.0;
m_logicalOriginX = 0; m_logicalOriginX = 0;
m_logicalOriginY = 0; m_logicalOriginY = 0;
m_deviceOriginX = 0; m_deviceOriginX = 0;
m_deviceOriginY = 0; m_deviceOriginY = 0;
m_internalDeviceOriginX = 0; m_internalDeviceOriginX = 0;
m_internalDeviceOriginY = 0; m_internalDeviceOriginY = 0;
m_externalDeviceOriginX = 0; m_externalDeviceOriginX = 0;
m_externalDeviceOriginY = 0; m_externalDeviceOriginY = 0;
m_logicalScaleX = 1.0; m_logicalScaleX = 1.0;
m_logicalScaleY = 1.0; m_logicalScaleY = 1.0;
m_userScaleX = 1.0; m_userScaleX = 1.0;
m_userScaleY = 1.0; m_userScaleY = 1.0;
m_scaleX = 1.0; m_scaleX = 1.0;
m_scaleY = 1.0; m_scaleY = 1.0;
m_mappingMode = MM_TEXT; m_mappingMode = MM_TEXT;
m_needComputeScaleX = FALSE; m_needComputeScaleX = FALSE;
m_needComputeScaleY = FALSE; m_needComputeScaleY = FALSE;
m_signX = 1; // default x-axis left to right m_signX = 1; // default x-axis left to right
m_signY = 1; // default y-axis top down m_signY = 1; // default y-axis top down
m_maxX = m_maxY = -100000; m_maxX = m_maxY = -100000;
m_minY = m_minY = 100000; m_minY = m_minY = 100000;
m_logicalFunction = wxCOPY; m_logicalFunction = wxCOPY;
// m_textAlignment = wxALIGN_TOP_LEFT; // m_textAlignment = wxALIGN_TOP_LEFT;
m_backgroundMode = wxTRANSPARENT; m_backgroundMode = wxTRANSPARENT;
m_textForegroundColour = *wxBLACK; m_textForegroundColour = *wxBLACK;
m_textBackgroundColour = *wxWHITE; m_textBackgroundColour = *wxWHITE;
m_pen = *wxBLACK_PEN; m_pen = *wxBLACK_PEN;
m_font = *wxNORMAL_FONT; m_font = *wxNORMAL_FONT;
m_brush = *wxTRANSPARENT_BRUSH; m_brush = *wxTRANSPARENT_BRUSH;
m_backgroundBrush = *wxWHITE_BRUSH; m_backgroundBrush = *wxWHITE_BRUSH;
m_isInteractive = FALSE; m_isInteractive = FALSE;
// m_palette = wxAPP_COLOURMAP; // m_palette = wxAPP_COLOURMAP;
}; };
wxDC::~wxDC(void) wxDC::~wxDC(void)
@@ -99,314 +99,314 @@ void wxDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
{ {
if (!bitmap.Ok()) if (!bitmap.Ok())
return; return;
wxMemoryDC memDC; wxMemoryDC memDC;
memDC.SelectObject(bitmap); memDC.SelectObject(bitmap);
/* Not sure if we need this. The mask should leave the /* Not sure if we need this. The mask should leave the
* masked areas as per the original background of this DC. * masked areas as per the original background of this DC.
if (useMask) if (useMask)
{ {
// There might be transparent areas, so make these // There might be transparent areas, so make these
// the same colour as this DC // the same colour as this DC
memDC.SetBackground(* GetBackground()); memDC.SetBackground(* GetBackground());
memDC.Clear(); memDC.Clear();
} }
*/ */
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask); Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap); memDC.SelectObject(wxNullBitmap);
}; };
void wxDC::DrawPoint( wxPoint& point ) 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 ) void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
{ {
int n = list->Number(); int n = list->Number();
wxPoint *points = new wxPoint[n]; wxPoint *points = new wxPoint[n];
int i = 0; int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() ) for( wxNode *node = list->First(); node; node = node->Next() )
{ {
wxPoint *point = (wxPoint *)node->Data(); wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x; points[i].x = point->x;
points[i++].y = point->y; points[i++].y = point->y;
}; };
DrawPolygon( n, points, xoffset, yoffset, fillStyle ); DrawPolygon( n, points, xoffset, yoffset, fillStyle );
delete[] points; delete[] points;
}; };
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset ) void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
{ {
int n = list->Number(); int n = list->Number();
wxPoint *points = new wxPoint[n]; wxPoint *points = new wxPoint[n];
int i = 0; int i = 0;
for( wxNode *node = list->First(); node; node = node->Next() ) for( wxNode *node = list->First(); node; node = node->Next() )
{ {
wxPoint *point = (wxPoint *)node->Data(); wxPoint *point = (wxPoint *)node->Data();
points[i].x = point->x; points[i].x = point->x;
points[i++].y = point->y; points[i++].y = point->y;
}; };
DrawLines( n, points, xoffset, yoffset ); DrawLines( n, points, xoffset, yoffset );
delete []points; delete []points;
}; };
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 ) void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
{ {
wxList list; wxList list;
list.Append( (wxObject*)new wxPoint(x1, y1) ); list.Append( (wxObject*)new wxPoint(x1, y1) );
list.Append( (wxObject*)new wxPoint(x2, y2) ); list.Append( (wxObject*)new wxPoint(x2, y2) );
list.Append( (wxObject*)new wxPoint(x3, y3) ); list.Append( (wxObject*)new wxPoint(x3, y3) );
DrawSpline(&list); DrawSpline(&list);
wxNode *node = list.First(); wxNode *node = list.First();
while (node) while (node)
{ {
wxPoint *p = (wxPoint*)node->Data(); wxPoint *p = (wxPoint*)node->Data();
delete p; delete p;
node = node->Next(); node = node->Next();
}; };
}; };
void wxDC::DrawSpline( int n, wxPoint points[] ) void wxDC::DrawSpline( int n, wxPoint points[] )
{ {
wxList list; wxList list;
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] ); for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
DrawSpline( &list ); DrawSpline( &list );
}; };
void wxDC::SetClippingRegion( long x, long y, long width, long height ) void wxDC::SetClippingRegion( long x, long y, long width, long height )
{ {
m_clipping = TRUE; m_clipping = TRUE;
m_clipX1 = x; m_clipX1 = x;
m_clipY1 = y; m_clipY1 = y;
m_clipX2 = x + width; m_clipX2 = x + width;
m_clipY2 = y + height; m_clipY2 = y + height;
}; };
void wxDC::DestroyClippingRegion(void) void wxDC::DestroyClippingRegion(void)
{ {
m_clipping = FALSE; m_clipping = FALSE;
}; };
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
{ {
if (m_clipping) if (m_clipping)
{ {
if (x) *x = m_clipX1; if (x) *x = m_clipX1;
if (y) *y = m_clipY1; if (y) *y = m_clipY1;
if (width) *width = (m_clipX2 - m_clipX1); if (width) *width = (m_clipX2 - m_clipX1);
if (height) *height = (m_clipY2 - m_clipY1); if (height) *height = (m_clipY2 - m_clipY1);
} }
else else
*x = *y = *width = *height = 0; *x = *y = *width = *height = 0;
}; };
void wxDC::GetSize( int* width, int* height ) const void wxDC::GetSize( int* width, int* height ) const
{ {
*width = m_maxX-m_minX; *width = m_maxX-m_minX;
*height = m_maxY-m_minY; *height = m_maxY-m_minY;
}; };
void wxDC::GetSizeMM( long* width, long* height ) const void wxDC::GetSizeMM( long* width, long* height ) const
{ {
int w = 0; int w = 0;
int h = 0; int h = 0;
GetSize( &w, &h ); GetSize( &w, &h );
*width = long( double(w) / (m_scaleX*m_mm_to_pix_x) ); *width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
*height = long( double(h) / (m_scaleY*m_mm_to_pix_y) ); *height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
}; };
void wxDC::SetTextForeground( const wxColour &col ) void wxDC::SetTextForeground( const wxColour &col )
{ {
if (!Ok()) return; if (!Ok()) return;
m_textForegroundColour = col; m_textForegroundColour = col;
}; };
void wxDC::SetTextBackground( const wxColour &col ) void wxDC::SetTextBackground( const wxColour &col )
{ {
if (!Ok()) return; if (!Ok()) return;
m_textBackgroundColour = col; m_textBackgroundColour = col;
}; };
void wxDC::SetMapMode( int mode ) void wxDC::SetMapMode( int mode )
{ {
switch (mode) switch (mode)
{ {
case MM_TWIPS: case MM_TWIPS:
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y ); SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
break; break;
case MM_POINTS: case MM_POINTS:
SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y ); SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
break; break;
case MM_METRIC: case MM_METRIC:
SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y ); SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
break; break;
case MM_LOMETRIC: case MM_LOMETRIC:
SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 ); SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
break; break;
default: default:
case MM_TEXT: case MM_TEXT:
SetLogicalScale( 1.0, 1.0 ); SetLogicalScale( 1.0, 1.0 );
break; break;
}; };
if (mode != MM_TEXT) if (mode != MM_TEXT)
{ {
m_needComputeScaleX = TRUE; m_needComputeScaleX = TRUE;
m_needComputeScaleY = TRUE; m_needComputeScaleY = TRUE;
}; };
}; };
void wxDC::SetUserScale( double x, double y ) void wxDC::SetUserScale( double x, double y )
{ {
// allow negative ? -> no // allow negative ? -> no
m_userScaleX = x; m_userScaleX = x;
m_userScaleY = y; m_userScaleY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetUserScale( double *x, double *y ) void wxDC::GetUserScale( double *x, double *y )
{ {
if (x) *x = m_userScaleX; if (x) *x = m_userScaleX;
if (y) *y = m_userScaleY; if (y) *y = m_userScaleY;
}; };
void wxDC::SetLogicalScale( double x, double y ) void wxDC::SetLogicalScale( double x, double y )
{ {
// allow negative ? // allow negative ?
m_logicalScaleX = x; m_logicalScaleX = x;
m_logicalScaleY = y; m_logicalScaleY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalScale( double *x, double *y ) void wxDC::GetLogicalScale( double *x, double *y )
{ {
if (x) *x = m_logicalScaleX; if (x) *x = m_logicalScaleX;
if (y) *y = m_logicalScaleY; if (y) *y = m_logicalScaleY;
}; };
void wxDC::SetLogicalOrigin( long x, long y ) void wxDC::SetLogicalOrigin( long x, long y )
{ {
m_logicalOriginX = x * m_signX; // is this still correct ? m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY; m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetLogicalOrigin( long *x, long *y ) void wxDC::GetLogicalOrigin( long *x, long *y )
{ {
if (x) *x = m_logicalOriginX; if (x) *x = m_logicalOriginX;
if (y) *y = m_logicalOriginY; if (y) *y = m_logicalOriginY;
}; };
void wxDC::SetDeviceOrigin( long x, long y ) void wxDC::SetDeviceOrigin( long x, long y )
{ {
m_externalDeviceOriginX = x; m_externalDeviceOriginX = x;
m_externalDeviceOriginY = y; m_externalDeviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetDeviceOrigin( long *x, long *y ) void wxDC::GetDeviceOrigin( long *x, long *y )
{ {
// if (x) *x = m_externalDeviceOriginX; // if (x) *x = m_externalDeviceOriginX;
// if (y) *y = m_externalDeviceOriginY; // if (y) *y = m_externalDeviceOriginY;
if (x) *x = m_deviceOriginX; if (x) *x = m_deviceOriginX;
if (y) *y = m_deviceOriginY; if (y) *y = m_deviceOriginY;
}; };
void wxDC::SetInternalDeviceOrigin( long x, long y ) void wxDC::SetInternalDeviceOrigin( long x, long y )
{ {
m_internalDeviceOriginX = x; m_internalDeviceOriginX = x;
m_internalDeviceOriginY = y; m_internalDeviceOriginY = y;
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
void wxDC::GetInternalDeviceOrigin( long *x, long *y ) void wxDC::GetInternalDeviceOrigin( long *x, long *y )
{ {
if (x) *x = m_internalDeviceOriginX; if (x) *x = m_internalDeviceOriginX;
if (y) *y = m_internalDeviceOriginY; if (y) *y = m_internalDeviceOriginY;
}; };
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{ {
m_signX = (xLeftRight ? 1 : -1); m_signX = (xLeftRight ? 1 : -1);
m_signY = (yBottomUp ? -1 : 1); m_signY = (yBottomUp ? -1 : 1);
ComputeScaleAndOrigin(); ComputeScaleAndOrigin();
}; };
long wxDC::DeviceToLogicalX(long x) const long wxDC::DeviceToLogicalX(long x) const
{ {
return XDEV2LOG(x); return XDEV2LOG(x);
}; };
long wxDC::DeviceToLogicalY(long y) const long wxDC::DeviceToLogicalY(long y) const
{ {
return YDEV2LOG(y); return YDEV2LOG(y);
}; };
long wxDC::DeviceToLogicalXRel(long x) const long wxDC::DeviceToLogicalXRel(long x) const
{ {
return XDEV2LOGREL(x); return XDEV2LOGREL(x);
}; };
long wxDC::DeviceToLogicalYRel(long y) const long wxDC::DeviceToLogicalYRel(long y) const
{ {
return YDEV2LOGREL(y); return YDEV2LOGREL(y);
}; };
long wxDC::LogicalToDeviceX(long x) const long wxDC::LogicalToDeviceX(long x) const
{ {
return XLOG2DEV(x); return XLOG2DEV(x);
}; };
long wxDC::LogicalToDeviceY(long y) const long wxDC::LogicalToDeviceY(long y) const
{ {
return YLOG2DEV(y); return YLOG2DEV(y);
}; };
long wxDC::LogicalToDeviceXRel(long x) const long wxDC::LogicalToDeviceXRel(long x) const
{ {
return XLOG2DEVREL(x); return XLOG2DEVREL(x);
}; };
long wxDC::LogicalToDeviceYRel(long y) const long wxDC::LogicalToDeviceYRel(long y) const
{ {
return YLOG2DEVREL(y); return YLOG2DEVREL(y);
}; };
void wxDC::CalcBoundingBox( long x, long y ) void wxDC::CalcBoundingBox( long x, long y )
{ {
if (x < m_minX) m_minX = x; if (x < m_minX) m_minX = x;
if (y < m_minY) m_minY = y; if (y < m_minY) m_minY = y;
if (x > m_maxX) m_maxX = x; if (x > m_maxX) m_maxX = x;
if (y > m_maxY) m_maxY = y; if (y > m_maxY) m_maxY = y;
}; };
void wxDC::ComputeScaleAndOrigin(void) void wxDC::ComputeScaleAndOrigin(void)
{ {
// CMB: copy scale to see if it changes // CMB: copy scale to see if it changes
double origScaleX = m_scaleX; double origScaleX = m_scaleX;
double origScaleY = m_scaleY; double origScaleY = m_scaleY;
m_scaleX = m_logicalScaleX * m_userScaleX; m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY; m_scaleY = m_logicalScaleY * m_userScaleY;
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX; m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY; m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
// CMB: if scale has changed call SetPen to recalulate the line width // CMB: if scale has changed call SetPen to recalulate the line width
if (m_scaleX != origScaleX || m_scaleY != origScaleY) if (m_scaleX != origScaleX || m_scaleY != origScaleY)
{ {
// this is a bit artificial, but we need to force wxDC to think // this is a bit artificial, but we need to force wxDC to think
// the pen has changed // the pen has changed
wxPen* pen = & GetPen(); wxPen* pen = & GetPen();
wxPen tempPen; wxPen tempPen;
m_pen = tempPen; m_pen = tempPen;
SetPen(* pen); SetPen(* pen);
} }
}; };

File diff suppressed because it is too large Load Diff

View File

@@ -30,9 +30,9 @@ wxMemoryDC::wxMemoryDC(void)
{ {
m_ok = TRUE; m_ok = TRUE;
m_display = wxGetDisplay(); m_display = wxGetDisplay();
Display* display = (Display*) m_display; Display* display = (Display*) m_display;
XGCValues gcvalues; XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display)); gcvalues.background = WhitePixel (display, DefaultScreen (display));
@@ -40,10 +40,10 @@ wxMemoryDC::wxMemoryDC(void)
gcvalues.line_width = 1; gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
&gcvalues); &gcvalues);
m_backgroundPixel = (int) gcvalues.background; m_backgroundPixel = (int) gcvalues.background;
// Get the current Font so we can set it back later // Get the current Font so we can set it back later
XGCValues valReturn; XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
@@ -59,9 +59,9 @@ wxMemoryDC::wxMemoryDC( wxDC* dc )
m_display = ((wxWindowDC*)dc)->GetDisplay(); m_display = ((wxWindowDC*)dc)->GetDisplay();
else else
m_display = wxGetDisplay(); m_display = wxGetDisplay();
Display* display = (Display*) m_display; Display* display = (Display*) m_display;
XGCValues gcvalues; XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display)); gcvalues.background = WhitePixel (display, DefaultScreen (display));
@@ -69,10 +69,10 @@ wxMemoryDC::wxMemoryDC( wxDC* dc )
gcvalues.line_width = 1; gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)), m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
&gcvalues); &gcvalues);
m_backgroundPixel = (int) gcvalues.background; m_backgroundPixel = (int) gcvalues.background;
// Get the current Font so we can set it back later // Get the current Font so we can set it back later
XGCValues valReturn; XGCValues valReturn;
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn); XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
@@ -87,62 +87,62 @@ wxMemoryDC::~wxMemoryDC(void)
void wxMemoryDC::SelectObject( const wxBitmap& bitmap ) void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
{ {
m_bitmap = 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);
SetBrush (* wxWHITE_BRUSH); if (m_gc)
SetPen (* wxBLACK_PEN); XFreeGC((Display*) m_display, (GC) m_gc);
m_gc = (WXGC) NULL;
SetOptimization(oldOpt);
if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
m_ok = TRUE; {
} m_pixmap = m_bitmap.GetPixmap();
else Display* display = (Display*) m_display;
{
m_ok = FALSE; XGCValues gcvalues;
m_pixmap = (WXPixmap) 0; 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 void wxMemoryDC::GetSize( int *width, int *height ) const
{ {
if (m_bitmap.Ok()) if (m_bitmap.Ok())
{ {
if (width) (*width) = m_bitmap.GetWidth(); if (width) (*width) = m_bitmap.GetWidth();
if (height) (*height) = m_bitmap.GetHeight(); if (height) (*height) = m_bitmap.GetHeight();
} }
else else
{ {
if (width) (*width) = 0; if (width) (*width) = 0;
if (height) (*height) = 0; if (height) (*height) = 0;
}; };
}; };

View File

@@ -31,30 +31,30 @@ int wxScreenDC::sm_overlayWindowY = 0;
// Create a DC representing the whole screen // Create a DC representing the whole screen
wxScreenDC::wxScreenDC() wxScreenDC::wxScreenDC()
{ {
m_display = wxGetDisplay(); m_display = wxGetDisplay();
Display* display = (Display*) m_display; Display* display = (Display*) m_display;
if (sm_overlayWindow) if (sm_overlayWindow)
{ {
m_pixmap = sm_overlayWindow; m_pixmap = sm_overlayWindow;
m_deviceOriginX = - sm_overlayWindowX; m_deviceOriginX = - sm_overlayWindowX;
m_deviceOriginY = - sm_overlayWindowY; m_deviceOriginY = - sm_overlayWindowY;
} }
else else
m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display)); m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
XGCValues gcvalues; XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display)); gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display)); gcvalues.background = WhitePixel (display, DefaultScreen (display));
gcvalues.graphics_exposures = False; gcvalues.graphics_exposures = False;
gcvalues.subwindow_mode = IncludeInferiors; gcvalues.subwindow_mode = IncludeInferiors;
gcvalues.line_width = 1; gcvalues.line_width = 1;
m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)), m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode, GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
&gcvalues); &gcvalues);
m_backgroundPixel = (int) gcvalues.background; m_backgroundPixel = (int) gcvalues.background;
m_ok = TRUE; m_ok = TRUE;
} }
wxScreenDC::~wxScreenDC() wxScreenDC::~wxScreenDC()
@@ -63,65 +63,65 @@ wxScreenDC::~wxScreenDC()
bool wxScreenDC::StartDrawingOnTop(wxWindow* window) bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
{ {
wxRect rect; wxRect rect;
int x, y, width, height; int x, y, width, height;
window->GetPosition(& x, & y); window->GetPosition(& x, & y);
if (window->GetParent()) if (window->GetParent())
window->GetParent()->ClientToScreen(& x, & y); window->GetParent()->ClientToScreen(& x, & y);
window->GetSize(& width, & height); window->GetSize(& width, & height);
rect.x = x; rect.y = y; rect.x = x; rect.y = y;
rect.width = width; rect.height = height; rect.width = width; rect.height = height;
return StartDrawingOnTop(& rect); return StartDrawingOnTop(& rect);
} }
bool wxScreenDC::StartDrawingOnTop(wxRect* rect) bool wxScreenDC::StartDrawingOnTop(wxRect* rect)
{ {
if (sm_overlayWindow) if (sm_overlayWindow)
return FALSE; return FALSE;
Display *dpy = (Display*) wxGetDisplay(); Display *dpy = (Display*) wxGetDisplay();
Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy)); Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
int x = 0; int x = 0;
int y = 0; int y = 0;
int width, height; int width, height;
wxDisplaySize(&width, &height); wxDisplaySize(&width, &height);
if (rect) if (rect)
{ {
x = rect->x; y = rect->y; x = rect->x; y = rect->y;
width = rect->width; height = rect->height; width = rect->width; height = rect->height;
} }
sm_overlayWindowX = x; sm_overlayWindowX = x;
sm_overlayWindowY = y; sm_overlayWindowY = y;
XSetWindowAttributes attributes; XSetWindowAttributes attributes;
attributes.override_redirect = True; attributes.override_redirect = True;
unsigned long valueMask = CWOverrideRedirect; unsigned long valueMask = CWOverrideRedirect;
sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0, sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
wxDisplayDepth(), InputOutput, wxDisplayDepth(), InputOutput,
DefaultVisual(dpy, 0), valueMask, DefaultVisual(dpy, 0), valueMask,
& attributes); & attributes);
if (sm_overlayWindow) if (sm_overlayWindow)
{ {
XMapWindow(dpy, (Window) sm_overlayWindow); XMapWindow(dpy, (Window) sm_overlayWindow);
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} }
bool wxScreenDC::EndDrawingOnTop() bool wxScreenDC::EndDrawingOnTop()
{ {
if (sm_overlayWindow) if (sm_overlayWindow)
{ {
XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow); XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
sm_overlayWindow = 0; sm_overlayWindow = 0;
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} }

View File

@@ -44,9 +44,9 @@
static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs); static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs);
static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *); static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *);
static void wxDialogBoxEventHandler (Widget wid, static void wxDialogBoxEventHandler (Widget wid,
XtPointer client_data, XtPointer client_data,
XEvent* event, XEvent* event,
Boolean *continueToDispatch); Boolean *continueToDispatch);
static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call); static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call);
@@ -67,12 +67,12 @@ extern wxList wxPendingDelete;
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel) IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
BEGIN_EVENT_TABLE(wxDialog, wxPanel) BEGIN_EVENT_TABLE(wxDialog, wxPanel)
EVT_BUTTON(wxID_OK, wxDialog::OnOK) EVT_BUTTON(wxID_OK, wxDialog::OnOK)
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply) EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel) EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
EVT_CHAR_HOOK(wxDialog::OnCharHook) EVT_CHAR_HOOK(wxDialog::OnCharHook)
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
EVT_CLOSE(wxDialog::OnCloseWindow) EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #endif
@@ -84,76 +84,76 @@ wxDialog::wxDialog()
} }
bool wxDialog::Create(wxWindow *parent, wxWindowID id, bool wxDialog::Create(wxWindow *parent, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_windowStyle = style; m_windowStyle = style;
m_modalShowing = FALSE; m_modalShowing = FALSE;
m_dialogTitle = title; m_dialogTitle = title;
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
SetName(name); SetName(name);
if (!parent) if (!parent)
wxTopLevelWindows.Append(this); wxTopLevelWindows.Append(this);
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
Widget parentWidget = (Widget) 0; Widget parentWidget = (Widget) 0;
if (parent) if (parent)
parentWidget = (Widget) parent->GetTopWidget(); parentWidget = (Widget) parent->GetTopWidget();
if (!parent) if (!parent)
parentWidget = (Widget) wxTheApp->GetTopLevelWidget(); parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." ); wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
Arg args[2]; Arg args[2];
XtSetArg (args[0], XmNdefaultPosition, False); XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False); XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2); Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
m_mainWidget = (WXWidget) dialogShell; m_mainWidget = (WXWidget) dialogShell;
// We don't want margins, since there is enough elsewhere. // We don't want margins, since there is enough elsewhere.
XtVaSetValues(dialogShell, XtVaSetValues(dialogShell,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
XmNresizePolicy, XmRESIZE_NONE, XmNresizePolicy, XmRESIZE_NONE,
NULL) ; NULL) ;
Widget shell = XtParent(dialogShell) ; Widget shell = XtParent(dialogShell) ;
if (!title.IsNull()) if (!title.IsNull())
{ {
XmString str = XmStringCreateSimple((char*) (const char*)title); XmString str = XmStringCreateSimple((char*) (const char*)title);
XtVaSetValues(dialogShell, XtVaSetValues(dialogShell,
XmNdialogTitle, str, XmNdialogTitle, str,
NULL); NULL);
XmStringFree(str); XmStringFree(str);
} }
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
ChangeFont(FALSE); ChangeFont(FALSE);
wxAddWindowToTable(dialogShell, this); wxAddWindowToTable(dialogShell, this);
// Intercept CLOSE messages from the window manager // Intercept CLOSE messages from the window manager
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False); Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
/* Remove and add WM_DELETE_WINDOW so ours is only handler */ /* Remove and add WM_DELETE_WINDOW so ours is only handler */
/* Why do we have to do this for wxDialog, but not wxFrame? */ /* Why do we have to do this for wxDialog, but not wxFrame? */
XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1); XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1); XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
XmActivateWMProtocol(shell, WM_DELETE_WINDOW); XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
// Modified Steve Hammes for Motif 2.0 // Modified Steve Hammes for Motif 2.0
#if (XmREVISION > 1 || XmVERSION > 1) #if (XmREVISION > 1 || XmVERSION > 1)
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this); XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
@@ -162,85 +162,85 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
#else #else
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this); XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
#endif #endif
XtTranslations ptr ; XtTranslations ptr ;
XtOverrideTranslations(dialogShell, XtOverrideTranslations(dialogShell,
ptr = XtParseTranslationTable("<Configure>: resize()")); ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr); XtFree((char *)ptr);
// Can't remember what this was about... but I think it's necessary. // Can't remember what this was about... but I think it's necessary.
if (wxUSE_INVISIBLE_RESIZE) if (wxUSE_INVISIBLE_RESIZE)
{ {
if (pos.x > -1) if (pos.x > -1)
XtVaSetValues(dialogShell, XmNx, pos.x, XtVaSetValues(dialogShell, XmNx, pos.x,
NULL); NULL);
if (pos.y > -1) if (pos.y > -1)
XtVaSetValues(dialogShell, XmNy, pos.y, XtVaSetValues(dialogShell, XmNy, pos.y,
NULL); NULL);
if (size.x > -1) if (size.x > -1)
XtVaSetValues(dialogShell, XmNwidth, size.x, NULL); XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
if (size.y > -1) if (size.y > -1)
XtVaSetValues(dialogShell, XmNheight, size.y, NULL); XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
} }
// This patch come from Torsten Liermann lier@lier1.muc.de // This patch come from Torsten Liermann lier@lier1.muc.de
if (XmIsMotifWMRunning(shell)) if (XmIsMotifWMRunning(shell))
{ {
int decor = 0 ; int decor = 0 ;
if (m_windowStyle & wxRESIZE_BORDER) if (m_windowStyle & wxRESIZE_BORDER)
decor |= MWM_DECOR_RESIZEH ; decor |= MWM_DECOR_RESIZEH ;
if (m_windowStyle & wxSYSTEM_MENU) if (m_windowStyle & wxSYSTEM_MENU)
decor |= MWM_DECOR_MENU; decor |= MWM_DECOR_MENU;
if ((m_windowStyle & wxCAPTION) || if ((m_windowStyle & wxCAPTION) ||
(m_windowStyle & wxTINY_CAPTION_HORIZ) || (m_windowStyle & wxTINY_CAPTION_HORIZ) ||
(m_windowStyle & wxTINY_CAPTION_VERT)) (m_windowStyle & wxTINY_CAPTION_VERT))
decor |= MWM_DECOR_TITLE; decor |= MWM_DECOR_TITLE;
if (m_windowStyle & wxTHICK_FRAME) if (m_windowStyle & wxTHICK_FRAME)
decor |= MWM_DECOR_BORDER; decor |= MWM_DECOR_BORDER;
if (m_windowStyle & wxMINIMIZE_BOX) if (m_windowStyle & wxMINIMIZE_BOX)
decor |= MWM_DECOR_MINIMIZE; decor |= MWM_DECOR_MINIMIZE;
if (m_windowStyle & wxMAXIMIZE_BOX) if (m_windowStyle & wxMAXIMIZE_BOX)
decor |= MWM_DECOR_MAXIMIZE; decor |= MWM_DECOR_MAXIMIZE;
XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ; XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
} }
// This allows non-Motif window managers to support at least the // This allows non-Motif window managers to support at least the
// no-decorations case. // no-decorations case.
else else
{ {
if ((m_windowStyle & wxCAPTION) != wxCAPTION) if ((m_windowStyle & wxCAPTION) != wxCAPTION)
XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL); XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
} }
XtRealizeWidget(dialogShell); XtRealizeWidget(dialogShell);
XtAddCallback(dialogShell,XmNunmapCallback, XtAddCallback(dialogShell,XmNunmapCallback,
(XtCallbackProc)wxUnmapBulletinBoard,this) ; (XtCallbackProc)wxUnmapBulletinBoard,this) ;
// Positioning of the dialog doesn't work properly unless the dialog // Positioning of the dialog doesn't work properly unless the dialog
// is managed, so we manage without mapping to the screen. // is managed, so we manage without mapping to the screen.
// To show, we map the shell (actually it's parent). // To show, we map the shell (actually it's parent).
if (!wxUSE_INVISIBLE_RESIZE) if (!wxUSE_INVISIBLE_RESIZE)
XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL); XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
if (!wxUSE_INVISIBLE_RESIZE) if (!wxUSE_INVISIBLE_RESIZE)
{ {
XtManageChild(dialogShell); XtManageChild(dialogShell);
SetSize(pos.x, pos.y, size.x, size.y); SetSize(pos.x, pos.y, size.x, size.y);
} }
XtAddEventHandler(dialogShell,ExposureMask,FALSE, XtAddEventHandler(dialogShell,ExposureMask,FALSE,
wxDialogBoxRepaintProc, (XtPointer) this); wxDialogBoxRepaintProc, (XtPointer) this);
XtAddEventHandler(dialogShell, XtAddEventHandler(dialogShell,
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
FALSE, FALSE,
wxDialogBoxEventHandler, wxDialogBoxEventHandler,
(XtPointer)this); (XtPointer)this);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -250,11 +250,11 @@ void wxDialog::SetModal(bool flag)
m_windowStyle |= wxDIALOG_MODAL ; m_windowStyle |= wxDIALOG_MODAL ;
else else
if ( m_windowStyle & wxDIALOG_MODAL ) if ( m_windowStyle & wxDIALOG_MODAL )
m_windowStyle -= wxDIALOG_MODAL ; m_windowStyle -= wxDIALOG_MODAL ;
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
if (!flag) if (!flag)
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
} }
wxDialog::~wxDialog() wxDialog::~wxDialog()
@@ -262,30 +262,30 @@ wxDialog::~wxDialog()
m_modalShowing = FALSE; m_modalShowing = FALSE;
if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget) if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
{ {
XtUnmapWidget((Widget) m_mainWidget); XtUnmapWidget((Widget) m_mainWidget);
} }
wxTopLevelWindows.DeleteObject(this); wxTopLevelWindows.DeleteObject(this);
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL ) if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
wxModelessWindows.DeleteObject(this); wxModelessWindows.DeleteObject(this);
// If this is the last top-level window, exit. // If this is the last top-level window, exit.
if (wxTheApp && (wxTopLevelWindows.Number() == 0)) if (wxTheApp && (wxTopLevelWindows.Number() == 0))
{ {
wxTheApp->SetTopWindow(NULL); wxTheApp->SetTopWindow(NULL);
if (wxTheApp->GetExitOnFrameDelete()) if (wxTheApp->GetExitOnFrameDelete())
{ {
wxTheApp->ExitMainLoop(); wxTheApp->ExitMainLoop();
} }
} }
// This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp) // 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. // but I think this should work, if we destroy the children first.
// Note that this might need to be done for wxFrame also. // Note that this might need to be done for wxFrame also.
DestroyChildren(); DestroyChildren();
// This causes a crash in e.g. the resource sample when closing // This causes a crash in e.g. the resource sample when closing
// the example dialog. TODO: Probably not necessary (?) // the example dialog. TODO: Probably not necessary (?)
#if 0 #if 0
@@ -293,16 +293,16 @@ wxDialog::~wxDialog()
// this might remain on the screen. // this might remain on the screen.
Display* display; Display* display;
if (m_mainWidget) if (m_mainWidget)
display = XtDisplay((Widget) m_mainWidget); display = XtDisplay((Widget) m_mainWidget);
else else
display = (Display*) wxGetDisplay(); display = (Display*) wxGetDisplay();
XSync(display, FALSE); XSync(display, FALSE);
XEvent event; XEvent event;
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) { while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
XFlush(display); XFlush(display);
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
XtDispatchEvent(&event); XtDispatchEvent(&event);
} }
#endif #endif
} }
@@ -310,35 +310,35 @@ wxDialog::~wxDialog()
// By default, pressing escape cancels the dialog // By default, pressing escape cancels the dialog
void wxDialog::OnCharHook(wxKeyEvent& event) void wxDialog::OnCharHook(wxKeyEvent& event)
{ {
if (event.m_keyCode == WXK_ESCAPE) if (event.m_keyCode == WXK_ESCAPE)
{ {
// Behaviour changed in 2.0: we'll send a Cancel message // Behaviour changed in 2.0: we'll send a Cancel message
// to the dialog instead of Close. // to the dialog instead of Close.
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this ); cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); GetEventHandler()->ProcessEvent(cancelEvent);
return; return;
} }
// We didn't process this event. // We didn't process this event.
event.Skip(); event.Skip();
} }
void wxDialog::Iconize(bool WXUNUSED(iconize)) void wxDialog::Iconize(bool WXUNUSED(iconize))
{ {
// Can't iconize a dialog in Motif, apparently // Can't iconize a dialog in Motif, apparently
// TODO: try using the parent of m_mainShell. // TODO: try using the parent of m_mainShell.
// XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL); // XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
} }
bool wxDialog::IsIconized() const bool wxDialog::IsIconized() const
{ {
/* /*
Boolean iconic; Boolean iconic;
XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL); XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
return iconic; return iconic;
*/ */
return FALSE; return FALSE;
} }
@@ -362,61 +362,61 @@ void wxDialog::SetTitle(const wxString& title)
{ {
XmString str = XmStringCreateSimple((char*) (const char*) title); XmString str = XmStringCreateSimple((char*) (const char*) title);
XtVaSetValues((Widget) m_mainWidget, XtVaSetValues((Widget) m_mainWidget,
XmNtitle, (char*) (const char*) title, XmNtitle, (char*) (const char*) title,
XmNdialogTitle, str, // Roberto Cocchi XmNdialogTitle, str, // Roberto Cocchi
XmNiconName, (char*) (const char*) title, XmNiconName, (char*) (const char*) title,
NULL); NULL);
XmStringFree(str); XmStringFree(str);
} }
} }
wxString wxDialog::GetTitle() const wxString wxDialog::GetTitle() const
{ {
return m_dialogTitle; return m_dialogTitle;
} }
void wxDialog::Centre(int direction) void wxDialog::Centre(int direction)
{ {
int x_offset,y_offset ; int x_offset,y_offset ;
int display_width, display_height; int display_width, display_height;
int width, height, x, y; int width, height, x, y;
wxWindow *parent = GetParent(); wxWindow *parent = GetParent();
if ((direction & wxCENTER_FRAME) && parent) if ((direction & wxCENTER_FRAME) && parent)
{ {
parent->GetPosition(&x_offset,&y_offset) ; parent->GetPosition(&x_offset,&y_offset) ;
parent->GetSize(&display_width,&display_height) ; parent->GetSize(&display_width,&display_height) ;
} }
else else
{ {
wxDisplaySize(&display_width, &display_height); wxDisplaySize(&display_width, &display_height);
x_offset = 0 ; x_offset = 0 ;
y_offset = 0 ; y_offset = 0 ;
} }
GetSize(&width, &height); GetSize(&width, &height);
GetPosition(&x, &y); GetPosition(&x, &y);
if (direction & wxHORIZONTAL) if (direction & wxHORIZONTAL)
x = (int)((display_width - width)/2); x = (int)((display_width - width)/2);
if (direction & wxVERTICAL) if (direction & wxVERTICAL)
y = (int)((display_height - height)/2); y = (int)((display_height - height)/2);
SetSize(x+x_offset, y+y_offset, width, height); SetSize(x+x_offset, y+y_offset, width, height);
} }
void wxDialog::Raise() void wxDialog::Raise()
{ {
Window parent_window = XtWindow((Widget) m_mainWidget), Window parent_window = XtWindow((Widget) m_mainWidget),
next_parent = XtWindow((Widget) m_mainWidget), next_parent = XtWindow((Widget) m_mainWidget),
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget)); root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may // search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM) // reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) { while (next_parent != root) {
Window *theChildren; unsigned int n; Window *theChildren; unsigned int n;
parent_window = next_parent; parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root, XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&next_parent, &theChildren, &n); &next_parent, &theChildren, &n);
XFree(theChildren); // not needed XFree(theChildren); // not needed
} }
XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window); XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
} }
@@ -424,16 +424,16 @@ void wxDialog::Raise()
void wxDialog::Lower() void wxDialog::Lower()
{ {
Window parent_window = XtWindow((Widget) m_mainWidget), Window parent_window = XtWindow((Widget) m_mainWidget),
next_parent = XtWindow((Widget) m_mainWidget), next_parent = XtWindow((Widget) m_mainWidget),
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget)); root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
// search for the parent that is child of ROOT, because the WM may // search for the parent that is child of ROOT, because the WM may
// reparent twice and notify only the next parent (like FVWM) // reparent twice and notify only the next parent (like FVWM)
while (next_parent != root) { while (next_parent != root) {
Window *theChildren; unsigned int n; Window *theChildren; unsigned int n;
parent_window = next_parent; parent_window = next_parent;
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root, XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
&next_parent, &theChildren, &n); &next_parent, &theChildren, &n);
XFree(theChildren); // not needed XFree(theChildren); // not needed
} }
XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window); XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
} }
@@ -441,16 +441,16 @@ void wxDialog::Lower()
bool wxDialog::Show(bool show) bool wxDialog::Show(bool show)
{ {
m_isShown = show; m_isShown = show;
if (show) if (show)
{ {
if (!wxUSE_INVISIBLE_RESIZE) if (!wxUSE_INVISIBLE_RESIZE)
XtMapWidget(XtParent((Widget) m_mainWidget)); XtMapWidget(XtParent((Widget) m_mainWidget));
else else
XtManageChild((Widget) m_mainWidget) ; XtManageChild((Widget) m_mainWidget) ;
XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget)); XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
} }
else else
{ {
@@ -458,11 +458,11 @@ bool wxDialog::Show(bool show)
XtUnmapWidget(XtParent((Widget) m_mainWidget)); XtUnmapWidget(XtParent((Widget) m_mainWidget));
else else
XtUnmanageChild((Widget) m_mainWidget) ; XtUnmanageChild((Widget) m_mainWidget) ;
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
} }
return TRUE; return TRUE;
} }
@@ -470,43 +470,43 @@ bool wxDialog::Show(bool show)
int wxDialog::ShowModal() int wxDialog::ShowModal()
{ {
m_windowStyle |= wxDIALOG_MODAL; m_windowStyle |= wxDIALOG_MODAL;
Show(TRUE); Show(TRUE);
if (m_modalShowing) if (m_modalShowing)
return 0; return 0;
wxModalShowingStack.Insert((wxObject *)TRUE); wxModalShowingStack.Insert((wxObject *)TRUE);
m_modalShowing = TRUE; m_modalShowing = TRUE;
XtAddGrab((Widget) m_mainWidget, TRUE, FALSE); XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
XEvent event; XEvent event;
// Loop until we signal that the dialog should be closed // Loop until we signal that the dialog should be closed
while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0)) while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
{ {
// XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll); // XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
wxTheApp->ProcessXEvent((WXEvent*) &event); wxTheApp->ProcessXEvent((WXEvent*) &event);
} }
// Remove modal dialog flag from stack // Remove modal dialog flag from stack
wxNode *node = wxModalShowingStack.First(); wxNode *node = wxModalShowingStack.First();
if (node) if (node)
delete node; delete node;
// Now process all events in case they get sent to a destroyed dialog // Now process all events in case they get sent to a destroyed dialog
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
{ {
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
wxTheApp->ProcessXEvent((WXEvent*) &event); wxTheApp->ProcessXEvent((WXEvent*) &event);
} }
// TODO: is it safe to call this, if the dialog may have been deleted // 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. // by now? Probably only if we're using delayed deletion of dialogs.
return GetReturnCode(); return GetReturnCode();
@@ -516,41 +516,41 @@ void wxDialog::EndModal(int retCode)
{ {
if (!m_modalShowing) if (!m_modalShowing)
return; return;
SetReturnCode(retCode); SetReturnCode(retCode);
// Strangely, we don't seem to need this now. // Strangely, we don't seem to need this now.
// XtRemoveGrab((Widget) m_mainWidget); // XtRemoveGrab((Widget) m_mainWidget);
Show(FALSE); Show(FALSE);
m_modalShowing = FALSE; m_modalShowing = FALSE;
wxNode *node = wxModalShowingStack.First(); wxNode *node = wxModalShowingStack.First();
if (node) if (node)
node->SetData((wxObject *)FALSE); node->SetData((wxObject *)FALSE);
} }
// Standard buttons // Standard buttons
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event)) void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{ {
if ( Validate() && TransferDataFromWindow() ) if ( Validate() && TransferDataFromWindow() )
{ {
if ( IsModal() ) if ( IsModal() )
EndModal(wxID_OK); EndModal(wxID_OK);
else else
{ {
SetReturnCode(wxID_OK); SetReturnCode(wxID_OK);
this->Show(FALSE); this->Show(FALSE);
} }
} }
} }
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event)) void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
{ {
if (Validate()) if (Validate())
TransferDataFromWindow(); TransferDataFromWindow();
// TODO probably need to disable the Apply button until things change again // TODO probably need to disable the Apply button until things change again
} }
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event)) void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
@@ -560,30 +560,30 @@ void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
else else
{ {
SetReturnCode(wxID_CANCEL); SetReturnCode(wxID_CANCEL);
this->Show(FALSE); this->Show(FALSE);
} }
} }
bool wxDialog::OnClose() 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. // which may close the dialog.
// Check for looping if the Cancel event handler calls Close() // Check for looping if the Cancel event handler calls Close()
static wxList closing; static wxList closing;
if ( closing.Member(this) ) if ( closing.Member(this) )
return FALSE; return FALSE;
closing.Append(this); closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this ); cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); GetEventHandler()->ProcessEvent(cancelEvent);
closing.DeleteObject(this); closing.DeleteObject(this);
return FALSE; return FALSE;
} }
void wxDialog::OnCloseWindow(wxCloseEvent& event) void wxDialog::OnCloseWindow(wxCloseEvent& event)
@@ -598,15 +598,15 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
// Destroy the window (delayed, if a managed window) // Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy() bool wxDialog::Destroy()
{ {
if (!wxPendingDelete.Member(this)) if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this); wxPendingDelete.Append(this);
return TRUE; return TRUE;
} }
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{ {
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
Refresh(); Refresh();
} }
void wxDialog::Fit() void wxDialog::Fit()
@@ -615,106 +615,106 @@ void wxDialog::Fit()
// Handle a close event from the window manager // Handle a close event from the window manager
static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data, static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data,
XmAnyCallbackStruct *WXUNUSED(cbs)) XmAnyCallbackStruct *WXUNUSED(cbs))
{ {
wxDialog *dialog = (wxDialog *)client_data; wxDialog *dialog = (wxDialog *)client_data;
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId()); wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
closeEvent.SetEventObject(dialog); closeEvent.SetEventObject(dialog);
// May delete the dialog (with delayed deletion) // May delete the dialog (with delayed deletion)
dialog->GetEventHandler()->ProcessEvent(closeEvent); dialog->GetEventHandler()->ProcessEvent(closeEvent);
} }
// TODO: Preferably, we should have a universal repaint proc. // TODO: Preferably, we should have a universal repaint proc.
// Meanwhile, use a special one for dialogs. // Meanwhile, use a special one for dialogs.
static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *) static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
{ {
Window window; Window window;
Display *display; Display *display;
wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w); wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
if (!win) if (!win)
return; return;
switch(event -> type) switch(event -> type)
{ {
case Expose : case Expose :
{ {
window = (Window) win -> GetXWindow(); window = (Window) win -> GetXWindow();
display = (Display *) win -> GetXDisplay(); display = (Display *) win -> GetXDisplay();
wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y, wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
event->xexpose.width, event->xexpose.height); event->xexpose.width, event->xexpose.height);
win->m_updateRects.Append((wxObject*) rect); win->m_updateRects.Append((wxObject*) rect);
if (event -> xexpose.count == 0) if (event -> xexpose.count == 0)
{ {
wxPaintEvent event(win->GetId()); wxPaintEvent event(win->GetId());
event.SetEventObject(win); event.SetEventObject(win);
win->GetEventHandler()->ProcessEvent(event); win->GetEventHandler()->ProcessEvent(event);
win->ClearUpdateRects(); win->ClearUpdateRects();
} }
break; break;
} }
default : default :
{ {
cout << "\n\nNew Event ! is = " << event -> type << "\n"; cout << "\n\nNew Event ! is = " << event -> type << "\n";
break; break;
} }
} }
} }
static void wxDialogBoxEventHandler (Widget wid, static void wxDialogBoxEventHandler (Widget wid,
XtPointer WXUNUSED(client_data), XtPointer WXUNUSED(client_data),
XEvent* event, XEvent* event,
Boolean *continueToDispatch) Boolean *continueToDispatch)
{ {
wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid); wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
if (dialog) if (dialog)
{
wxMouseEvent wxevent(wxEVT_NULL);
if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
{ {
wxevent.SetEventObject(dialog); wxMouseEvent wxevent(wxEVT_NULL);
wxevent.SetId(dialog->GetId()); if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
dialog->GetEventHandler()->ProcessEvent(wxevent);
}
else
{
// 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; wxevent.SetEventObject(dialog);
return; wxevent.SetId(dialog->GetId());
dialog->GetEventHandler()->ProcessEvent(wxevent);
} }
else else
{ {
keyEvent.SetEventType(wxEVT_CHAR); // An attempt to implement OnCharHook by calling OnCharHook first;
dialog->GetEventHandler()->ProcessEvent(keyEvent); // 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) ) static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
{ {
/* This gets called when the dialog is being shown, which /* This gets called when the dialog is being shown, which
* defeats modal showing. * defeats modal showing.
client->m_modalShowing = FALSE ; client->m_modalShowing = FALSE ;
client->m_isShown = FALSE; client->m_isShown = FALSE;
*/ */
} }
void wxDialog::ChangeFont(bool keepOriginalSize) void wxDialog::ChangeFont(bool keepOriginalSize)

View File

@@ -1,22 +1,29 @@
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp // Name: dnd.cpp
// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation // Purpose: wxDropTarget, wxDropSource classes
// Author: Julian Smart // Author: Julian Smart
// Modified by: // Id: $Id$
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart // Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__ #ifdef __GNUG__
#pragma implementation "dnd.h" #pragma implementation "dnd.h"
#endif #endif
#include "wx/setup.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/window.h" #include "wx/window.h"
#include "wx/app.h" #include "wx/app.h"
#include "wx/gdicmn.h" #include "wx/gdicmn.h"
#include "wx/intl.h"
#include "wx/utils.h"
#include "wx/log.h"
#include <X11/Xlib.h>
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// global // global
@@ -28,28 +35,28 @@
wxDropTarget::wxDropTarget() wxDropTarget::wxDropTarget()
{ {
}; }
wxDropTarget::~wxDropTarget() wxDropTarget::~wxDropTarget()
{ {
}; }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxTextDropTarget // 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; return TRUE;
}; }
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz ) bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{ {
printf( "Got dropped text: %s.\n", psz ); wxLogDebug( "Got dropped text: %s.", psz );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
return TRUE; return TRUE;
}; }
size_t wxTextDropTarget::GetFormatCount() const size_t wxTextDropTarget::GetFormatCount() const
{ {
@@ -65,18 +72,41 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
// wxFileDropTarget // 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 ); wxLogDebug( "Got %d dropped files.", (int)nFiles );
printf( "At x: %d, y: %d.\n", (int)x, (int)y ); wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
for (size_t i = 0; i < nFiles; i++)
{
wxLogDebug( aszFiles[i] );
}
return TRUE; 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"; size_t number = 0;
char *text = (char*) data;
for (size_t i = 0; i < size; i++)
if (text[i] == 0) number++;
return OnDropFiles(x, y, 1, &str ); 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 size_t wxFileDropTarget::GetFormatCount() const
@@ -93,41 +123,100 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
// wxDropSource // wxDropSource
//------------------------------------------------------------------------- //-------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// drag request
wxDropSource::wxDropSource( wxWindow *win ) wxDropSource::wxDropSource( wxWindow *win )
{ {
// TODO #if 0
// m_window = win; m_window = win;
m_data = NULL; m_data = (wxDataObject *) NULL;
m_retValue = wxDragCancel;
// m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY ); m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
// m_goaheadCursor = wxCursor( wxCURSOR_HAND ); m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}; #endif
}
wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win ) wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
{ {
// TODO #if 0
// m_window = win; g_blockEventsOnDrag = TRUE;
m_data = &data;
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_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
// m_goaheadCursor = wxCursor( wxCURSOR_HAND ); m_goaheadCursor = wxCursor( wxCURSOR_HAND );
}; #endif
}
void wxDropSource::SetData( wxDataObject &data ) void wxDropSource::SetData( wxDataObject &data )
{ {
m_data = &data; // m_data = &data;
}; }
wxDropSource::~wxDropSource(void) wxDropSource::~wxDropSource(void)
{ {
}; // if (m_data) delete m_data;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) ) wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{ {
// TODO // wxASSERT_MSG( m_data, "wxDragSource: no data" );
return wxDragError;
};
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

View File

@@ -36,9 +36,9 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
#endif #endif
#define DEFAULT_FILE_SELECTOR_SIZE 0 #define DEFAULT_FILE_SELECTOR_SIZE 0
// Let Motif defines the size of File // Let Motif defines the size of File
// Selector Box (if 1), or fix it to // Selector Box (if 1), or fix it to
// wxFSB_WIDTH x wxFSB_HEIGHT (if 0) // wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
#define wxFSB_WIDTH 600 #define wxFSB_WIDTH 600
#define wxFSB_HEIGHT 500 #define wxFSB_HEIGHT 500
@@ -50,27 +50,27 @@ char *wxFileSelector(const char *title,
{ {
// If there's a default extension specified but no filter, we create a suitable // If there's a default extension specified but no filter, we create a suitable
// filter. // filter.
wxString filter2(""); wxString filter2("");
if ( defaultExtension && !filter ) if ( defaultExtension && !filter )
filter2 = wxString("*.") + wxString(defaultExtension) ; filter2 = wxString("*.") + wxString(defaultExtension) ;
else if ( filter ) else if ( filter )
filter2 = filter; filter2 = filter;
wxString defaultDirString; wxString defaultDirString;
if (defaultDir) if (defaultDir)
defaultDirString = defaultDir; defaultDirString = defaultDir;
else else
defaultDirString = ""; defaultDirString = "";
wxString defaultFilenameString; wxString defaultFilenameString;
if (defaultFileName) if (defaultFileName)
defaultFilenameString = defaultFileName; defaultFilenameString = defaultFileName;
else else
defaultFilenameString = ""; defaultFilenameString = "";
wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y)); wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
if ( fileDialog.ShowModal() == wxID_OK ) if ( fileDialog.ShowModal() == wxID_OK )
{ {
strcpy(wxBuffer, (const char *)fileDialog.GetPath()); strcpy(wxBuffer, (const char *)fileDialog.GetPath());
@@ -89,11 +89,11 @@ char *wxFileSelectorEx(const char *title,
wxWindow* parent, wxWindow* parent,
int x, int x,
int y) int y)
{ {
wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "", wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y)); defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
if ( fileDialog.ShowModal() == wxID_OK ) if ( fileDialog.ShowModal() == wxID_OK )
{ {
*defaultFilterIndex = fileDialog.GetFilterIndex(); *defaultFilterIndex = fileDialog.GetFilterIndex();
@@ -108,30 +108,30 @@ wxString wxFileDialog::m_fileSelectorAnswer = "";
bool wxFileDialog::m_fileSelectorReturned = FALSE; bool wxFileDialog::m_fileSelectorReturned = FALSE;
void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data),
XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) ) XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
{ {
wxFileDialog::m_fileSelectorAnswer = ""; wxFileDialog::m_fileSelectorAnswer = "";
wxFileDialog::m_fileSelectorReturned = TRUE; wxFileDialog::m_fileSelectorReturned = TRUE;
} }
void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSelectionBoxCallbackStruct *cbs) void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSelectionBoxCallbackStruct *cbs)
{ {
char *filename = NULL; char *filename = NULL;
if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) { if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
wxFileDialog::m_fileSelectorAnswer = ""; wxFileDialog::m_fileSelectorAnswer = "";
wxFileDialog::m_fileSelectorReturned = TRUE; wxFileDialog::m_fileSelectorReturned = TRUE;
} else { } else {
if (filename) { if (filename) {
wxFileDialog::m_fileSelectorAnswer = filename; wxFileDialog::m_fileSelectorAnswer = filename;
XtFree(filename); XtFree(filename);
}
wxFileDialog::m_fileSelectorReturned = TRUE;
} }
wxFileDialog::m_fileSelectorReturned = TRUE;
}
} }
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message, wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard, const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos) long style, const wxPoint& pos)
{ {
m_message = message; m_message = message;
m_dialogStyle = style; m_dialogStyle = style;
@@ -146,159 +146,159 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
int wxFileDialog::ShowModal() int wxFileDialog::ShowModal()
{ {
wxBeginBusyCursor(); wxBeginBusyCursor();
// static char fileBuf[512]; // static char fileBuf[512];
Widget parentWidget = (Widget) 0; Widget parentWidget = (Widget) 0;
if (m_parent) if (m_parent)
{ {
parentWidget = (Widget) m_parent->GetTopWidget(); 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;
else else
filter = m_wildCard; parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT); Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
XmTextSetString(filterWidget, (char*) (const char*) filter); XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
XmFileSelectionDoSearch(fileSel, NULL);
} Widget shell = XtParent(fileSel);
// Suggested by Terry Gitnick, 16/9/97, because of change in Motif if (!m_message.IsNull())
// file selector on Solaris 1.5.1. XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
if ( m_dir != "" )
{ wxString entirePath("");
XmString thePath = XmStringCreateLtoR ((char*) (const char*) m_dir,
XmSTRING_DEFAULT_CHARSET); if ((m_dir != "") && (m_fileName != ""))
{
XtVaSetValues (fileSel, entirePath = m_dir + wxString("/") + m_fileName;
XmNdirectory, thePath, }
NULL); else if ((m_dir != "") && (m_fileName == ""))
{
XmStringFree(thePath); entirePath = m_dir + wxString("/");
} }
else if ((m_dir == "") && (m_fileName != ""))
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL); {
XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL); entirePath = m_fileName;
}
//#if XmVersion > 1000
// I'm not sure about what you mean with XmVersion. if (entirePath != "")
// If this is for Motif1.1/Motif1.2, then check XmVersion>=1200 {
// (Motif1.1.4 ==> XmVersion 1100 ) Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
// Nevertheless, I put here a #define, so anyone can choose in (I)makefile... 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 #if !DEFAULT_FILE_SELECTOR_SIZE
int width = wxFSB_WIDTH; int width = wxFSB_WIDTH;
int height = wxFSB_HEIGHT; int height = wxFSB_HEIGHT;
XtVaSetValues(fileSel, XtVaSetValues(fileSel,
XmNwidth, width, XmNwidth, width,
XmNheight, height, XmNheight, height,
XmNresizePolicy, XmRESIZE_NONE, XmNresizePolicy, XmRESIZE_NONE,
NULL); NULL);
#endif #endif
XtManageChild(fileSel); XtManageChild(fileSel);
m_fileSelectorAnswer = ""; m_fileSelectorAnswer = "";
m_fileSelectorReturned = FALSE; m_fileSelectorReturned = FALSE;
wxEndBusyCursor(); wxEndBusyCursor();
XtAddGrab(XtParent(fileSel), TRUE, FALSE); XtAddGrab(XtParent(fileSel), TRUE, FALSE);
XEvent event; XEvent event;
while (!m_fileSelectorReturned) while (!m_fileSelectorReturned)
{ {
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll); XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
} }
XtRemoveGrab(XtParent(fileSel)); XtRemoveGrab(XtParent(fileSel));
XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
// XtDestroyWidget(fileSel); // XtDestroyWidget(fileSel);
XtUnmapWidget(XtParent(fileSel)); XtUnmapWidget(XtParent(fileSel));
XtDestroyWidget(XtParent(fileSel)); XtDestroyWidget(XtParent(fileSel));
// Now process all events, because otherwise // Now process all events, because otherwise
// this might remain on the screen // this might remain on the screen
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE); XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
{ {
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())); XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event); XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
XtDispatchEvent(&event); XtDispatchEvent(&event);
} }
m_path = m_fileSelectorAnswer; m_path = m_fileSelectorAnswer;
m_fileName = wxFileNameFromPath(m_fileSelectorAnswer); m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
m_dir = wxPathOnly(m_path); m_dir = wxPathOnly(m_path);
if (m_fileName == "") if (m_fileName == "")
return wxID_CANCEL; return wxID_CANCEL;
else else
return wxID_OK; return wxID_OK;
} }
// Generic file load/save dialog // Generic file load/save dialog
static char * static char *
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent) wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
{ {
char *ext = (char *)extension; char *ext = (char *)extension;
char prompt[50]; char prompt[50];
wxString str; wxString str;
if (load) if (load)
str = "Load %s file"; str = "Load %s file";
else else
str = "Save %s file"; str = "Save %s file";
sprintf(prompt, wxGetTranslation(str), what); sprintf(prompt, wxGetTranslation(str), what);
if (*ext == '.') ext++; if (*ext == '.') ext++;
char wild[60]; char wild[60];
sprintf(wild, "*.%s", ext); sprintf(wild, "*.%s", ext);
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent); return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
} }
// Generic file load dialog // Generic file load dialog
char * char *
wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) 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);
} }
@@ -306,7 +306,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_
char * char *
wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent) 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);
} }

View File

@@ -37,12 +37,12 @@ wxXFont::~wxXFont()
{ {
XFontStruct* fontStruct = (XFontStruct*) m_fontStruct; XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
XmFontList fontList = (XmFontList) m_fontList; XmFontList fontList = (XmFontList) m_fontList;
XmFontListFree (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. // Note that XFreeFont wasn't called in wxWin 1.68 either.
// XFreeFont((Display*) m_display, fontStruct); // XFreeFont((Display*) m_display, fontStruct);
} }
wxFontRefData::wxFontRefData() wxFontRefData::wxFontRefData()
@@ -65,7 +65,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data)
m_weight = data.m_weight; m_weight = data.m_weight;
m_underlined = data.m_underlined; m_underlined = data.m_underlined;
m_faceName = data.m_faceName; m_faceName = data.m_faceName;
// Don't have to copy actual fonts, because they'll be created // Don't have to copy actual fonts, because they'll be created
// on demand. // on demand.
} }
@@ -91,7 +91,7 @@ wxFont::wxFont()
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName) wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
{ {
Create(pointSize, family, style, weight, underlined, faceName); Create(pointSize, family, style, weight, underlined, faceName);
if ( wxTheFontList ) if ( wxTheFontList )
wxTheFontList->Append(this); wxTheFontList->Append(this);
} }
@@ -100,16 +100,16 @@ bool wxFont::Create(int pointSize, int family, int style, int weight, bool under
{ {
UnRef(); UnRef();
m_refData = new wxFontRefData; m_refData = new wxFontRefData;
M_FONTDATA->m_family = family; M_FONTDATA->m_family = family;
M_FONTDATA->m_style = style; M_FONTDATA->m_style = style;
M_FONTDATA->m_weight = weight; M_FONTDATA->m_weight = weight;
M_FONTDATA->m_pointSize = pointSize; M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_underlined = underlined; M_FONTDATA->m_underlined = underlined;
M_FONTDATA->m_faceName = faceName; M_FONTDATA->m_faceName = faceName;
RealizeResource(); RealizeResource();
return TRUE; return TRUE;
} }
@@ -127,101 +127,101 @@ bool wxFont::RealizeResource()
void wxFont::Unshare() void wxFont::Unshare()
{ {
// Don't change shared data // Don't change shared data
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxFontRefData(); m_refData = new wxFontRefData();
} }
else else
{ {
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData); wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
UnRef(); UnRef();
m_refData = ref; m_refData = ref;
} }
} }
void wxFont::SetPointSize(int pointSize) void wxFont::SetPointSize(int pointSize)
{ {
Unshare(); Unshare();
M_FONTDATA->m_pointSize = pointSize; M_FONTDATA->m_pointSize = pointSize;
RealizeResource(); RealizeResource();
} }
void wxFont::SetFamily(int family) void wxFont::SetFamily(int family)
{ {
Unshare(); Unshare();
M_FONTDATA->m_family = family; M_FONTDATA->m_family = family;
RealizeResource(); RealizeResource();
} }
void wxFont::SetStyle(int style) void wxFont::SetStyle(int style)
{ {
Unshare(); Unshare();
M_FONTDATA->m_style = style; M_FONTDATA->m_style = style;
RealizeResource(); RealizeResource();
} }
void wxFont::SetWeight(int weight) void wxFont::SetWeight(int weight)
{ {
Unshare(); Unshare();
M_FONTDATA->m_weight = weight; M_FONTDATA->m_weight = weight;
RealizeResource(); RealizeResource();
} }
void wxFont::SetFaceName(const wxString& faceName) void wxFont::SetFaceName(const wxString& faceName)
{ {
Unshare(); Unshare();
M_FONTDATA->m_faceName = faceName; M_FONTDATA->m_faceName = faceName;
RealizeResource(); RealizeResource();
} }
void wxFont::SetUnderlined(bool underlined) void wxFont::SetUnderlined(bool underlined)
{ {
Unshare(); Unshare();
M_FONTDATA->m_underlined = underlined; M_FONTDATA->m_underlined = underlined;
RealizeResource(); RealizeResource();
} }
wxString wxFont::GetFamilyString() const wxString wxFont::GetFamilyString() const
{ {
wxString fam(""); wxString fam("");
switch (GetFamily()) switch (GetFamily())
{ {
case wxDECORATIVE: case wxDECORATIVE:
fam = "wxDECORATIVE"; fam = "wxDECORATIVE";
break; break;
case wxROMAN: case wxROMAN:
fam = "wxROMAN"; fam = "wxROMAN";
break; break;
case wxSCRIPT: case wxSCRIPT:
fam = "wxSCRIPT"; fam = "wxSCRIPT";
break; break;
case wxSWISS: case wxSWISS:
fam = "wxSWISS"; fam = "wxSWISS";
break; break;
case wxMODERN: case wxMODERN:
fam = "wxMODERN"; fam = "wxMODERN";
break; break;
case wxTELETYPE: case wxTELETYPE:
fam = "wxTELETYPE"; fam = "wxTELETYPE";
break; break;
default: default:
fam = "wxDEFAULT"; fam = "wxDEFAULT";
break; break;
} }
return fam; return fam;
} }
/* New font system */ /* New font system */
@@ -229,7 +229,7 @@ wxString wxFont::GetFaceName() const
{ {
wxString str(""); wxString str("");
if (M_FONTDATA) if (M_FONTDATA)
str = M_FONTDATA->m_faceName ; str = M_FONTDATA->m_faceName ;
return str; return str;
} }
@@ -238,15 +238,15 @@ wxString wxFont::GetStyleString() const
wxString styl(""); wxString styl("");
switch (GetStyle()) switch (GetStyle())
{ {
case wxITALIC: case wxITALIC:
styl = "wxITALIC"; styl = "wxITALIC";
break; break;
case wxSLANT: case wxSLANT:
styl = "wxSLANT"; styl = "wxSLANT";
break; break;
default: default:
styl = "wxNORMAL"; styl = "wxNORMAL";
break; break;
} }
return styl; return styl;
} }
@@ -256,15 +256,15 @@ wxString wxFont::GetWeightString() const
wxString w(""); wxString w("");
switch (GetWeight()) switch (GetWeight())
{ {
case wxBOLD: case wxBOLD:
w = "wxBOLD"; w = "wxBOLD";
break; break;
case wxLIGHT: case wxLIGHT:
w = "wxLIGHT"; w = "wxLIGHT";
break; break;
default: default:
w = "wxNORMAL"; w = "wxNORMAL";
break; break;
} }
return w; return w;
} }
@@ -274,106 +274,106 @@ wxString wxFont::GetWeightString() const
// font to list in the private data for future reference. // font to list in the private data for future reference.
wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
{ {
if (!Ok()) if (!Ok())
return (wxXFont*) NULL; return (wxXFont*) NULL;
long intScale = long(scale * 100.0 + 0.5); // key for wxXFont long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100; int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
wxNode* node = M_FONTDATA->m_fonts.First(); wxNode* node = M_FONTDATA->m_fonts.First();
while (node) while (node)
{ {
wxXFont* f = (wxXFont*) node->Data(); wxXFont* f = (wxXFont*) node->Data();
if ((!display || (f->m_display == display)) && (f->m_scale == intScale)) if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
return f; return f;
node = node->Next(); node = node->Next();
} }
WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family, WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined); M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
if (!font) if (!font)
{ {
// search up and down by stepsize 10 // search up and down by stepsize 10
int max_size = pointSize + 20 * (1 + (pointSize/180)); int max_size = pointSize + 20 * (1 + (pointSize/180));
int min_size = pointSize - 20 * (1 + (pointSize/180)); int min_size = pointSize - 20 * (1 + (pointSize/180));
int i; int i;
// Search for smaller size (approx.) // Search for smaller size (approx.)
for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10) 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); font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
// Search for larger size (approx.) // Search for larger size (approx.)
for (i=pointSize+10; !font && i <= max_size; i += 10) 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); font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
// Try default family // Try default family
if (!font && M_FONTDATA->m_family != wxDEFAULT) if (!font && M_FONTDATA->m_family != wxDEFAULT)
font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style, font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
M_FONTDATA->m_weight, M_FONTDATA->m_underlined); M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
// Bogus font // Bogus font
if (!font) if (!font)
font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL, font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
M_FONTDATA->m_underlined); M_FONTDATA->m_underlined);
wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." ); wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." );
} }
if (font) if (font)
{ {
wxXFont* f = new wxXFont; wxXFont* f = new wxXFont;
f->m_fontStruct = font; f->m_fontStruct = font;
f->m_display = ( display ? display : wxGetDisplay() ); f->m_display = ( display ? display : wxGetDisplay() );
f->m_scale = intScale; f->m_scale = intScale;
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET); f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
M_FONTDATA->m_fonts.Append(f); M_FONTDATA->m_fonts.Append(f);
return f; return f;
} }
return (wxXFont*) NULL; return (wxXFont*) NULL;
} }
WXFontStructPtr wxFont::LoadQueryFont(int pointSize, int family, int style, WXFontStructPtr wxFont::LoadQueryFont(int pointSize, int family, int style,
int weight, bool underlined) const int weight, bool underlined) const
{ {
char *xfamily; char *xfamily;
char *xstyle; char *xstyle;
char *xweight; char *xweight;
switch (family) switch (family)
{ {
case wxDECORATIVE: xfamily = "lucida"; case wxDECORATIVE: xfamily = "lucida";
break; break;
case wxROMAN: xfamily = "times"; case wxROMAN: xfamily = "times";
break; break;
case wxMODERN: xfamily = "courier"; case wxMODERN: xfamily = "courier";
break; break;
case wxSWISS: xfamily = "lucida"; case wxSWISS: xfamily = "lucida";
break; break;
case wxDEFAULT: case wxDEFAULT:
default: xfamily = "*"; default: xfamily = "*";
} }
switch (style) switch (style)
{ {
case wxITALIC: xstyle = "i"; case wxITALIC: xstyle = "i";
break; break;
case wxSLANT: xstyle = "o"; case wxSLANT: xstyle = "o";
break; break;
case wxNORMAL: xstyle = "r"; case wxNORMAL: xstyle = "r";
break; break;
default: xstyle = "*"; default: xstyle = "*";
break; break;
} }
switch (weight) switch (weight)
{ {
case wxBOLD: xweight = "bold"; case wxBOLD: xweight = "bold";
break; break;
case wxLIGHT: case wxLIGHT:
case wxNORMAL: xweight = "medium"; case wxNORMAL: xweight = "medium";
break; break;
default: xweight = "*"; default: xweight = "*";
break; break;
} }
sprintf(wxBuffer, "-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*", sprintf(wxBuffer, "-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*",
xfamily, xweight, xstyle, pointSize); xfamily, xweight, xstyle, pointSize);
Display *dpy = (Display*) wxGetDisplay(); Display *dpy = (Display*) wxGetDisplay();
XFontStruct* font = XLoadQueryFont(dpy, wxBuffer); XFontStruct* font = XLoadQueryFont(dpy, wxBuffer);
return (WXFontStructPtr) font; return (WXFontStructPtr) font;
} }

File diff suppressed because it is too large Load Diff

View File

@@ -25,28 +25,28 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
// XmGauge copyright notice: // XmGauge copyright notice:
/* /*
* Copyright 1994 GROUPE BULL * Copyright 1994 GROUPE BULL
* *
* Permission to use, copy, modify, and distribute this software and its * Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided * documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that * that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting * copyright notice and this permission notice appear in supporting
* documentation, and that the name of GROUPE BULL not be used in advertising * documentation, and that the name of GROUPE BULL not be used in advertising
* or publicity pertaining to distribution of the software without specific, * or publicity pertaining to distribution of the software without specific,
* written prior permission. GROUPE BULL makes no representations about the * written prior permission. GROUPE BULL makes no representations about the
* suitability of this software for any purpose. It is provided "as is" * suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty. * without express or implied warranty.
* *
* GROUPE BULL disclaims all warranties with regard to this software, * GROUPE BULL disclaims all warranties with regard to this software,
* including all implied warranties of merchantability and fitness, * including all implied warranties of merchantability and fitness,
* in no event shall GROUPE BULL be liable for any special, * in no event shall GROUPE BULL be liable for any special,
* indirect or consequential damages or any damages * indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits, * whatsoever resulting from loss of use, data or profits,
* whether in an action of contract, negligence or other tortious * whether in an action of contract, negligence or other tortious
* action, arising out of or in connection with the use * action, arising out of or in connection with the use
* or performance of this software. * or performance of this software.
* *
*/ */
//// PUBLIC XMGAUGE DECLARATIONS //// PUBLIC XMGAUGE DECLARATIONS
typedef struct _XmGaugeClassRec* XmGaugeWidgetClass; typedef struct _XmGaugeClassRec* XmGaugeWidgetClass;
@@ -74,12 +74,12 @@ XmGaugeGetValue(Widget w);
bool wxGauge::Create(wxWindow *parent, wxWindowID id, bool wxGauge::Create(wxWindow *parent, wxWindowID id,
int range, int range,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
@@ -87,16 +87,16 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style; m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Arg args[4]; Arg args[4];
int count = 4; int count = 4;
if (style & wxHORIZONTAL) if (style & wxHORIZONTAL)
@@ -113,24 +113,24 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
XtSetArg(args[3], XmNmaximum, range); XtSetArg(args[3], XmNmaximum, range);
Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count); Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
m_mainWidget = (WXWidget) gaugeWidget ; m_mainWidget = (WXWidget) gaugeWidget ;
XtManageChild (gaugeWidget); XtManageChild (gaugeWidget);
int x = pos.x; int y = pos.y; int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y; int width = size.x; int height = size.y;
if (width == -1) if (width == -1)
width = 150; width = 150;
if (height == -1) if (height == -1)
height = 80; height = 80;
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -179,15 +179,15 @@ int wxGauge::GetRange() const
int r; int r;
XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL); XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
return (int)r; return (int)r;
// return m_rangeMax; // return m_rangeMax;
} }
int wxGauge::GetValue() const int wxGauge::GetValue() const
{ {
int pos; int pos;
XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL); XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
return pos; return pos;
// return m_gaugePos; // return m_gaugePos;
} }
void wxGauge::ChangeFont(bool keepOriginalSize) void wxGauge::ChangeFont(bool keepOriginalSize)
@@ -227,7 +227,7 @@ typedef struct _XmGaugePart{
int maximum; int maximum;
unsigned char orientation; unsigned char orientation;
unsigned char processingDirection; unsigned char processingDirection;
XtCallbackList dragCallback; XtCallbackList dragCallback;
XtCallbackList valueChangedCallback; XtCallbackList valueChangedCallback;
@@ -261,9 +261,9 @@ GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
static char translations[] = static char translations[] =
"<Btn1Down>: GaugePick()\n\ "<Btn1Down>: GaugePick()\n\
<Btn1Motion>: GaugeDrag()\n\ <Btn1Motion>: GaugeDrag()\n\
<Btn1Up>: GaugeDrop()\n\ <Btn1Up>: GaugeDrop()\n\
"; ";
@@ -279,100 +279,100 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
#define THIS gw->gauge #define THIS gw->gauge
int size, sht; int size, sht;
float ratio; float ratio;
/***chubraev /***chubraev
char string[20]; char string[20];
int len; int len;
unsigned long backgr,foregr; unsigned long backgr,foregr;
XRectangle rects[1]; XRectangle rects[1];
***/ ***/
sht = gw->primitive.shadow_thickness; sht = gw->primitive.shadow_thickness;
ratio = (float)THIS.value/ ratio = (float)THIS.value/
(float)(THIS.maximum - THIS.minimum); (float)(THIS.maximum - THIS.minimum);
/***chubraev /***chubraev
sprintf(string,"%-d%%",(int)(ratio*100)); sprintf(string,"%-d%%",(int)(ratio*100));
len=strlen(string); len=strlen(string);
XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL); XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
***/ ***/
if(clear) { if(clear) {
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht, XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False); gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
} }
switch(THIS.orientation) { switch(THIS.orientation) {
case XmHORIZONTAL: case XmHORIZONTAL:
size = (int) ((gw->core.width - 2 * sht)*ratio); size = (int) ((gw->core.width - 2 * sht)*ratio);
/***chubraev /***chubraev
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
gw->core.height - 2 * sht, string, len); gw->core.height - 2 * sht, string, len);
***/ ***/
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, size, gw->core.height - 2 * sht); 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);
/***chubraev /***chubraev
rects[0].x = gw->core.width - size - sht; rects[0].y = sht; rects[0].x = sht; rects[0].y = sht;
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht; rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
***/ ***/
break; 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 /***chubraev
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted); XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
XSetForeground(XtDisplay(gw), THIS.gc, backgr); XSetForeground(XtDisplay(gw), THIS.gc, backgr);
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2, XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
gw->core.height - 2 * sht, string, len); gw->core.height - 2 * sht, string, len);
***/ ***/
break; break;
case XmVERTICAL: case XmVERTICAL:
size = (int) ((gw->core.height - 2 * sht)*ratio); 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);
/***chubraev /***chubraev
rects[0].x = sht; rects[0].y = sht; XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size; sht+gw->core.height/2, string,len);
***/ ***/
break; switch(THIS.processingDirection) {
case XmMAX_ON_LEFT: case XmMAX_ON_RIGHT:
case XmMAX_ON_TOP: case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, gw->core.height - size - sht, sht, sht, gw->core.width - 2 * sht, size);
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 /***chubraev
rects[0].x = sht; rects[0].y = gw->core.height - size - sht; XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size; XSetForeground(XtDisplay(gw), THIS.gc, backgr);
***/ XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
} sht+gw->core.height/2, string,len);
/***chubraev ***/
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted); break;
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
sht+gw->core.height/2, string,len);
***/
break;
} }
/***chubraev /***chubraev
XSetClipMask(XtDisplay(gw), THIS.gc, None); XSetClipMask(XtDisplay(gw), THIS.gc, None);
@@ -382,59 +382,59 @@ sht+gw->core.height/2, string,len);
} }
/* Old code /* Old code
*/ */
#if 0 #if 0
static void static void
DrawSlider(XmGaugeWidget gw, Boolean clear) DrawSlider(XmGaugeWidget gw, Boolean clear)
{ {
#define THIS gw->gauge #define THIS gw->gauge
int size, sht; int size, sht;
/* float ratio; */ /* float ratio; */
sht = gw->primitive.shadow_thickness; 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 - ratio = (float)((float)THIS.maximum -
(float)THIS.minimum) / (float)THIS.value; (float)THIS.minimum) / (float)THIS.value;
*/ */
if(clear) { if(clear) {
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht, XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False); gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
} }
switch(THIS.orientation) { switch(THIS.orientation) {
case XmHORIZONTAL: case XmHORIZONTAL:
/* size = (gw->core.width - 2 * sht) / ratio; */ /* size = (gw->core.width - 2 * sht) / ratio; */
/* A fix suggested by Dmitri Chubraev */ /* A fix suggested by Dmitri Chubraev */
size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value; size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, size, gw->core.height - 2 * sht); sht, sht, size, gw->core.height - 2 * sht);
break; break;
case XmMAX_ON_LEFT: case XmMAX_ON_LEFT:
case XmMAX_ON_TOP: case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
gw->core.width - size - sht, sht, gw->core.width - size - sht, sht,
size, gw->core.height - 2 * sht); size, gw->core.height - 2 * sht);
break; break;
} }
break; break;
case XmVERTICAL: case XmVERTICAL:
size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value; size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
/* size = (gw->core.height - 2 * sht)/ ratio; */ /* size = (gw->core.height - 2 * sht)/ ratio; */
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, gw->core.width - 2 * sht, size); sht, sht, gw->core.width - 2 * sht, size);
break; break;
case XmMAX_ON_LEFT: case XmMAX_ON_LEFT:
case XmMAX_ON_TOP: case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc, XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, gw->core.height - size - sht, sht, gw->core.height - size - sht,
gw->core.width - 2 * sht, size); gw->core.width - 2 * sht, size);
} }
break; break;
} }
#undef THIS #undef THIS
} }
@@ -446,7 +446,7 @@ Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
XmGaugeWidget gw = (XmGaugeWidget)new_w; XmGaugeWidget gw = (XmGaugeWidget)new_w;
#define THIS gw->gauge #define THIS gw->gauge
XGCValues values; XGCValues values;
values.foreground = gw->primitive.foreground; values.foreground = gw->primitive.foreground;
THIS.gc = XtGetGC(new_w, GCForeground, &values); THIS.gc = XtGetGC(new_w, GCForeground, &values);
@@ -467,29 +467,29 @@ Destroy(Widget w)
static Boolean static Boolean
SetValues( SetValues(
Widget cw, Widget cw,
Widget rw, Widget rw,
Widget nw, Widget nw,
ArgList args, ArgList args,
Cardinal *num_args ) Cardinal *num_args )
{ {
XmGaugeWidget cgw = (XmGaugeWidget)cw; XmGaugeWidget cgw = (XmGaugeWidget)cw;
XmGaugeWidget ngw = (XmGaugeWidget)nw; XmGaugeWidget ngw = (XmGaugeWidget)nw;
Boolean redraw = False; Boolean redraw = False;
if(cgw->primitive.foreground != ngw->primitive.foreground) { if(cgw->primitive.foreground != ngw->primitive.foreground) {
XGCValues values; XGCValues values;
redraw = True; redraw = True;
XtReleaseGC(nw, ngw->gauge.gc); XtReleaseGC(nw, ngw->gauge.gc);
values.foreground = ngw->primitive.foreground; values.foreground = ngw->primitive.foreground;
ngw->gauge.gc = XtGetGC(nw, GCForeground, &values); ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
} }
if(cgw->gauge.value != ngw->gauge.value) { if(cgw->gauge.value != ngw->gauge.value) {
redraw = True; redraw = True;
} }
return redraw; return redraw;
} }
@@ -503,13 +503,13 @@ ExposeProc(Widget w, XEvent *event, Region r)
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge #define THIS gw->gauge
int sht; int sht;
sht = gw->primitive.shadow_thickness; sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w), _XmDrawShadows(XtDisplay(w), XtWindow(w),
gw->primitive.top_shadow_GC, gw->primitive.top_shadow_GC,
gw->primitive.bottom_shadow_GC, gw->primitive.bottom_shadow_GC,
0, 0, w->core.width, w->core.height, 0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN); sht, XmSHADOW_IN);
DrawSlider(gw, False); DrawSlider(gw, False);
#undef THIS #undef THIS
} }
@@ -521,81 +521,81 @@ ExposeProc(Widget w, XEvent *event, Region r)
static XtResource static XtResource
resources[] = { resources[] = {
#define offset(field) XtOffset(XmGaugeWidget, gauge.field) #define offset(field) XtOffset(XmGaugeWidget, gauge.field)
{XmNvalue, XmCValue, XtRInt, sizeof(int), {XmNvalue, XmCValue, XtRInt, sizeof(int),
offset(value), XtRImmediate, (caddr_t)10}, offset(value), XtRImmediate, (caddr_t)10},
{XmNminimum, XmCValue, XtRInt, sizeof(int), {XmNminimum, XmCValue, XtRInt, sizeof(int),
offset(minimum), XtRImmediate, (caddr_t)0}, offset(minimum), XtRImmediate, (caddr_t)0},
{XmNmaximum, XmCValue, XtRInt, sizeof(int), {XmNmaximum, XmCValue, XtRInt, sizeof(int),
offset(maximum), XtRImmediate, (caddr_t)100}, offset(maximum), XtRImmediate, (caddr_t)100},
{XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char), {XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL}, offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
{XmNprocessingDirection, XmCProcessingDirection, {XmNprocessingDirection, XmCProcessingDirection,
XmRProcessingDirection, sizeof(unsigned char), XmRProcessingDirection, sizeof(unsigned char),
offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT}, offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
{XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList), {XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
offset(dragCallback), XtRImmediate, (caddr_t)NULL}, offset(dragCallback), XtRImmediate, (caddr_t)NULL},
{XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList), {XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL}, offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
#undef offset #undef offset
}; };
XmGaugeClassRec xmGaugeClassRec = { XmGaugeClassRec xmGaugeClassRec = {
{ /* core fields */ { /* core fields */
(WidgetClass) &xmPrimitiveClassRec, /* superclass */ (WidgetClass) &xmPrimitiveClassRec, /* superclass */
"XmGauge", /* class_name */ "XmGauge", /* class_name */
sizeof(XmGaugeRec), /* widget_size */ sizeof(XmGaugeRec), /* widget_size */
NULL, /* class_initialize */ NULL, /* class_initialize */
NULL, /* class_part_initialize */ NULL, /* class_part_initialize */
FALSE, /* class_inited */ FALSE, /* class_inited */
Initialize, /* initialize */ Initialize, /* initialize */
NULL, /* initialize_hook */ NULL, /* initialize_hook */
XtInheritRealize, /* realize */ XtInheritRealize, /* realize */
actions, /* actions */ actions, /* actions */
XtNumber(actions), /* num_actions */ XtNumber(actions), /* num_actions */
resources, /* resources */ resources, /* resources */
XtNumber(resources), /* num_resources */ XtNumber(resources), /* num_resources */
NULLQUARK, /* xrm_class */ NULLQUARK, /* xrm_class */
TRUE, /* compress_motion */ TRUE, /* compress_motion */
TRUE, /* compress_exposure */ TRUE, /* compress_exposure */
TRUE, /* compress_enterleave */ TRUE, /* compress_enterleave */
FALSE, /* visible_interest */ FALSE, /* visible_interest */
Destroy, /* destroy */ Destroy, /* destroy */
NULL, /* resize */ NULL, /* resize */
ExposeProc, /* expose */ ExposeProc, /* expose */
SetValues, /* set_values */ SetValues, /* set_values */
NULL, /* set_values_hook */ NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */ XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */ NULL, /* get_values_hook */
NULL, /* accept_focus */ NULL, /* accept_focus */
XtVersion, /* version */ XtVersion, /* version */
NULL, /* callback_private */ NULL, /* callback_private */
translations, /* tm_table */ translations, /* tm_table */
NULL, /* query_geometry */ NULL, /* query_geometry */
NULL, /* display_accelerator */ NULL, /* display_accelerator */
NULL /* extension */ NULL /* extension */
}, },
/* primitive_class fields */ /* primitive_class fields */
{ {
NULL, /* border_highlight */ NULL, /* border_highlight */
NULL, /* border_unhighlight */ NULL, /* border_unhighlight */
NULL, /* translations */ NULL, /* translations */
NULL, /* arm_and_activate */ NULL, /* arm_and_activate */
NULL, /* syn_resources */ NULL, /* syn_resources */
0, /* num_syn_resources */ 0, /* num_syn_resources */
NULL /* extension */ NULL /* extension */
}, },
{ /* gauge fields */ { /* gauge fields */
0 /* empty */ 0 /* empty */
} }
}; };
WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec; WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
@@ -606,7 +606,7 @@ WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
void void
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args) 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 #if 0
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge #define THIS gw->gauge
@@ -615,50 +615,50 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
Boolean dragging = False; Boolean dragging = False;
XButtonEvent *event = (XButtonEvent *)e; XButtonEvent *event = (XButtonEvent *)e;
int x, y; int x, y;
x = event->x; x = event->x;
y = event->y; y = event->y;
sht = gw->primitive.shadow_thickness; sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w), _XmDrawShadows(XtDisplay(w), XtWindow(w),
gw->primitive.top_shadow_GC, gw->primitive.top_shadow_GC,
gw->primitive.bottom_shadow_GC, gw->primitive.bottom_shadow_GC,
0, 0, w->core.width, w->core.height, 0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN); sht, XmSHADOW_IN);
ratio = (float)((float)THIS.maximum - ratio = (float)((float)THIS.maximum -
(float)THIS.minimum) / (float)THIS.value; (float)THIS.minimum) / (float)THIS.value;
switch(THIS.orientation) { switch(THIS.orientation) {
case XmHORIZONTAL: case XmHORIZONTAL:
size = (w->core.width - 2 * sht) / ratio; size = (w->core.width - 2 * sht) / ratio;
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
dragging = (x > sht) && (y > sht) && dragging = (x > sht) && (y > sht) &&
(x < sht + size) && (y < w->core.height - sht); (x < sht + size) && (y < w->core.height - sht);
break; break;
case XmMAX_ON_LEFT: case XmMAX_ON_LEFT:
case XmMAX_ON_TOP: case XmMAX_ON_TOP:
dragging = (x > w->core.width - size - sht) && (y > sht) && dragging = (x > w->core.width - size - sht) && (y > sht) &&
(x < w->core.width - sht) && (y < w->core.height + sht); (x < w->core.width - sht) && (y < w->core.height + sht);
break; break;
} }
break; break;
case XmVERTICAL: case XmVERTICAL:
size = (w->core.height - 2 * sht) / ratio; size = (w->core.height - 2 * sht) / ratio;
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
dragging = (x > sht) && (y > sht) && dragging = (x > sht) && (y > sht) &&
(x < w->core.width - sht) && (x < w->core.width - sht) &&
(y < w->core.width - 2 * sht + size); (y < w->core.width - 2 * sht + size);
break; break;
case XmMAX_ON_LEFT: case XmMAX_ON_LEFT:
case XmMAX_ON_TOP: case XmMAX_ON_TOP:
dragging = (x > sht) && (y > w->core.height - size - sht) && dragging = (x > sht) && (y > w->core.height - size - sht) &&
(x < w->core.width - sht) && (y < w->core.height - sht); (x < w->core.width - sht) && (y < w->core.height - sht);
} }
break; break;
} }
THIS.dragging = dragging; THIS.dragging = dragging;
THIS.oldx = x; THIS.oldx = x;
@@ -672,7 +672,7 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
void void
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args) 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 #if 0
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge #define THIS gw->gauge
@@ -681,57 +681,57 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
XMotionEvent *event = (XMotionEvent *)e; XMotionEvent *event = (XMotionEvent *)e;
if( ! THIS.dragging) return; if( ! THIS.dragging) return;
x = event->x; x = event->x;
y = event->y; y = event->y;
sht = gw->primitive.shadow_thickness; sht = gw->primitive.shadow_thickness;
ratio = (float)THIS.value / (float)((float)THIS.maximum - ratio = (float)THIS.value / (float)((float)THIS.maximum -
(float)THIS.minimum); (float)THIS.minimum);
switch(THIS.orientation) { switch(THIS.orientation) {
case XmHORIZONTAL: case XmHORIZONTAL:
max = (w->core.width - 2 * sht); max = (w->core.width - 2 * sht);
size = (float)max * ratio; size = (float)max * ratio;
delta = (float)x - (float)THIS.oldx; delta = (float)x - (float)THIS.oldx;
break; break;
case XmVERTICAL: case XmVERTICAL:
max = (w->core.height - 2 * sht); max = (w->core.height - 2 * sht);
size = (float) max * ratio; size = (float) max * ratio;
delta = (float)y - (float)THIS.oldy; delta = (float)y - (float)THIS.oldy;
break; break;
} }
switch(THIS.processingDirection) { switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT: case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM: case XmMAX_ON_BOTTOM:
nsize = size + delta; nsize = size + delta;
break; break;
default: default:
nsize = size - delta; nsize = size - delta;
} }
if(nsize > (float)max) nsize = (float)max; if(nsize > (float)max) nsize = (float)max;
if(nsize < (float)0 ) nsize = (float)0; if(nsize < (float)0 ) nsize = (float)0;
nratio = nsize / (float)max; nratio = nsize / (float)max;
fvalue = (int)((float)THIS.maximum - fvalue = (int)((float)THIS.maximum -
(float)THIS.minimum) * (float)nsize / (float)max; (float)THIS.minimum) * (float)nsize / (float)max;
value = round(fvalue); value = round(fvalue);
THIS.value = value; THIS.value = value;
THIS.oldx = x; THIS.oldx = x;
THIS.oldy = y; THIS.oldy = y;
/* clear old slider only if it was larger */ /* clear old slider only if it was larger */
DrawSlider(gw, (nsize < size)); DrawSlider(gw, (nsize < size));
{ {
XmGaugeCallbackStruct call; XmGaugeCallbackStruct call;
if(NULL != THIS.dragCallback) { if(NULL != THIS.dragCallback) {
call.reason = XmCR_DRAG; call.reason = XmCR_DRAG;
call.event = e; call.event = e;
call.value = THIS.value; call.value = THIS.value;
XtCallCallbacks(w, XmNdragCallback, &call); XtCallCallbacks(w, XmNdragCallback, &call);
} }
} }
#undef THIS #undef THIS
#endif #endif
@@ -741,18 +741,18 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
void void
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args) 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 #if 0
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge #define THIS gw->gauge
if( ! THIS.dragging) return; if( ! THIS.dragging) return;
if(NULL != THIS.valueChangedCallback) { if(NULL != THIS.valueChangedCallback) {
XmGaugeCallbackStruct call; XmGaugeCallbackStruct call;
call.reason = XmCR_VALUE_CHANGED; call.reason = XmCR_VALUE_CHANGED;
call.event = e; call.event = e;
call.value = THIS.value; call.value = THIS.value;
XtCallCallbacks(w, XmNvalueChangedCallback, &call); XtCallCallbacks(w, XmNvalueChangedCallback, &call);
} }
THIS.dragging = False; THIS.dragging = False;
#undef THIS #undef THIS
@@ -763,7 +763,7 @@ void
XmGaugeSetValue(Widget w, int value) XmGaugeSetValue(Widget w, int value)
{ {
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
gw->gauge.value = value; gw->gauge.value = value;
DrawSlider(gw, True); DrawSlider(gw, True);
XFlush(XtDisplay(w)); XFlush(XtDisplay(w));
@@ -773,6 +773,6 @@ int
XmGaugeGetValue(Widget w) XmGaugeGetValue(Widget w)
{ {
XmGaugeWidget gw = (XmGaugeWidget)w; XmGaugeWidget gw = (XmGaugeWidget)w;
return gw->gauge.value; return gw->gauge.value;
} }

View File

@@ -18,5 +18,3 @@
#if !USE_SHARED_LIBRARIES #if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
#endif #endif
// TODO: Nothing to do, unless you want to.

View File

@@ -26,8 +26,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
#endif #endif
/* /*
* Icons * Icons
*/ */
wxIcon::wxIcon() wxIcon::wxIcon()
{ {
@@ -46,8 +46,8 @@ wxIcon::wxIcon(char **data)
} }
wxIcon::wxIcon(const wxString& icon_file, long flags, wxIcon::wxIcon(const wxString& icon_file, long flags,
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
{ {
LoadFile(icon_file, flags, desiredWidth, desiredHeight); LoadFile(icon_file, flags, desiredWidth, desiredHeight);
} }
@@ -57,17 +57,17 @@ wxIcon::~wxIcon()
} }
bool wxIcon::LoadFile(const wxString& filename, long type, bool wxIcon::LoadFile(const wxString& filename, long type,
int desiredWidth, int desiredHeight) int desiredWidth, int desiredHeight)
{ {
UnRef(); UnRef();
m_refData = new wxBitmapRefData; m_refData = new wxBitmapRefData;
wxBitmapHandler *handler = FindHandler(type); wxBitmapHandler *handler = FindHandler(type);
if ( handler ) if ( handler )
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight); return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
else else
return FALSE; return FALSE;
} }

View File

@@ -23,11 +23,11 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
#endif #endif
void wxListBoxCallback (Widget w, XtPointer clientData, void wxListBoxCallback (Widget w, XtPointer clientData,
XmListCallbackStruct * cbs); XmListCallbackStruct * cbs);
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs); void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs);
@@ -56,16 +56,16 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
// m_backgroundColour = parent->GetBackgroundColour(); // m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE; m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_windowId = ( id == -1 ) ? (int)NewControlId() : id; m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Arg args[3]; Arg args[3];
int count; int count;
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT); XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
@@ -82,39 +82,39 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
} }
else else
count = 2; count = 2;
Widget listWidget = XmCreateScrolledList (parentWidget, (char*) (const char*) name, args, count); Widget listWidget = XmCreateScrolledList (parentWidget, (char*) (const char*) name, args, count);
m_mainWidget = (WXWidget) listWidget; m_mainWidget = (WXWidget) listWidget;
Set(n, choices); Set(n, choices);
XtManageChild (listWidget); XtManageChild (listWidget);
long width = size.x; long width = size.x;
long height = size.y; long height = size.y;
if (width == -1) if (width == -1)
width = 150; width = 150;
if (height == -1) if (height == -1)
height = 80; height = 80;
XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback, XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback, XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback, XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc, XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc,
(XtPointer) this); (XtPointer) this);
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -124,297 +124,297 @@ wxListBox::~wxListBox()
void wxListBox::SetFirstItem(int N) void wxListBox::SetFirstItem(int N)
{ {
int count, length; int count, length;
if (N < 0) if (N < 0)
return; return;
XtVaGetValues ((Widget) m_mainWidget, XtVaGetValues ((Widget) m_mainWidget,
XmNvisibleItemCount, &count, XmNvisibleItemCount, &count,
XmNitemCount, &length, XmNitemCount, &length,
NULL); NULL);
if ((N + count) >= length) if ((N + count) >= length)
N = length - count; N = length - count;
XmListSetPos ((Widget) m_mainWidget, N + 1); XmListSetPos ((Widget) m_mainWidget, N + 1);
} }
void wxListBox::SetFirstItem(const wxString& s) void wxListBox::SetFirstItem(const wxString& s)
{ {
int N = FindString (s); int N = FindString (s);
if (N >= 0) if (N >= 0)
SetFirstItem (N); SetFirstItem (N);
} }
void wxListBox::Delete(int N) void wxListBox::Delete(int N)
{ {
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
bool managed = XtIsManaged(listBox); bool managed = XtIsManaged(listBox);
if (managed) if (managed)
XtUnmanageChild (listBox); XtUnmanageChild (listBox);
XmListDeletePos (listBox, N + 1); XmListDeletePos (listBox, N + 1);
if (managed) if (managed)
XtManageChild (listBox); XtManageChild (listBox);
GetSize (&width2, &height2); GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2) if (width1 != width2 || height1 != height2)
SetSize (-1, -1, width1, height1); SetSize (-1, -1, width1, height1);
// (JDH) need to add code here to take care of clientDataList // (JDH) need to add code here to take care of clientDataList
wxNode *node = m_clientDataList.Find((long)N); // get item from list wxNode *node = m_clientDataList.Find((long)N); // get item from list
if (node) m_clientDataList.DeleteNode(node); // if existed then delete 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 node = m_clientDataList.First(); // we now have to adjust all keys that
while (node) // are >=N+1 while (node) // are >=N+1
{ if (node->GetKeyInteger() >= (long)(N+1)) { if (node->GetKeyInteger() >= (long)(N+1))
node->SetKeyInteger(node->GetKeyInteger() - 1); node->SetKeyInteger(node->GetKeyInteger() - 1);
node = node->Next(); node = node->Next();
} }
m_noItems --; m_noItems --;
} }
void wxListBox::Append(const wxString& item) void wxListBox::Append(const wxString& item)
{ {
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
bool managed = XtIsManaged(listBox); bool managed = XtIsManaged(listBox);
if (managed) if (managed)
XtUnmanageChild (listBox); XtUnmanageChild (listBox);
int n; int n;
XtVaGetValues (listBox, XmNitemCount, &n, NULL); XtVaGetValues (listBox, XmNitemCount, &n, NULL);
XmString text = XmStringCreateSimple ((char*) (const char*) item); XmString text = XmStringCreateSimple ((char*) (const char*) item);
// XmListAddItem(listBox, text, n + 1); // XmListAddItem(listBox, text, n + 1);
XmListAddItemUnselected (listBox, text, 0); XmListAddItemUnselected (listBox, text, 0);
XmStringFree (text); XmStringFree (text);
// It seems that if the list is cleared, we must re-ask for // It seems that if the list is cleared, we must re-ask for
// selection policy!! // selection policy!!
Arg args[3]; Arg args[3];
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT); XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
if (m_windowStyle & wxLB_MULTIPLE) if (m_windowStyle & wxLB_MULTIPLE)
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
else if (m_windowStyle & wxLB_EXTENDED) else if (m_windowStyle & wxLB_EXTENDED)
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
else else
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues (listBox, args, 2); XtSetValues (listBox, args, 2);
if (managed) if (managed)
XtManageChild (listBox); XtManageChild (listBox);
GetSize (&width2, &height2); GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2) if (width1 != width2 || height1 != height2)
SetSize (-1, -1, width1, height1); SetSize (-1, -1, width1, height1);
m_noItems ++; m_noItems ++;
} }
void wxListBox::Append(const wxString& item, char *clientData) void wxListBox::Append(const wxString& item, char *clientData)
{ {
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
Bool managed = XtIsManaged(listBox); Bool managed = XtIsManaged(listBox);
if (managed) if (managed)
XtUnmanageChild (listBox); XtUnmanageChild (listBox);
int n; int n;
XtVaGetValues (listBox, XmNitemCount, &n, NULL); XtVaGetValues (listBox, XmNitemCount, &n, NULL);
XmString text = XmStringCreateSimple ((char*) (const char*) item); XmString text = XmStringCreateSimple ((char*) (const char*) item);
// XmListAddItem(listBox, text, n + 1); // XmListAddItem(listBox, text, n + 1);
XmListAddItemUnselected (listBox, text, 0); XmListAddItemUnselected (listBox, text, 0);
XmStringFree (text); XmStringFree (text);
// It seems that if the list is cleared, we must re-ask for // It seems that if the list is cleared, we must re-ask for
// selection policy!! // selection policy!!
Arg args[3]; Arg args[3];
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT); XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
if (m_windowStyle & wxLB_MULTIPLE) if (m_windowStyle & wxLB_MULTIPLE)
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
else if (m_windowStyle & wxLB_EXTENDED) else if (m_windowStyle & wxLB_EXTENDED)
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
else else
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues (listBox, args, 2); XtSetValues (listBox, args, 2);
m_clientDataList.Append ((long) n, (wxObject *) clientData); m_clientDataList.Append ((long) n, (wxObject *) clientData);
if (managed) if (managed)
XtManageChild (listBox); XtManageChild (listBox);
GetSize (&width2, &height2); GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2) if (width1 != width2 || height1 != height2)
SetSize (-1, -1, width1, height1); SetSize (-1, -1, width1, height1);
m_noItems ++; m_noItems ++;
} }
void wxListBox::Set(int n, const wxString *choices, char** clientData) void wxListBox::Set(int n, const wxString *choices, char** clientData)
{ {
m_clientDataList.Clear(); m_clientDataList.Clear();
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
bool managed = XtIsManaged(listBox); bool managed = XtIsManaged(listBox);
if (managed) if (managed)
XtUnmanageChild (listBox); XtUnmanageChild (listBox);
/*** /***
for (int i=0; i<n; i++) for (int i=0; i<n; i++)
{ {
XmString text = XmStringCreateSimple(choices[i]); XmString text = XmStringCreateSimple(choices[i]);
XmListAddItemUnselected(listBox, text, 0); XmListAddItemUnselected(listBox, text, 0);
XmStringFree(text); XmStringFree(text);
} }
***/ ***/
XmString *text = new XmString[n]; XmString *text = new XmString[n];
int i; int i;
for (i = 0; i < n; i++)
text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
if ( clientData )
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
m_clientDataList.Append ((long) i, (wxObject *) clientData[i]); text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
XmListAddItems (listBox, text, n, 0); if ( clientData )
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
XmStringFree (text[i]); m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
delete[]text;
XmListAddItems (listBox, text, n, 0);
// It seems that if the list is cleared, we must re-ask for for (i = 0; i < n; i++)
// selection policy!! XmStringFree (text[i]);
Arg args[3]; delete[]text;
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
if (m_windowStyle & wxLB_MULTIPLE) // It seems that if the list is cleared, we must re-ask for
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT); // selection policy!!
else if (m_windowStyle & wxLB_EXTENDED) Arg args[3];
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT); XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
else if (m_windowStyle & wxLB_MULTIPLE)
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
XtSetValues (listBox, args, 2); else if (m_windowStyle & wxLB_EXTENDED)
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
if (managed) else
XtManageChild (listBox); XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues (listBox, args, 2);
GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! if (managed)
if (width1 != width2 || height1 != height2) XtManageChild (listBox);
SetSize (-1, -1, width1, height1);
GetSize (&width2, &height2);
m_noItems = n; // 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 int wxListBox::FindString(const wxString& s) const
{ {
XmString str = XmStringCreateSimple ((char*) (const char*) s); XmString str = XmStringCreateSimple ((char*) (const char*) s);
int *positions = NULL; int *positions = NULL;
int no_positions = 0; int no_positions = 0;
bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions); bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
XmStringFree (str); XmStringFree (str);
if (success) if (success)
{ {
int pos = positions[0]; int pos = positions[0];
if (positions) if (positions)
XtFree ((char *) positions); XtFree ((char *) positions);
return pos - 1; return pos - 1;
} }
else else
return -1; return -1;
} }
void wxListBox::Clear() void wxListBox::Clear()
{ {
if (m_noItems <= 0) if (m_noItems <= 0)
return; return;
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
XmListDeleteAllItems (listBox); XmListDeleteAllItems (listBox);
m_clientDataList.Clear (); m_clientDataList.Clear ();
GetSize (&width2, &height2); GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2) if (width1 != width2 || height1 != height2)
SetSize (-1, -1, width1, height1); SetSize (-1, -1, width1, height1);
m_noItems = 0; m_noItems = 0;
} }
void wxListBox::SetSelection(int N, bool select) void wxListBox::SetSelection(int N, bool select)
{ {
m_inSetValue = TRUE; m_inSetValue = TRUE;
if (select) if (select)
{ {
/* /*
if (m_windowStyle & wxLB_MULTIPLE) if (m_windowStyle & wxLB_MULTIPLE)
{ {
int *selections = NULL; int *selections = NULL;
int n = GetSelections (&selections); int n = GetSelections (&selections);
// This hack is supposed to work, to make it possible to select more // This hack is supposed to work, to make it possible to select more
// than one item, but it DOESN'T under Motif 1.1. // than one item, but it DOESN'T under Motif 1.1.
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
int i; int i;
for (i = 0; i < n; i++) for (i = 0; i < n; i++)
XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE); XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE); XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
}
else
*/
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
} }
else else
*/ XmListDeselectPos ((Widget) m_mainWidget, N + 1);
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
m_inSetValue = FALSE;
}
else
XmListDeselectPos ((Widget) m_mainWidget, N + 1);
m_inSetValue = FALSE;
} }
bool wxListBox::Selected(int N) const bool wxListBox::Selected(int N) const
{ {
// In Motif, no simple way to determine if the item is selected. // In Motif, no simple way to determine if the item is selected.
wxArrayInt theSelections; wxArrayInt theSelections;
int count = GetSelections (theSelections); int count = GetSelections (theSelections);
if (count == 0) if (count == 0)
return FALSE;
else
{
int j;
for (j = 0; j < count; j++)
if (theSelections[j] == N)
return TRUE;
}
return FALSE; return FALSE;
else
{
int j;
for (j = 0; j < count; j++)
if (theSelections[j] == N)
return TRUE;
}
return FALSE;
} }
void wxListBox::Deselect(int N) void wxListBox::Deselect(int N)
@@ -443,30 +443,30 @@ void wxListBox::SetClientData(int N, char *Client_data)
// Return number of selections and an array of selected integers // Return number of selections and an array of selected integers
int wxListBox::GetSelections(wxArrayInt& aSelections) const int wxListBox::GetSelections(wxArrayInt& aSelections) const
{ {
aSelections.Empty(); aSelections.Empty();
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
int *posList = NULL; int *posList = NULL;
int posCnt = 0; int posCnt = 0;
bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt); bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
if (flag) if (flag)
{ {
if (posCnt > 0) if (posCnt > 0)
{ {
aSelections.Alloc(posCnt); aSelections.Alloc(posCnt);
int i; int i;
for (i = 0; i < posCnt; i++) for (i = 0; i < posCnt; i++)
aSelections.Add(posList[i] - 1); aSelections.Add(posList[i] - 1);
XtFree ((char *) posList); XtFree ((char *) posList);
return posCnt; return posCnt;
} }
else else
return 0; return 0;
} }
else else
return 0; return 0;
} }
// Get single selection, for single choice list items // Get single selection, for single choice list items
@@ -514,15 +514,15 @@ wxString wxListBox::GetString(int N) const
void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags) void wxListBox::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);
// Check resulting size is correct // Check resulting size is correct
int tempW, tempH; int tempW, tempH;
GetSize (&tempW, &tempH); GetSize (&tempW, &tempH);
/* /*
if (tempW != width || tempH != height) if (tempW != width || tempH != height)
{ {
cout << "wxListBox::SetSize sizes not set correctly."); cout << "wxListBox::SetSize sizes not set correctly.");
} }
*/ */
} }
@@ -531,21 +531,21 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
{ {
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize(&width1, &height1); GetSize(&width1, &height1);
bool managed = XtIsManaged(listBox); bool managed = XtIsManaged(listBox);
if (managed) if (managed)
XtUnmanageChild(listBox); XtUnmanageChild(listBox);
XmString *text = new XmString[nItems]; XmString *text = new XmString[nItems];
int i; int i;
// Steve Hammes: Motif 1.1 compatibility // Steve Hammes: Motif 1.1 compatibility
// #if XmVersion > 1100 // #if XmVersion > 1100
// Corrected by Sergey Krasnov from Steve Hammes' code // Corrected by Sergey Krasnov from Steve Hammes' code
#if XmVersion > 1001 #if XmVersion > 1001
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++)
text[i] = XmStringCreateSimple((char*) (const char*) items[i]); text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
@@ -554,15 +554,15 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++)
{ {
text[i] = XmStringCreateSimple((char*) (const char*) items[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 XmListAddItemUnselected(listBox, text[i], pos+i+1); // Another Sergey correction
} }
#endif #endif
for (i = 0; i < nItems; i++) for (i = 0; i < nItems; i++)
XmStringFree(text[i]); XmStringFree(text[i]);
delete[] text; delete[] text;
// It seems that if the list is cleared, we must re-ask for // It seems that if the list is cleared, we must re-ask for
// selection policy!! // selection policy!!
Arg args[3]; Arg args[3];
@@ -573,15 +573,15 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
XtSetArg(args[1], XmNselectionPolicy, XmEXTENDED_SELECT); XtSetArg(args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
else XtSetArg(args[1], XmNselectionPolicy, XmBROWSE_SELECT); else XtSetArg(args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues(listBox,args,2) ; XtSetValues(listBox,args,2) ;
if (managed) if (managed)
XtManageChild(listBox); XtManageChild(listBox);
GetSize(&width2, &height2); GetSize(&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 /*|| height1 != height2*/) if (width1 != width2 /*|| height1 != height2*/)
SetSize(-1, -1, width1, height1); SetSize(-1, -1, width1, height1);
m_noItems += nItems; m_noItems += nItems;
} }
@@ -589,34 +589,34 @@ void wxListBox::SetString(int N, const wxString& s)
{ {
int width1, height1; int width1, height1;
int width2, height2; int width2, height2;
Widget listBox = (Widget) m_mainWidget; Widget listBox = (Widget) m_mainWidget;
GetSize (&width1, &height1); GetSize (&width1, &height1);
XmString text = XmStringCreateSimple ((char*) (const char*) s); XmString text = XmStringCreateSimple ((char*) (const char*) s);
// WHAT'S THE MOTIF CALL TO SET THE TEXT OF AN EXISTING // WHAT'S THE MOTIF CALL TO SET THE TEXT OF AN EXISTING
// ITEM??? // ITEM???
// There isn't one, so delete the item and add it again. // There isn't one, so delete the item and add it again.
XmListDeletePos (listBox, N+1); XmListDeletePos (listBox, N+1);
XmListAddItem (listBox, text, N+1); XmListAddItem (listBox, text, N+1);
XmStringFree(text); XmStringFree(text);
/* /*
// It seems that if the list is cleared, we must re-ask for // It seems that if the list is cleared, we must re-ask for
// selection policy!! // selection policy!!
Arg args[3]; Arg args[3];
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT); XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
if (m_windowStyle & wxLB_MULTIPLE) if (m_windowStyle & wxLB_MULTIPLE)
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
else if (m_windowStyle & wxLB_EXTENDED) else if (m_windowStyle & wxLB_EXTENDED)
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
else else
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT); XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
XtSetValues (listBox, args, 2); XtSetValues (listBox, args, 2);
*/ */
GetSize (&width2, &height2); GetSize (&width2, &height2);
// Correct for randomly resized listbox - bad boy, Motif! // Correct for randomly resized listbox - bad boy, Motif!
if (width1 != width2 || height1 != height2) if (width1 != width2 || height1 != height2)
@@ -663,7 +663,7 @@ void wxListBox::Command (wxCommandEvent & event)
} }
void wxListBoxCallback (Widget w, XtPointer clientData, void wxListBoxCallback (Widget w, XtPointer clientData,
XmListCallbackStruct * cbs) XmListCallbackStruct * cbs)
{ {
/* /*
if (cbs->reason == XmCR_EXTENDED_SELECT) if (cbs->reason == XmCR_EXTENDED_SELECT)
@@ -681,18 +681,18 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
cout << "*** Initial\n"; cout << "*** Initial\n";
else if (cbs->selection_type == XmADDITION) else if (cbs->selection_type == XmADDITION)
cout << "*** Addition\n"; cout << "*** Addition\n";
*/ */
wxListBox *item = (wxListBox *) clientData; wxListBox *item = (wxListBox *) clientData;
if (item->InSetValue()) if (item->InSetValue())
return; return;
wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED, item->GetId());
switch (cbs->reason) switch (cbs->reason)
{ {
case XmCR_MULTIPLE_SELECT: case XmCR_MULTIPLE_SELECT:
case XmCR_BROWSE_SELECT: case XmCR_BROWSE_SELECT:
{ {
event.m_clientData = item->GetClientData (cbs->item_position - 1); event.m_clientData = item->GetClientData (cbs->item_position - 1);
//event.commandString = item->GetStringSelection(); //event.commandString = item->GetStringSelection();
@@ -703,13 +703,13 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
//delete[] event.commandString; // Let's not store the command string any more //delete[] event.commandString; // Let's not store the command string any more
break; break;
} }
case XmCR_EXTENDED_SELECT: case XmCR_EXTENDED_SELECT:
{ {
switch (cbs->selection_type) switch (cbs->selection_type)
{ {
case XmINITIAL: case XmINITIAL:
case XmADDITION: case XmADDITION:
case XmMODIFICATION: case XmMODIFICATION:
{ {
event.m_clientData = item->GetClientData (cbs->item_position - 1); event.m_clientData = item->GetClientData (cbs->item_position - 1);
event.m_commandInt = cbs->item_position - 1; event.m_commandInt = cbs->item_position - 1;
@@ -725,13 +725,13 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
} }
/* Respond by getting the /* Respond by getting the
* designated "default button" in the action area and activate it * designated "default button" in the action area and activate it
* as if the user had selected it. * as if the user had selected it.
*/ */
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs) void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs)
{ {
wxListBox *lbox = (wxListBox *) client_data; wxListBox *lbox = (wxListBox *) client_data;
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId()); wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId());
event.SetEventObject( lbox ); event.SetEventObject( lbox );
lbox->GetEventHandler()->ProcessEvent(event) ; lbox->GetEventHandler()->ProcessEvent(event) ;
@@ -739,7 +739,7 @@ void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCal
WXWidget wxListBox::GetTopWidget() const WXWidget wxListBox::GetTopWidget() const
{ {
return (WXWidget) XtParent( (Widget) m_mainWidget ); return (WXWidget) XtParent( (Widget) m_mainWidget );
} }
void wxListBox::ChangeFont(bool keepOriginalSize) void wxListBox::ChangeFont(bool keepOriginalSize)
@@ -750,41 +750,41 @@ void wxListBox::ChangeFont(bool keepOriginalSize)
void wxListBox::ChangeBackgroundColour() void wxListBox::ChangeBackgroundColour()
{ {
wxWindow::ChangeBackgroundColour(); wxWindow::ChangeBackgroundColour();
Widget parent = XtParent ((Widget) m_mainWidget); Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb; Widget hsb, vsb;
XtVaGetValues (parent, XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb, XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb, XmNverticalScrollBar, &vsb,
NULL); NULL);
/* TODO: should scrollbars be affected? Should probably have separate /* 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)
*/ */
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
} }
void wxListBox::ChangeForegroundColour() void wxListBox::ChangeForegroundColour()
{ {
wxWindow::ChangeForegroundColour(); wxWindow::ChangeForegroundColour();
Widget parent = XtParent ((Widget) m_mainWidget); Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb; Widget hsb, vsb;
XtVaGetValues (parent, XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb, XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb, XmNverticalScrollBar, &vsb,
NULL); NULL);
/* TODO: should scrollbars be affected? Should probably have separate /* 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)
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
*/ */
} }

View File

@@ -13,6 +13,6 @@
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
return wxEntry(argc, argv); return wxEntry(argc, argv);
} }

View File

@@ -87,6 +87,7 @@ LIB_CPP_SRC=\
combobox.cpp \ combobox.cpp \
cursor.cpp \ cursor.cpp \
data.cpp \ data.cpp \
dataobj.cpp \
dc.cpp \ dc.cpp \
dcclient.cpp \ dcclient.cpp \
dcmemory.cpp \ dcmemory.cpp \

View File

@@ -34,7 +34,7 @@ extern wxList wxModelessWindows;
// Implemented in frame.cpp // Implemented in frame.cpp
extern void wxFrameFocusProc(Widget workArea, XtPointer clientData, extern void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs); XmAnyCallbackStruct *cbs);
#define wxID_NOTEBOOK_CLIENT_AREA wxID_HIGHEST + 100 #define wxID_NOTEBOOK_CLIENT_AREA wxID_HIGHEST + 100
@@ -44,14 +44,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxNotebook) IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxNotebook)
BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame) BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
EVT_SIZE(wxMDIParentFrame::OnSize) EVT_SIZE(wxMDIParentFrame::OnSize)
EVT_ACTIVATE(wxMDIParentFrame::OnActivate) EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
END_EVENT_TABLE() END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook) BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook)
EVT_SCROLL(wxMDIClientWindow::OnScroll) EVT_SCROLL(wxMDIClientWindow::OnScroll)
EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged) EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #endif
@@ -66,29 +66,29 @@ wxMDIParentFrame::wxMDIParentFrame()
} }
bool wxMDIParentFrame::Create(wxWindow *parent, bool wxMDIParentFrame::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxString& name) const wxString& name)
{ {
m_clientWindow = (wxMDIClientWindow*) NULL; m_clientWindow = (wxMDIClientWindow*) NULL;
m_activeChild = (wxMDIChildFrame*) NULL; m_activeChild = (wxMDIChildFrame*) NULL;
m_activeMenuBar = (wxMenuBar*) NULL; m_activeMenuBar = (wxMenuBar*) NULL;
bool success = wxFrame::Create(parent, id, title, pos, size, style, name); bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
if (success) if (success)
{ {
// TODO: app cannot override OnCreateClient since // TODO: app cannot override OnCreateClient since
// wxMDIParentFrame::OnCreateClient will still be called // wxMDIParentFrame::OnCreateClient will still be called
// (we're in the constructor). How to resolve? // (we're in the constructor). How to resolve?
m_clientWindow = OnCreateClient(); m_clientWindow = OnCreateClient();
// Uses own style for client style // Uses own style for client style
m_clientWindow->CreateClient(this, GetWindowStyleFlag()); m_clientWindow->CreateClient(this, GetWindowStyleFlag());
int w, h; int w, h;
GetClientSize(& w, & h); GetClientSize(& w, & h);
m_clientWindow->SetSize(0, 0, w, h); m_clientWindow->SetSize(0, 0, w, h);
@@ -102,9 +102,9 @@ wxMDIParentFrame::~wxMDIParentFrame()
{ {
// Make sure we delete the client window last of all // Make sure we delete the client window last of all
RemoveChild(m_clientWindow); RemoveChild(m_clientWindow);
DestroyChildren(); DestroyChildren();
delete m_clientWindow; delete m_clientWindow;
m_clientWindow = NULL; m_clientWindow = NULL;
} }
@@ -118,7 +118,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar) void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
{ {
m_frameMenuBar = menu_bar; m_frameMenuBar = menu_bar;
SetChildMenuBar((wxMDIChildFrame*) NULL); SetChildMenuBar((wxMDIChildFrame*) NULL);
} }
@@ -126,20 +126,20 @@ void wxMDIParentFrame::OnSize(wxSizeEvent& event)
{ {
#if wxUSE_CONSTRAINTS #if wxUSE_CONSTRAINTS
if (GetAutoLayout()) if (GetAutoLayout())
Layout(); Layout();
#endif #endif
int x = 0; int x = 0;
int y = 0; int y = 0;
int width, height; int width, height;
GetClientSize(&width, &height); GetClientSize(&width, &height);
if ( GetClientWindow() ) if ( GetClientWindow() )
GetClientWindow()->SetSize(x, y, width, height); GetClientWindow()->SetSize(x, y, width, height);
} }
void wxMDIParentFrame::OnActivate(wxActivateEvent& event) void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
{ {
// Do nothing // Do nothing
} }
// Returns the active MDI child window // Returns the active MDI child window
@@ -152,63 +152,63 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
// just return a new class) // just return a new class)
wxMDIClientWindow *wxMDIParentFrame::OnCreateClient() wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
{ {
return new wxMDIClientWindow ; return new wxMDIClientWindow ;
} }
// Set the child's menu into the parent frame // Set the child's menu into the parent frame
void wxMDIParentFrame::SetChildMenuBar(wxMDIChildFrame* child) void wxMDIParentFrame::SetChildMenuBar(wxMDIChildFrame* child)
{ {
wxMenuBar* oldMenuBar = m_activeMenuBar; wxMenuBar* oldMenuBar = m_activeMenuBar;
if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame
{ {
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar)) if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
{ {
// if (m_activeMenuBar) // if (m_activeMenuBar)
// m_activeMenuBar->DestroyMenuBar(); // m_activeMenuBar->DestroyMenuBar();
m_activeMenuBar = GetMenuBar(); m_activeMenuBar = GetMenuBar();
m_activeMenuBar->CreateMenuBar(this); m_activeMenuBar->CreateMenuBar(this);
/* /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
*/ */
if (oldMenuBar && 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 else if (child->GetMenuBar() == (wxMenuBar*) NULL) // No child menu bar: use parent frame
{ {
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar)) if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
{ {
// if (m_activeMenuBar) // if (m_activeMenuBar)
// m_activeMenuBar->DestroyMenuBar(); // m_activeMenuBar->DestroyMenuBar();
m_activeMenuBar = GetMenuBar(); m_activeMenuBar = GetMenuBar();
m_activeMenuBar->CreateMenuBar(this); m_activeMenuBar->CreateMenuBar(this);
/* /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
*/ */
if (oldMenuBar && oldMenuBar->GetMainWidget()) if (oldMenuBar && oldMenuBar->GetMainWidget())
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget()); XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
} }
} }
else // The child has a menubar else // The child has a menubar
{ {
if (child->GetMenuBar() != m_activeMenuBar) if (child->GetMenuBar() != m_activeMenuBar)
{ {
// if (m_activeMenuBar) // if (m_activeMenuBar)
// m_activeMenuBar->DestroyMenuBar(); // m_activeMenuBar->DestroyMenuBar();
m_activeMenuBar = child->GetMenuBar(); m_activeMenuBar = child->GetMenuBar();
m_activeMenuBar->CreateMenuBar(this); m_activeMenuBar->CreateMenuBar(this);
/* /*
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget())) if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget()); XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
*/ */
if (oldMenuBar && oldMenuBar->GetMainWidget()) if (oldMenuBar && oldMenuBar->GetMainWidget())
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget()); XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
} }
} }
} }
@@ -220,20 +220,20 @@ bool wxMDIParentFrame::ProcessEvent(wxEvent& event)
static wxEventType inEvent = wxEVT_NULL; static wxEventType inEvent = wxEVT_NULL;
if (inEvent == event.GetEventType()) if (inEvent == event.GetEventType())
return FALSE; return FALSE;
inEvent = event.GetEventType(); inEvent = event.GetEventType();
bool res = FALSE; bool res = FALSE;
if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent))) if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent)))
{ {
res = m_activeChild->GetEventHandler()->ProcessEvent(event); res = m_activeChild->GetEventHandler()->ProcessEvent(event);
} }
if (!res) if (!res)
res = GetEventHandler()->wxEvtHandler::ProcessEvent(event); res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
inEvent = wxEVT_NULL; inEvent = wxEVT_NULL;
return res; return res;
} }
@@ -241,7 +241,7 @@ bool wxMDIParentFrame::ProcessEvent(wxEvent& event)
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event) void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{ {
// TODO // TODO
// Propagate the event to the non-top-level children // Propagate the event to the non-top-level children
wxFrame::OnSysColourChanged(event); wxFrame::OnSysColourChanged(event);
} }
@@ -280,39 +280,39 @@ wxMDIChildFrame::wxMDIChildFrame()
} }
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent, bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
wxWindowID id, wxWindowID id,
const wxString& title, const wxString& title,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, const wxSize& size,
long style, long style,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
if ( id > -1 ) if ( id > -1 )
m_windowId = id; m_windowId = id;
else else
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
wxMDIClientWindow* clientWindow = parent->GetClientWindow(); wxMDIClientWindow* clientWindow = parent->GetClientWindow();
wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window."); wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window.");
if (clientWindow) clientWindow->AddChild(this); if (clientWindow) clientWindow->AddChild(this);
SetMDIParentFrame(parent); SetMDIParentFrame(parent);
int x = pos.x; int y = pos.y; int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y; int width = size.x; int height = size.y;
if (width == -1) if (width == -1)
width = 200; // TODO: give reasonable default width = 200; // TODO: give reasonable default
if (height == -1) if (height == -1)
height = 200; // TODO: give reasonable default height = 200; // TODO: give reasonable default
// We're deactivating the old child // We're deactivating the old child
wxMDIChildFrame* oldActiveChild = parent->GetActiveChild(); wxMDIChildFrame* oldActiveChild = parent->GetActiveChild();
if (oldActiveChild) if (oldActiveChild)
@@ -321,104 +321,41 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
event.SetEventObject( oldActiveChild ); event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event); oldActiveChild->GetEventHandler()->ProcessEvent(event);
} }
// This is the currently active child // This is the currently active child
parent->SetActiveChild((wxMDIChildFrame*) this); parent->SetActiveChild((wxMDIChildFrame*) this);
// This time we'll try a bog-standard bulletin board for // This time we'll try a bog-standard bulletin board for
// the 'frame'. A main window doesn't seem to work. // the 'frame'. A main window doesn't seem to work.
m_mainWidget = (WXWidget) XtVaCreateWidget("client", m_mainWidget = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(), xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
XmNmarginWidth, 0, XmNmarginWidth, 0,
XmNmarginHeight, 0, XmNmarginHeight, 0,
/* /*
XmNrightAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM, XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_FORM,
*/ */
XmNresizePolicy, XmRESIZE_NONE, XmNresizePolicy, XmRESIZE_NONE,
NULL); NULL);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); 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); 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
XtManageChild((Widget) m_mainWidget);
SetTitle(title); SetTitle(title);
clientWindow->AddPage(this, title, TRUE); clientWindow->AddPage(this, title, TRUE);
clientWindow->Refresh(); clientWindow->Refresh();
// Positions the toolbar and status bar -- but we don't have any. // Positions the toolbar and status bar -- but we don't have any.
// PreResize(); // PreResize();
wxModelessWindows.Append(this); wxModelessWindows.Append(this);
return TRUE; return TRUE;
} }
@@ -429,15 +366,15 @@ wxMDIChildFrame::~wxMDIChildFrame()
if (GetMDIParentFrame()) if (GetMDIParentFrame())
{ {
wxMDIParentFrame* parentFrame = GetMDIParentFrame(); wxMDIParentFrame* parentFrame = GetMDIParentFrame();
if (parentFrame->GetActiveChild() == this) if (parentFrame->GetActiveChild() == this)
parentFrame->SetActiveChild((wxMDIChildFrame*) NULL); parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow(); wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
// Remove page if still there // Remove page if still there
if (clientWindow->RemovePage(this)) if (clientWindow->RemovePage(this))
clientWindow->Refresh(); clientWindow->Refresh();
// Set the selection to the first remaining page // Set the selection to the first remaining page
if (clientWindow->GetPageCount() > 0) if (clientWindow->GetPageCount() > 0)
{ {
@@ -460,14 +397,14 @@ void wxMDIChildFrame::OnRaise()
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
parentFrame->SetActiveChild(this); parentFrame->SetActiveChild(this);
if (oldActiveChild) if (oldActiveChild)
{ {
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
event.SetEventObject( oldActiveChild ); event.SetEventObject( oldActiveChild );
oldActiveChild->GetEventHandler()->ProcessEvent(event); oldActiveChild->GetEventHandler()->ProcessEvent(event);
} }
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId()); wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
event.SetEventObject( this ); event.SetEventObject( this );
this->GetEventHandler()->ProcessEvent(event); this->GetEventHandler()->ProcessEvent(event);
@@ -477,7 +414,7 @@ void wxMDIChildFrame::OnLower()
{ {
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ; wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild(); wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
if (oldActiveChild == this) if (oldActiveChild == this)
{ {
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId()); wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
@@ -494,7 +431,7 @@ void wxMDIChildFrame::OnLower()
// to wxWindows) // to wxWindows)
void wxMDIChildFrame::SetClientSize(int width, int height) 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::GetClientSize(int* width, int* height) const
@@ -504,7 +441,7 @@ void wxMDIChildFrame::GetClientSize(int* width, int* height) const
void wxMDIChildFrame::SetSize(int x, int y, int width, int height, int sizeFlags) 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 void wxMDIChildFrame::GetSize(int* width, int* height) const
@@ -528,7 +465,7 @@ void wxMDIChildFrame::SetMenuBar(wxMenuBar *menuBar)
// Don't create the underlying menubar yet; need to recreate // Don't create the underlying menubar yet; need to recreate
// it every time the child is activated. // it every time the child is activated.
m_frameMenuBar = menuBar; m_frameMenuBar = menuBar;
// We make the assumption that if you're setting the menubar, // We make the assumption that if you're setting the menubar,
// this is the currently active child. // this is the currently active child.
GetMDIParentFrame()->SetChildMenuBar(this); GetMDIParentFrame()->SetChildMenuBar(this);
@@ -540,10 +477,8 @@ void wxMDIChildFrame::SetIcon(const wxIcon& icon)
m_icon = icon; m_icon = icon;
if (m_icon.Ok()) if (m_icon.Ok())
{ {
/* TODO: doesn't work yet (crashes in XCopyArea) // Not appropriate since there are no icons in
Pixmap pixmap = (Pixmap) m_icon.GetPixmap(); // a tabbed window
m_mdiWindow->setPixmap(pixmap);
*/
} }
} }
@@ -564,7 +499,7 @@ void wxMDIChildFrame::Maximize()
void wxMDIChildFrame::Iconize(bool iconize) void wxMDIChildFrame::Iconize(bool iconize)
{ {
// TODO // TODO
} }
bool wxMDIChildFrame::IsIconized() const bool wxMDIChildFrame::IsIconized() const
@@ -591,22 +526,22 @@ void wxMDIChildFrame::Activate()
void wxMDIChildFrame::CaptureMouse() void wxMDIChildFrame::CaptureMouse()
{ {
wxWindow::CaptureMouse(); wxWindow::CaptureMouse();
} }
void wxMDIChildFrame::ReleaseMouse() void wxMDIChildFrame::ReleaseMouse()
{ {
wxWindow::ReleaseMouse(); wxWindow::ReleaseMouse();
} }
void wxMDIChildFrame::Raise() void wxMDIChildFrame::Raise()
{ {
wxWindow::Raise(); wxWindow::Raise();
} }
void wxMDIChildFrame::Lower(void) 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)) void wxMDIChildFrame::SetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH))
@@ -622,17 +557,17 @@ wxMDIClientWindow::wxMDIClientWindow()
wxMDIClientWindow::~wxMDIClientWindow() wxMDIClientWindow::~wxMDIClientWindow()
{ {
// By the time this destructor is called, the child frames will have been // 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(); DestroyChildren();
m_mainWidget = (WXWidget) 0; m_mainWidget = (WXWidget) 0;
} }
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style) bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
{ {
// m_windowParent = parent; // m_windowParent = parent;
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); // m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0); bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
if (success) if (success)
{ {
@@ -645,7 +580,7 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
return TRUE; return TRUE;
} }
else else
return FALSE; return FALSE;
} }
void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags) void wxMDIClientWindow::SetSize(int x, int y, int width, int height, int sizeFlags)
@@ -694,19 +629,19 @@ void wxMDIClientWindow::OnPageChanged(wxNotebookEvent& event)
} }
if (event.GetSelection() != -1) if (event.GetSelection() != -1)
{ {
wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection()); wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
if (activeChild) if (activeChild)
{
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
event.SetEventObject( activeChild );
activeChild->GetEventHandler()->ProcessEvent(event);
if (activeChild->GetMDIParentFrame())
{ {
activeChild->GetMDIParentFrame()->SetActiveChild(activeChild); wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild); event.SetEventObject( activeChild );
activeChild->GetEventHandler()->ProcessEvent(event);
if (activeChild->GetMDIParentFrame())
{
activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
}
} }
}
} }
event.Skip(); event.Skip();
} }

File diff suppressed because it is too large Load Diff

View File

@@ -31,11 +31,11 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
void wxMenuItemCallback (Widget w, XtPointer clientData, void wxMenuItemCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
void wxMenuItemArmCallback (Widget w, XtPointer clientData, void wxMenuItemArmCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
void wxMenuItemDisarmCallback (Widget w, XtPointer clientData, void wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
XtPointer ptr); XtPointer ptr);
// ============================================================================ // ============================================================================
// implementation // implementation
@@ -46,7 +46,7 @@ void wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject) IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
#endif //USE_SHARED_LIBRARY #endif //USE_SHARED_LIBRARY
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -60,22 +60,22 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
const wxString& strName, const wxString& strHelp, const wxString& strName, const wxString& strHelp,
bool bCheckable, bool bCheckable,
wxMenu *pSubMenu) : wxMenu *pSubMenu) :
m_strHelp(strHelp), m_strHelp(strHelp),
m_bCheckable(bCheckable), m_bCheckable(bCheckable),
m_strName(strName) m_strName(strName)
{ {
wxASSERT( pParentMenu != NULL ); wxASSERT( pParentMenu != NULL );
m_pParentMenu = pParentMenu; m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu; m_pSubMenu = pSubMenu;
m_idItem = id; m_idItem = id;
m_bEnabled = TRUE; m_bEnabled = TRUE;
m_bChecked = FALSE; m_bChecked = FALSE;
//// Motif-specific //// Motif-specific
m_menuBar = NULL; m_menuBar = NULL;
m_buttonWidget = (WXWidget) NULL; m_buttonWidget = (WXWidget) NULL;
m_topMenu = NULL; m_topMenu = NULL;
} }
wxMenuItem::~wxMenuItem() wxMenuItem::~wxMenuItem()
@@ -88,10 +88,10 @@ wxMenuItem::~wxMenuItem()
// delete the sub menu // delete the sub menu
void wxMenuItem::DeleteSubMenu() void wxMenuItem::DeleteSubMenu()
{ {
wxASSERT( m_pSubMenu != NULL ); wxASSERT( m_pSubMenu != NULL );
delete m_pSubMenu; delete m_pSubMenu;
m_pSubMenu = NULL; m_pSubMenu = NULL;
} }
// change item state // change item state
@@ -99,266 +99,265 @@ void wxMenuItem::DeleteSubMenu()
void wxMenuItem::Enable(bool bDoEnable) void wxMenuItem::Enable(bool bDoEnable)
{ {
if ( m_bEnabled != bDoEnable ) if ( m_bEnabled != 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? if ( m_pSubMenu == NULL )
// Or perhaps it works anyway. { // normal menu item
if (m_buttonWidget) if (m_buttonWidget)
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable); 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) void wxMenuItem::Check(bool bDoCheck)
{ {
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" ); wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
if ( m_bChecked != bDoCheck ) if ( m_bChecked != bDoCheck )
{
if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
{ {
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 //// Motif-specific
void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu) void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu)
{ {
m_menuBar = menuBar; m_menuBar = menuBar;
m_topMenu = topMenu; m_topMenu = topMenu;
if (GetId() == -2) if (GetId() == -2)
{ {
// Id=-2 identifies a Title item. // Id=-2 identifies a Title item.
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer); wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
xmLabelGadgetClass, (Widget) menu, NULL); 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); wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
if (IsCheckable()) if (IsCheckable())
{ {
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
xmToggleButtonGadgetClass, (Widget) menu, xmToggleButtonGadgetClass, (Widget) menu,
NULL); NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
} }
else else
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
xmPushButtonGadgetClass, (Widget) menu, xmPushButtonGadgetClass, (Widget) menu,
NULL); NULL);
char mnem = wxFindMnemonic (m_strName); char mnem = wxFindMnemonic (m_strName);
if (mnem != 0) if (mnem != 0)
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
//// TODO: proper accelerator treatment. What does wxFindAccelerator //// TODO: proper accelerator treatment. What does wxFindAccelerator
//// look for? //// look for?
strcpy(wxBuffer, (char*) (const char*) m_strName); strcpy(wxBuffer, (char*) (const char*) m_strName);
char *accel = wxFindAccelerator (wxBuffer); char *accel = wxFindAccelerator (wxBuffer);
if (accel) if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
// TODO: What does this do? // TODO: What does this do?
strcpy(wxBuffer, (char*) (const char*) m_strName); strcpy(wxBuffer, (char*) (const char*) m_strName);
XmString accel_str = wxFindAcceleratorText (wxBuffer); XmString accel_str = wxFindAcceleratorText (wxBuffer);
if (accel_str) if (accel_str)
{ {
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
XmStringFree (accel_str); XmStringFree (accel_str);
} }
if (IsCheckable()) if (IsCheckable())
XtAddCallback ((Widget) m_buttonWidget, XtAddCallback ((Widget) m_buttonWidget,
XmNvalueChangedCallback, XmNvalueChangedCallback,
(XtCallbackProc) wxMenuItemCallback, (XtCallbackProc) wxMenuItemCallback,
(XtPointer) this); (XtPointer) this);
else else
XtAddCallback ((Widget) m_buttonWidget, XtAddCallback ((Widget) m_buttonWidget,
XmNactivateCallback, XmNactivateCallback,
(XtCallbackProc) wxMenuItemCallback, (XtCallbackProc) wxMenuItemCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback ((Widget) m_buttonWidget, XtAddCallback ((Widget) m_buttonWidget,
XmNarmCallback, XmNarmCallback,
(XtCallbackProc) wxMenuItemArmCallback, (XtCallbackProc) wxMenuItemArmCallback,
(XtPointer) this); (XtPointer) this);
XtAddCallback ((Widget) m_buttonWidget, XtAddCallback ((Widget) m_buttonWidget,
XmNdisarmCallback, XmNdisarmCallback,
(XtCallbackProc) wxMenuItemDisarmCallback, (XtCallbackProc) wxMenuItemDisarmCallback,
(XtPointer) this); (XtPointer) this);
} }
else if (GetId() == -1) else if (GetId() == -1)
{ {
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator", m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
xmSeparatorGadgetClass, (Widget) menu, NULL); xmSeparatorGadgetClass, (Widget) menu, NULL);
} }
else if (m_pSubMenu) else if (m_pSubMenu)
{ {
m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE); m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE);
m_pSubMenu->SetButtonWidget(m_buttonWidget); m_pSubMenu->SetButtonWidget(m_buttonWidget);
XtAddCallback ((Widget) m_buttonWidget, XtAddCallback ((Widget) m_buttonWidget,
XmNcascadingCallback, XmNcascadingCallback,
(XtCallbackProc) wxMenuItemArmCallback, (XtCallbackProc) wxMenuItemArmCallback,
(XtPointer) this); (XtPointer) this);
} }
if (m_buttonWidget) if (m_buttonWidget)
XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled()); XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
} }
void wxMenuItem::DestroyItem(bool full) 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 (m_buttonWidget)
{ {
if (IsCheckable()) if (IsCheckable())
XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback, XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
wxMenuItemCallback, (XtPointer) this); wxMenuItemCallback, (XtPointer) this);
else else
XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback, XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
wxMenuItemCallback, (XtPointer) this); wxMenuItemCallback, (XtPointer) this);
XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback, XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
wxMenuItemArmCallback, (XtPointer) this); wxMenuItemArmCallback, (XtPointer) this);
XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback, XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
wxMenuItemDisarmCallback, (XtPointer) this); wxMenuItemDisarmCallback, (XtPointer) this);
} }
} }
else if (GetId() == -1) else if (GetId() == -1)
{ {
; // Nothing ; // Nothing
} }
else if (GetSubMenu()) else if (GetSubMenu())
{ {
if (m_buttonWidget) if (m_buttonWidget)
{ {
XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback, XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
wxMenuItemArmCallback, (XtPointer) this); wxMenuItemArmCallback, (XtPointer) this);
} }
m_pSubMenu->DestroyMenu(full); m_pSubMenu->DestroyMenu(full);
if (full) if (full)
m_buttonWidget = NULL; m_buttonWidget = NULL;
} }
if (m_buttonWidget && full) if (m_buttonWidget && full)
{ {
XtDestroyWidget ((Widget) m_buttonWidget); XtDestroyWidget ((Widget) m_buttonWidget);
m_buttonWidget = (WXWidget) 0; m_buttonWidget = (WXWidget) 0;
} }
} }
void wxMenuItem::SetLabel(const wxString& label) void wxMenuItem::SetLabel(const wxString& label)
{ {
char mnem = wxFindMnemonic (label); char mnem = wxFindMnemonic (label);
wxStripMenuCodes ((char*) (const char*) label, wxBuffer); wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
m_strName = label; m_strName = label;
if (m_buttonWidget) if (m_buttonWidget)
{ {
XmString label_str = XmStringCreateSimple (wxBuffer); XmString label_str = XmStringCreateSimple (wxBuffer);
XtVaSetValues ((Widget) m_buttonWidget, XtVaSetValues ((Widget) m_buttonWidget,
XmNlabelString, label_str, XmNlabelString, label_str,
NULL); NULL);
XmStringFree (label_str); XmStringFree (label_str);
if (mnem != 0) if (mnem != 0)
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
strcpy(wxBuffer, (char*) (const char*) label); strcpy(wxBuffer, (char*) (const char*) label);
char *accel = wxFindAccelerator (wxBuffer); char *accel = wxFindAccelerator (wxBuffer);
if (accel) if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
strcpy(wxBuffer, (char*) (const char*) label); strcpy(wxBuffer, (char*) (const char*) label);
XmString accel_str = wxFindAcceleratorText (wxBuffer); XmString accel_str = wxFindAcceleratorText (wxBuffer);
if (accel_str) if (accel_str)
{ {
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
XmStringFree (accel_str); XmStringFree (accel_str);
} }
} }
} }
void wxMenuItemCallback (Widget w, XtPointer clientData, void wxMenuItemCallback (Widget w, XtPointer clientData,
XtPointer ptr) XtPointer ptr)
{ {
wxMenuItem *item = (wxMenuItem *) clientData; wxMenuItem *item = (wxMenuItem *) clientData;
if (item) if (item)
{ {
if (item->IsCheckable()) if (item->IsCheckable())
{ {
Boolean isChecked = FALSE; Boolean isChecked = FALSE;
XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL); XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
item->SetChecked(isChecked); item->SetChecked(isChecked);
} }
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame()) if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
{ {
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId()); wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame()); commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
commandEvent.SetInt( item->GetId() ); commandEvent.SetInt( item->GetId() );
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent); item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
} }
else if (item->GetTopMenu()) else if (item->GetTopMenu())
{ {
wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
event.SetEventObject(item->GetTopMenu()); event.SetEventObject(item->GetTopMenu());
event.SetInt( item->GetId() ); event.SetInt( item->GetId() );
item->GetTopMenu()->ProcessCommand (event); item->GetTopMenu()->ProcessCommand (event);
} }
} }
} }
void void wxMenuItemArmCallback (Widget w, XtPointer clientData,
wxMenuItemArmCallback (Widget w, XtPointer clientData, XtPointer ptr)
XtPointer ptr)
{ {
wxMenuItem *item = (wxMenuItem *) clientData; wxMenuItem *item = (wxMenuItem *) clientData;
if (item) if (item)
{ {
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame()) if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
{ {
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId()); wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame()); menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent); item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
} }
} }
} }
void void
wxMenuItemDisarmCallback (Widget w, XtPointer clientData, wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
XtPointer ptr) XtPointer ptr)
{ {
wxMenuItem *item = (wxMenuItem *) clientData; wxMenuItem *item = (wxMenuItem *) clientData;
if (item) if (item)
{ {
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame()) if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
{ {
// TODO: not sure this is correct, since -1 means something // TODO: not sure this is correct, since -1 means something
// special to event system // special to event system
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1); wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame()); menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent); item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
} }
} }
} }

View File

@@ -52,9 +52,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxXPalette, wxObject)
#endif #endif
/* /*
* Palette * Palette
* *
*/ */
wxXPalette::wxXPalette() wxXPalette::wxXPalette()
{ {
@@ -71,39 +71,39 @@ wxPaletteRefData::wxPaletteRefData()
wxPaletteRefData::~wxPaletteRefData() wxPaletteRefData::~wxPaletteRefData()
{ {
XColor xcol; XColor xcol;
Display *display = (Display*) NULL; Display *display = (Display*) NULL;
wxNode *node, *next; wxNode *node, *next;
for (node = m_palettes.First(); node; node = next) { for (node = m_palettes.First(); node; node = next) {
wxXPalette *c = (wxXPalette *)node->Data(); wxXPalette *c = (wxXPalette *)node->Data();
unsigned long *pix_array = c->m_pix_array; unsigned long *pix_array = c->m_pix_array;
Colormap cmap = (Colormap) c->m_cmap; Colormap cmap = (Colormap) c->m_cmap;
bool destroyable = c->m_destroyable; bool destroyable = c->m_destroyable;
int pix_array_n = c->m_pix_array_n; int pix_array_n = c->m_pix_array_n;
display = (Display*) c->m_display; display = (Display*) c->m_display;
if (pix_array_n > 0) if (pix_array_n > 0)
{ {
// XFreeColors(display, cmap, pix_array, pix_array_n, 0); // XFreeColors(display, cmap, pix_array, pix_array_n, 0);
// Be careful not to free '0' pixels... // Be careful not to free '0' pixels...
int i, j; int i, j;
for(i=j=0; i<pix_array_n; i=j) { for(i=j=0; i<pix_array_n; i=j) {
while(j<pix_array_n && pix_array[j]!=0) j++; while(j<pix_array_n && pix_array[j]!=0) j++;
if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0); if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
while(j<pix_array_n && pix_array[j]==0) j++; while(j<pix_array_n && pix_array[j]==0) j++;
} }
delete [] pix_array; 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() wxPalette::wxPalette()
@@ -121,53 +121,53 @@ wxPalette::~wxPalette()
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue) bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{ {
UnRef(); UnRef();
if (!n) { if (!n) {
return FALSE; return FALSE;
} }
m_refData = new wxPaletteRefData; m_refData = new wxPaletteRefData;
XColor xcol; XColor xcol;
Display* display = (Display*) wxGetDisplay(); Display* display = (Display*) wxGetDisplay();
unsigned long *pix_array; unsigned long *pix_array;
Colormap cmap; Colormap cmap;
int pix_array_n; int pix_array_n;
cmap = (Colormap) wxTheApp->GetMainColormap(display); cmap = (Colormap) wxTheApp->GetMainColormap(display);
pix_array = new unsigned long[n]; pix_array = new unsigned long[n];
if (!pix_array) if (!pix_array)
return FALSE; return FALSE;
pix_array_n = n; pix_array_n = n;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
for(int i = 0; i < n; i++) { for(int i = 0; i < n; i++) {
xcol.red = (unsigned short)red[i] << 8; xcol.red = (unsigned short)red[i] << 8;
xcol.green = (unsigned short)green[i] << 8; xcol.green = (unsigned short)green[i] << 8;
xcol.blue = (unsigned short)blue[i] << 8; xcol.blue = (unsigned short)blue[i] << 8;
pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel; pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
} }
wxXPalette *c = new wxXPalette; wxXPalette *c = new wxXPalette;
c->m_pix_array_n = pix_array_n; c->m_pix_array_n = pix_array_n;
c->m_pix_array = pix_array; c->m_pix_array = pix_array;
c->m_cmap = (WXColormap) cmap; c->m_cmap = (WXColormap) cmap;
c->m_display = (WXDisplay*) display; c->m_display = (WXDisplay*) display;
c->m_destroyable = FALSE; c->m_destroyable = FALSE;
M_PALETTEDATA->m_palettes.Append(c); M_PALETTEDATA->m_palettes.Append(c);
return TRUE; return TRUE;
} }
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
{ {
if ( !m_refData ) if ( !m_refData )
return FALSE; return FALSE;
// TODO // TODO
return FALSE; return FALSE;
} }
@@ -175,11 +175,11 @@ int wxPalette::GetPixel(const unsigned char red, const unsigned char green, cons
bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const bool wxPalette::GetRGB(int index, unsigned char *red, unsigned char *green, unsigned char *blue) const
{ {
if ( !m_refData ) if ( !m_refData )
return FALSE; return FALSE;
if (index < 0 || index > 255) if (index < 0 || index > 255)
return FALSE; return FALSE;
// TODO // TODO
return FALSE; return FALSE;
} }
@@ -188,7 +188,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
{ {
if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0)) if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0))
return wxTheApp->GetMainColormap(display); return wxTheApp->GetMainColormap(display);
wxNode* node = M_PALETTEDATA->m_palettes.First(); wxNode* node = M_PALETTEDATA->m_palettes.First();
if (!display && node) if (!display && node)
{ {
@@ -200,22 +200,22 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
wxXPalette* p = (wxXPalette*) node->Data(); wxXPalette* p = (wxXPalette*) node->Data();
if (p->m_display == display) if (p->m_display == display)
return p->m_cmap; return p->m_cmap;
node = node->Next(); node = node->Next();
} }
/* Make a new one: */ /* Make a new one: */
wxXPalette *c = new wxXPalette; wxXPalette *c = new wxXPalette;
wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data(); wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data();
XColor xcol; XColor xcol;
int pix_array_n = first->m_pix_array_n; int pix_array_n = first->m_pix_array_n;
c->m_pix_array_n = pix_array_n; c->m_pix_array_n = pix_array_n;
c->m_pix_array = new unsigned long[pix_array_n]; c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display; c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display); c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE; c->m_destroyable = FALSE;
xcol.flags = DoRed | DoGreen | DoBlue; xcol.flags = DoRed | DoGreen | DoBlue;
int i; int i;
for (i = 0; i < pix_array_n; i++) for (i = 0; i < pix_array_n; i++)
@@ -225,87 +225,87 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
c->m_pix_array[i] = c->m_pix_array[i] =
(XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel; (XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel;
} }
// wxPalette* nonConstThis = (wxPalette*) this; // wxPalette* nonConstThis = (wxPalette*) this;
M_PALETTEDATA->m_palettes.Append(c); M_PALETTEDATA->m_palettes.Append(c);
return c->m_cmap; return c->m_cmap;
} }
bool wxPalette::TransferBitmap(void *data, int depth, int size) bool wxPalette::TransferBitmap(void *data, int depth, int size)
{ {
switch(depth) { switch(depth) {
case 8: case 8:
{ {
unsigned char *uptr = (unsigned char *)data; unsigned char *uptr = (unsigned char *)data;
int pix_array_n; int pix_array_n;
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
while(size-- > 0) while(size-- > 0)
{ {
if((int)*uptr < pix_array_n) if((int)*uptr < pix_array_n)
*uptr = (unsigned char)pix_array[*uptr]; *uptr = (unsigned char)pix_array[*uptr];
uptr++; uptr++;
}
return TRUE;
}
default:
return FALSE;
} }
return TRUE;
}
default:
return FALSE;
}
} }
bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz, bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
void *dest, unsigned int bpp) void *dest, unsigned int bpp)
{ {
int pix_array_n; int pix_array_n;
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n); unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
switch(bpp) { switch(bpp) {
case 8: { case 8: {
unsigned char *dptr = (unsigned char *)dest; unsigned char *dptr = (unsigned char *)dest;
while(sz-- > 0) { while(sz-- > 0) {
if((int)*data < pix_array_n) if((int)*data < pix_array_n)
*dptr = (unsigned char)pix_array[*data]; *dptr = (unsigned char)pix_array[*data];
data++; data++;
dptr++; 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;
}
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;
} }
data++; break;
dptr++; }
} case 16: {
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;
}
data++;
dptr++;
}
break;
}
case 32: { case 32: {
unsigned long *dptr = (unsigned long *)dest; unsigned long *dptr = (unsigned long *)dest;
while(sz-- > 0) { while(sz-- > 0) {
if((int)*data < pix_array_n) if((int)*data < pix_array_n)
*dptr = pix_array[*data]; *dptr = pix_array[*data];
data++; data++;
dptr++; dptr++;
} }
break; break;
} }
default: default:
return FALSE; return FALSE;
} }
return TRUE; return TRUE;
} }
@@ -315,7 +315,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
if (!M_PALETTEDATA) if (!M_PALETTEDATA)
return (unsigned long*) 0; return (unsigned long*) 0;
wxNode *node; wxNode *node;
for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next()) for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next())
{ {
wxXPalette *c = (wxXPalette *)node->Data(); wxXPalette *c = (wxXPalette *)node->Data();
@@ -326,7 +326,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
return c->m_pix_array; return c->m_pix_array;
} }
} }
/* Not found; call GetXColormap, which will create it, then this again */ /* Not found; call GetXColormap, which will create it, then this again */
if (GetXColormap(display)) if (GetXColormap(display))
return GetXPixArray(display, n); return GetXPixArray(display, n);
@@ -337,17 +337,17 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp) void wxPalette::PutXColormap(WXDisplay* display, WXColormap cm, bool dp)
{ {
UnRef(); UnRef();
m_refData = new wxPaletteRefData; m_refData = new wxPaletteRefData;
wxXPalette *c = new wxXPalette; wxXPalette *c = new wxXPalette;
c->m_pix_array_n = 0; c->m_pix_array_n = 0;
c->m_pix_array = (unsigned long*) NULL; c->m_pix_array = (unsigned long*) NULL;
c->m_display = display; c->m_display = display;
c->m_cmap = cm; c->m_cmap = cm;
c->m_destroyable = dp; c->m_destroyable = dp;
M_PALETTEDATA->m_palettes.Append(c); M_PALETTEDATA->m_palettes.Append(c);
} }

View File

@@ -64,7 +64,7 @@ wxPen::~wxPen()
wxPen::wxPen(const wxColour& col, int Width, int Style) wxPen::wxPen(const wxColour& col, int Width, int Style)
{ {
m_refData = new wxPenRefData; m_refData = new wxPenRefData;
M_PENDATA->m_colour = col; M_PENDATA->m_colour = col;
M_PENDATA->m_width = Width; M_PENDATA->m_width = Width;
M_PENDATA->m_style = Style; M_PENDATA->m_style = Style;
@@ -72,9 +72,9 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ; M_PENDATA->m_dash = 0 ;
RealizeResource(); RealizeResource();
if ( wxThePenList ) if ( wxThePenList )
wxThePenList->AddPen(this); wxThePenList->AddPen(this);
} }
@@ -82,7 +82,7 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
wxPen::wxPen(const wxBitmap& stipple, int Width) wxPen::wxPen(const wxBitmap& stipple, int Width)
{ {
m_refData = new wxPenRefData; m_refData = new wxPenRefData;
M_PENDATA->m_stipple = stipple; M_PENDATA->m_stipple = stipple;
M_PENDATA->m_width = Width; M_PENDATA->m_width = Width;
M_PENDATA->m_style = wxSTIPPLE; M_PENDATA->m_style = wxSTIPPLE;
@@ -90,99 +90,99 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
M_PENDATA->m_cap = wxCAP_ROUND ; M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ; M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = 0 ; M_PENDATA->m_dash = 0 ;
RealizeResource(); RealizeResource();
if ( wxThePenList ) if ( wxThePenList )
wxThePenList->AddPen(this); wxThePenList->AddPen(this);
} }
void wxPen::Unshare() void wxPen::Unshare()
{ {
// Don't change shared data // Don't change shared data
if (!m_refData) if (!m_refData)
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
} }
else else
{ {
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData); wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
UnRef(); UnRef();
m_refData = ref; m_refData = ref;
} }
} }
void wxPen::SetColour(const wxColour& col) void wxPen::SetColour(const wxColour& col)
{ {
Unshare(); Unshare();
M_PENDATA->m_colour = col; M_PENDATA->m_colour = col;
RealizeResource(); RealizeResource();
} }
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b) void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
{ {
Unshare(); Unshare();
M_PENDATA->m_colour.Set(r, g, b); M_PENDATA->m_colour.Set(r, g, b);
RealizeResource(); RealizeResource();
} }
void wxPen::SetWidth(int Width) void wxPen::SetWidth(int Width)
{ {
Unshare(); Unshare();
M_PENDATA->m_width = Width; M_PENDATA->m_width = Width;
RealizeResource(); RealizeResource();
} }
void wxPen::SetStyle(int Style) void wxPen::SetStyle(int Style)
{ {
Unshare(); Unshare();
M_PENDATA->m_style = Style; M_PENDATA->m_style = Style;
RealizeResource(); RealizeResource();
} }
void wxPen::SetStipple(const wxBitmap& Stipple) void wxPen::SetStipple(const wxBitmap& Stipple)
{ {
Unshare(); Unshare();
M_PENDATA->m_stipple = Stipple; M_PENDATA->m_stipple = Stipple;
M_PENDATA->m_style = wxSTIPPLE; M_PENDATA->m_style = wxSTIPPLE;
RealizeResource(); RealizeResource();
} }
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash) void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
{ {
Unshare(); Unshare();
M_PENDATA->m_nbDash = nb_dashes; M_PENDATA->m_nbDash = nb_dashes;
M_PENDATA->m_dash = (wxDash *)Dash; M_PENDATA->m_dash = (wxDash *)Dash;
RealizeResource(); RealizeResource();
} }
void wxPen::SetJoin(int Join) void wxPen::SetJoin(int Join)
{ {
Unshare(); Unshare();
M_PENDATA->m_join = Join; M_PENDATA->m_join = Join;
RealizeResource(); RealizeResource();
} }
void wxPen::SetCap(int Cap) void wxPen::SetCap(int Cap)
{ {
Unshare(); Unshare();
M_PENDATA->m_cap = Cap; M_PENDATA->m_cap = Cap;
RealizeResource(); RealizeResource();
} }

View File

@@ -26,7 +26,7 @@
#include <wx/motif/private.h> #include <wx/motif/private.h>
void wxRadioButtonCallback (Widget w, XtPointer clientData, void wxRadioButtonCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs); XmToggleButtonCallbackStruct * cbs);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
@@ -37,60 +37,60 @@ wxRadioButton::wxRadioButton()
} }
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id, bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
m_windowStyle = style ; m_windowStyle = style ;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
wxString label1(wxStripMenuCodes(label)); wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1); XmString text = XmStringCreateSimple ((char*) (const char*) label1);
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget)); XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle", Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle",
#if wxUSE_GADGETS #if wxUSE_GADGETS
xmToggleButtonGadgetClass, parentWidget, xmToggleButtonGadgetClass, parentWidget,
#else #else
xmToggleButtonWidgetClass, parentWidget, xmToggleButtonWidgetClass, parentWidget,
#endif #endif
XmNfontList, fontList, XmNfontList, fontList,
XmNlabelString, text, XmNlabelString, text,
XmNfillOnSelect, True, XmNfillOnSelect, True,
XmNindicatorType, XmONE_OF_MANY, // diamond-shape XmNindicatorType, XmONE_OF_MANY, // diamond-shape
NULL); NULL);
XmStringFree (text); XmStringFree (text);
XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback, XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback,
(XtCallbackProc) this); (XtCallbackProc) this);
m_mainWidget = (WXWidget) radioButtonWidget; m_mainWidget = (WXWidget) radioButtonWidget;
XtManageChild (radioButtonWidget); XtManageChild (radioButtonWidget);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -109,8 +109,8 @@ bool wxRadioButton::GetValue() const
void wxRadioButton::Command (wxCommandEvent & event) void wxRadioButton::Command (wxCommandEvent & event)
{ {
SetValue ( (event.m_commandInt != 0) ); SetValue ( (event.m_commandInt != 0) );
ProcessCommand (event); ProcessCommand (event);
} }
void wxRadioButton::ChangeFont(bool keepOriginalSize) void wxRadioButton::ChangeFont(bool keepOriginalSize)
@@ -129,18 +129,18 @@ void wxRadioButton::ChangeForegroundColour()
} }
void wxRadioButtonCallback (Widget w, XtPointer clientData, void wxRadioButtonCallback (Widget w, XtPointer clientData,
XmToggleButtonCallbackStruct * cbs) XmToggleButtonCallbackStruct * cbs)
{ {
if (!cbs->set) if (!cbs->set)
return; return;
wxRadioButton *item = (wxRadioButton *) clientData; wxRadioButton *item = (wxRadioButton *) clientData;
if (item->InSetValue()) if (item->InSetValue())
return; return;
wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId()); wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
event.SetEventObject(item); event.SetEventObject(item);
item->ProcessCommand (event); item->ProcessCommand (event);
} }

View File

@@ -38,75 +38,75 @@ END_EVENT_TABLE()
// Slider // Slider
wxSlider::wxSlider() wxSlider::wxSlider()
{ {
m_pageSize = 1; m_pageSize = 1;
m_lineSize = 1; m_lineSize = 1;
m_rangeMax = 0; m_rangeMax = 0;
m_rangeMin = 0; m_rangeMin = 0;
m_tickFreq = 0; m_tickFreq = 0;
} }
bool wxSlider::Create(wxWindow *parent, wxWindowID id, bool wxSlider::Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue, int value, int minValue, int maxValue,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour(); m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_lineSize = 1; m_lineSize = 1;
m_windowStyle = style; m_windowStyle = style;
m_tickFreq = 0; m_tickFreq = 0;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
m_rangeMax = maxValue; m_rangeMax = maxValue;
m_rangeMin = minValue; m_rangeMin = minValue;
// Not used in Motif, I think // Not used in Motif, I think
m_pageSize = (int)((maxValue-minValue)/10); m_pageSize = (int)((maxValue-minValue)/10);
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget", Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget",
xmScaleWidgetClass, parentWidget, xmScaleWidgetClass, parentWidget,
XmNorientation, XmNorientation,
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL), (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL),
XmNprocessingDirection, XmNprocessingDirection,
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT), (((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT),
XmNmaximum, maxValue, XmNmaximum, maxValue,
XmNminimum, minValue, XmNminimum, minValue,
XmNvalue, value, XmNvalue, value,
XmNshowValue, True, XmNshowValue, True,
NULL); NULL);
m_mainWidget = (WXWidget) sliderWidget; m_mainWidget = (WXWidget) sliderWidget;
if(style & wxSL_NOTIFY_DRAG) if(style & wxSL_NOTIFY_DRAG)
XtAddCallback (sliderWidget, XmNdragCallback, XtAddCallback (sliderWidget, XmNdragCallback,
(XtCallbackProc) wxSliderCallback, (XtPointer) this); (XtCallbackProc) wxSliderCallback, (XtPointer) this);
else else
XtAddCallback (sliderWidget, XmNvalueChangedCallback, XtAddCallback (sliderWidget, XmNvalueChangedCallback,
(XtCallbackProc) wxSliderCallback, (XtPointer) this); (XtCallbackProc) wxSliderCallback, (XtPointer) this);
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this); XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -133,40 +133,40 @@ void wxSlider::GetSize(int *width, int *height) const
void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags) void wxSlider::SetSize(int x, int y, int width, int height, int sizeFlags)
{ {
Widget widget = (Widget) m_mainWidget; Widget widget = (Widget) m_mainWidget;
bool managed = XtIsManaged(widget); bool managed = XtIsManaged(widget);
if (managed) if (managed)
XtUnmanageChild (widget); XtUnmanageChild (widget);
if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1)) if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
{ {
XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL); XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
} }
if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1)) if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
{ {
XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL); XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
} }
int xx = x; int yy = y; int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags); AdjustForParentClientOrigin(xx, yy, sizeFlags);
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues (widget, XmNx, xx, NULL); XtVaSetValues (widget, XmNx, xx, NULL);
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues (widget, XmNy, yy, NULL); XtVaSetValues (widget, XmNy, yy, NULL);
if (managed) if (managed)
XtManageChild (widget); XtManageChild (widget);
} }
void wxSlider::SetRange(int minValue, int maxValue) void wxSlider::SetRange(int minValue, int maxValue)
{ {
m_rangeMin = minValue; m_rangeMin = minValue;
m_rangeMax = maxValue; m_rangeMax = maxValue;
XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL); XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL);
} }
@@ -245,8 +245,8 @@ void wxSlider::SetTick(int WXUNUSED(tickPos))
void wxSlider::Command (wxCommandEvent & event) void wxSlider::Command (wxCommandEvent & event)
{ {
SetValue (event.GetInt()); SetValue (event.GetInt());
ProcessCommand (event); ProcessCommand (event);
} }
void wxSlider::ChangeFont(bool keepOriginalSize) void wxSlider::ChangeFont(bool keepOriginalSize)
@@ -269,19 +269,19 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc
wxSlider *slider = (wxSlider *) clientData; wxSlider *slider = (wxSlider *) clientData;
switch (cbs->reason) switch (cbs->reason)
{ {
case XmCR_VALUE_CHANGED: case XmCR_VALUE_CHANGED:
case XmCR_DRAG: case XmCR_DRAG:
default: default:
{ {
// TODO: the XmCR_VALUE_CHANGED case should be handled // TODO: the XmCR_VALUE_CHANGED case should be handled
// differently (it's not sent continually as the slider moves). // differently (it's not sent continually as the slider moves).
// In which case we need a similar behaviour for other platforms. // In which case we need a similar behaviour for other platforms.
wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId()); wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId());
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL); XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider); event.SetEventObject(slider);
slider->ProcessCommand(event); slider->ProcessCommand(event);
// Also send a wxCommandEvent for compatibility. // Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId()); wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider); event2.SetEventObject(slider);

View File

@@ -46,21 +46,21 @@ wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *
static void static void
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs); wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
static void wxTextWindowActivateProc(Widget w, XtPointer clientData, static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
XmAnyCallbackStruct *ptr); XmAnyCallbackStruct *ptr);
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl) BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
EVT_DROP_FILES(wxTextCtrl::OnDropFiles) EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
EVT_CHAR(wxTextCtrl::OnChar) EVT_CHAR(wxTextCtrl::OnChar)
END_EVENT_TABLE() END_EVENT_TABLE()
#endif #endif
// Text item // Text item
wxTextCtrl::wxTextCtrl() wxTextCtrl::wxTextCtrl()
#ifndef NO_TEXT_WINDOW_STREAM #ifndef NO_TEXT_WINDOW_STREAM
:streambuf() :streambuf()
#endif #endif
{ {
m_fileName = ""; m_fileName = "";
@@ -70,11 +70,11 @@ wxTextCtrl::wxTextCtrl()
} }
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id, bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
const wxString& value, const wxString& value,
const wxPoint& pos, const wxPoint& pos,
const wxSize& size, long style, const wxSize& size, long style,
const wxValidator& validator, const wxValidator& validator,
const wxString& name) const wxString& name)
{ {
m_tempCallbackStruct = (void*) NULL; m_tempCallbackStruct = (void*) NULL;
m_modified = FALSE; m_modified = FALSE;
@@ -83,75 +83,75 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
// m_backgroundColour = parent->GetBackgroundColour(); // m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE; m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour(); m_foregroundColour = parent->GetForegroundColour();
SetName(name); SetName(name);
SetValidator(validator); SetValidator(validator);
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_windowStyle = style; m_windowStyle = style;
if ( id == -1 ) if ( id == -1 )
m_windowId = (int)NewControlId(); m_windowId = (int)NewControlId();
else else
m_windowId = id; m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
bool wantHorizScrolling = ((m_windowStyle & wxHSCROLL) != 0); bool wantHorizScrolling = ((m_windowStyle & wxHSCROLL) != 0);
// If we don't have horizontal scrollbars, we want word wrap. // If we don't have horizontal scrollbars, we want word wrap.
bool wantWordWrap = !wantHorizScrolling; bool wantWordWrap = !wantHorizScrolling;
if (m_windowStyle & wxTE_MULTILINE) if (m_windowStyle & wxTE_MULTILINE)
{ {
Arg args[2]; Arg args[2];
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False); XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False); XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
m_mainWidget = (WXWidget) XmCreateScrolledText (parentWidget, (char*) (const char*) name, args, 2); m_mainWidget = (WXWidget) XmCreateScrolledText (parentWidget, (char*) (const char*) name, args, 2);
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNeditable, ((style & wxTE_READONLY) ? False : True), XmNeditable, ((style & wxTE_READONLY) ? False : True),
XmNeditMode, XmMULTI_LINE_EDIT, XmNeditMode, XmMULTI_LINE_EDIT,
NULL); NULL);
XtManageChild ((Widget) m_mainWidget); XtManageChild ((Widget) m_mainWidget);
} }
else else
{ {
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
xmTextWidgetClass, parentWidget, xmTextWidgetClass, parentWidget,
NULL); NULL);
// TODO: Is this relevant? What does it do? // TODO: Is this relevant? What does it do?
int noCols = 2; int noCols = 2;
if (!value.IsNull() && (value.Length() > (unsigned int) noCols)) if (!value.IsNull() && (value.Length() > (unsigned int) noCols))
noCols = value.Length(); noCols = value.Length();
XtVaSetValues ((Widget) m_mainWidget, XtVaSetValues ((Widget) m_mainWidget,
XmNcolumns, noCols, XmNcolumns, noCols,
NULL); NULL);
} }
if (!value.IsNull()) if (!value.IsNull())
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value); XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this);
XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this);
XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this);
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this); XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
m_windowFont = parent->GetFont(); m_windowFont = parent->GetFont();
ChangeFont(FALSE); ChangeFont(FALSE);
SetCanAddEventHandler(TRUE); SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y); AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour(); ChangeBackgroundColour();
return TRUE; return TRUE;
} }
@@ -169,11 +169,11 @@ wxString wxTextCtrl::GetValue() const
char *s = XmTextGetString ((Widget) m_mainWidget); char *s = XmTextGetString ((Widget) m_mainWidget);
if (s) if (s)
{ {
wxString str(s); wxString str(s);
XtFree (s); XtFree (s);
return str; return str;
} }
else else
{ {
return wxEmptyString; return wxEmptyString;
} }
@@ -182,13 +182,13 @@ wxString wxTextCtrl::GetValue() const
void wxTextCtrl::SetValue(const wxString& value) void wxTextCtrl::SetValue(const wxString& value)
{ {
// This assert is wrong -- means that you can't set an empty // This assert is wrong -- means that you can't set an empty
// string (IsNull == IsEmpty). // string (IsNull == IsEmpty).
// wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ; // wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
m_inSetValue = TRUE; m_inSetValue = TRUE;
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value); XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
m_inSetValue = FALSE; m_inSetValue = FALSE;
} }
@@ -237,7 +237,7 @@ long wxTextCtrl::GetLastPosition() const
void wxTextCtrl::Replace(long from, long to, const wxString& value) void wxTextCtrl::Replace(long from, long to, const wxString& value)
{ {
XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to, XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(char*) (const char*) value); (char*) (const char*) value);
} }
void wxTextCtrl::Remove(long from, long to) void wxTextCtrl::Remove(long from, long to)
@@ -257,40 +257,40 @@ bool wxTextCtrl::LoadFile(const wxString& file)
{ {
if (!wxFileExists(file)) if (!wxFileExists(file))
return FALSE; return FALSE;
m_fileName = file; m_fileName = file;
Clear(); Clear();
Widget textWidget = (Widget) m_mainWidget; Widget textWidget = (Widget) m_mainWidget;
FILE *fp; FILE *fp;
struct stat statb; struct stat statb;
if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG || 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 else
{ {
long len = statb.st_size; long len = statb.st_size;
char *text; char *text;
if (!(text = XtMalloc ((unsigned) (len + 1)))) if (!(text = XtMalloc ((unsigned) (len + 1))))
{ {
fclose (fp); fclose (fp);
return FALSE; return FALSE;
} }
if (fread (text, sizeof (char), len, fp) != (size_t) len) if (fread (text, sizeof (char), len, fp) != (size_t) len)
{ {
} }
fclose (fp); fclose (fp);
text[len] = 0; text[len] = 0;
XmTextSetString (textWidget, text); XmTextSetString (textWidget, text);
// m_textPosition = len; // m_textPosition = len;
XtFree (text); XtFree (text);
m_modified = FALSE; m_modified = FALSE;
return TRUE; return TRUE;
} }
} }
@@ -304,31 +304,31 @@ bool wxTextCtrl::SaveFile(const wxString& file)
if (theFile == "") if (theFile == "")
return FALSE; return FALSE;
m_fileName = theFile; m_fileName = theFile;
Widget textWidget = (Widget) m_mainWidget; Widget textWidget = (Widget) m_mainWidget;
FILE *fp; FILE *fp;
if (!(fp = fopen ((char*) (const char*) theFile, "w"))) if (!(fp = fopen ((char*) (const char*) theFile, "w")))
{ {
return FALSE; return FALSE;
} }
else else
{ {
char *text = XmTextGetString (textWidget); char *text = XmTextGetString (textWidget);
long len = XmTextGetLastPosition (textWidget); long len = XmTextGetLastPosition (textWidget);
if (fwrite (text, sizeof (char), len, fp) != (size_t) len) if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
{ {
// Did not write whole file // Did not write whole file
} }
// Make sure newline terminates the file // Make sure newline terminates the file
if (text[len - 1] != '\n') if (text[len - 1] != '\n')
fputc ('\n', fp); fputc ('\n', fp);
fclose (fp); fclose (fp);
XtFree (text); XtFree (text);
m_modified = FALSE; m_modified = FALSE;
return TRUE; return TRUE;
} }
} }
@@ -366,27 +366,27 @@ int wxTextCtrl::GetNumberOfLines() const
char *s = XmTextGetString ((Widget) m_mainWidget); char *s = XmTextGetString ((Widget) m_mainWidget);
if (s) if (s)
{ {
long i = 0; long i = 0;
int currentLine = 0; int currentLine = 0;
bool finished = FALSE; bool finished = FALSE;
while (!finished) while (!finished)
{ {
int ch = s[i]; int ch = s[i];
if (ch == '\n') if (ch == '\n')
{ {
currentLine++; currentLine++;
i++; i++;
} }
else if (ch == 0) else if (ch == 0)
{ {
finished = TRUE; finished = TRUE;
} }
else else
i++; i++;
} }
XtFree (s); XtFree (s);
return currentLine; return currentLine;
} }
return 0; return 0;
} }
@@ -394,11 +394,11 @@ int wxTextCtrl::GetNumberOfLines() const
long wxTextCtrl::XYToPosition(long x, long y) const long wxTextCtrl::XYToPosition(long x, long y) const
{ {
/* It seems, that there is a bug in some versions of the Motif library, /* It seems, that there is a bug in some versions of the Motif library,
so the original wxWin-Code doesn't work. */ so the original wxWin-Code doesn't work. */
/* /*
Widget textWidget = (Widget) handle; Widget textWidget = (Widget) handle;
return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y); return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y);
*/ */
/* Now a little workaround: */ /* Now a little workaround: */
long r=0; long r=0;
for (int i=0; i<y; i++) r+=(GetLineLength(i)+1); for (int i=0; i<y; i++) r+=(GetLineLength(i)+1);
@@ -427,31 +427,31 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
{ {
// HIDEOUSLY inefficient, but we have no choice. // HIDEOUSLY inefficient, but we have no choice.
char *s = XmTextGetString ((Widget) m_mainWidget); char *s = XmTextGetString ((Widget) m_mainWidget);
if (s) if (s)
{ {
wxString buf(""); wxString buf("");
long i; long i;
int currentLine = 0; int currentLine = 0;
for (i = 0; currentLine != lineNo && s[i]; i++ ) for (i = 0; currentLine != lineNo && s[i]; i++ )
if (s[i] == '\n') if (s[i] == '\n')
currentLine++; currentLine++;
// Now get the text // Now get the text
int j; int j;
for (j = 0; s[i] && s[i] != '\n'; i++, j++ ) for (j = 0; s[i] && s[i] != '\n'; i++, j++ )
buf += s[i]; buf += s[i];
XtFree(s); XtFree(s);
return buf; return buf;
} }
else else
return wxEmptyString; return wxEmptyString;
} }
/* /*
* Text item * Text item
*/ */
void wxTextCtrl::Command(wxCommandEvent & event) void wxTextCtrl::Command(wxCommandEvent & event)
{ {
SetValue (event.GetString()); SetValue (event.GetString());
@@ -479,62 +479,62 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
#ifndef NO_TEXT_WINDOW_STREAM #ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow(int c) int wxTextCtrl::overflow(int c)
{ {
// Make sure there is a holding area // Make sure there is a holding area
if ( allocate()==EOF ) if ( allocate()==EOF )
{ {
wxError("Streambuf allocation failed","Internal error"); wxError("Streambuf allocation failed","Internal error");
return EOF; return EOF;
} }
// Verify that there are no characters in get area // Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() ) if ( gptr() && gptr() < egptr() )
{ {
wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error"); wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
return EOF; return EOF;
} }
// Reset get area // Reset get area
setg(0,0,0); setg(0,0,0);
// Make sure there is a put area // Make sure there is a put area
if ( ! pptr() ) if ( ! pptr() )
{ {
/* This doesn't seem to be fatal so comment out error message */ /* This doesn't seem to be fatal so comment out error message */
// wxError("Put area not opened","Internal error"); // wxError("Put area not opened","Internal error");
setp( base(), base() ); setp( base(), base() );
} }
// Determine how many characters have been inserted but no consumed // Determine how many characters have been inserted but no consumed
int plen = pptr() - pbase(); int plen = pptr() - pbase();
// Now Jerry relies on the fact that the buffer is at least 2 chars // 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" ??? // long, but the holding area "may be as small as 1" ???
// And we need an additional \0, so let's keep this inefficient but // And we need an additional \0, so let's keep this inefficient but
// safe copy. // safe copy.
// If c!=EOF, it is a character that must also be comsumed // If c!=EOF, it is a character that must also be comsumed
int xtra = c==EOF? 0 : 1; int xtra = c==EOF? 0 : 1;
// Write temporary C-string to wxTextWindow // Write temporary C-string to wxTextWindow
{ {
char *txt = new char[plen+xtra+1]; char *txt = new char[plen+xtra+1];
memcpy(txt, pbase(), plen); memcpy(txt, pbase(), plen);
txt[plen] = (char)c; // append c txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there // If the put area already contained \0, output will be truncated there
WriteText(txt); WriteText(txt);
delete[] txt; delete[] txt;
} }
// Reset put area // Reset put area
setp(pbase(), epptr()); setp(pbase(), epptr());
#if defined(__WATCOMC__) #if defined(__WATCOMC__)
return __NOT_EOF; return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?) #elif defined(zapeof) // HP-UX (all cfront based?)
return zapeof(c); return zapeof(c);
#else #else
return c!=EOF ? c : 0; // this should make everybody happy return c!=EOF ? c : 0; // this should make everybody happy
#endif #endif
} }
@@ -543,26 +543,26 @@ int wxTextCtrl::overflow(int c)
//========================================================================= //=========================================================================
int wxTextCtrl::sync() int wxTextCtrl::sync()
{ {
// Verify that there are no characters in get area // Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() ) if ( gptr() && gptr() < egptr() )
{ {
wxError("Who's trespassing my get area?","Internal error"); wxError("Who's trespassing my get area?","Internal error");
return EOF; return EOF;
} }
if ( pptr() && pptr() > pbase() ) return overflow(EOF); if ( pptr() && pptr() > pbase() ) return overflow(EOF);
return 0; return 0;
/* OLD CODE /* OLD CODE
int len = pptr() - pbase(); int len = pptr() - pbase();
char *txt = new char[len+1]; char *txt = new char[len+1];
strncpy(txt, pbase(), len); strncpy(txt, pbase(), len);
txt[len] = '\0'; txt[len] = '\0';
(*this) << txt; (*this) << txt;
setp(pbase(), epptr()); setp(pbase(), epptr());
delete[] txt; delete[] txt;
return 0; return 0;
*/ */
} }
//========================================================================= //=========================================================================
@@ -570,7 +570,7 @@ int wxTextCtrl::sync()
//========================================================================= //=========================================================================
int wxTextCtrl::underflow() int wxTextCtrl::underflow()
{ {
return EOF; return EOF;
} }
#endif #endif
@@ -615,7 +615,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i)
wxTextCtrl& wxTextCtrl::operator<<(const char c) wxTextCtrl& wxTextCtrl::operator<<(const char c)
{ {
char buf[2]; char buf[2];
buf[0] = c; buf[0] = c;
buf[1] = 0; buf[1] = 0;
WriteText(buf); WriteText(buf);
@@ -624,21 +624,21 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
void wxTextCtrl::OnChar(wxKeyEvent& event) void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
// Indicates that we should generate a normal command, because // Indicates that we should generate a normal command, because
// we're letting default behaviour happen (otherwise it's vetoed // we're letting default behaviour happen (otherwise it's vetoed
// by virtue of overriding OnChar) // by virtue of overriding OnChar)
m_processedDefault = TRUE; m_processedDefault = TRUE;
if (m_tempCallbackStruct) if (m_tempCallbackStruct)
{
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); 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::ChangeFont(bool keepOriginalSize)
@@ -649,25 +649,25 @@ void wxTextCtrl::ChangeFont(bool keepOriginalSize)
void wxTextCtrl::ChangeBackgroundColour() void wxTextCtrl::ChangeBackgroundColour()
{ {
wxWindow::ChangeBackgroundColour(); wxWindow::ChangeBackgroundColour();
/* TODO: should scrollbars be affected? Should probably have separate /* 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) if (m_windowStyle & wxTE_MULTILINE)
{ {
Widget parent = XtParent ((Widget) m_mainWidget); Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb; Widget hsb, vsb;
XtVaGetValues (parent, XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb, XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb, XmNverticalScrollBar, &vsb,
NULL); NULL);
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
if (hsb) if (hsb)
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
if (vsb) if (vsb)
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE); DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
} }
} }
@@ -675,36 +675,36 @@ void wxTextCtrl::ChangeBackgroundColour()
void wxTextCtrl::ChangeForegroundColour() void wxTextCtrl::ChangeForegroundColour()
{ {
wxWindow::ChangeForegroundColour(); wxWindow::ChangeForegroundColour();
if (m_windowStyle & wxTE_MULTILINE) if (m_windowStyle & wxTE_MULTILINE)
{ {
Widget parent = XtParent ((Widget) m_mainWidget); Widget parent = XtParent ((Widget) m_mainWidget);
Widget hsb, vsb; Widget hsb, vsb;
XtVaGetValues (parent, XtVaGetValues (parent,
XmNhorizontalScrollBar, &hsb, XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb, XmNverticalScrollBar, &vsb,
NULL); NULL);
/* TODO: should scrollbars be affected? Should probably have separate /* 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 (hsb) if (hsb)
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour); DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
if (vsb) if (vsb)
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour); DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
*/ */
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour); DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
} }
} }
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr) static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)
{ {
if (!wxGetWindowFromTable(w)) if (!wxGetWindowFromTable(w))
// Widget has been deleted! // Widget has been deleted!
return; return;
wxTextCtrl *tw = (wxTextCtrl *) clientData; wxTextCtrl *tw = (wxTextCtrl *) clientData;
tw->SetModified(TRUE); tw->SetModified(TRUE);
} }
static void static void
@@ -712,23 +712,23 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
{ {
wxTextCtrl *tw = (wxTextCtrl *) clientData; wxTextCtrl *tw = (wxTextCtrl *) clientData;
tw->m_processedDefault = FALSE; tw->m_processedDefault = FALSE;
// First, do some stuff if it's a password control. // First, do some stuff if it's a password control.
// (What does this do exactly?) // (What does this do exactly?)
if (tw->GetWindowStyleFlag() & wxTE_PASSWORD) if (tw->GetWindowStyleFlag() & wxTE_PASSWORD)
{ {
/* _sm_ /* _sm_
* At least on my system (SunOS 4.1.3 + Motif 1.2), you need to think of * 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 * 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 * 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 * replace, and cbs->endPos gives the index one more than the last char
* affected by the replace (startPos == endPos implies an empty range). * affected by the replace (startPos == endPos implies an empty range).
* Hence, a deletion is represented by replacing all input text with a * Hence, a deletion is represented by replacing all input text with a
* blank string ("", *not* NULL!). A simple insertion that does not * blank string ("", *not* NULL!). A simple insertion that does not
* overwrite any text has startPos == endPos. * overwrite any text has startPos == endPos.
*/ */
if (tw->m_value.IsNull()) if (tw->m_value.IsNull())
{ {
tw->m_value = cbs->text->ptr; tw->m_value = cbs->text->ptr;
@@ -736,33 +736,33 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
else else
{ {
char * passwd = (char*) (const char*) tw->m_value; // Set up a more convenient alias. 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 int len = passwd ? strlen(passwd) : 0; // Enough room for old text
len += strlen(cbs->text->ptr) + 1; // + new text (if any) + NUL len += strlen(cbs->text->ptr) + 1; // + new text (if any) + NUL
len -= cbs->endPos - cbs->startPos; // - text from affected region. len -= cbs->endPos - cbs->startPos; // - text from affected region.
char * newS = new char [len]; char * newS = new char [len];
char * p = passwd, * dest = newS, * insert = cbs->text->ptr; char * p = passwd, * dest = newS, * insert = cbs->text->ptr;
// Copy (old) text from passwd, up to the start posn of the change. // Copy (old) text from passwd, up to the start posn of the change.
int i; int i;
for (i = 0; i < cbs->startPos; ++i) for (i = 0; i < cbs->startPos; ++i)
*dest++ = *p++; *dest++ = *p++;
// Copy the text to be inserted). // Copy the text to be inserted).
while (*insert) while (*insert)
*dest++ = *insert++; *dest++ = *insert++;
// Finally, copy into newS any remaining text from passwd[endPos] on. // Finally, copy into newS any remaining text from passwd[endPos] on.
for (p = passwd + cbs->endPos; *p; ) for (p = passwd + cbs->endPos; *p; )
*dest++ = *p++; *dest++ = *p++;
*dest = 0; *dest = 0;
tw->m_value = newS; tw->m_value = newS;
delete[] newS; delete[] newS;
} }
if (cbs->text->length>0) if (cbs->text->length>0)
{ {
int i; int i;
@@ -771,70 +771,70 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
cbs->text->ptr[i] = 0; cbs->text->ptr[i] = 0;
} }
} }
// If we're already within an OnChar, return: probably // If we're already within an OnChar, return: probably
// a programmatic insertion. // a programmatic insertion.
if (tw->m_tempCallbackStruct) if (tw->m_tempCallbackStruct)
return; return;
// Check for a backspace // Check for a backspace
if (cbs->startPos == (cbs->currInsert - 1)) if (cbs->startPos == (cbs->currInsert - 1))
{ {
tw->m_tempCallbackStruct = (void*) cbs; tw->m_tempCallbackStruct = (void*) cbs;
wxKeyEvent event (wxEVT_CHAR); wxKeyEvent event (wxEVT_CHAR);
event.SetId(tw->GetId()); event.SetId(tw->GetId());
event.m_keyCode = WXK_DELETE; event.m_keyCode = WXK_DELETE;
event.SetEventObject(tw); event.SetEventObject(tw);
// Only if wxTextCtrl::OnChar is called // Only if wxTextCtrl::OnChar is called
// will this be set to True (and the character // will this be set to True (and the character
// passed through) // passed through)
cbs->doit = False; cbs->doit = False;
tw->GetEventHandler()->ProcessEvent(event); tw->GetEventHandler()->ProcessEvent(event);
tw->m_tempCallbackStruct = NULL; tw->m_tempCallbackStruct = NULL;
if (tw->InSetValue()) if (tw->InSetValue())
return; return;
if (tw->m_processedDefault) if (tw->m_processedDefault)
{ {
// Can generate a command // Can generate a command
wxCommandEvent commandEvent(wxEVT_COMMAND_TEXT_UPDATED, tw->GetId()); wxCommandEvent commandEvent(wxEVT_COMMAND_TEXT_UPDATED, tw->GetId());
commandEvent.SetEventObject(tw); commandEvent.SetEventObject(tw);
tw->ProcessCommand(commandEvent); tw->ProcessCommand(commandEvent);
} }
return; return;
} }
// Pasting operation: let it through without // Pasting operation: let it through without
// calling OnChar // calling OnChar
if (cbs->text->length > 1) if (cbs->text->length > 1)
return; return;
// Something other than text // Something other than text
if (cbs->text->ptr == NULL) if (cbs->text->ptr == NULL)
return; return;
tw->m_tempCallbackStruct = (void*) cbs; tw->m_tempCallbackStruct = (void*) cbs;
wxKeyEvent event (wxEVT_CHAR); wxKeyEvent event (wxEVT_CHAR);
event.SetId(tw->GetId()); event.SetId(tw->GetId());
event.SetEventObject(tw); event.SetEventObject(tw);
event.m_keyCode = (cbs->text->ptr[0] == 10 ? 13 : cbs->text->ptr[0]); event.m_keyCode = (cbs->text->ptr[0] == 10 ? 13 : cbs->text->ptr[0]);
// Only if wxTextCtrl::OnChar is called // Only if wxTextCtrl::OnChar is called
// will this be set to True (and the character // will this be set to True (and the character
// passed through) // passed through)
cbs->doit = False; cbs->doit = False;
tw->GetEventHandler()->ProcessEvent(event); tw->GetEventHandler()->ProcessEvent(event);
tw->m_tempCallbackStruct = NULL; tw->m_tempCallbackStruct = NULL;
if (tw->InSetValue()) if (tw->InSetValue())
return; return;
@@ -850,49 +850,49 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
static void static void
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs) wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
{ {
if (!wxGetWindowFromTable(w)) if (!wxGetWindowFromTable(w))
return; return;
wxTextCtrl *tw = (wxTextCtrl *) clientData; wxTextCtrl *tw = (wxTextCtrl *) clientData;
wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId()); wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
event.SetEventObject(tw); event.SetEventObject(tw);
tw->GetEventHandler()->ProcessEvent(event); tw->GetEventHandler()->ProcessEvent(event);
} }
static void static void
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs) wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
{ {
if (!wxGetWindowFromTable(w)) if (!wxGetWindowFromTable(w))
return; return;
wxTextCtrl *tw = (wxTextCtrl *) clientData; wxTextCtrl *tw = (wxTextCtrl *) clientData;
wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId()); wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
event.SetEventObject(tw); event.SetEventObject(tw);
tw->GetEventHandler()->ProcessEvent(event); tw->GetEventHandler()->ProcessEvent(event);
} }
static void wxTextWindowActivateProc(Widget w, XtPointer clientData, static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
XmAnyCallbackStruct *ptr) XmAnyCallbackStruct *ptr)
{ {
if (!wxGetWindowFromTable(w)) if (!wxGetWindowFromTable(w))
return; return;
wxTextCtrl *tw = (wxTextCtrl *) clientData; wxTextCtrl *tw = (wxTextCtrl *) clientData;
/* /*
case XmCR_ACTIVATE: case XmCR_ACTIVATE:
type_event = wxEVENT_TYPE_TEXT_ENTER_COMMAND ; type_event = wxEVENT_TYPE_TEXT_ENTER_COMMAND ;
break; break;
default: default:
type_event = wxEVENT_TYPE_TEXT_COMMAND ; type_event = wxEVENT_TYPE_TEXT_COMMAND ;
break; break;
} }
*/ */
if (tw->InSetValue())
return;
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER); if (tw->InSetValue())
event.SetId(tw->GetId()); return;
event.SetEventObject(tw);
tw->ProcessCommand(event); wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
event.SetId(tw->GetId());
event.SetEventObject(tw);
tw->ProcessCommand(event);
} }

File diff suppressed because it is too large Load Diff

View File

@@ -53,15 +53,15 @@
#endif #endif
#ifdef __SVR4__ #ifdef __SVR4__
#include <sys/systeminfo.h> #include <sys/systeminfo.h>
#endif #endif
#ifdef __SOLARIS__ #ifdef __SOLARIS__
// somehow missing from sys/wait.h but in the system's docs // somehow missing from sys/wait.h but in the system's docs
extern "C" extern "C"
{ {
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
*rusage); *rusage);
} }
#endif #endif
@@ -72,146 +72,146 @@ extern "C"
struct wxLocalProcessData struct wxLocalProcessData
{ {
int pid, end_process; int pid, end_process;
wxProcess *process; wxProcess *process;
}; };
#ifdef __SOLARIS__ #ifdef __SOLARIS__
// somehow missing from sys/wait.h but in the system's docs // somehow missing from sys/wait.h but in the system's docs
extern "C" extern "C"
{ {
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
*rusage); *rusage);
} }
#endif #endif
void xt_notify_end_process(XtPointer client, int *fid, void xt_notify_end_process(XtPointer client, int *fid,
XtInputId *id) XtInputId *id)
{ {
wxLocalProcessData *process_data = (wxLocalProcessData *)client; wxLocalProcessData *process_data = (wxLocalProcessData *)client;
int pid; int pid;
pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid); pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid);
/* wait4 is not part of any standard, use at own risk /* 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 ;-) * not sure what wait4 does, but wait3 seems to be closest, whats a digit ;-)
* --- offer@sgi.com */ * --- offer@sgi.com */
#if !defined(__sgi) && !defined(__SGI__) && !defined(__ALPHA__) && !defined(__SUNCC__) #if !defined(__sgi) && !defined(__SGI__) && !defined(__ALPHA__) && !defined(__SUNCC__)
wait4(process_data->pid, NULL, 0, NULL); wait4(process_data->pid, NULL, 0, NULL);
#else #else
wait3((int *) NULL, 0, (rusage *) NULL); wait3((int *) NULL, 0, (rusage *) NULL);
#endif #endif
XtRemoveInput(*id); XtRemoveInput(*id);
if (process_data->process) if (process_data->process)
process_data->process->OnTerminate(process_data->pid); process_data->process->OnTerminate(process_data->pid);
process_data->end_process = TRUE; process_data->end_process = TRUE;
if (process_data->pid > 0) if (process_data->pid > 0)
delete process_data; delete process_data;
else else
process_data->pid = 0; process_data->pid = 0;
} }
long wxExecute(char **argv, bool sync, wxProcess *handler) long wxExecute(char **argv, bool sync, wxProcess *handler)
{ {
#ifdef VMS #ifdef VMS
return(0); return(0);
#else #else
if (*argv == NULL) if (*argv == NULL)
return 0; // Nothing??? return 0; // Nothing???
int proc_link[2]; int proc_link[2];
if (pipe(proc_link)) if (pipe(proc_link))
return 0; return 0;
/* fork the process */ /* fork the process */
#if defined(sun) || defined(__ultrix) || defined(__bsdi__) #if defined(sun) || defined(__ultrix) || defined(__bsdi__)
pid_t pid = vfork (); pid_t pid = vfork ();
#else #else
pid_t pid = fork (); pid_t pid = fork ();
#endif #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 */ /* GUILHEM: Close all fds when sync == 0 */
if (sync == 0) if (sync == 0)
for (int fd=0;fd<FD_SETSIZE;fd++) { for (int fd=0;fd<FD_SETSIZE;fd++) {
if (proc_link[1] != fd) if (proc_link[1] != fd)
close(fd); close(fd);
} }
/* child */ /* child */
#ifdef _AIX #ifdef _AIX
execvp ((const char *)*argv, (const char **)argv); execvp ((const char *)*argv, (const char **)argv);
#else #else
execvp (*argv, argv); execvp (*argv, argv);
#endif #endif
/* GUILHEM: Reopen output stream */ /* GUILHEM: Reopen output stream */
// open("/dev/console", O_WRONLY); // open("/dev/console", O_WRONLY);
/* GUILHEM: End */ /* GUILHEM: End */
if (errno == ENOENT) if (errno == ENOENT)
printf ("%s: command not found\n", *argv); printf ("%s: command not found\n", *argv);
else else
perror (*argv); perror (*argv);
printf ("wxWindows: could not execute '%s'\n", *argv); printf ("wxWindows: could not execute '%s'\n", *argv);
_exit (-1); _exit (-1);
} }
wxLocalProcessData *process_data = new wxLocalProcessData; wxLocalProcessData *process_data = new wxLocalProcessData;
process_data->end_process = 0; process_data->end_process = 0;
process_data->process = handler; process_data->process = handler;
process_data->pid = (sync) ? pid : -pid; process_data->pid = (sync) ? pid : -pid;
close(proc_link[1]); close(proc_link[1]);
XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0], XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0],
(XtPointer *) XtInputReadMask, (XtPointer *) XtInputReadMask,
(XtInputCallbackProc) xt_notify_end_process, (XtInputCallbackProc) xt_notify_end_process,
(XtPointer) process_data); (XtPointer) process_data);
if (sync) { if (sync) {
while (!process_data->end_process) while (!process_data->end_process)
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll); XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
if (WIFEXITED(process_data->end_process) != 0) if (WIFEXITED(process_data->end_process) != 0)
return WEXITSTATUS(process_data->end_process); return WEXITSTATUS(process_data->end_process);
} }
delete process_data; delete process_data;
return pid; return pid;
#endif #endif
// end VMS // end VMS
} }
long wxExecute (const wxString& command, bool sync, wxProcess* handler) long wxExecute (const wxString& command, bool sync, wxProcess* handler)
{ {
#ifdef VMS #ifdef VMS
return(0); return(0);
#else #else
if (command.IsNull() || command == "") if (command.IsNull() || command == "")
return 0; // Nothing to do return 0; // Nothing to do
// Run a program the recomended way under X (XView) // Run a program the recomended way under X (XView)
int argc = 0; int argc = 0;
char *argv[127]; char *argv[127];
char tmp[1024]; char tmp[1024];
const char *IFS = " \t\n"; const char *IFS = " \t\n";
// Build argument vector // Build argument vector
strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1); strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1);
tmp[sizeof (tmp) / sizeof (char) - 1] = '\0'; tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
argv[argc++] = strtok (tmp, IFS); argv[argc++] = strtok (tmp, IFS);
while ((argv[argc++] = strtok (NULL, IFS)) != NULL) while ((argv[argc++] = strtok (NULL, IFS)) != NULL)
/* loop */ ; /* loop */ ;
return wxExecute(argv, sync, handler); return wxExecute(argv, sync, handler);
#endif #endif
// VMS // VMS
} }

File diff suppressed because it is too large Load Diff

View File

@@ -323,10 +323,6 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int max
return (::GetClipboardFormatName((int) dataFormat, formatName, maxCount) > 0); return (::GetClipboardFormatName((int) dataFormat, formatName, maxCount) > 0);
} }
/*
* wxClipboard
*/
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxClipboard // wxClipboard
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------