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:
@@ -41,10 +41,6 @@ High Priority
|
||||
|
||||
- Get wxGLCanvas from 1.68 working.
|
||||
|
||||
- wxClipboard
|
||||
|
||||
- EVT_KEY_DOWN, EVT_KEY_UP events.
|
||||
|
||||
Low Priority
|
||||
------------
|
||||
|
||||
|
@@ -16,6 +16,8 @@ Please see also:
|
||||
|
||||
- Documentation: mention include files with each class.
|
||||
|
||||
- Document wxTime.
|
||||
|
||||
- Get Karsten to remove trashed CVS files:
|
||||
|
||||
include/wx/msw/magnif1.cur
|
||||
|
@@ -4,7 +4,7 @@
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/ole/dataobj.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/dnd.h"
|
||||
#include "wx/motif/dataobj.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/dataobj.h"
|
||||
#elif defined(__WXQT__)
|
||||
|
@@ -23,17 +23,77 @@
|
||||
#include "wx/setup.h"
|
||||
|
||||
#include "wx/list.h"
|
||||
#include "wx/module.h"
|
||||
|
||||
bool WXDLLEXPORT wxOpenClipboard();
|
||||
bool WXDLLEXPORT wxClipboardOpen();
|
||||
bool WXDLLEXPORT wxCloseClipboard();
|
||||
bool WXDLLEXPORT wxEmptyClipboard();
|
||||
bool WXDLLEXPORT wxIsClipboardFormatAvailable(int dataFormat);
|
||||
bool WXDLLEXPORT wxSetClipboardData(int dataFormat, wxObject *obj, int width = 0, int height = 0);
|
||||
wxObject* WXDLLEXPORT wxGetClipboardData(int dataFormat, long *len = NULL);
|
||||
int WXDLLEXPORT wxEnumClipboardFormats(int dataFormat);
|
||||
int WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
|
||||
bool WXDLLEXPORT wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount);
|
||||
bool WXDLLEXPORT wxIsClipboardFormatAvailable(wxDataFormat dataFormat);
|
||||
bool WXDLLEXPORT wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width = 0, int height = 0);
|
||||
wxObject* WXDLLEXPORT wxGetClipboardData(wxDataFormat dataFormat, long *len = NULL);
|
||||
wxDataFormat WXDLLEXPORT wxEnumClipboardFormats(wxDataFormat dataFormat);
|
||||
wxDataFormat WXDLLEXPORT wxRegisterClipboardFormat(char *formatName);
|
||||
bool WXDLLEXPORT wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount);
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClipboard
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDataObject;
|
||||
class WXDLLEXPORT wxClipboard: public wxObject
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxClipboard)
|
||||
|
||||
public:
|
||||
|
||||
wxClipboard();
|
||||
~wxClipboard();
|
||||
|
||||
// open the clipboard before SetData() and GetData()
|
||||
virtual bool Open();
|
||||
|
||||
// close the clipboard after SetData() and GetData()
|
||||
virtual void Close();
|
||||
|
||||
// can be called several times
|
||||
virtual bool SetData( wxDataObject *data );
|
||||
|
||||
// format available on the clipboard ?
|
||||
// supply ID if private format, the same as wxPrivateDataObject::SetId()
|
||||
virtual bool IsSupportedFormat( wxDataFormat format, const wxString &id = wxEmptyString );
|
||||
|
||||
// fill data with data on the clipboard (if available)
|
||||
virtual bool GetData( wxDataObject *data );
|
||||
|
||||
// clears wxTheClipboard and the system's clipboard if possible
|
||||
virtual void Clear();
|
||||
|
||||
// implementation
|
||||
|
||||
bool m_open;
|
||||
wxList m_data;
|
||||
};
|
||||
|
||||
/* The clipboard */
|
||||
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClipboardModule
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxClipboardModule: public wxModule
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxClipboardModule)
|
||||
|
||||
public:
|
||||
wxClipboardModule() {}
|
||||
bool OnInit();
|
||||
void OnExit();
|
||||
};
|
||||
|
||||
// This is the old, 1.68 implementation
|
||||
#if 0
|
||||
|
||||
/* A clipboard client holds data belonging to the clipboard.
|
||||
For plain text, a client is not necessary. */
|
||||
@@ -100,5 +160,8 @@ void WXDLLEXPORT wxInitClipboard();
|
||||
/* The clipboard */
|
||||
WXDLLEXPORT_DATA(extern wxClipboard*) wxTheClipboard;
|
||||
|
||||
#endif
|
||||
// Old clipboard class
|
||||
|
||||
#endif
|
||||
// _WX_CLIPBRD_H_
|
||||
|
@@ -1,22 +1,27 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dnd.h
|
||||
// Purpose: Declaration of the wxDropTarget, wxDropSource class etc.
|
||||
// Purpose: declaration of wxDropTarget, wxDropSource classes
|
||||
// Author: Julian Smart
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#ifndef _WX_DND_H_
|
||||
#define _WX_DND_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "dnd.h"
|
||||
#pragma interface
|
||||
#endif
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/string.h"
|
||||
#include "wx/dataobj.h"
|
||||
#include "wx/cursor.h"
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -25,119 +30,13 @@
|
||||
|
||||
class WXDLLEXPORT wxWindow;
|
||||
|
||||
class WXDLLEXPORT wxDataObject;
|
||||
class WXDLLEXPORT wxTextDataObject;
|
||||
class WXDLLEXPORT wxFileDataObject;
|
||||
|
||||
class WXDLLEXPORT wxDropTarget;
|
||||
class WXDLLEXPORT wxTextDropTarget;
|
||||
class WXDLLEXPORT wxFileDropTarget;
|
||||
class WXDLLEXPORT wxPrivateDropTarget;
|
||||
|
||||
class WXDLLEXPORT wxDropSource;
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDataObject
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxDataObject: public wxObject
|
||||
{
|
||||
public:
|
||||
// all data formats (values are the same as in windows.h, do not change!)
|
||||
enum StdFormat
|
||||
{
|
||||
Invalid,
|
||||
Text,
|
||||
Bitmap,
|
||||
MetafilePict,
|
||||
Sylk,
|
||||
Dif,
|
||||
Tiff,
|
||||
OemText,
|
||||
Dib,
|
||||
Palette,
|
||||
Pendata,
|
||||
Riff,
|
||||
Wave,
|
||||
UnicodeText,
|
||||
EnhMetafile,
|
||||
Hdrop,
|
||||
Locale,
|
||||
Max
|
||||
};
|
||||
|
||||
// function to return symbolic name of clipboard format (debug messages)
|
||||
static const char *GetFormatName(wxDataFormat format);
|
||||
|
||||
// ctor & dtor
|
||||
wxDataObject() {};
|
||||
~wxDataObject() {};
|
||||
|
||||
// pure virtuals to override
|
||||
// get the best suited format for our data
|
||||
virtual wxDataFormat GetPreferredFormat() const = 0;
|
||||
// decide if we support this format (should be one of values of
|
||||
// StdFormat enumerations or a user-defined format)
|
||||
virtual bool IsSupportedFormat(wxDataFormat format) const = 0;
|
||||
// get the (total) size of data
|
||||
virtual size_t GetDataSize() const = 0;
|
||||
// copy raw data to provided pointer
|
||||
virtual void GetDataHere(void *pBuf) const = 0;
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextDataObject is a specialization of wxDataObject for text data
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxTextDataObject : public wxDataObject
|
||||
{
|
||||
public:
|
||||
// ctors
|
||||
wxTextDataObject() { }
|
||||
wxTextDataObject(const wxString& strText) : m_strText(strText) { }
|
||||
void Init(const wxString& strText) { m_strText = strText; }
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual wxDataFormat GetPreferredFormat() const
|
||||
{ return wxDF_TEXT; }
|
||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||
{ return format == wxDF_TEXT; }
|
||||
virtual size_t GetDataSize() const
|
||||
{ return m_strText.Len() + 1; } // +1 for trailing '\0'of course
|
||||
virtual void GetDataHere(void *pBuf) const
|
||||
{ memcpy(pBuf, m_strText.c_str(), GetDataSize()); }
|
||||
|
||||
private:
|
||||
wxString m_strText;
|
||||
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFileDataObject is a specialization of wxDataObject for file names
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxFileDataObject : public wxDataObject
|
||||
{
|
||||
public:
|
||||
|
||||
wxFileDataObject(void) { }
|
||||
void AddFile( const wxString &file )
|
||||
{ m_files += file; m_files += ";"; }
|
||||
|
||||
// implement base class pure virtuals
|
||||
virtual wxDataFormat GetPreferredFormat() const
|
||||
{ return wxDF_FILENAME; }
|
||||
virtual bool IsSupportedFormat(wxDataFormat format) const
|
||||
{ return format == wxDF_FILENAME; }
|
||||
virtual size_t GetDataSize() const
|
||||
{ return m_files.Len() + 1; } // +1 for trailing '\0'of course
|
||||
virtual void GetDataHere(void *pBuf) const
|
||||
{ memcpy(pBuf, m_files.c_str(), GetDataSize()); }
|
||||
|
||||
private:
|
||||
wxString m_files;
|
||||
|
||||
};
|
||||
//-------------------------------------------------------------------------
|
||||
// wxDropTarget
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -151,16 +50,14 @@ class WXDLLEXPORT wxDropTarget: public wxObject
|
||||
|
||||
virtual void OnEnter() { }
|
||||
virtual void OnLeave() { }
|
||||
virtual bool OnDrop( long x, long y, const void *pData ) = 0;
|
||||
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
|
||||
|
||||
// protected:
|
||||
|
||||
friend wxWindow;
|
||||
|
||||
// Override these to indicate what kind of data you support:
|
||||
|
||||
virtual size_t GetFormatCount() const = 0;
|
||||
virtual wxDataFormat GetFormat(size_t n) const = 0;
|
||||
|
||||
// implementation
|
||||
};
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
@@ -172,7 +69,7 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
|
||||
public:
|
||||
|
||||
wxTextDropTarget() {};
|
||||
virtual bool OnDrop( long x, long y, const void *pData );
|
||||
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
||||
virtual bool OnDropText( long x, long y, const char *psz );
|
||||
|
||||
protected:
|
||||
@@ -181,6 +78,36 @@ class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
|
||||
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)
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -191,9 +118,9 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
|
||||
|
||||
wxFileDropTarget() {};
|
||||
|
||||
virtual bool OnDrop(long x, long y, const void *pData);
|
||||
virtual bool OnDrop( long x, long y, const void *data, size_t size );
|
||||
virtual bool OnDropFiles( long x, long y,
|
||||
size_t nFiles, const char * const aszFiles[]);
|
||||
size_t nFiles, const char * const aszFiles[] );
|
||||
|
||||
protected:
|
||||
|
||||
@@ -205,14 +132,14 @@ class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
|
||||
// wxDropSource
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
enum wxDragResult
|
||||
{
|
||||
wxDragError, // error prevented the d&d operation from completing
|
||||
wxDragNone, // drag target didn't accept the data
|
||||
wxDragCopy, // the data was successfully copied
|
||||
wxDragMove, // the data was successfully moved
|
||||
wxDragCancel // the operation was cancelled by user (not an error)
|
||||
};
|
||||
enum wxDragResult
|
||||
{
|
||||
wxDragError, // error prevented the d&d operation from completing
|
||||
wxDragNone, // drag target didn't accept the data
|
||||
wxDragCopy, // the data was successfully copied
|
||||
wxDragMove, // the data was successfully moved
|
||||
wxDragCancel // the operation was cancelled by user (not an error)
|
||||
};
|
||||
|
||||
class WXDLLEXPORT wxDropSource: public wxObject
|
||||
{
|
||||
@@ -227,12 +154,25 @@ class WXDLLEXPORT wxDropSource: public wxObject
|
||||
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
|
||||
|
||||
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
|
||||
|
||||
protected:
|
||||
|
||||
// implementation
|
||||
#if 0
|
||||
void RegisterWindow(void);
|
||||
void UnregisterWindow(void);
|
||||
|
||||
wxWindow *m_window;
|
||||
wxDragResult m_retValue;
|
||||
wxDataObject *m_data;
|
||||
|
||||
wxCursor m_defaultCursor;
|
||||
wxCursor m_goaheadCursor;
|
||||
#endif
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
// wxUSE_DRAG_AND_DROP
|
||||
|
||||
#endif
|
||||
//_WX_DND_H_
|
||||
|
||||
|
@@ -418,7 +418,6 @@ public:
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnKeyDown(wxKeyEvent& event);
|
||||
void OnKeyUp(wxKeyEvent& event);
|
||||
void OnChar(wxKeyEvent& event);
|
||||
void OnPaint(wxPaintEvent& event);
|
||||
void OnIdle(wxIdleEvent& event);
|
||||
|
||||
|
@@ -29,7 +29,7 @@ class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
|
||||
public:
|
||||
wxAcceleratorRefData();
|
||||
~wxAcceleratorRefData();
|
||||
|
||||
|
||||
public:
|
||||
int m_count;
|
||||
wxAcceleratorEntry* m_entries;
|
||||
@@ -71,13 +71,13 @@ wxAcceleratorTable::wxAcceleratorTable(int n, wxAcceleratorEntry entries[])
|
||||
{
|
||||
wxAcceleratorRefData* data = new wxAcceleratorRefData;
|
||||
m_refData = data;
|
||||
|
||||
|
||||
data->m_count = n;
|
||||
data->m_entries = new wxAcceleratorEntry[n];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
data->m_entries[i] = entries[i];
|
||||
|
||||
|
||||
}
|
||||
|
||||
bool wxAcceleratorTable::Ok() const
|
||||
@@ -102,17 +102,17 @@ bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
|
||||
bool eventCtrlDown = event.ControlDown();
|
||||
bool eventShiftDown = event.ShiftDown();
|
||||
int eventKeyCode = event.KeyCode();
|
||||
|
||||
|
||||
bool accAltDown = ((GetFlags() & wxACCEL_ALT) == wxACCEL_ALT);
|
||||
bool accCtrlDown = ((GetFlags() & wxACCEL_CTRL) == wxACCEL_CTRL);
|
||||
bool accShiftDown = ((GetFlags() & wxACCEL_SHIFT) == wxACCEL_SHIFT);
|
||||
int accKeyCode = GetKeyCode();
|
||||
int accKeyCode2 = GetKeyCode();
|
||||
if (isascii(accKeyCode2))
|
||||
accKeyCode2 = wxToLower(accKeyCode2);
|
||||
|
||||
accKeyCode2 = wxToLower(accKeyCode2);
|
||||
|
||||
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
|
||||
(eventShiftDown == accShiftDown) &&
|
||||
((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
|
||||
(eventShiftDown == accShiftDown) &&
|
||||
((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
|
||||
}
|
||||
|
||||
|
@@ -57,7 +57,7 @@ wxHashTable *wxWidgetHashTable = NULL;
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
|
||||
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
EVT_IDLE(wxApp::OnIdle)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
@@ -70,35 +70,35 @@ bool wxApp::Initialize()
|
||||
#else
|
||||
wxBuffer = new char[BUFSIZ + 512];
|
||||
#endif
|
||||
|
||||
|
||||
wxClassInfo::InitializeClasses();
|
||||
|
||||
|
||||
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
|
||||
wxTheColourDatabase->Initialize();
|
||||
|
||||
|
||||
wxInitializeStockLists();
|
||||
wxInitializeStockObjects();
|
||||
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
wxInitializeResourceSystem();
|
||||
#endif
|
||||
|
||||
// For PostScript printing
|
||||
|
||||
// For PostScript printing
|
||||
#if wxUSE_POSTSCRIPT
|
||||
/* Done using wxModule now
|
||||
/* Done using wxModule now
|
||||
wxInitializePrintSetupData();
|
||||
wxThePrintPaperDatabase = new wxPrintPaperDatabase;
|
||||
wxThePrintPaperDatabase->CreateDatabase();
|
||||
*/
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
wxBitmap::InitStandardHandlers();
|
||||
|
||||
|
||||
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
|
||||
|
||||
|
||||
wxModule::RegisterModules();
|
||||
if (!wxModule::InitializeModules()) return FALSE;
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -106,50 +106,50 @@ void wxApp::CleanUp()
|
||||
{
|
||||
delete wxWidgetHashTable;
|
||||
wxWidgetHashTable = NULL;
|
||||
|
||||
|
||||
wxModule::CleanUpModules();
|
||||
|
||||
|
||||
#if wxUSE_WX_RESOURCES
|
||||
wxCleanUpResourceSystem();
|
||||
#endif
|
||||
|
||||
|
||||
wxDeleteStockObjects() ;
|
||||
|
||||
|
||||
// Destroy all GDI lists, etc.
|
||||
|
||||
|
||||
delete wxTheBrushList;
|
||||
wxTheBrushList = NULL;
|
||||
|
||||
|
||||
delete wxThePenList;
|
||||
wxThePenList = NULL;
|
||||
|
||||
|
||||
delete wxTheFontList;
|
||||
wxTheFontList = NULL;
|
||||
|
||||
|
||||
delete wxTheBitmapList;
|
||||
wxTheBitmapList = NULL;
|
||||
|
||||
|
||||
delete wxTheColourDatabase;
|
||||
wxTheColourDatabase = NULL;
|
||||
|
||||
|
||||
#if wxUSE_POSTSCRIPT
|
||||
/* Done using wxModule now
|
||||
/* Done using wxModule now
|
||||
wxInitializePrintSetupData(FALSE);
|
||||
delete wxThePrintPaperDatabase;
|
||||
wxThePrintPaperDatabase = NULL;
|
||||
*/
|
||||
*/
|
||||
#endif
|
||||
|
||||
|
||||
wxBitmap::CleanUpHandlers();
|
||||
|
||||
|
||||
delete[] wxBuffer;
|
||||
wxBuffer = NULL;
|
||||
|
||||
|
||||
wxClassInfo::CleanUpClasses();
|
||||
|
||||
|
||||
delete wxTheApp;
|
||||
wxTheApp = NULL;
|
||||
|
||||
|
||||
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
|
||||
// At this point we want to check if there are any memory
|
||||
// blocks that aren't part of the wxDebugContext itself,
|
||||
@@ -157,12 +157,12 @@ void wxApp::CleanUp()
|
||||
// wxDebugContext, too.
|
||||
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
|
||||
{
|
||||
wxLogDebug("There were memory leaks.\n");
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
wxLogDebug("There were memory leaks.\n");
|
||||
wxDebugContext::Dump();
|
||||
wxDebugContext::PrintStatistics();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// do it as the very last thing because everything else can log messages
|
||||
wxLog::DontCreateOnDemand();
|
||||
// do it as the very last thing because everything else can log messages
|
||||
@@ -180,66 +180,66 @@ int wxEntry( int argc, char *argv[] )
|
||||
// checked, but this is a reasonable compromise.
|
||||
wxDebugContext::SetCheckpoint();
|
||||
#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)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
if (!wxApp::GetInitializerFunction())
|
||||
{
|
||||
printf( "wxWindows error: No initializer - use IMPLEMENT_APP macro.\n" );
|
||||
return 0;
|
||||
};
|
||||
|
||||
wxTheApp = (wxApp*) (* wxApp::GetInitializerFunction()) ();
|
||||
};
|
||||
|
||||
|
||||
if (!wxTheApp)
|
||||
{
|
||||
printf( "wxWindows error: wxTheApp == NULL\n" );
|
||||
return 0;
|
||||
};
|
||||
|
||||
wxTheApp->SetClassName(wxFileNameFromPath(argv[0]));
|
||||
wxTheApp->SetAppName(wxFileNameFromPath(argv[0]));
|
||||
|
||||
|
||||
wxTheApp->argc = argc;
|
||||
wxTheApp->argv = argv;
|
||||
|
||||
|
||||
// GUI-specific initialization, such as creating an app context.
|
||||
wxTheApp->OnInitGui();
|
||||
|
||||
|
||||
// Here frames insert themselves automatically
|
||||
// into wxTopLevelWindows by getting created
|
||||
// in OnInit().
|
||||
|
||||
|
||||
int retValue = 0;
|
||||
if (wxTheApp->OnInit())
|
||||
{
|
||||
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
||||
if (wxTheApp->Initialized()) retValue = wxTheApp->OnRun();
|
||||
}
|
||||
|
||||
|
||||
// flush the logged messages if any
|
||||
wxLog *pLog = wxLog::GetActiveTarget();
|
||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
||||
pLog->Flush();
|
||||
|
||||
pLog->Flush();
|
||||
|
||||
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
|
||||
// for further messages
|
||||
|
||||
// for further messages
|
||||
|
||||
if (wxTheApp->GetTopWindow())
|
||||
{
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
delete wxTheApp->GetTopWindow();
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
}
|
||||
|
||||
|
||||
wxTheApp->DeletePendingObjects();
|
||||
|
||||
|
||||
wxTheApp->OnExit();
|
||||
|
||||
|
||||
wxApp::CleanUp();
|
||||
|
||||
|
||||
return retValue;
|
||||
};
|
||||
|
||||
@@ -258,7 +258,7 @@ wxApp::wxApp()
|
||||
m_printMode = wxPRINT_POSTSCRIPT;
|
||||
m_exitOnFrameDelete = TRUE;
|
||||
m_auto3D = TRUE;
|
||||
|
||||
|
||||
m_mainColormap = (WXColormap) NULL;
|
||||
m_appContext = (WXAppContext) NULL;
|
||||
m_topLevelWidget = (WXWidget) NULL;
|
||||
@@ -269,50 +269,50 @@ wxApp::wxApp()
|
||||
bool wxApp::Initialized()
|
||||
{
|
||||
if (GetTopWindow())
|
||||
return TRUE;
|
||||
return TRUE;
|
||||
else
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int wxApp::MainLoop()
|
||||
{
|
||||
m_keepGoing = TRUE;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Sit around forever waiting to process X-events. Property Change
|
||||
* event are handled special, because they have to refer to
|
||||
* the root window rather than to a widget. therefore we can't
|
||||
* use an Xt-eventhandler.
|
||||
*/
|
||||
|
||||
|
||||
XSelectInput(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()),
|
||||
XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
|
||||
PropertyChangeMask);
|
||||
|
||||
XDefaultRootWindow(XtDisplay((Widget) wxTheApp->GetTopLevelWidget())),
|
||||
PropertyChangeMask);
|
||||
|
||||
XEvent event;
|
||||
|
||||
|
||||
// Use this flag to allow breaking the loop via wxApp::ExitMainLoop()
|
||||
while (m_keepGoing)
|
||||
{
|
||||
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
|
||||
ProcessXEvent((WXEvent*) & event);
|
||||
|
||||
if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
|
||||
{
|
||||
if (!ProcessIdle())
|
||||
{
|
||||
// TODO: Robert, what's this for?
|
||||
XtAppNextEvent( (XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
|
||||
ProcessXEvent((WXEvent*) & event);
|
||||
|
||||
if (XtAppPending( (XtAppContext) wxTheApp->GetAppContext() ) == 0)
|
||||
{
|
||||
if (!ProcessIdle())
|
||||
{
|
||||
// TODO: Robert, what's this for?
|
||||
#if wxUSE_THREADS
|
||||
wxMutexGuiLeave();
|
||||
usleep(20);
|
||||
wxMutexGuiEnter();
|
||||
wxMutexGuiLeave();
|
||||
usleep(20);
|
||||
wxMutexGuiEnter();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -320,7 +320,7 @@ int wxApp::MainLoop()
|
||||
void wxApp::ProcessXEvent(WXEvent* _event)
|
||||
{
|
||||
XEvent* event = (XEvent*) _event;
|
||||
|
||||
|
||||
if ((event->type == KeyPress) && CheckForAccelerator(_event))
|
||||
{
|
||||
// Do nothing! We intercepted and processed the event as an accelerator.
|
||||
@@ -333,22 +333,22 @@ void wxApp::ProcessXEvent(WXEvent* _event)
|
||||
}
|
||||
else if (event->type == ResizeRequest)
|
||||
{
|
||||
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
||||
* If resize event, don't resize until the last resize event for this
|
||||
* window is recieved. Prevents flicker as windows are resized.
|
||||
*/
|
||||
|
||||
/* Terry Gitnick <terryg@scientech.com> - 1/21/98
|
||||
* If resize event, don't resize until the last resize event for this
|
||||
* window is recieved. Prevents flicker as windows are resized.
|
||||
*/
|
||||
|
||||
Display *disp = XtDisplay((Widget) wxTheApp->GetTopLevelWidget());
|
||||
Window win = event->xany.window;
|
||||
XEvent report;
|
||||
|
||||
|
||||
// to avoid flicker
|
||||
report = * event;
|
||||
while( XCheckTypedWindowEvent (disp, win, ResizeRequest, &report));
|
||||
|
||||
|
||||
// TODO: when implementing refresh optimization, we can use
|
||||
// XtAddExposureToRegion to expand the window's paint region.
|
||||
|
||||
|
||||
XtDispatchEvent(event);
|
||||
}
|
||||
else
|
||||
@@ -363,7 +363,7 @@ bool wxApp::ProcessIdle()
|
||||
wxIdleEvent event;
|
||||
event.SetEventObject(this);
|
||||
ProcessEvent(event);
|
||||
|
||||
|
||||
return event.MoreRequested();
|
||||
}
|
||||
|
||||
@@ -376,7 +376,7 @@ void wxApp::ExitMainLoop()
|
||||
bool wxApp::Pending()
|
||||
{
|
||||
XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
|
||||
|
||||
|
||||
// Fix by Doug from STI, to prevent a stall if non-X event
|
||||
// is found.
|
||||
return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
|
||||
@@ -385,8 +385,8 @@ bool wxApp::Pending()
|
||||
// Dispatch a message.
|
||||
void wxApp::Dispatch()
|
||||
{
|
||||
// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
XEvent event;
|
||||
XtAppNextEvent((XtAppContext) GetAppContext(), &event);
|
||||
ProcessXEvent((WXEvent*) & event);
|
||||
@@ -403,27 +403,27 @@ void wxApp::HandlePropertyChange(WXEvent *event)
|
||||
void wxApp::OnIdle(wxIdleEvent& event)
|
||||
{
|
||||
static bool inOnIdle = FALSE;
|
||||
|
||||
|
||||
// Avoid recursion (via ProcessEvent default case)
|
||||
if (inOnIdle)
|
||||
return;
|
||||
|
||||
return;
|
||||
|
||||
inOnIdle = TRUE;
|
||||
|
||||
|
||||
// 'Garbage' collection of windows deleted with Close().
|
||||
DeletePendingObjects();
|
||||
|
||||
|
||||
// flush the logged messages if any
|
||||
wxLog *pLog = wxLog::GetActiveTarget();
|
||||
if ( pLog != NULL && pLog->HasPendingMessages() )
|
||||
pLog->Flush();
|
||||
|
||||
pLog->Flush();
|
||||
|
||||
// Send OnIdle events to all windows
|
||||
bool needMore = SendIdleEvents();
|
||||
|
||||
|
||||
if (needMore)
|
||||
event.RequestMore(TRUE);
|
||||
|
||||
event.RequestMore(TRUE);
|
||||
|
||||
inOnIdle = FALSE;
|
||||
}
|
||||
|
||||
@@ -431,15 +431,15 @@ void wxApp::OnIdle(wxIdleEvent& event)
|
||||
bool wxApp::SendIdleEvents()
|
||||
{
|
||||
bool needMore = FALSE;
|
||||
wxNode* node = wxTopLevelWindows.First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = (wxWindow*) node->Data();
|
||||
if (SendIdleEvents(win))
|
||||
wxNode* node = wxTopLevelWindows.First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = (wxWindow*) node->Data();
|
||||
if (SendIdleEvents(win))
|
||||
needMore = TRUE;
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
return needMore;
|
||||
}
|
||||
|
||||
@@ -447,23 +447,23 @@ bool wxApp::SendIdleEvents()
|
||||
bool wxApp::SendIdleEvents(wxWindow* win)
|
||||
{
|
||||
bool needMore = FALSE;
|
||||
|
||||
wxIdleEvent event;
|
||||
event.SetEventObject(win);
|
||||
win->ProcessEvent(event);
|
||||
|
||||
|
||||
wxIdleEvent event;
|
||||
event.SetEventObject(win);
|
||||
win->ProcessEvent(event);
|
||||
|
||||
if (event.MoreRequested())
|
||||
needMore = TRUE;
|
||||
|
||||
wxNode* node = win->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = (wxWindow*) node->Data();
|
||||
if (SendIdleEvents(win))
|
||||
|
||||
wxNode* node = win->GetChildren().First();
|
||||
while (node)
|
||||
{
|
||||
wxWindow* win = (wxWindow*) node->Data();
|
||||
if (SendIdleEvents(win))
|
||||
needMore = TRUE;
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
return needMore ;
|
||||
}
|
||||
|
||||
@@ -472,16 +472,16 @@ void wxApp::DeletePendingObjects()
|
||||
wxNode *node = wxPendingDelete.First();
|
||||
while (node)
|
||||
{
|
||||
wxObject *obj = (wxObject *)node->Data();
|
||||
|
||||
delete obj;
|
||||
|
||||
if (wxPendingDelete.Member(obj))
|
||||
delete node;
|
||||
|
||||
// Deleting one object may have deleted other pending
|
||||
// objects, so start from beginning of list again.
|
||||
node = wxPendingDelete.First();
|
||||
wxObject *obj = (wxObject *)node->Data();
|
||||
|
||||
delete obj;
|
||||
|
||||
if (wxPendingDelete.Member(obj))
|
||||
delete node;
|
||||
|
||||
// Deleting one object may have deleted other pending
|
||||
// objects, so start from beginning of list again.
|
||||
node = wxPendingDelete.First();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -506,46 +506,46 @@ bool wxApp::OnInitGui()
|
||||
XtToolkitInitialize() ;
|
||||
wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ;
|
||||
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
|
||||
(const char*) wxTheApp->GetClassName(), NULL,
|
||||
(const char*) wxTheApp->GetClassName(), NULL,
|
||||
# if XtSpecificationRelease < 5
|
||||
0,(Cardinal*) &argc,argv) ;
|
||||
0,(Cardinal*) &argc,argv) ;
|
||||
# else
|
||||
0,&argc,argv) ;
|
||||
0,&argc,argv) ;
|
||||
# endif
|
||||
if (!dpy) {
|
||||
cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
|
||||
exit(-1);
|
||||
cerr << "wxWindows could not open display for " << wxTheApp->GetClassName() << ": exiting.\n";
|
||||
exit(-1);
|
||||
}
|
||||
m_initialDisplay = (WXDisplay*) dpy;
|
||||
|
||||
|
||||
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
|
||||
applicationShellWidgetClass,dpy,
|
||||
NULL,0) ;
|
||||
|
||||
applicationShellWidgetClass,dpy,
|
||||
NULL,0) ;
|
||||
|
||||
// Add general resize proc
|
||||
XtActionsRec rec;
|
||||
rec.string = "resize";
|
||||
rec.proc = (XtActionProc)wxWidgetResizeProc;
|
||||
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
|
||||
|
||||
|
||||
GetMainColormap(dpy);
|
||||
m_maxRequestSize = XMaxRequestSize((Display*) dpy);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
WXColormap wxApp::GetMainColormap(WXDisplay* display)
|
||||
{
|
||||
if (!display) /* Must be called first with non-NULL display */
|
||||
return m_mainColormap;
|
||||
|
||||
return m_mainColormap;
|
||||
|
||||
Colormap c =
|
||||
DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
|
||||
DefaultScreen((Display*) display)));
|
||||
|
||||
DefaultColormapOfScreen(XScreenOfDisplay((Display*) display,
|
||||
DefaultScreen((Display*) display)));
|
||||
|
||||
if (!m_mainColormap)
|
||||
m_mainColormap = (WXColormap) c;
|
||||
|
||||
m_mainColormap = (WXColormap) c;
|
||||
|
||||
return (WXColormap) c;
|
||||
}
|
||||
|
||||
@@ -559,17 +559,17 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
|
||||
// TODO: should get display for the window, not the current display
|
||||
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), xEvent->xany.window);
|
||||
wxWindow* win = NULL;
|
||||
|
||||
|
||||
// Find the first wxWindow that corresponds to this event window
|
||||
while (widget && !(win = wxGetWindowFromTable(widget)))
|
||||
widget = XtParent(widget);
|
||||
|
||||
|
||||
if (!widget || !win)
|
||||
return FALSE;
|
||||
|
||||
|
||||
wxKeyEvent keyEvent(wxEVT_CHAR);
|
||||
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
|
||||
|
||||
|
||||
// Now we have a wxKeyEvent and we have a wxWindow.
|
||||
// Go up the hierarchy until we find a matching accelerator,
|
||||
// or we get to the top.
|
||||
@@ -588,13 +588,13 @@ void wxExit()
|
||||
{
|
||||
int retValue = 0;
|
||||
if (wxTheApp)
|
||||
retValue = wxTheApp->OnExit();
|
||||
|
||||
retValue = wxTheApp->OnExit();
|
||||
|
||||
wxApp::CleanUp();
|
||||
/*
|
||||
* Exit in some platform-specific way. Not recommended that the app calls this:
|
||||
* only for emergencies.
|
||||
*/
|
||||
* Exit in some platform-specific way. Not recommended that the app calls this:
|
||||
* only for emergencies.
|
||||
*/
|
||||
exit(retValue);
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ void wxExit()
|
||||
bool wxYield()
|
||||
{
|
||||
while (wxTheApp && wxTheApp->Pending())
|
||||
wxTheApp->Dispatch();
|
||||
wxTheApp->Dispatch();
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -36,82 +36,82 @@ wxBitmapButton::wxBitmapButton()
|
||||
}
|
||||
|
||||
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_buttonBitmap = bitmap;
|
||||
m_buttonBitmapOriginal = bitmap;
|
||||
m_buttonBitmapSelected = bitmap;
|
||||
m_buttonBitmapSelectedOriginal = bitmap;
|
||||
|
||||
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
parent->AddChild(this);
|
||||
|
||||
|
||||
m_backgroundColour = parent->GetBackgroundColour() ;
|
||||
m_foregroundColour = parent->GetForegroundColour() ;
|
||||
m_windowStyle = style;
|
||||
m_marginX = 0;
|
||||
m_marginY = 0;
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
int x = pos.x;
|
||||
int y = pos.y;
|
||||
int width = size.x;
|
||||
int height = size.y;
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
if (id == -1)
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
/*
|
||||
* Patch Note (important)
|
||||
* There is no major reason to put a defaultButtonThickness here.
|
||||
* Not requesting it give the ability to put wxButton with a spacing
|
||||
* as small as requested. However, if some button become a DefaultButton,
|
||||
* other buttons are no more aligned -- This is why we set
|
||||
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
|
||||
* in the ::SetDefaultButton method.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Patch Note (important)
|
||||
* There is no major reason to put a defaultButtonThickness here.
|
||||
* Not requesting it give the ability to put wxButton with a spacing
|
||||
* as small as requested. However, if some button become a DefaultButton,
|
||||
* other buttons are no more aligned -- This is why we set
|
||||
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
|
||||
* in the ::SetDefaultButton method.
|
||||
*/
|
||||
Widget buttonWidget = XtVaCreateManagedWidget ("button",
|
||||
|
||||
// Gadget causes problems for default button operation.
|
||||
|
||||
// Gadget causes problems for default button operation.
|
||||
#if wxUSE_GADGETS
|
||||
xmPushButtonGadgetClass, parentWidget,
|
||||
xmPushButtonGadgetClass, parentWidget,
|
||||
#else
|
||||
xmPushButtonWidgetClass, parentWidget,
|
||||
xmPushButtonWidgetClass, parentWidget,
|
||||
#endif
|
||||
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
|
||||
NULL);
|
||||
|
||||
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
|
||||
NULL);
|
||||
|
||||
m_mainWidget = (WXWidget) buttonWidget;
|
||||
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
ChangeBackgroundColour ();
|
||||
|
||||
|
||||
DoSetBitmap();
|
||||
|
||||
|
||||
XtAddCallback (buttonWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxBitmapButton::~wxBitmapButton()
|
||||
{
|
||||
SetBitmapLabel(wxNullBitmap);
|
||||
|
||||
|
||||
if (m_insensPixmap)
|
||||
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()), (Pixmap) m_insensPixmap);
|
||||
}
|
||||
@@ -120,7 +120,7 @@ void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
|
||||
{
|
||||
m_buttonBitmapOriginal = bitmap;
|
||||
m_buttonBitmap = bitmap;
|
||||
|
||||
|
||||
DoSetBitmap();
|
||||
}
|
||||
|
||||
@@ -128,7 +128,7 @@ void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel)
|
||||
{
|
||||
m_buttonBitmapSelected = sel;
|
||||
m_buttonBitmapSelectedOriginal = sel;
|
||||
|
||||
|
||||
DoSetBitmap();
|
||||
};
|
||||
|
||||
@@ -142,7 +142,7 @@ void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled)
|
||||
{
|
||||
m_buttonBitmapDisabled = disabled;
|
||||
m_buttonBitmapDisabledOriginal = disabled;
|
||||
|
||||
|
||||
DoSetBitmap();
|
||||
};
|
||||
|
||||
@@ -153,40 +153,40 @@ void wxBitmapButton::DoSetBitmap()
|
||||
Pixmap pixmap = 0;
|
||||
Pixmap insensPixmap = 0;
|
||||
Pixmap armPixmap = 0;
|
||||
|
||||
|
||||
// Must re-make the bitmap to have its transparent areas drawn
|
||||
// in the current widget background colour.
|
||||
if (m_buttonBitmapOriginal.GetMask())
|
||||
{
|
||||
int backgroundPixel;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
|
||||
NULL);
|
||||
|
||||
NULL);
|
||||
|
||||
wxColour col;
|
||||
col.SetPixel(backgroundPixel);
|
||||
|
||||
|
||||
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapOriginal, col);
|
||||
m_buttonBitmap = newBitmap;
|
||||
|
||||
|
||||
pixmap = (Pixmap) m_buttonBitmap.GetPixmap();
|
||||
}
|
||||
else
|
||||
pixmap = (Pixmap) m_buttonBitmap.GetLabelPixmap(m_mainWidget);
|
||||
|
||||
|
||||
if (m_buttonBitmapDisabledOriginal.Ok())
|
||||
{
|
||||
if (m_buttonBitmapDisabledOriginal.GetMask())
|
||||
{
|
||||
int backgroundPixel;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNbackground, &backgroundPixel,
|
||||
NULL);
|
||||
|
||||
NULL);
|
||||
|
||||
wxColour col;
|
||||
col.SetPixel(backgroundPixel);
|
||||
|
||||
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapDisabledOriginal, col);
|
||||
m_buttonBitmapDisabled = newBitmap;
|
||||
|
||||
|
||||
insensPixmap = (Pixmap) m_buttonBitmapDisabled.GetPixmap();
|
||||
}
|
||||
else
|
||||
@@ -194,7 +194,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
}
|
||||
else
|
||||
insensPixmap = (Pixmap) m_buttonBitmap.GetInsensPixmap(m_mainWidget);
|
||||
|
||||
|
||||
// Now make the bitmap representing the armed state
|
||||
if (m_buttonBitmapSelectedOriginal.Ok())
|
||||
{
|
||||
@@ -202,29 +202,29 @@ void wxBitmapButton::DoSetBitmap()
|
||||
{
|
||||
int backgroundPixel;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNarmColor, &backgroundPixel,
|
||||
NULL);
|
||||
|
||||
NULL);
|
||||
|
||||
wxColour col;
|
||||
col.SetPixel(backgroundPixel);
|
||||
|
||||
wxBitmap newBitmap = wxCreateMaskedBitmap(m_buttonBitmapSelectedOriginal, col);
|
||||
m_buttonBitmapSelected = newBitmap;
|
||||
|
||||
|
||||
armPixmap = (Pixmap) m_buttonBitmapSelected.GetPixmap();
|
||||
}
|
||||
else
|
||||
armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
|
||||
armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
|
||||
}
|
||||
else
|
||||
armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
|
||||
|
||||
armPixmap = (Pixmap) m_buttonBitmap.GetArmPixmap(m_mainWidget);
|
||||
|
||||
if (insensPixmap == pixmap) // <- the Get...Pixmap()-functions return the same pixmap!
|
||||
{
|
||||
insensPixmap =
|
||||
XCreateInsensitivePixmap(DisplayOfScreen(XtScreen((Widget) m_mainWidget)), pixmap);
|
||||
m_insensPixmap = (WXPixmap) insensPixmap;
|
||||
}
|
||||
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNlabelPixmap, pixmap,
|
||||
XmNlabelInsensitivePixmap, insensPixmap,
|
||||
@@ -239,7 +239,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNlabelType, XmSTRING,
|
||||
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
|
||||
XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
|
||||
XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
|
||||
XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
|
||||
NULL);
|
||||
}
|
||||
@@ -248,7 +248,7 @@ void wxBitmapButton::DoSetBitmap()
|
||||
void wxBitmapButton::ChangeBackgroundColour()
|
||||
{
|
||||
DoChangeBackgroundColour(m_mainWidget, m_backgroundColour, TRUE);
|
||||
|
||||
|
||||
// Must reset the bitmaps since the colours have changed.
|
||||
DoSetBitmap();
|
||||
}
|
||||
|
@@ -28,9 +28,9 @@ wxBrushRefData::wxBrushRefData()
|
||||
|
||||
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
||||
{
|
||||
m_style = data.m_style;
|
||||
m_stipple = data.m_stipple;
|
||||
m_colour = data.m_colour;
|
||||
m_style = data.m_style;
|
||||
m_stipple = data.m_stipple;
|
||||
m_colour = data.m_colour;
|
||||
}
|
||||
|
||||
wxBrushRefData::~wxBrushRefData()
|
||||
@@ -53,12 +53,12 @@ wxBrush::~wxBrush()
|
||||
wxBrush::wxBrush(const wxColour& col, int Style)
|
||||
{
|
||||
m_refData = new wxBrushRefData;
|
||||
|
||||
|
||||
M_BRUSHDATA->m_colour = col;
|
||||
M_BRUSHDATA->m_style = Style;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
|
||||
|
||||
if ( wxTheBrushList )
|
||||
wxTheBrushList->AddBrush(this);
|
||||
}
|
||||
@@ -66,64 +66,64 @@ wxBrush::wxBrush(const wxColour& col, int Style)
|
||||
wxBrush::wxBrush(const wxBitmap& stipple)
|
||||
{
|
||||
m_refData = new wxBrushRefData;
|
||||
|
||||
|
||||
M_BRUSHDATA->m_style = wxSTIPPLE;
|
||||
M_BRUSHDATA->m_stipple = stipple;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
|
||||
|
||||
if ( wxTheBrushList )
|
||||
wxTheBrushList->AddBrush(this);
|
||||
}
|
||||
|
||||
void wxBrush::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxBrushRefData();
|
||||
}
|
||||
m_refData = new wxBrushRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(const wxColour& col)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_BRUSHDATA->m_colour = col;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_BRUSHDATA->m_colour.Set(r, g, b);
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetStyle(int Style)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_BRUSHDATA->m_style = Style;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxBrush::SetStipple(const wxBitmap& Stipple)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_BRUSHDATA->m_stipple = Stipple;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
|
@@ -30,10 +30,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
|
||||
// Button
|
||||
|
||||
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
@@ -41,48 +41,48 @@ bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
m_windowFont = parent->GetFont();
|
||||
|
||||
|
||||
parent->AddChild((wxButton *)this);
|
||||
|
||||
|
||||
if (id == -1)
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
|
||||
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
|
||||
|
||||
|
||||
/*
|
||||
* Patch Note (important)
|
||||
* There is no major reason to put a defaultButtonThickness here.
|
||||
* Not requesting it give the ability to put wxButton with a spacing
|
||||
* as small as requested. However, if some button become a DefaultButton,
|
||||
* other buttons are no more aligned -- This is why we set
|
||||
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
|
||||
* in the ::SetDefaultButton method.
|
||||
*/
|
||||
* Patch Note (important)
|
||||
* There is no major reason to put a defaultButtonThickness here.
|
||||
* Not requesting it give the ability to put wxButton with a spacing
|
||||
* as small as requested. However, if some button become a DefaultButton,
|
||||
* other buttons are no more aligned -- This is why we set
|
||||
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
|
||||
* in the ::SetDefaultButton method.
|
||||
*/
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
|
||||
xmPushButtonWidgetClass,
|
||||
parentWidget,
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
|
||||
NULL);
|
||||
|
||||
xmPushButtonWidgetClass,
|
||||
parentWidget,
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
// XmNdefaultButtonShadowThickness, 1, // See comment for wxButton::SetDefault
|
||||
NULL);
|
||||
|
||||
XmStringFree (text);
|
||||
|
||||
|
||||
XtAddCallback ((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -91,33 +91,33 @@ void wxButton::SetDefault()
|
||||
wxWindow *parent = (wxWindow *)GetParent();
|
||||
if (parent)
|
||||
parent->SetDefaultItem(this);
|
||||
|
||||
// We initially do not set XmNdefaultShadowThickness, to have small buttons.
|
||||
// Unfortunately, buttons are now mis-aligned. We try to correct this
|
||||
// now -- setting this ressource to 1 for each button in the same row.
|
||||
// Because it's very hard to find wxButton in the same row,
|
||||
// correction is straighforward: we set resource for all wxButton
|
||||
// in this parent (but not sub panels)
|
||||
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
|
||||
|
||||
// We initially do not set XmNdefaultShadowThickness, to have small buttons.
|
||||
// Unfortunately, buttons are now mis-aligned. We try to correct this
|
||||
// now -- setting this ressource to 1 for each button in the same row.
|
||||
// Because it's very hard to find wxButton in the same row,
|
||||
// correction is straighforward: we set resource for all wxButton
|
||||
// in this parent (but not sub panels)
|
||||
for (wxNode * node = parent->GetChildren().First (); node; node = node->Next ())
|
||||
{
|
||||
wxButton *item = (wxButton *) node->Data ();
|
||||
if (item->IsKindOf(CLASSINFO(wxButton)))
|
||||
{
|
||||
bool managed = XtIsManaged((Widget) item->GetMainWidget());
|
||||
if (managed)
|
||||
XtUnmanageChild ((Widget) item->GetMainWidget());
|
||||
|
||||
XtVaSetValues ((Widget) item->GetMainWidget(),
|
||||
XmNdefaultButtonShadowThickness, 1,
|
||||
NULL);
|
||||
|
||||
if (managed)
|
||||
XtManageChild ((Widget) item->GetMainWidget());
|
||||
}
|
||||
wxButton *item = (wxButton *) node->Data ();
|
||||
if (item->IsKindOf(CLASSINFO(wxButton)))
|
||||
{
|
||||
bool managed = XtIsManaged((Widget) item->GetMainWidget());
|
||||
if (managed)
|
||||
XtUnmanageChild ((Widget) item->GetMainWidget());
|
||||
|
||||
XtVaSetValues ((Widget) item->GetMainWidget(),
|
||||
XmNdefaultButtonShadowThickness, 1,
|
||||
NULL);
|
||||
|
||||
if (managed)
|
||||
XtManageChild ((Widget) item->GetMainWidget());
|
||||
}
|
||||
} // while
|
||||
|
||||
// XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
|
||||
XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
|
||||
|
||||
// XtVaSetValues((Widget)handle, XmNshowAsDefault, 1, NULL);
|
||||
XtVaSetValues ((Widget) parent->GetMainWidget(), XmNdefaultButton, (Widget) GetMainWidget(), NULL);
|
||||
}
|
||||
|
||||
void wxButton::Command (wxCommandEvent & event)
|
||||
@@ -127,14 +127,14 @@ void wxButton::Command (wxCommandEvent & event)
|
||||
|
||||
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
|
||||
{
|
||||
if (!wxGetWindowFromTable(w))
|
||||
// Widget has been deleted!
|
||||
return;
|
||||
|
||||
wxButton *item = (wxButton *) clientData;
|
||||
wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
if (!wxGetWindowFromTable(w))
|
||||
// Widget has been deleted!
|
||||
return;
|
||||
|
||||
wxButton *item = (wxButton *) clientData;
|
||||
wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxButton::ChangeFont(bool keepOriginalSize)
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "wx/motif/private.h"
|
||||
|
||||
void wxCheckBoxCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
XtPointer ptr);
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
|
||||
@@ -32,10 +32,10 @@ IMPLEMENT_DYNAMIC_CLASS(wxBitmapCheckBox, wxCheckBox)
|
||||
|
||||
// Single check box item
|
||||
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
@@ -43,35 +43,35 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
m_windowFont = parent->GetFont();
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
|
||||
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
|
||||
|
||||
|
||||
XmString text = XmStringCreateSimple (label1);
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
|
||||
|
||||
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
|
||||
|
||||
XtAddCallback ((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc) wxCheckBoxCallback,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE);
|
||||
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
return TRUE;
|
||||
}
|
||||
@@ -96,24 +96,24 @@ void wxCheckBox::Command (wxCommandEvent & event)
|
||||
|
||||
// Bitmap checkbox
|
||||
bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
m_windowStyle = style;
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
|
||||
// TODO: Create the bitmap checkbox
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -139,17 +139,17 @@ bool wxBitmapCheckBox::GetValue() const
|
||||
}
|
||||
|
||||
void wxCheckBoxCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
XtPointer ptr)
|
||||
{
|
||||
wxCheckBox *item = (wxCheckBox *) clientData;
|
||||
|
||||
if (item->InSetValue())
|
||||
return;
|
||||
wxCheckBox *item = (wxCheckBox *) clientData;
|
||||
|
||||
wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
|
||||
event.SetInt((int) item->GetValue ());
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
if (item->InSetValue())
|
||||
return;
|
||||
|
||||
wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
|
||||
event.SetInt((int) item->GetValue ());
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxCheckBox::ChangeFont(bool keepOriginalSize)
|
||||
@@ -159,19 +159,19 @@ void wxCheckBox::ChangeFont(bool keepOriginalSize)
|
||||
|
||||
void wxCheckBox::ChangeBackgroundColour()
|
||||
{
|
||||
wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
|
||||
(wxColour*) NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
|
||||
XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
|
||||
XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
|
||||
XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNselectColor, g_itemColors[wxSELE_INDEX].pixel,
|
||||
NULL);
|
||||
wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
|
||||
(wxColour*) NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
|
||||
XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
|
||||
XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
|
||||
XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNselectColor, g_itemColors[wxSELE_INDEX].pixel,
|
||||
NULL);
|
||||
}
|
||||
|
||||
void wxCheckBox::ChangeForegroundColour()
|
||||
|
@@ -24,7 +24,7 @@
|
||||
// ============================================================================
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -50,7 +50,7 @@ wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
|
||||
int nStrings, const wxString choices[],
|
||||
long style, const wxValidator& val,
|
||||
const wxString& name)
|
||||
: wxListBox()
|
||||
: wxListBox()
|
||||
{
|
||||
// TODO: you'll probably need a separate Create instead of using
|
||||
// the wxListBox one as here.
|
||||
|
@@ -29,7 +29,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
|
||||
#endif
|
||||
|
||||
void wxChoiceCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
XtPointer ptr);
|
||||
|
||||
wxChoice::wxChoice()
|
||||
{
|
||||
@@ -41,12 +41,12 @@ wxChoice::wxChoice()
|
||||
}
|
||||
|
||||
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
@@ -56,49 +56,49 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
m_menuWidget = (WXWidget) 0;
|
||||
m_widgetList = (WXWidget*) 0;
|
||||
m_formWidget = (WXWidget) 0;
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
m_windowFont = parent->GetFont();
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
|
||||
xmRowColumnWidgetClass, parentWidget,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNpacking, XmPACK_TIGHT,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
NULL);
|
||||
|
||||
xmRowColumnWidgetClass, parentWidget,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNpacking, XmPACK_TIGHT,
|
||||
XmNorientation, XmHORIZONTAL,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL);
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Create the popup menu
|
||||
*/
|
||||
m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, "choiceMenu", NULL, 0);
|
||||
|
||||
// int i;
|
||||
|
||||
// int i;
|
||||
if (n > 0)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
Append (choices[i]);
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/*
|
||||
* Create button
|
||||
*/
|
||||
Arg args[10];
|
||||
Cardinal argcnt = 0;
|
||||
|
||||
|
||||
XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget);
|
||||
argcnt++;
|
||||
XtSetArg (args[argcnt], XmNmarginWidth, 0);
|
||||
@@ -108,11 +108,11 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT);
|
||||
argcnt++;
|
||||
m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, "choiceButton", args, argcnt);
|
||||
|
||||
|
||||
m_mainWidget = m_buttonWidget;
|
||||
|
||||
|
||||
XtManageChild ((Widget) m_buttonWidget);
|
||||
|
||||
|
||||
// New code from Roland Haenel (roland_haenel@ac.cybercity.de)
|
||||
// Some time ago, I reported a problem with wxChoice-items under
|
||||
// Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems
|
||||
@@ -123,36 +123,36 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
|
||||
XtUnmanageChild (optionLabel);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
|
||||
|
||||
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxChoice::~wxChoice()
|
||||
{
|
||||
// For some reason destroying the menuWidget
|
||||
// can cause crashes on some machines. It will
|
||||
// be deleted implicitly by deleting the parent form
|
||||
// anyway.
|
||||
// XtDestroyWidget (menuWidget);
|
||||
// For some reason destroying the menuWidget
|
||||
// can cause crashes on some machines. It will
|
||||
// be deleted implicitly by deleting the parent form
|
||||
// anyway.
|
||||
// XtDestroyWidget (menuWidget);
|
||||
if (m_widgetList)
|
||||
delete[] m_widgetList;
|
||||
|
||||
|
||||
if (GetMainWidget())
|
||||
{
|
||||
DetachWidget(GetMainWidget()); // Removes event handlers
|
||||
DetachWidget(m_formWidget);
|
||||
|
||||
|
||||
XtDestroyWidget((Widget) m_formWidget);
|
||||
m_formWidget = (WXWidget) 0;
|
||||
|
||||
|
||||
// Presumably the other widgets have been deleted now, via the form
|
||||
m_mainWidget = (WXWidget) 0;
|
||||
m_buttonWidget = (WXWidget) 0;
|
||||
@@ -161,64 +161,64 @@ wxChoice::~wxChoice()
|
||||
|
||||
void wxChoice::Append(const wxString& item)
|
||||
{
|
||||
wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
|
||||
Widget w = XtVaCreateManagedWidget (wxBuffer,
|
||||
wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
|
||||
Widget w = XtVaCreateManagedWidget (wxBuffer,
|
||||
#if USE_GADGETS
|
||||
xmPushButtonGadgetClass, (Widget) m_menuWidget,
|
||||
xmPushButtonGadgetClass, (Widget) m_menuWidget,
|
||||
#else
|
||||
xmPushButtonWidgetClass, (Widget) m_menuWidget,
|
||||
xmPushButtonWidgetClass, (Widget) m_menuWidget,
|
||||
#endif
|
||||
NULL);
|
||||
|
||||
DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
|
||||
|
||||
if (m_windowFont.Ok())
|
||||
XtVaSetValues (w,
|
||||
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
|
||||
NULL);
|
||||
|
||||
WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
|
||||
int i;
|
||||
if (m_widgetList)
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
new_widgetList[i] = m_widgetList[i];
|
||||
|
||||
new_widgetList[m_noStrings] = (WXWidget) w;
|
||||
|
||||
if (m_widgetList)
|
||||
delete[] m_widgetList;
|
||||
m_widgetList = new_widgetList;
|
||||
|
||||
char mnem = wxFindMnemonic ((char*) (const char*) item);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues (w, XmNmnemonic, mnem, NULL);
|
||||
|
||||
XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
|
||||
|
||||
if (m_noStrings == 0 && m_buttonWidget)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
XtVaSetValues (label,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
wxNode *node = m_stringList.Add (item);
|
||||
XtVaSetValues (w, XmNuserData, node->Data (), NULL);
|
||||
|
||||
m_noStrings ++;
|
||||
NULL);
|
||||
|
||||
DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
|
||||
|
||||
if (m_windowFont.Ok())
|
||||
XtVaSetValues (w,
|
||||
XmNfontList, (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
|
||||
NULL);
|
||||
|
||||
WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
|
||||
int i;
|
||||
if (m_widgetList)
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
new_widgetList[i] = m_widgetList[i];
|
||||
|
||||
new_widgetList[m_noStrings] = (WXWidget) w;
|
||||
|
||||
if (m_widgetList)
|
||||
delete[] m_widgetList;
|
||||
m_widgetList = new_widgetList;
|
||||
|
||||
char mnem = wxFindMnemonic ((char*) (const char*) item);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues (w, XmNmnemonic, mnem, NULL);
|
||||
|
||||
XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
|
||||
|
||||
if (m_noStrings == 0 && m_buttonWidget)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
XtVaSetValues (label,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
wxNode *node = m_stringList.Add (item);
|
||||
XtVaSetValues (w, XmNuserData, node->Data (), NULL);
|
||||
|
||||
m_noStrings ++;
|
||||
}
|
||||
|
||||
void wxChoice::Delete(int WXUNUSED(n))
|
||||
{
|
||||
wxFAIL_MSG( "Sorry, wxChoice::Delete isn't implemented yet. Maybe you'd like to volunteer? :-)" );
|
||||
|
||||
|
||||
// What should we do -- remove the callback for this button widget,
|
||||
// delete the m_stringList entry, delete the button widget, construct a new widget list
|
||||
// (see Append)
|
||||
|
||||
|
||||
// TODO
|
||||
m_noStrings --;
|
||||
}
|
||||
@@ -242,59 +242,59 @@ void wxChoice::Clear()
|
||||
|
||||
int wxChoice::GetSelection() const
|
||||
{
|
||||
XmString text;
|
||||
char *s;
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XtVaGetValues (label,
|
||||
XmNlabelString, &text,
|
||||
NULL);
|
||||
|
||||
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
|
||||
{
|
||||
int i = 0;
|
||||
for (wxNode * node = m_stringList.First (); node; node = node->Next ())
|
||||
{
|
||||
char *s1 = (char *) node->Data ();
|
||||
if (s1 == s || strcmp (s1, s) == 0)
|
||||
XmString text;
|
||||
char *s;
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XtVaGetValues (label,
|
||||
XmNlabelString, &text,
|
||||
NULL);
|
||||
|
||||
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
|
||||
{
|
||||
int i = 0;
|
||||
for (wxNode * node = m_stringList.First (); node; node = node->Next ())
|
||||
{
|
||||
XmStringFree(text) ;
|
||||
XtFree (s);
|
||||
return i;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
} // for()
|
||||
|
||||
XmStringFree(text) ;
|
||||
XtFree (s);
|
||||
return -1;
|
||||
}
|
||||
XmStringFree(text) ;
|
||||
return -1;
|
||||
char *s1 = (char *) node->Data ();
|
||||
if (s1 == s || strcmp (s1, s) == 0)
|
||||
{
|
||||
XmStringFree(text) ;
|
||||
XtFree (s);
|
||||
return i;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
} // for()
|
||||
|
||||
XmStringFree(text) ;
|
||||
XtFree (s);
|
||||
return -1;
|
||||
}
|
||||
XmStringFree(text) ;
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxChoice::SetSelection(int n)
|
||||
{
|
||||
m_inSetValue = TRUE;
|
||||
|
||||
wxNode *node = m_stringList.Nth (n);
|
||||
if (node)
|
||||
m_inSetValue = TRUE;
|
||||
|
||||
wxNode *node = m_stringList.Nth (n);
|
||||
if (node)
|
||||
{
|
||||
Dimension selectionWidth, selectionHeight;
|
||||
|
||||
char *s = (char *) node->Data ();
|
||||
XmString text = XmStringCreateSimple (s);
|
||||
XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XtVaSetValues (label,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
XmNwidth, selectionWidth, XmNheight, selectionHeight,
|
||||
XmNmenuHistory, (Widget) m_widgetList[n], NULL);
|
||||
Dimension selectionWidth, selectionHeight;
|
||||
|
||||
char *s = (char *) node->Data ();
|
||||
XmString text = XmStringCreateSimple (s);
|
||||
XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
|
||||
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
|
||||
XtVaSetValues (label,
|
||||
XmNlabelString, text,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
XmNwidth, selectionWidth, XmNheight, selectionHeight,
|
||||
XmNmenuHistory, (Widget) m_widgetList[n], NULL);
|
||||
}
|
||||
m_inSetValue = FALSE;
|
||||
m_inSetValue = FALSE;
|
||||
}
|
||||
|
||||
int wxChoice::FindString(const wxString& s) const
|
||||
@@ -315,55 +315,55 @@ int wxChoice::FindString(const wxString& s) const
|
||||
|
||||
wxString wxChoice::GetString(int n) const
|
||||
{
|
||||
wxNode *node = m_stringList.Nth (n);
|
||||
if (node)
|
||||
return wxString((char *) node->Data ());
|
||||
else
|
||||
return wxEmptyString;
|
||||
wxNode *node = m_stringList.Nth (n);
|
||||
if (node)
|
||||
return wxString((char *) node->Data ());
|
||||
else
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
void wxChoice::SetColumns(int n)
|
||||
{
|
||||
if (n<1) n = 1 ;
|
||||
|
||||
short numColumns = n ;
|
||||
Arg args[3];
|
||||
|
||||
XtSetArg(args[0], XmNnumColumns, numColumns);
|
||||
XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
|
||||
XtSetValues((Widget) m_menuWidget,args,2) ;
|
||||
if (n<1) n = 1 ;
|
||||
|
||||
short numColumns = n ;
|
||||
Arg args[3];
|
||||
|
||||
XtSetArg(args[0], XmNnumColumns, numColumns);
|
||||
XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
|
||||
XtSetValues((Widget) m_menuWidget,args,2) ;
|
||||
}
|
||||
|
||||
int wxChoice::GetColumns(void) const
|
||||
{
|
||||
short numColumns ;
|
||||
|
||||
XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
|
||||
return numColumns ;
|
||||
short numColumns ;
|
||||
|
||||
XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
|
||||
return numColumns ;
|
||||
}
|
||||
|
||||
void wxChoice::SetFocus()
|
||||
{
|
||||
XmProcessTraversal(XtParent((Widget)m_mainWidget), XmTRAVERSE_CURRENT);
|
||||
XmProcessTraversal(XtParent((Widget)m_mainWidget), XmTRAVERSE_CURRENT);
|
||||
}
|
||||
|
||||
void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
|
||||
bool managed = XtIsManaged((Widget) m_formWidget);
|
||||
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild ((Widget) m_formWidget);
|
||||
|
||||
|
||||
int actualWidth = width, actualHeight = height;
|
||||
|
||||
|
||||
if (width > -1)
|
||||
{
|
||||
int i;
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
XtVaSetValues ((Widget) m_widgetList[i], XmNwidth, actualWidth, NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNwidth, actualWidth,
|
||||
NULL);
|
||||
NULL);
|
||||
}
|
||||
if (height > -1)
|
||||
{
|
||||
@@ -371,13 +371,13 @@ void wxChoice::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
XtVaSetValues ((Widget) m_widgetList[i], XmNheight, actualHeight, NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNheight, actualHeight,
|
||||
NULL);
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
if (managed)
|
||||
XtManageChild ((Widget) m_formWidget);
|
||||
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
|
||||
|
||||
|
||||
wxControl::SetSize (x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
@@ -394,10 +394,10 @@ bool wxChoice::SetStringSelection (const wxString& s)
|
||||
{
|
||||
int sel = FindString (s);
|
||||
if (sel > -1)
|
||||
{
|
||||
SetSelection (sel);
|
||||
return TRUE;
|
||||
}
|
||||
{
|
||||
SetSelection (sel);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
@@ -423,7 +423,7 @@ void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
|
||||
wxCommandEvent event (wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
|
||||
event.SetEventObject(item);
|
||||
event.m_commandInt = item->FindString (s);
|
||||
// event.m_commandString = s;
|
||||
// event.m_commandString = s;
|
||||
item->ProcessCommand (event);
|
||||
}
|
||||
}
|
||||
@@ -438,15 +438,15 @@ void wxChoice::ChangeFont(bool keepOriginalSize)
|
||||
{
|
||||
int width, height, width1, height1;
|
||||
GetSize(& width, & height);
|
||||
|
||||
|
||||
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay((Widget) m_mainWidget));
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
|
||||
|
||||
|
||||
/* TODO: why does this cause a crash in XtWidgetToApplicationContext?
|
||||
int i;
|
||||
for (i = 0; i < m_noStrings; i++)
|
||||
XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
|
||||
XtVaSetValues ((Widget) m_widgetList[i], XmNfontList, fontList, NULL);
|
||||
*/
|
||||
GetSize(& width1, & height1);
|
||||
if (keepOriginalSize && (width != width1 || height != height1))
|
||||
|
@@ -20,218 +20,508 @@
|
||||
#include "wx/utils.h"
|
||||
#include "wx/metafile.h"
|
||||
#include "wx/clipbrd.h"
|
||||
#include "wx/dataobj.h"
|
||||
|
||||
#include <Xm/Xm.h>
|
||||
#include <Xm/CutPaste.h>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||
IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
|
||||
// IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
|
||||
// IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
|
||||
#endif
|
||||
|
||||
static bool gs_clipboardIsOpen = FALSE;
|
||||
|
||||
bool wxOpenClipboard()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
if (!gs_clipboardIsOpen)
|
||||
{
|
||||
gs_clipboardIsOpen = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxCloseClipboard()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
if (gs_clipboardIsOpen)
|
||||
{
|
||||
gs_clipboardIsOpen = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxEmptyClipboard()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
// No equivalent in Motif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxClipboardOpen()
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
return gs_clipboardIsOpen;
|
||||
}
|
||||
|
||||
bool wxIsClipboardFormatAvailable(int dataFormat)
|
||||
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
// Only text is supported.
|
||||
if (dataFormat != wxDF_TEXT)
|
||||
return FALSE;
|
||||
|
||||
unsigned long numBytes = 0;
|
||||
long privateId = 0;
|
||||
|
||||
Window window = (Window) 0;
|
||||
if (wxTheApp->GetTopWindow())
|
||||
window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
|
||||
|
||||
int success = XmClipboardRetrieve((Display*) wxGetDisplay(),
|
||||
window, "TEXT", (XtPointer) 0, 0, & numBytes, & privateId) ;
|
||||
|
||||
// Assume only text is supported. If we have anything at all,
|
||||
// or the clipboard is locked so we're not sure, we say we support it.
|
||||
if (success == ClipboardNoData)
|
||||
return FALSE;
|
||||
else
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxSetClipboardData(int dataFormat, wxObject *obj, int width, int height)
|
||||
bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj, int width, int height)
|
||||
{
|
||||
// TODO
|
||||
return FALSE;
|
||||
if (dataFormat != wxDF_TEXT)
|
||||
return FALSE;
|
||||
|
||||
char* data = (char*) obj;
|
||||
|
||||
XmString text = XmStringCreateSimple ("CLIPBOARD");
|
||||
Window window = (Window) 0;
|
||||
if (wxTheApp->GetTopWindow())
|
||||
window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
|
||||
|
||||
long itemId = 0;
|
||||
int result = 0;
|
||||
|
||||
while ((result =
|
||||
XmClipboardStartCopy((Display*) wxGetDisplay(),
|
||||
window,
|
||||
text,
|
||||
XtLastTimestampProcessed((Display*) wxGetDisplay()),
|
||||
(Widget) 0,
|
||||
(XmCutPasteProc) 0,
|
||||
& itemId)) != ClipboardSuccess)
|
||||
|
||||
;
|
||||
|
||||
XmStringFree (text);
|
||||
|
||||
long dataId = 0;
|
||||
while ((result =
|
||||
XmClipboardCopy((Display*) wxGetDisplay(),
|
||||
window,
|
||||
itemId,
|
||||
"TEXT",
|
||||
(XtPointer) data,
|
||||
strlen(data) + 1,
|
||||
0,
|
||||
& dataId)) != ClipboardSuccess)
|
||||
|
||||
;
|
||||
|
||||
while (( result =
|
||||
XmClipboardEndCopy((Display*) wxGetDisplay(),
|
||||
window, itemId) ) != ClipboardSuccess)
|
||||
|
||||
;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
wxObject *wxGetClipboardData(int dataFormat, long *len)
|
||||
wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
|
||||
{
|
||||
// TODO
|
||||
if (dataFormat != wxDF_TEXT)
|
||||
return (wxObject*) NULL;
|
||||
|
||||
bool done = FALSE;
|
||||
long id = 0;
|
||||
unsigned long numBytes = 0;
|
||||
int result = 0;
|
||||
Window window = (Window) 0;
|
||||
if (wxTheApp->GetTopWindow())
|
||||
window = XtWindow( (Widget) wxTheApp->GetTopWindow()->GetTopWidget() );
|
||||
|
||||
int currentDataSize = 256;
|
||||
char* data = new char[currentDataSize];
|
||||
|
||||
while (!done)
|
||||
{
|
||||
if (result == ClipboardTruncate)
|
||||
{
|
||||
delete[] data;
|
||||
currentDataSize = 2*currentDataSize;
|
||||
data = new char[currentDataSize];
|
||||
}
|
||||
result = XmClipboardRetrieve((Display*) wxGetDisplay(),
|
||||
window,
|
||||
"TEXT",
|
||||
(XtPointer) data,
|
||||
currentDataSize,
|
||||
&numBytes,
|
||||
&id);
|
||||
|
||||
switch (result)
|
||||
{
|
||||
case ClipboardSuccess:
|
||||
{
|
||||
if (len)
|
||||
*len = strlen(data) + 1;
|
||||
return (wxObject*) data;
|
||||
break;
|
||||
}
|
||||
case ClipboardTruncate:
|
||||
case ClipboardLocked:
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case ClipboardNoData:
|
||||
{
|
||||
return (wxObject*) NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int wxEnumClipboardFormats(int dataFormat)
|
||||
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
// Only wxDF_TEXT supported
|
||||
if (dataFormat == (wxDataFormat) 0)
|
||||
return wxDF_TEXT;
|
||||
else
|
||||
return (wxDataFormat) 0;
|
||||
}
|
||||
|
||||
int wxRegisterClipboardFormat(char *formatName)
|
||||
wxDataFormat wxRegisterClipboardFormat(char *formatName)
|
||||
{
|
||||
// TODO
|
||||
return 0;
|
||||
// Not supported
|
||||
return (wxDataFormat) 0;
|
||||
}
|
||||
|
||||
bool wxGetClipboardFormatName(int dataFormat, char *formatName, int maxCount)
|
||||
bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int maxCount)
|
||||
{
|
||||
// TODO
|
||||
// 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;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
void wxInitClipboard()
|
||||
{
|
||||
if (!wxTheClipboard)
|
||||
wxTheClipboard = new wxClipboard;
|
||||
if (!wxTheClipboard)
|
||||
wxTheClipboard = new wxClipboard;
|
||||
}
|
||||
|
||||
wxClipboard::wxClipboard()
|
||||
{
|
||||
clipOwner = NULL;
|
||||
cbString = NULL;
|
||||
clipOwner = NULL;
|
||||
cbString = NULL;
|
||||
}
|
||||
|
||||
wxClipboard::~wxClipboard()
|
||||
{
|
||||
if (clipOwner)
|
||||
clipOwner->BeingReplaced();
|
||||
if (cbString)
|
||||
delete[] cbString;
|
||||
if (clipOwner)
|
||||
clipOwner->BeingReplaced();
|
||||
if (cbString)
|
||||
delete[] cbString;
|
||||
}
|
||||
|
||||
static int FormatStringToID(char *str)
|
||||
{
|
||||
if (!strcmp(str, "TEXT"))
|
||||
return wxDF_TEXT;
|
||||
|
||||
return wxRegisterClipboardFormat(str);
|
||||
if (!strcmp(str, "TEXT"))
|
||||
return wxDF_TEXT;
|
||||
|
||||
return wxRegisterClipboardFormat(str);
|
||||
}
|
||||
|
||||
void wxClipboard::SetClipboardClient(wxClipboardClient *client, long time)
|
||||
{
|
||||
bool got_selection;
|
||||
|
||||
if (clipOwner)
|
||||
clipOwner->BeingReplaced();
|
||||
clipOwner = client;
|
||||
if (cbString) {
|
||||
delete[] cbString;
|
||||
cbString = NULL;
|
||||
}
|
||||
|
||||
if (wxOpenClipboard()) {
|
||||
char **formats, *data;
|
||||
int i;
|
||||
int ftype;
|
||||
long size;
|
||||
|
||||
formats = clipOwner->formats.ListToArray(FALSE);
|
||||
for (i = clipOwner->formats.Number(); i--; ) {
|
||||
ftype = FormatStringToID(formats[i]);
|
||||
data = clipOwner->GetData(formats[i], &size);
|
||||
if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
|
||||
got_selection = FALSE;
|
||||
break;
|
||||
}
|
||||
bool got_selection;
|
||||
|
||||
if (clipOwner)
|
||||
clipOwner->BeingReplaced();
|
||||
clipOwner = client;
|
||||
if (cbString) {
|
||||
delete[] cbString;
|
||||
cbString = NULL;
|
||||
}
|
||||
|
||||
if (wxOpenClipboard()) {
|
||||
char **formats, *data;
|
||||
int i;
|
||||
int ftype;
|
||||
long size;
|
||||
|
||||
formats = clipOwner->formats.ListToArray(FALSE);
|
||||
for (i = clipOwner->formats.Number(); i--; ) {
|
||||
ftype = FormatStringToID(formats[i]);
|
||||
data = clipOwner->GetData(formats[i], &size);
|
||||
if (!wxSetClipboardData(ftype, (wxObject *)data, size, 1)) {
|
||||
got_selection = FALSE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i < 0)
|
||||
got_selection = wxCloseClipboard();
|
||||
} else
|
||||
got_selection = FALSE;
|
||||
|
||||
got_selection = FALSE; // Assume another process takes over
|
||||
|
||||
if (!got_selection) {
|
||||
clipOwner->BeingReplaced();
|
||||
clipOwner = NULL;
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
return clipOwner;
|
||||
return clipOwner;
|
||||
}
|
||||
|
||||
void wxClipboard::SetClipboardString(char *str, long time)
|
||||
{
|
||||
bool got_selection;
|
||||
|
||||
if (clipOwner) {
|
||||
clipOwner->BeingReplaced();
|
||||
clipOwner = NULL;
|
||||
}
|
||||
if (cbString)
|
||||
delete[] cbString;
|
||||
|
||||
cbString = str;
|
||||
|
||||
if (wxOpenClipboard()) {
|
||||
if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
|
||||
got_selection = FALSE;
|
||||
else
|
||||
got_selection = wxCloseClipboard();
|
||||
} else
|
||||
got_selection = FALSE;
|
||||
|
||||
got_selection = FALSE; // Assume another process takes over
|
||||
|
||||
if (!got_selection) {
|
||||
delete[] cbString;
|
||||
cbString = NULL;
|
||||
}
|
||||
bool got_selection;
|
||||
|
||||
if (clipOwner) {
|
||||
clipOwner->BeingReplaced();
|
||||
clipOwner = NULL;
|
||||
}
|
||||
if (cbString)
|
||||
delete[] cbString;
|
||||
|
||||
cbString = str;
|
||||
|
||||
if (wxOpenClipboard()) {
|
||||
if (!wxSetClipboardData(wxDF_TEXT, (wxObject *)str))
|
||||
got_selection = FALSE;
|
||||
else
|
||||
got_selection = wxCloseClipboard();
|
||||
} else
|
||||
got_selection = FALSE;
|
||||
|
||||
got_selection = FALSE; // Assume another process takes over
|
||||
|
||||
if (!got_selection) {
|
||||
delete[] cbString;
|
||||
cbString = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
char *wxClipboard::GetClipboardString(long time)
|
||||
{
|
||||
char *str;
|
||||
long length;
|
||||
|
||||
str = GetClipboardData("TEXT", &length, time);
|
||||
if (!str) {
|
||||
str = new char[1];
|
||||
*str = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
char *str;
|
||||
long length;
|
||||
|
||||
str = GetClipboardData("TEXT", &length, time);
|
||||
if (!str) {
|
||||
str = new char[1];
|
||||
*str = 0;
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
char *wxClipboard::GetClipboardData(char *format, long *length, long time)
|
||||
{
|
||||
if (clipOwner) {
|
||||
if (clipOwner->formats.Member(format))
|
||||
return clipOwner->GetData(format, length);
|
||||
else
|
||||
return NULL;
|
||||
} else if (cbString) {
|
||||
if (!strcmp(format, "TEXT"))
|
||||
return copystring(cbString);
|
||||
else
|
||||
return NULL;
|
||||
} else {
|
||||
if (wxOpenClipboard()) {
|
||||
receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
|
||||
length);
|
||||
wxCloseClipboard();
|
||||
} else
|
||||
receivedString = NULL;
|
||||
|
||||
return receivedString;
|
||||
}
|
||||
if (clipOwner) {
|
||||
if (clipOwner->formats.Member(format))
|
||||
return clipOwner->GetData(format, length);
|
||||
else
|
||||
return NULL;
|
||||
} else if (cbString) {
|
||||
if (!strcmp(format, "TEXT"))
|
||||
return copystring(cbString);
|
||||
else
|
||||
return NULL;
|
||||
} else {
|
||||
if (wxOpenClipboard()) {
|
||||
receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
|
||||
length);
|
||||
wxCloseClipboard();
|
||||
} else
|
||||
receivedString = NULL;
|
||||
|
||||
return receivedString;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@@ -57,12 +57,12 @@ wxColour::wxColour (const wxColour& col)
|
||||
|
||||
wxColour& wxColour::operator =(const wxColour& col)
|
||||
{
|
||||
m_red = col.m_red;
|
||||
m_green = col.m_green;
|
||||
m_blue = col.m_blue;
|
||||
m_isInit = col.m_isInit;
|
||||
m_pixel = col.m_pixel;
|
||||
return *this;
|
||||
m_red = col.m_red;
|
||||
m_green = col.m_green;
|
||||
m_blue = col.m_blue;
|
||||
m_isInit = col.m_isInit;
|
||||
m_pixel = col.m_pixel;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void wxColour::InitFromName(const wxString& col)
|
||||
@@ -109,8 +109,8 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
|
||||
int wxColour::AllocColour(WXDisplay* display, bool realloc)
|
||||
{
|
||||
if ((m_pixel != -1) && !realloc)
|
||||
return m_pixel;
|
||||
|
||||
return m_pixel;
|
||||
|
||||
XColor color;
|
||||
color.red = (unsigned short) Red ();
|
||||
color.red |= color.red << 8;
|
||||
@@ -118,20 +118,20 @@ int wxColour::AllocColour(WXDisplay* display, bool realloc)
|
||||
color.green |= color.green << 8;
|
||||
color.blue = (unsigned short) Blue ();
|
||||
color.blue |= color.blue << 8;
|
||||
|
||||
|
||||
color.flags = DoRed | DoGreen | DoBlue;
|
||||
|
||||
|
||||
WXColormap cmap = wxTheApp->GetMainColormap(display);
|
||||
|
||||
|
||||
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
|
||||
{
|
||||
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
|
||||
return m_pixel;
|
||||
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
|
||||
return m_pixel;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pixel = (int) color.pixel;
|
||||
return m_pixel;
|
||||
m_pixel = (int) color.pixel;
|
||||
return m_pixel;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -146,30 +146,30 @@ But in many cases, that is still better than always using black.
|
||||
Chris Breeze <chris@hel.co.uk>
|
||||
Improvements:
|
||||
1) More efficient calculation of RGB distance of colour cell from
|
||||
the desired colour. There is no need to take the sqrt of 'dist', and
|
||||
since we are only interested in the top 8-bits of R, G and B we
|
||||
can perform integer arithmetic.
|
||||
the desired colour. There is no need to take the sqrt of 'dist', and
|
||||
since we are only interested in the top 8-bits of R, G and B we
|
||||
can perform integer arithmetic.
|
||||
2) Attempt to allocate a read-only colour when a close match is found.
|
||||
A read-only colour will not change.
|
||||
A read-only colour will not change.
|
||||
3) Fall back to the closest match if no read-only colours are available.
|
||||
|
||||
Possible further improvements:
|
||||
1) Scan the lookup table and sort the colour cells in order of
|
||||
increasing
|
||||
distance from the desired colour. Then attempt to allocate a
|
||||
read-only
|
||||
colour starting from the nearest match.
|
||||
2) Linear RGB distance is not a particularly good method of colour
|
||||
matching
|
||||
(though it is quick). Converting the colour to HLS and then comparing
|
||||
may give better matching.
|
||||
Possible further improvements:
|
||||
1) Scan the lookup table and sort the colour cells in order of
|
||||
increasing
|
||||
distance from the desired colour. Then attempt to allocate a
|
||||
read-only
|
||||
colour starting from the nearest match.
|
||||
2) Linear RGB distance is not a particularly good method of colour
|
||||
matching
|
||||
(though it is quick). Converting the colour to HLS and then comparing
|
||||
may give better matching.
|
||||
-------------------------------------------*/
|
||||
|
||||
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap)
|
||||
{
|
||||
if (cmap == (Colormap) NULL)
|
||||
cmap = (Colormap) wxTheApp->GetMainColormap(display);
|
||||
|
||||
cmap = (Colormap) wxTheApp->GetMainColormap(display);
|
||||
|
||||
int numPixVals = XDisplayCells(display, DefaultScreen (display));
|
||||
int mindist = 256 * 256 * 3;
|
||||
int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
|
||||
@@ -177,21 +177,21 @@ int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap
|
||||
int green = desiredColor->green >> 8;
|
||||
int blue = desiredColor->blue >> 8;
|
||||
const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B
|
||||
|
||||
|
||||
for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++)
|
||||
{
|
||||
XColor matching_color;
|
||||
matching_color.pixel = pixelcount;
|
||||
XQueryColor(display,cmap,&matching_color);
|
||||
|
||||
|
||||
int delta_red = red - (matching_color.red >> 8);
|
||||
int delta_green = green - (matching_color.green >> 8);
|
||||
int delta_blue = blue - (matching_color.blue >> 8);
|
||||
|
||||
|
||||
int dist = delta_red * delta_red +
|
||||
delta_green * delta_green +
|
||||
delta_blue * delta_blue;
|
||||
|
||||
delta_green * delta_green +
|
||||
delta_blue * delta_blue;
|
||||
|
||||
if (dist <= threshold)
|
||||
{
|
||||
// try to allocate a read-only colour...
|
||||
|
@@ -21,20 +21,20 @@
|
||||
#include "xmcombo/xmcombo.h"
|
||||
|
||||
void wxComboBoxCallback (Widget w, XtPointer clientData,
|
||||
XmComboBoxSelectionCallbackStruct * cbs);
|
||||
XmComboBoxSelectionCallbackStruct * cbs);
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
|
||||
#endif
|
||||
|
||||
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
int n, const wxString choices[],
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
@@ -43,31 +43,31 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
// m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_backgroundColour = * wxWHITE;
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name,
|
||||
xmComboBoxWidgetClass, parentWidget,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNshowLabel, False,
|
||||
XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
|
||||
XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
|
||||
XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
|
||||
NULL);
|
||||
|
||||
xmComboBoxWidgetClass, parentWidget,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNshowLabel, False,
|
||||
XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
|
||||
XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
|
||||
XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
|
||||
NULL);
|
||||
|
||||
XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback,
|
||||
(XtPointer) this);
|
||||
(XtPointer) this);
|
||||
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
@@ -77,21 +77,21 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
|
||||
m_stringList.Add(choices[i]);
|
||||
}
|
||||
m_noStrings = n;
|
||||
|
||||
|
||||
m_mainWidget = (Widget) buttonWidget;
|
||||
|
||||
|
||||
XtManageChild (buttonWidget);
|
||||
|
||||
|
||||
SetValue(value);
|
||||
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ void wxComboBox::Delete(int n)
|
||||
wxNode *node = m_stringList.Nth(n);
|
||||
if (node)
|
||||
{
|
||||
delete[] (char *)node->Data();
|
||||
delete node;
|
||||
delete[] (char *)node->Data();
|
||||
delete node;
|
||||
}
|
||||
m_noStrings--;
|
||||
}
|
||||
@@ -163,20 +163,20 @@ void wxComboBox::SetSelection (int n)
|
||||
|
||||
int wxComboBox::GetSelection (void) const
|
||||
{
|
||||
int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
|
||||
if (sel == 0)
|
||||
return -1;
|
||||
else
|
||||
return sel - 1;
|
||||
int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
|
||||
if (sel == 0)
|
||||
return -1;
|
||||
else
|
||||
return sel - 1;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetString(int n) const
|
||||
{
|
||||
wxNode *node = m_stringList.Nth (n);
|
||||
if (node)
|
||||
return wxString((char *) node->Data ());
|
||||
return wxString((char *) node->Data ());
|
||||
else
|
||||
return wxEmptyString;
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
wxString wxComboBox::GetStringSelection() const
|
||||
@@ -202,22 +202,22 @@ bool wxComboBox::SetStringSelection(const wxString& sel)
|
||||
|
||||
int wxComboBox::FindString(const wxString& s) const
|
||||
{
|
||||
int *pos_list = NULL;
|
||||
int count = 0;
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) s);
|
||||
bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
|
||||
text, &pos_list, &count) != 0);
|
||||
|
||||
XmStringFree(text);
|
||||
|
||||
if (found && count > 0)
|
||||
{
|
||||
int pos = pos_list[0] - 1;
|
||||
free(pos_list);
|
||||
return pos;
|
||||
}
|
||||
|
||||
return -1;
|
||||
int *pos_list = NULL;
|
||||
int count = 0;
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) s);
|
||||
bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
|
||||
text, &pos_list, &count) != 0);
|
||||
|
||||
XmStringFree(text);
|
||||
|
||||
if (found && count > 0)
|
||||
{
|
||||
int pos = pos_list[0] - 1;
|
||||
free(pos_list);
|
||||
return pos;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Clipboard operations
|
||||
@@ -265,7 +265,7 @@ long wxComboBox::GetLastPosition() const
|
||||
void wxComboBox::Replace(long from, long to, const wxString& value)
|
||||
{
|
||||
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
|
||||
(char*) (const char*) value);
|
||||
(char*) (const char*) value);
|
||||
}
|
||||
|
||||
void wxComboBox::Remove(long from, long to)
|
||||
@@ -282,35 +282,35 @@ void wxComboBox::SetSelection(long from, long to)
|
||||
}
|
||||
|
||||
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
|
||||
XmComboBoxSelectionCallbackStruct * cbs)
|
||||
XmComboBoxSelectionCallbackStruct * cbs)
|
||||
{
|
||||
wxComboBox *item = (wxComboBox *) clientData;
|
||||
|
||||
|
||||
switch (cbs->reason)
|
||||
{
|
||||
case XmCR_SINGLE_SELECT:
|
||||
case XmCR_BROWSE_SELECT:
|
||||
case XmCR_SINGLE_SELECT:
|
||||
case XmCR_BROWSE_SELECT:
|
||||
{
|
||||
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId());
|
||||
event.m_commandInt = cbs->index - 1;
|
||||
// event.m_commandString = item->GetString (event.m_commandInt);
|
||||
event.m_extraLong = TRUE;
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
break;
|
||||
event.m_commandInt = cbs->index - 1;
|
||||
// event.m_commandString = item->GetString (event.m_commandInt);
|
||||
event.m_extraLong = TRUE;
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
break;
|
||||
}
|
||||
case XmCR_VALUE_CHANGED:
|
||||
case XmCR_VALUE_CHANGED:
|
||||
{
|
||||
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
|
||||
event.m_commandInt = -1;
|
||||
// event.m_commandString = item->GetValue();
|
||||
event.m_extraLong = TRUE;
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
event.m_commandInt = -1;
|
||||
// event.m_commandString = item->GetValue();
|
||||
event.m_extraLong = TRUE;
|
||||
event.SetEventObject(item);
|
||||
item->ProcessCommand (event);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,14 +51,14 @@ void wxControl::SetLabel(const wxString& label)
|
||||
Widget widget = (Widget) GetLabelWidget() ;
|
||||
if (!widget)
|
||||
return;
|
||||
|
||||
|
||||
wxStripMenuCodes((char*) (const char*) label, wxBuffer);
|
||||
|
||||
|
||||
XmString text = XmStringCreateSimple (wxBuffer);
|
||||
XtVaSetValues (widget,
|
||||
XmNlabelString, text,
|
||||
XmNlabelType, XmSTRING,
|
||||
NULL);
|
||||
XmNlabelString, text,
|
||||
XmNlabelType, XmSTRING,
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
}
|
||||
|
||||
@@ -67,13 +67,13 @@ wxString wxControl::GetLabel() const
|
||||
Widget widget = (Widget) GetLabelWidget() ;
|
||||
if (!widget)
|
||||
return wxEmptyString;
|
||||
|
||||
|
||||
XmString text;
|
||||
char *s;
|
||||
XtVaGetValues (widget,
|
||||
XmNlabelString, &text,
|
||||
NULL);
|
||||
|
||||
XmNlabelString, &text,
|
||||
NULL);
|
||||
|
||||
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
|
||||
{
|
||||
wxString str(s);
|
||||
@@ -90,41 +90,41 @@ wxString wxControl::GetLabel() const
|
||||
|
||||
void wxControl::ProcessCommand (wxCommandEvent & event)
|
||||
{
|
||||
// Tries:
|
||||
// 1) A callback function (to become obsolete)
|
||||
// 2) OnCommand, starting at this window and working up parent hierarchy
|
||||
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
||||
if (m_callback)
|
||||
// Tries:
|
||||
// 1) A callback function (to become obsolete)
|
||||
// 2) OnCommand, starting at this window and working up parent hierarchy
|
||||
// 3) OnCommand then calls ProcessEvent to search the event tables.
|
||||
if (m_callback)
|
||||
{
|
||||
(void) (*(m_callback)) (*this, event);
|
||||
(void) (*(m_callback)) (*this, event);
|
||||
}
|
||||
else
|
||||
{
|
||||
GetEventHandler()->OnCommand(*this, event);
|
||||
GetEventHandler()->OnCommand(*this, event);
|
||||
}
|
||||
}
|
||||
|
||||
void wxControl::Centre (int direction)
|
||||
{
|
||||
int x, y, width, height, panel_width, panel_height, new_x, new_y;
|
||||
|
||||
wxWindow *parent = (wxWindow *) GetParent ();
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
parent->GetClientSize (&panel_width, &panel_height);
|
||||
GetSize (&width, &height);
|
||||
GetPosition (&x, &y);
|
||||
|
||||
new_x = x;
|
||||
new_y = y;
|
||||
|
||||
if (direction & wxHORIZONTAL)
|
||||
new_x = (int) ((panel_width - width) / 2);
|
||||
|
||||
if (direction & wxVERTICAL)
|
||||
new_y = (int) ((panel_height - height) / 2);
|
||||
|
||||
SetSize (new_x, new_y, width, height);
|
||||
int x, y, width, height, panel_width, panel_height, new_x, new_y;
|
||||
|
||||
wxWindow *parent = (wxWindow *) GetParent ();
|
||||
if (!parent)
|
||||
return;
|
||||
|
||||
parent->GetClientSize (&panel_width, &panel_height);
|
||||
GetSize (&width, &height);
|
||||
GetPosition (&x, &y);
|
||||
|
||||
new_x = x;
|
||||
new_y = y;
|
||||
|
||||
if (direction & wxHORIZONTAL)
|
||||
new_x = (int) ((panel_width - width) / 2);
|
||||
|
||||
if (direction & wxVERTICAL)
|
||||
new_y = (int) ((panel_height - height) / 2);
|
||||
|
||||
SetSize (new_x, new_y, width, height);
|
||||
}
|
||||
|
||||
|
416
src/motif/dc.cpp
416
src/motif/dc.cpp
@@ -37,54 +37,54 @@ IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
|
||||
|
||||
wxDC::wxDC(void)
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_optimize = FALSE;
|
||||
m_colour = TRUE;
|
||||
m_clipping = FALSE;
|
||||
|
||||
m_mm_to_pix_x = 1.0;
|
||||
m_mm_to_pix_y = 1.0;
|
||||
|
||||
m_logicalOriginX = 0;
|
||||
m_logicalOriginY = 0;
|
||||
m_deviceOriginX = 0;
|
||||
m_deviceOriginY = 0;
|
||||
m_internalDeviceOriginX = 0;
|
||||
m_internalDeviceOriginY = 0;
|
||||
m_externalDeviceOriginX = 0;
|
||||
m_externalDeviceOriginY = 0;
|
||||
|
||||
m_logicalScaleX = 1.0;
|
||||
m_logicalScaleY = 1.0;
|
||||
m_userScaleX = 1.0;
|
||||
m_userScaleY = 1.0;
|
||||
m_scaleX = 1.0;
|
||||
m_scaleY = 1.0;
|
||||
|
||||
m_mappingMode = MM_TEXT;
|
||||
m_needComputeScaleX = FALSE;
|
||||
m_needComputeScaleY = FALSE;
|
||||
|
||||
m_signX = 1; // default x-axis left to right
|
||||
m_signY = 1; // default y-axis top down
|
||||
|
||||
m_maxX = m_maxY = -100000;
|
||||
m_minY = m_minY = 100000;
|
||||
|
||||
m_logicalFunction = wxCOPY;
|
||||
// m_textAlignment = wxALIGN_TOP_LEFT;
|
||||
m_backgroundMode = wxTRANSPARENT;
|
||||
|
||||
m_textForegroundColour = *wxBLACK;
|
||||
m_textBackgroundColour = *wxWHITE;
|
||||
m_pen = *wxBLACK_PEN;
|
||||
m_font = *wxNORMAL_FONT;
|
||||
m_brush = *wxTRANSPARENT_BRUSH;
|
||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||
|
||||
m_isInteractive = FALSE;
|
||||
|
||||
// m_palette = wxAPP_COLOURMAP;
|
||||
m_ok = FALSE;
|
||||
m_optimize = FALSE;
|
||||
m_colour = TRUE;
|
||||
m_clipping = FALSE;
|
||||
|
||||
m_mm_to_pix_x = 1.0;
|
||||
m_mm_to_pix_y = 1.0;
|
||||
|
||||
m_logicalOriginX = 0;
|
||||
m_logicalOriginY = 0;
|
||||
m_deviceOriginX = 0;
|
||||
m_deviceOriginY = 0;
|
||||
m_internalDeviceOriginX = 0;
|
||||
m_internalDeviceOriginY = 0;
|
||||
m_externalDeviceOriginX = 0;
|
||||
m_externalDeviceOriginY = 0;
|
||||
|
||||
m_logicalScaleX = 1.0;
|
||||
m_logicalScaleY = 1.0;
|
||||
m_userScaleX = 1.0;
|
||||
m_userScaleY = 1.0;
|
||||
m_scaleX = 1.0;
|
||||
m_scaleY = 1.0;
|
||||
|
||||
m_mappingMode = MM_TEXT;
|
||||
m_needComputeScaleX = FALSE;
|
||||
m_needComputeScaleY = FALSE;
|
||||
|
||||
m_signX = 1; // default x-axis left to right
|
||||
m_signY = 1; // default y-axis top down
|
||||
|
||||
m_maxX = m_maxY = -100000;
|
||||
m_minY = m_minY = 100000;
|
||||
|
||||
m_logicalFunction = wxCOPY;
|
||||
// m_textAlignment = wxALIGN_TOP_LEFT;
|
||||
m_backgroundMode = wxTRANSPARENT;
|
||||
|
||||
m_textForegroundColour = *wxBLACK;
|
||||
m_textBackgroundColour = *wxWHITE;
|
||||
m_pen = *wxBLACK_PEN;
|
||||
m_font = *wxNORMAL_FONT;
|
||||
m_brush = *wxTRANSPARENT_BRUSH;
|
||||
m_backgroundBrush = *wxWHITE_BRUSH;
|
||||
|
||||
m_isInteractive = FALSE;
|
||||
|
||||
// m_palette = wxAPP_COLOURMAP;
|
||||
};
|
||||
|
||||
wxDC::~wxDC(void)
|
||||
@@ -99,314 +99,314 @@ void wxDC::DrawBitmap( const wxBitmap& bitmap, long x, long y, bool useMask )
|
||||
{
|
||||
if (!bitmap.Ok())
|
||||
return;
|
||||
|
||||
|
||||
wxMemoryDC memDC;
|
||||
memDC.SelectObject(bitmap);
|
||||
|
||||
/* Not sure if we need this. The mask should leave the
|
||||
* masked areas as per the original background of this DC.
|
||||
|
||||
/* Not sure if we need this. The mask should leave the
|
||||
* masked areas as per the original background of this DC.
|
||||
if (useMask)
|
||||
{
|
||||
// There might be transparent areas, so make these
|
||||
// the same colour as this DC
|
||||
memDC.SetBackground(* GetBackground());
|
||||
memDC.Clear();
|
||||
// There might be transparent areas, so make these
|
||||
// the same colour as this DC
|
||||
memDC.SetBackground(* GetBackground());
|
||||
memDC.Clear();
|
||||
}
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), & memDC, 0, 0, wxCOPY, useMask);
|
||||
|
||||
|
||||
memDC.SelectObject(wxNullBitmap);
|
||||
};
|
||||
|
||||
|
||||
void wxDC::DrawPoint( wxPoint& point )
|
||||
{
|
||||
DrawPoint( point.x, point.y );
|
||||
DrawPoint( point.x, point.y );
|
||||
};
|
||||
|
||||
void wxDC::DrawPolygon( wxList *list, long xoffset, long yoffset, int fillStyle )
|
||||
{
|
||||
int n = list->Number();
|
||||
wxPoint *points = new wxPoint[n];
|
||||
|
||||
int i = 0;
|
||||
for( wxNode *node = list->First(); node; node = node->Next() )
|
||||
{
|
||||
wxPoint *point = (wxPoint *)node->Data();
|
||||
points[i].x = point->x;
|
||||
points[i++].y = point->y;
|
||||
};
|
||||
DrawPolygon( n, points, xoffset, yoffset, fillStyle );
|
||||
delete[] points;
|
||||
int n = list->Number();
|
||||
wxPoint *points = new wxPoint[n];
|
||||
|
||||
int i = 0;
|
||||
for( wxNode *node = list->First(); node; node = node->Next() )
|
||||
{
|
||||
wxPoint *point = (wxPoint *)node->Data();
|
||||
points[i].x = point->x;
|
||||
points[i++].y = point->y;
|
||||
};
|
||||
DrawPolygon( n, points, xoffset, yoffset, fillStyle );
|
||||
delete[] points;
|
||||
};
|
||||
|
||||
void wxDC::DrawLines( wxList *list, long xoffset, long yoffset )
|
||||
{
|
||||
int n = list->Number();
|
||||
wxPoint *points = new wxPoint[n];
|
||||
|
||||
int i = 0;
|
||||
for( wxNode *node = list->First(); node; node = node->Next() )
|
||||
{
|
||||
wxPoint *point = (wxPoint *)node->Data();
|
||||
points[i].x = point->x;
|
||||
points[i++].y = point->y;
|
||||
};
|
||||
DrawLines( n, points, xoffset, yoffset );
|
||||
delete []points;
|
||||
int n = list->Number();
|
||||
wxPoint *points = new wxPoint[n];
|
||||
|
||||
int i = 0;
|
||||
for( wxNode *node = list->First(); node; node = node->Next() )
|
||||
{
|
||||
wxPoint *point = (wxPoint *)node->Data();
|
||||
points[i].x = point->x;
|
||||
points[i++].y = point->y;
|
||||
};
|
||||
DrawLines( n, points, xoffset, yoffset );
|
||||
delete []points;
|
||||
};
|
||||
|
||||
void wxDC::DrawSpline( long x1, long y1, long x2, long y2, long x3, long y3 )
|
||||
{
|
||||
wxList list;
|
||||
list.Append( (wxObject*)new wxPoint(x1, y1) );
|
||||
list.Append( (wxObject*)new wxPoint(x2, y2) );
|
||||
list.Append( (wxObject*)new wxPoint(x3, y3) );
|
||||
DrawSpline(&list);
|
||||
wxNode *node = list.First();
|
||||
while (node)
|
||||
{
|
||||
wxPoint *p = (wxPoint*)node->Data();
|
||||
delete p;
|
||||
node = node->Next();
|
||||
};
|
||||
wxList list;
|
||||
list.Append( (wxObject*)new wxPoint(x1, y1) );
|
||||
list.Append( (wxObject*)new wxPoint(x2, y2) );
|
||||
list.Append( (wxObject*)new wxPoint(x3, y3) );
|
||||
DrawSpline(&list);
|
||||
wxNode *node = list.First();
|
||||
while (node)
|
||||
{
|
||||
wxPoint *p = (wxPoint*)node->Data();
|
||||
delete p;
|
||||
node = node->Next();
|
||||
};
|
||||
};
|
||||
|
||||
void wxDC::DrawSpline( int n, wxPoint points[] )
|
||||
{
|
||||
wxList list;
|
||||
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
|
||||
DrawSpline( &list );
|
||||
wxList list;
|
||||
for (int i = 0; i < n; i++) list.Append( (wxObject*)&points[i] );
|
||||
DrawSpline( &list );
|
||||
};
|
||||
|
||||
void wxDC::SetClippingRegion( long x, long y, long width, long height )
|
||||
{
|
||||
m_clipping = TRUE;
|
||||
m_clipX1 = x;
|
||||
m_clipY1 = y;
|
||||
m_clipX2 = x + width;
|
||||
m_clipY2 = y + height;
|
||||
m_clipping = TRUE;
|
||||
m_clipX1 = x;
|
||||
m_clipY1 = y;
|
||||
m_clipX2 = x + width;
|
||||
m_clipY2 = y + height;
|
||||
};
|
||||
|
||||
void wxDC::DestroyClippingRegion(void)
|
||||
{
|
||||
m_clipping = FALSE;
|
||||
m_clipping = FALSE;
|
||||
};
|
||||
|
||||
void wxDC::GetClippingBox( long *x, long *y, long *width, long *height ) const
|
||||
{
|
||||
if (m_clipping)
|
||||
{
|
||||
if (x) *x = m_clipX1;
|
||||
if (y) *y = m_clipY1;
|
||||
if (width) *width = (m_clipX2 - m_clipX1);
|
||||
if (height) *height = (m_clipY2 - m_clipY1);
|
||||
}
|
||||
else
|
||||
*x = *y = *width = *height = 0;
|
||||
if (m_clipping)
|
||||
{
|
||||
if (x) *x = m_clipX1;
|
||||
if (y) *y = m_clipY1;
|
||||
if (width) *width = (m_clipX2 - m_clipX1);
|
||||
if (height) *height = (m_clipY2 - m_clipY1);
|
||||
}
|
||||
else
|
||||
*x = *y = *width = *height = 0;
|
||||
};
|
||||
|
||||
void wxDC::GetSize( int* width, int* height ) const
|
||||
{
|
||||
*width = m_maxX-m_minX;
|
||||
*height = m_maxY-m_minY;
|
||||
*width = m_maxX-m_minX;
|
||||
*height = m_maxY-m_minY;
|
||||
};
|
||||
|
||||
void wxDC::GetSizeMM( long* width, long* height ) const
|
||||
{
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
GetSize( &w, &h );
|
||||
*width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
|
||||
*height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
|
||||
int w = 0;
|
||||
int h = 0;
|
||||
GetSize( &w, &h );
|
||||
*width = long( double(w) / (m_scaleX*m_mm_to_pix_x) );
|
||||
*height = long( double(h) / (m_scaleY*m_mm_to_pix_y) );
|
||||
};
|
||||
|
||||
void wxDC::SetTextForeground( const wxColour &col )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
m_textForegroundColour = col;
|
||||
if (!Ok()) return;
|
||||
m_textForegroundColour = col;
|
||||
};
|
||||
|
||||
void wxDC::SetTextBackground( const wxColour &col )
|
||||
{
|
||||
if (!Ok()) return;
|
||||
m_textBackgroundColour = col;
|
||||
if (!Ok()) return;
|
||||
m_textBackgroundColour = col;
|
||||
};
|
||||
|
||||
void wxDC::SetMapMode( int mode )
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
switch (mode)
|
||||
{
|
||||
case MM_TWIPS:
|
||||
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
|
||||
break;
|
||||
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
|
||||
break;
|
||||
case MM_POINTS:
|
||||
SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
|
||||
break;
|
||||
SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
|
||||
break;
|
||||
case MM_METRIC:
|
||||
SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
|
||||
break;
|
||||
SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
|
||||
break;
|
||||
case MM_LOMETRIC:
|
||||
SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
|
||||
break;
|
||||
SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
|
||||
break;
|
||||
default:
|
||||
case MM_TEXT:
|
||||
SetLogicalScale( 1.0, 1.0 );
|
||||
break;
|
||||
};
|
||||
if (mode != MM_TEXT)
|
||||
{
|
||||
m_needComputeScaleX = TRUE;
|
||||
m_needComputeScaleY = TRUE;
|
||||
};
|
||||
SetLogicalScale( 1.0, 1.0 );
|
||||
break;
|
||||
};
|
||||
if (mode != MM_TEXT)
|
||||
{
|
||||
m_needComputeScaleX = TRUE;
|
||||
m_needComputeScaleY = TRUE;
|
||||
};
|
||||
};
|
||||
|
||||
void wxDC::SetUserScale( double x, double y )
|
||||
{
|
||||
// allow negative ? -> no
|
||||
m_userScaleX = x;
|
||||
m_userScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
// allow negative ? -> no
|
||||
m_userScaleX = x;
|
||||
m_userScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetUserScale( double *x, double *y )
|
||||
{
|
||||
if (x) *x = m_userScaleX;
|
||||
if (y) *y = m_userScaleY;
|
||||
if (x) *x = m_userScaleX;
|
||||
if (y) *y = m_userScaleY;
|
||||
};
|
||||
|
||||
void wxDC::SetLogicalScale( double x, double y )
|
||||
{
|
||||
// allow negative ?
|
||||
m_logicalScaleX = x;
|
||||
m_logicalScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
// allow negative ?
|
||||
m_logicalScaleX = x;
|
||||
m_logicalScaleY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalScale( double *x, double *y )
|
||||
{
|
||||
if (x) *x = m_logicalScaleX;
|
||||
if (y) *y = m_logicalScaleY;
|
||||
if (x) *x = m_logicalScaleX;
|
||||
if (y) *y = m_logicalScaleY;
|
||||
};
|
||||
|
||||
void wxDC::SetLogicalOrigin( long x, long y )
|
||||
{
|
||||
m_logicalOriginX = x * m_signX; // is this still correct ?
|
||||
m_logicalOriginY = y * m_signY;
|
||||
ComputeScaleAndOrigin();
|
||||
m_logicalOriginX = x * m_signX; // is this still correct ?
|
||||
m_logicalOriginY = y * m_signY;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetLogicalOrigin( long *x, long *y )
|
||||
{
|
||||
if (x) *x = m_logicalOriginX;
|
||||
if (y) *y = m_logicalOriginY;
|
||||
if (x) *x = m_logicalOriginX;
|
||||
if (y) *y = m_logicalOriginY;
|
||||
};
|
||||
|
||||
void wxDC::SetDeviceOrigin( long x, long y )
|
||||
{
|
||||
m_externalDeviceOriginX = x;
|
||||
m_externalDeviceOriginY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
m_externalDeviceOriginX = x;
|
||||
m_externalDeviceOriginY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetDeviceOrigin( long *x, long *y )
|
||||
{
|
||||
// if (x) *x = m_externalDeviceOriginX;
|
||||
// if (y) *y = m_externalDeviceOriginY;
|
||||
if (x) *x = m_deviceOriginX;
|
||||
if (y) *y = m_deviceOriginY;
|
||||
// if (x) *x = m_externalDeviceOriginX;
|
||||
// if (y) *y = m_externalDeviceOriginY;
|
||||
if (x) *x = m_deviceOriginX;
|
||||
if (y) *y = m_deviceOriginY;
|
||||
};
|
||||
|
||||
void wxDC::SetInternalDeviceOrigin( long x, long y )
|
||||
{
|
||||
m_internalDeviceOriginX = x;
|
||||
m_internalDeviceOriginY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
m_internalDeviceOriginX = x;
|
||||
m_internalDeviceOriginY = y;
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
void wxDC::GetInternalDeviceOrigin( long *x, long *y )
|
||||
{
|
||||
if (x) *x = m_internalDeviceOriginX;
|
||||
if (y) *y = m_internalDeviceOriginY;
|
||||
if (x) *x = m_internalDeviceOriginX;
|
||||
if (y) *y = m_internalDeviceOriginY;
|
||||
};
|
||||
|
||||
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
|
||||
{
|
||||
m_signX = (xLeftRight ? 1 : -1);
|
||||
m_signY = (yBottomUp ? -1 : 1);
|
||||
ComputeScaleAndOrigin();
|
||||
m_signX = (xLeftRight ? 1 : -1);
|
||||
m_signY = (yBottomUp ? -1 : 1);
|
||||
ComputeScaleAndOrigin();
|
||||
};
|
||||
|
||||
long wxDC::DeviceToLogicalX(long x) const
|
||||
{
|
||||
return XDEV2LOG(x);
|
||||
return XDEV2LOG(x);
|
||||
};
|
||||
|
||||
long wxDC::DeviceToLogicalY(long y) const
|
||||
{
|
||||
return YDEV2LOG(y);
|
||||
return YDEV2LOG(y);
|
||||
};
|
||||
|
||||
long wxDC::DeviceToLogicalXRel(long x) const
|
||||
{
|
||||
return XDEV2LOGREL(x);
|
||||
return XDEV2LOGREL(x);
|
||||
};
|
||||
|
||||
long wxDC::DeviceToLogicalYRel(long y) const
|
||||
{
|
||||
return YDEV2LOGREL(y);
|
||||
return YDEV2LOGREL(y);
|
||||
};
|
||||
|
||||
long wxDC::LogicalToDeviceX(long x) const
|
||||
{
|
||||
return XLOG2DEV(x);
|
||||
return XLOG2DEV(x);
|
||||
};
|
||||
|
||||
long wxDC::LogicalToDeviceY(long y) const
|
||||
{
|
||||
return YLOG2DEV(y);
|
||||
return YLOG2DEV(y);
|
||||
};
|
||||
|
||||
long wxDC::LogicalToDeviceXRel(long x) const
|
||||
{
|
||||
return XLOG2DEVREL(x);
|
||||
return XLOG2DEVREL(x);
|
||||
};
|
||||
|
||||
long wxDC::LogicalToDeviceYRel(long y) const
|
||||
{
|
||||
return YLOG2DEVREL(y);
|
||||
return YLOG2DEVREL(y);
|
||||
};
|
||||
|
||||
|
||||
void wxDC::CalcBoundingBox( long x, long y )
|
||||
{
|
||||
if (x < m_minX) m_minX = x;
|
||||
if (y < m_minY) m_minY = y;
|
||||
if (x > m_maxX) m_maxX = x;
|
||||
if (y > m_maxY) m_maxY = y;
|
||||
if (x < m_minX) m_minX = x;
|
||||
if (y < m_minY) m_minY = y;
|
||||
if (x > m_maxX) m_maxX = x;
|
||||
if (y > m_maxY) m_maxY = y;
|
||||
};
|
||||
|
||||
void wxDC::ComputeScaleAndOrigin(void)
|
||||
{
|
||||
// CMB: copy scale to see if it changes
|
||||
double origScaleX = m_scaleX;
|
||||
double origScaleY = m_scaleY;
|
||||
|
||||
m_scaleX = m_logicalScaleX * m_userScaleX;
|
||||
m_scaleY = m_logicalScaleY * m_userScaleY;
|
||||
|
||||
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
|
||||
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
|
||||
|
||||
// CMB: if scale has changed call SetPen to recalulate the line width
|
||||
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
|
||||
{
|
||||
// this is a bit artificial, but we need to force wxDC to think
|
||||
// the pen has changed
|
||||
wxPen* pen = & GetPen();
|
||||
wxPen tempPen;
|
||||
m_pen = tempPen;
|
||||
SetPen(* pen);
|
||||
}
|
||||
// CMB: copy scale to see if it changes
|
||||
double origScaleX = m_scaleX;
|
||||
double origScaleY = m_scaleY;
|
||||
|
||||
m_scaleX = m_logicalScaleX * m_userScaleX;
|
||||
m_scaleY = m_logicalScaleY * m_userScaleY;
|
||||
|
||||
m_deviceOriginX = m_internalDeviceOriginX + m_externalDeviceOriginX;
|
||||
m_deviceOriginY = m_internalDeviceOriginY + m_externalDeviceOriginY;
|
||||
|
||||
// CMB: if scale has changed call SetPen to recalulate the line width
|
||||
if (m_scaleX != origScaleX || m_scaleY != origScaleY)
|
||||
{
|
||||
// this is a bit artificial, but we need to force wxDC to think
|
||||
// the pen has changed
|
||||
wxPen* pen = & GetPen();
|
||||
wxPen tempPen;
|
||||
m_pen = tempPen;
|
||||
SetPen(* pen);
|
||||
}
|
||||
};
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -30,9 +30,9 @@ wxMemoryDC::wxMemoryDC(void)
|
||||
{
|
||||
m_ok = TRUE;
|
||||
m_display = wxGetDisplay();
|
||||
|
||||
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
@@ -40,10 +40,10 @@ wxMemoryDC::wxMemoryDC(void)
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
|
||||
&gcvalues);
|
||||
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
|
||||
|
||||
// Get the current Font so we can set it back later
|
||||
XGCValues valReturn;
|
||||
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
|
||||
@@ -59,9 +59,9 @@ wxMemoryDC::wxMemoryDC( wxDC* dc )
|
||||
m_display = ((wxWindowDC*)dc)->GetDisplay();
|
||||
else
|
||||
m_display = wxGetDisplay();
|
||||
|
||||
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
@@ -69,10 +69,10 @@ wxMemoryDC::wxMemoryDC( wxDC* dc )
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
|
||||
&gcvalues);
|
||||
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
|
||||
|
||||
// Get the current Font so we can set it back later
|
||||
XGCValues valReturn;
|
||||
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
|
||||
@@ -87,62 +87,62 @@ wxMemoryDC::~wxMemoryDC(void)
|
||||
|
||||
void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
|
||||
{
|
||||
m_bitmap = bitmap;
|
||||
|
||||
if (m_gc)
|
||||
XFreeGC((Display*) m_display, (GC) m_gc);
|
||||
m_gc = (WXGC) NULL;
|
||||
|
||||
if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
|
||||
{
|
||||
m_pixmap = m_bitmap.GetPixmap();
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
gcvalues.graphics_exposures = False;
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
|
||||
// Get the current Font so we can set it back later
|
||||
XGCValues valReturn;
|
||||
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
|
||||
m_oldFont = (WXFont) valReturn.font;
|
||||
|
||||
bool oldOpt = GetOptimization();
|
||||
SetOptimization(FALSE);
|
||||
m_bitmap = bitmap;
|
||||
|
||||
SetBrush (* wxWHITE_BRUSH);
|
||||
SetPen (* wxBLACK_PEN);
|
||||
|
||||
SetOptimization(oldOpt);
|
||||
|
||||
m_ok = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_pixmap = (WXPixmap) 0;
|
||||
};
|
||||
if (m_gc)
|
||||
XFreeGC((Display*) m_display, (GC) m_gc);
|
||||
m_gc = (WXGC) NULL;
|
||||
|
||||
if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
|
||||
{
|
||||
m_pixmap = m_bitmap.GetPixmap();
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
gcvalues.graphics_exposures = False;
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
|
||||
// Get the current Font so we can set it back later
|
||||
XGCValues valReturn;
|
||||
XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
|
||||
m_oldFont = (WXFont) valReturn.font;
|
||||
|
||||
bool oldOpt = GetOptimization();
|
||||
SetOptimization(FALSE);
|
||||
|
||||
SetBrush (* wxWHITE_BRUSH);
|
||||
SetPen (* wxBLACK_PEN);
|
||||
|
||||
SetOptimization(oldOpt);
|
||||
|
||||
m_ok = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_ok = FALSE;
|
||||
m_pixmap = (WXPixmap) 0;
|
||||
};
|
||||
};
|
||||
|
||||
void wxMemoryDC::GetSize( int *width, int *height ) const
|
||||
{
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
if (width) (*width) = m_bitmap.GetWidth();
|
||||
if (height) (*height) = m_bitmap.GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width) (*width) = 0;
|
||||
if (height) (*height) = 0;
|
||||
};
|
||||
if (m_bitmap.Ok())
|
||||
{
|
||||
if (width) (*width) = m_bitmap.GetWidth();
|
||||
if (height) (*height) = m_bitmap.GetHeight();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (width) (*width) = 0;
|
||||
if (height) (*height) = 0;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
@@ -31,30 +31,30 @@ int wxScreenDC::sm_overlayWindowY = 0;
|
||||
// Create a DC representing the whole screen
|
||||
wxScreenDC::wxScreenDC()
|
||||
{
|
||||
m_display = wxGetDisplay();
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
m_pixmap = sm_overlayWindow;
|
||||
m_deviceOriginX = - sm_overlayWindowX;
|
||||
m_deviceOriginY = - sm_overlayWindowY;
|
||||
}
|
||||
else
|
||||
m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
gcvalues.graphics_exposures = False;
|
||||
gcvalues.subwindow_mode = IncludeInferiors;
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
m_ok = TRUE;
|
||||
m_display = wxGetDisplay();
|
||||
Display* display = (Display*) m_display;
|
||||
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
m_pixmap = sm_overlayWindow;
|
||||
m_deviceOriginX = - sm_overlayWindowX;
|
||||
m_deviceOriginY = - sm_overlayWindowY;
|
||||
}
|
||||
else
|
||||
m_pixmap = (WXPixmap) RootWindow(display, DefaultScreen(display));
|
||||
|
||||
XGCValues gcvalues;
|
||||
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
|
||||
gcvalues.background = WhitePixel (display, DefaultScreen (display));
|
||||
gcvalues.graphics_exposures = False;
|
||||
gcvalues.subwindow_mode = IncludeInferiors;
|
||||
gcvalues.line_width = 1;
|
||||
m_gc = XCreateGC (display, RootWindow (display, DefaultScreen (display)),
|
||||
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
|
||||
&gcvalues);
|
||||
|
||||
m_backgroundPixel = (int) gcvalues.background;
|
||||
m_ok = TRUE;
|
||||
}
|
||||
|
||||
wxScreenDC::~wxScreenDC()
|
||||
@@ -63,65 +63,65 @@ wxScreenDC::~wxScreenDC()
|
||||
|
||||
bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
|
||||
{
|
||||
wxRect rect;
|
||||
int x, y, width, height;
|
||||
window->GetPosition(& x, & y);
|
||||
if (window->GetParent())
|
||||
window->GetParent()->ClientToScreen(& x, & y);
|
||||
window->GetSize(& width, & height);
|
||||
rect.x = x; rect.y = y;
|
||||
rect.width = width; rect.height = height;
|
||||
|
||||
return StartDrawingOnTop(& rect);
|
||||
wxRect rect;
|
||||
int x, y, width, height;
|
||||
window->GetPosition(& x, & y);
|
||||
if (window->GetParent())
|
||||
window->GetParent()->ClientToScreen(& x, & y);
|
||||
window->GetSize(& width, & height);
|
||||
rect.x = x; rect.y = y;
|
||||
rect.width = width; rect.height = height;
|
||||
|
||||
return StartDrawingOnTop(& rect);
|
||||
}
|
||||
|
||||
bool wxScreenDC::StartDrawingOnTop(wxRect* rect)
|
||||
{
|
||||
if (sm_overlayWindow)
|
||||
return FALSE;
|
||||
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width, height;
|
||||
wxDisplaySize(&width, &height);
|
||||
|
||||
if (rect)
|
||||
{
|
||||
x = rect->x; y = rect->y;
|
||||
width = rect->width; height = rect->height;
|
||||
}
|
||||
sm_overlayWindowX = x;
|
||||
sm_overlayWindowY = y;
|
||||
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.override_redirect = True;
|
||||
unsigned long valueMask = CWOverrideRedirect;
|
||||
|
||||
sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
|
||||
wxDisplayDepth(), InputOutput,
|
||||
DefaultVisual(dpy, 0), valueMask,
|
||||
& attributes);
|
||||
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
XMapWindow(dpy, (Window) sm_overlayWindow);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
if (sm_overlayWindow)
|
||||
return FALSE;
|
||||
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
Pixmap screenPixmap = RootWindow(dpy, DefaultScreen(dpy));
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width, height;
|
||||
wxDisplaySize(&width, &height);
|
||||
|
||||
if (rect)
|
||||
{
|
||||
x = rect->x; y = rect->y;
|
||||
width = rect->width; height = rect->height;
|
||||
}
|
||||
sm_overlayWindowX = x;
|
||||
sm_overlayWindowY = y;
|
||||
|
||||
XSetWindowAttributes attributes;
|
||||
attributes.override_redirect = True;
|
||||
unsigned long valueMask = CWOverrideRedirect;
|
||||
|
||||
sm_overlayWindow = (WXWindow) XCreateWindow(dpy, screenPixmap, x, y, width, height, 0,
|
||||
wxDisplayDepth(), InputOutput,
|
||||
DefaultVisual(dpy, 0), valueMask,
|
||||
& attributes);
|
||||
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
XMapWindow(dpy, (Window) sm_overlayWindow);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
bool wxScreenDC::EndDrawingOnTop()
|
||||
{
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
|
||||
sm_overlayWindow = 0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
if (sm_overlayWindow)
|
||||
{
|
||||
XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
|
||||
sm_overlayWindow = 0;
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
@@ -44,9 +44,9 @@
|
||||
static void wxCloseDialogCallback(Widget widget, XtPointer client_data, XmAnyCallbackStruct *cbs);
|
||||
static void wxDialogBoxRepaintProc(Widget w, XtPointer c_data, XEvent *event, char *);
|
||||
static void wxDialogBoxEventHandler (Widget wid,
|
||||
XtPointer client_data,
|
||||
XEvent* event,
|
||||
Boolean *continueToDispatch);
|
||||
XtPointer client_data,
|
||||
XEvent* event,
|
||||
Boolean *continueToDispatch);
|
||||
|
||||
static void wxUnmapBulletinBoard(Widget dialog, wxDialog *client,XtPointer call);
|
||||
|
||||
@@ -67,12 +67,12 @@ extern wxList wxPendingDelete;
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxPanel)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxDialog, wxPanel)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CHAR_HOOK(wxDialog::OnCharHook)
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
|
||||
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
|
||||
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
|
||||
EVT_CHAR_HOOK(wxDialog::OnCharHook)
|
||||
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
|
||||
EVT_CLOSE(wxDialog::OnCloseWindow)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
@@ -84,76 +84,76 @@ wxDialog::wxDialog()
|
||||
}
|
||||
|
||||
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
m_windowStyle = style;
|
||||
m_modalShowing = FALSE;
|
||||
m_dialogTitle = title;
|
||||
|
||||
|
||||
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
|
||||
m_foregroundColour = *wxBLACK;
|
||||
|
||||
|
||||
SetName(name);
|
||||
|
||||
|
||||
if (!parent)
|
||||
wxTopLevelWindows.Append(this);
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) 0;
|
||||
if (parent)
|
||||
parentWidget = (Widget) parent->GetTopWidget();
|
||||
if (!parent)
|
||||
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
|
||||
|
||||
|
||||
wxASSERT_MSG( (parentWidget != (Widget) 0), "Could not find a suitable parent shell for dialog." );
|
||||
|
||||
|
||||
Arg args[2];
|
||||
XtSetArg (args[0], XmNdefaultPosition, False);
|
||||
XtSetArg (args[1], XmNautoUnmanage, False);
|
||||
Widget dialogShell = XmCreateBulletinBoardDialog(parentWidget, (char*) (const char*) name, args, 2);
|
||||
m_mainWidget = (WXWidget) dialogShell;
|
||||
|
||||
|
||||
// We don't want margins, since there is enough elsewhere.
|
||||
XtVaSetValues(dialogShell,
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL) ;
|
||||
|
||||
XmNmarginHeight, 0,
|
||||
XmNmarginWidth, 0,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL) ;
|
||||
|
||||
Widget shell = XtParent(dialogShell) ;
|
||||
if (!title.IsNull())
|
||||
{
|
||||
XmString str = XmStringCreateSimple((char*) (const char*)title);
|
||||
XtVaSetValues(dialogShell,
|
||||
XmNdialogTitle, str,
|
||||
NULL);
|
||||
XmNdialogTitle, str,
|
||||
NULL);
|
||||
XmStringFree(str);
|
||||
}
|
||||
|
||||
|
||||
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
wxAddWindowToTable(dialogShell, this);
|
||||
|
||||
|
||||
// Intercept CLOSE messages from the window manager
|
||||
Atom WM_DELETE_WINDOW = XmInternAtom(XtDisplay(shell), "WM_DELETE_WINDOW", False);
|
||||
|
||||
|
||||
/* Remove and add WM_DELETE_WINDOW so ours is only handler */
|
||||
/* Why do we have to do this for wxDialog, but not wxFrame? */
|
||||
XmRemoveWMProtocols(shell, &WM_DELETE_WINDOW, 1);
|
||||
XmAddWMProtocols(shell, &WM_DELETE_WINDOW, 1);
|
||||
XmActivateWMProtocol(shell, WM_DELETE_WINDOW);
|
||||
|
||||
|
||||
// Modified Steve Hammes for Motif 2.0
|
||||
#if (XmREVISION > 1 || XmVERSION > 1)
|
||||
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (XtCallbackProc) wxCloseDialogCallback, (XtPointer)this);
|
||||
@@ -162,85 +162,85 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id,
|
||||
#else
|
||||
XmAddWMProtocolCallback(shell, WM_DELETE_WINDOW, (void (*)())wxCloseDialogCallback, (caddr_t)this);
|
||||
#endif
|
||||
|
||||
|
||||
XtTranslations ptr ;
|
||||
XtOverrideTranslations(dialogShell,
|
||||
ptr = XtParseTranslationTable("<Configure>: resize()"));
|
||||
ptr = XtParseTranslationTable("<Configure>: resize()"));
|
||||
XtFree((char *)ptr);
|
||||
|
||||
|
||||
// Can't remember what this was about... but I think it's necessary.
|
||||
|
||||
|
||||
if (wxUSE_INVISIBLE_RESIZE)
|
||||
{
|
||||
if (pos.x > -1)
|
||||
XtVaSetValues(dialogShell, XmNx, pos.x,
|
||||
NULL);
|
||||
if (pos.y > -1)
|
||||
XtVaSetValues(dialogShell, XmNy, pos.y,
|
||||
NULL);
|
||||
|
||||
if (size.x > -1)
|
||||
XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
|
||||
if (size.y > -1)
|
||||
XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
|
||||
if (pos.x > -1)
|
||||
XtVaSetValues(dialogShell, XmNx, pos.x,
|
||||
NULL);
|
||||
if (pos.y > -1)
|
||||
XtVaSetValues(dialogShell, XmNy, pos.y,
|
||||
NULL);
|
||||
|
||||
if (size.x > -1)
|
||||
XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
|
||||
if (size.y > -1)
|
||||
XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
|
||||
}
|
||||
|
||||
|
||||
// This patch come from Torsten Liermann lier@lier1.muc.de
|
||||
if (XmIsMotifWMRunning(shell))
|
||||
{
|
||||
int decor = 0 ;
|
||||
if (m_windowStyle & wxRESIZE_BORDER)
|
||||
decor |= MWM_DECOR_RESIZEH ;
|
||||
decor |= MWM_DECOR_RESIZEH ;
|
||||
if (m_windowStyle & wxSYSTEM_MENU)
|
||||
decor |= MWM_DECOR_MENU;
|
||||
decor |= MWM_DECOR_MENU;
|
||||
if ((m_windowStyle & wxCAPTION) ||
|
||||
(m_windowStyle & wxTINY_CAPTION_HORIZ) ||
|
||||
(m_windowStyle & wxTINY_CAPTION_VERT))
|
||||
decor |= MWM_DECOR_TITLE;
|
||||
decor |= MWM_DECOR_TITLE;
|
||||
if (m_windowStyle & wxTHICK_FRAME)
|
||||
decor |= MWM_DECOR_BORDER;
|
||||
decor |= MWM_DECOR_BORDER;
|
||||
if (m_windowStyle & wxMINIMIZE_BOX)
|
||||
decor |= MWM_DECOR_MINIMIZE;
|
||||
decor |= MWM_DECOR_MINIMIZE;
|
||||
if (m_windowStyle & wxMAXIMIZE_BOX)
|
||||
decor |= MWM_DECOR_MAXIMIZE;
|
||||
|
||||
decor |= MWM_DECOR_MAXIMIZE;
|
||||
|
||||
XtVaSetValues(shell,XmNmwmDecorations,decor,NULL) ;
|
||||
}
|
||||
// This allows non-Motif window managers to support at least the
|
||||
// no-decorations case.
|
||||
else
|
||||
{
|
||||
if ((m_windowStyle & wxCAPTION) != wxCAPTION)
|
||||
XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
|
||||
if ((m_windowStyle & wxCAPTION) != wxCAPTION)
|
||||
XtVaSetValues((Widget) shell,XmNoverrideRedirect,TRUE,NULL);
|
||||
}
|
||||
|
||||
|
||||
XtRealizeWidget(dialogShell);
|
||||
|
||||
|
||||
XtAddCallback(dialogShell,XmNunmapCallback,
|
||||
(XtCallbackProc)wxUnmapBulletinBoard,this) ;
|
||||
|
||||
(XtCallbackProc)wxUnmapBulletinBoard,this) ;
|
||||
|
||||
// Positioning of the dialog doesn't work properly unless the dialog
|
||||
// is managed, so we manage without mapping to the screen.
|
||||
// To show, we map the shell (actually it's parent).
|
||||
if (!wxUSE_INVISIBLE_RESIZE)
|
||||
XtVaSetValues(shell, XmNmappedWhenManaged, FALSE, NULL);
|
||||
|
||||
|
||||
if (!wxUSE_INVISIBLE_RESIZE)
|
||||
{
|
||||
XtManageChild(dialogShell);
|
||||
SetSize(pos.x, pos.y, size.x, size.y);
|
||||
}
|
||||
XtAddEventHandler(dialogShell,ExposureMask,FALSE,
|
||||
wxDialogBoxRepaintProc, (XtPointer) this);
|
||||
|
||||
wxDialogBoxRepaintProc, (XtPointer) this);
|
||||
|
||||
XtAddEventHandler(dialogShell,
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
|
||||
FALSE,
|
||||
wxDialogBoxEventHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask,
|
||||
FALSE,
|
||||
wxDialogBoxEventHandler,
|
||||
(XtPointer)this);
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -250,11 +250,11 @@ void wxDialog::SetModal(bool flag)
|
||||
m_windowStyle |= wxDIALOG_MODAL ;
|
||||
else
|
||||
if ( m_windowStyle & wxDIALOG_MODAL )
|
||||
m_windowStyle -= wxDIALOG_MODAL ;
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if (!flag)
|
||||
wxModelessWindows.Append(this);
|
||||
m_windowStyle -= wxDIALOG_MODAL ;
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
if (!flag)
|
||||
wxModelessWindows.Append(this);
|
||||
}
|
||||
|
||||
wxDialog::~wxDialog()
|
||||
@@ -262,30 +262,30 @@ wxDialog::~wxDialog()
|
||||
m_modalShowing = FALSE;
|
||||
if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
|
||||
{
|
||||
XtUnmapWidget((Widget) m_mainWidget);
|
||||
XtUnmapWidget((Widget) m_mainWidget);
|
||||
}
|
||||
|
||||
|
||||
wxTopLevelWindows.DeleteObject(this);
|
||||
|
||||
|
||||
if ( (GetWindowStyleFlag() & wxDIALOG_MODAL) != wxDIALOG_MODAL )
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
|
||||
wxModelessWindows.DeleteObject(this);
|
||||
|
||||
// If this is the last top-level window, exit.
|
||||
if (wxTheApp && (wxTopLevelWindows.Number() == 0))
|
||||
{
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
|
||||
if (wxTheApp->GetExitOnFrameDelete())
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
wxTheApp->SetTopWindow(NULL);
|
||||
|
||||
if (wxTheApp->GetExitOnFrameDelete())
|
||||
{
|
||||
wxTheApp->ExitMainLoop();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// This event-flushing code used to be in wxWindow::PostDestroyChildren (wx_dialog.cpp)
|
||||
// but I think this should work, if we destroy the children first.
|
||||
// Note that this might need to be done for wxFrame also.
|
||||
DestroyChildren();
|
||||
|
||||
|
||||
// This causes a crash in e.g. the resource sample when closing
|
||||
// the example dialog. TODO: Probably not necessary (?)
|
||||
#if 0
|
||||
@@ -293,16 +293,16 @@ wxDialog::~wxDialog()
|
||||
// this might remain on the screen.
|
||||
Display* display;
|
||||
if (m_mainWidget)
|
||||
display = XtDisplay((Widget) m_mainWidget);
|
||||
display = XtDisplay((Widget) m_mainWidget);
|
||||
else
|
||||
display = (Display*) wxGetDisplay();
|
||||
|
||||
display = (Display*) wxGetDisplay();
|
||||
|
||||
XSync(display, FALSE);
|
||||
XEvent event;
|
||||
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext())) {
|
||||
XFlush(display);
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
XtDispatchEvent(&event);
|
||||
XFlush(display);
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@@ -310,35 +310,35 @@ wxDialog::~wxDialog()
|
||||
// By default, pressing escape cancels the dialog
|
||||
void wxDialog::OnCharHook(wxKeyEvent& event)
|
||||
{
|
||||
if (event.m_keyCode == WXK_ESCAPE)
|
||||
{
|
||||
// Behaviour changed in 2.0: we'll send a Cancel message
|
||||
// to the dialog instead of Close.
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
// We didn't process this event.
|
||||
event.Skip();
|
||||
if (event.m_keyCode == WXK_ESCAPE)
|
||||
{
|
||||
// Behaviour changed in 2.0: we'll send a Cancel message
|
||||
// to the dialog instead of Close.
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
return;
|
||||
}
|
||||
// We didn't process this event.
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void wxDialog::Iconize(bool WXUNUSED(iconize))
|
||||
{
|
||||
// Can't iconize a dialog in Motif, apparently
|
||||
// TODO: try using the parent of m_mainShell.
|
||||
// XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
|
||||
// Can't iconize a dialog in Motif, apparently
|
||||
// TODO: try using the parent of m_mainShell.
|
||||
// XtVaSetValues((Widget) m_mainWidget, XmNiconic, iconize, NULL);
|
||||
}
|
||||
|
||||
bool wxDialog::IsIconized() const
|
||||
{
|
||||
/*
|
||||
Boolean iconic;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
|
||||
/*
|
||||
Boolean iconic;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNiconic, &iconic, NULL);
|
||||
|
||||
return iconic;
|
||||
*/
|
||||
return iconic;
|
||||
*/
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -362,61 +362,61 @@ void wxDialog::SetTitle(const wxString& title)
|
||||
{
|
||||
XmString str = XmStringCreateSimple((char*) (const char*) title);
|
||||
XtVaSetValues((Widget) m_mainWidget,
|
||||
XmNtitle, (char*) (const char*) title,
|
||||
XmNdialogTitle, str, // Roberto Cocchi
|
||||
XmNiconName, (char*) (const char*) title,
|
||||
NULL);
|
||||
XmNtitle, (char*) (const char*) title,
|
||||
XmNdialogTitle, str, // Roberto Cocchi
|
||||
XmNiconName, (char*) (const char*) title,
|
||||
NULL);
|
||||
XmStringFree(str);
|
||||
}
|
||||
}
|
||||
|
||||
wxString wxDialog::GetTitle() const
|
||||
{
|
||||
return m_dialogTitle;
|
||||
return m_dialogTitle;
|
||||
}
|
||||
|
||||
void wxDialog::Centre(int direction)
|
||||
{
|
||||
int x_offset,y_offset ;
|
||||
int display_width, display_height;
|
||||
int width, height, x, y;
|
||||
wxWindow *parent = GetParent();
|
||||
if ((direction & wxCENTER_FRAME) && parent)
|
||||
{
|
||||
parent->GetPosition(&x_offset,&y_offset) ;
|
||||
parent->GetSize(&display_width,&display_height) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDisplaySize(&display_width, &display_height);
|
||||
x_offset = 0 ;
|
||||
y_offset = 0 ;
|
||||
}
|
||||
|
||||
GetSize(&width, &height);
|
||||
GetPosition(&x, &y);
|
||||
|
||||
if (direction & wxHORIZONTAL)
|
||||
x = (int)((display_width - width)/2);
|
||||
if (direction & wxVERTICAL)
|
||||
y = (int)((display_height - height)/2);
|
||||
|
||||
SetSize(x+x_offset, y+y_offset, width, height);
|
||||
int x_offset,y_offset ;
|
||||
int display_width, display_height;
|
||||
int width, height, x, y;
|
||||
wxWindow *parent = GetParent();
|
||||
if ((direction & wxCENTER_FRAME) && parent)
|
||||
{
|
||||
parent->GetPosition(&x_offset,&y_offset) ;
|
||||
parent->GetSize(&display_width,&display_height) ;
|
||||
}
|
||||
else
|
||||
{
|
||||
wxDisplaySize(&display_width, &display_height);
|
||||
x_offset = 0 ;
|
||||
y_offset = 0 ;
|
||||
}
|
||||
|
||||
GetSize(&width, &height);
|
||||
GetPosition(&x, &y);
|
||||
|
||||
if (direction & wxHORIZONTAL)
|
||||
x = (int)((display_width - width)/2);
|
||||
if (direction & wxVERTICAL)
|
||||
y = (int)((display_height - height)/2);
|
||||
|
||||
SetSize(x+x_offset, y+y_offset, width, height);
|
||||
}
|
||||
|
||||
void wxDialog::Raise()
|
||||
{
|
||||
Window parent_window = XtWindow((Widget) m_mainWidget),
|
||||
next_parent = XtWindow((Widget) m_mainWidget),
|
||||
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
|
||||
next_parent = XtWindow((Widget) m_mainWidget),
|
||||
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
|
||||
// search for the parent that is child of ROOT, because the WM may
|
||||
// reparent twice and notify only the next parent (like FVWM)
|
||||
while (next_parent != root) {
|
||||
Window *theChildren; unsigned int n;
|
||||
parent_window = next_parent;
|
||||
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
|
||||
&next_parent, &theChildren, &n);
|
||||
XFree(theChildren); // not needed
|
||||
Window *theChildren; unsigned int n;
|
||||
parent_window = next_parent;
|
||||
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
|
||||
&next_parent, &theChildren, &n);
|
||||
XFree(theChildren); // not needed
|
||||
}
|
||||
XRaiseWindow(XtDisplay((Widget) m_mainWidget), parent_window);
|
||||
}
|
||||
@@ -424,16 +424,16 @@ void wxDialog::Raise()
|
||||
void wxDialog::Lower()
|
||||
{
|
||||
Window parent_window = XtWindow((Widget) m_mainWidget),
|
||||
next_parent = XtWindow((Widget) m_mainWidget),
|
||||
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
|
||||
next_parent = XtWindow((Widget) m_mainWidget),
|
||||
root = RootWindowOfScreen(XtScreen((Widget) m_mainWidget));
|
||||
// search for the parent that is child of ROOT, because the WM may
|
||||
// reparent twice and notify only the next parent (like FVWM)
|
||||
while (next_parent != root) {
|
||||
Window *theChildren; unsigned int n;
|
||||
parent_window = next_parent;
|
||||
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
|
||||
&next_parent, &theChildren, &n);
|
||||
XFree(theChildren); // not needed
|
||||
Window *theChildren; unsigned int n;
|
||||
parent_window = next_parent;
|
||||
XQueryTree(XtDisplay((Widget) m_mainWidget), parent_window, &root,
|
||||
&next_parent, &theChildren, &n);
|
||||
XFree(theChildren); // not needed
|
||||
}
|
||||
XLowerWindow(XtDisplay((Widget) m_mainWidget), parent_window);
|
||||
}
|
||||
@@ -441,16 +441,16 @@ void wxDialog::Lower()
|
||||
bool wxDialog::Show(bool show)
|
||||
{
|
||||
m_isShown = show;
|
||||
|
||||
|
||||
if (show)
|
||||
{
|
||||
if (!wxUSE_INVISIBLE_RESIZE)
|
||||
XtMapWidget(XtParent((Widget) m_mainWidget));
|
||||
XtMapWidget(XtParent((Widget) m_mainWidget));
|
||||
else
|
||||
XtManageChild((Widget) m_mainWidget) ;
|
||||
|
||||
XtManageChild((Widget) m_mainWidget) ;
|
||||
|
||||
XRaiseWindow(XtDisplay((Widget) m_mainWidget), XtWindow((Widget) m_mainWidget));
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -458,11 +458,11 @@ bool wxDialog::Show(bool show)
|
||||
XtUnmapWidget(XtParent((Widget) m_mainWidget));
|
||||
else
|
||||
XtUnmanageChild((Widget) m_mainWidget) ;
|
||||
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
}
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -470,43 +470,43 @@ bool wxDialog::Show(bool show)
|
||||
int wxDialog::ShowModal()
|
||||
{
|
||||
m_windowStyle |= wxDIALOG_MODAL;
|
||||
|
||||
|
||||
Show(TRUE);
|
||||
|
||||
|
||||
if (m_modalShowing)
|
||||
return 0;
|
||||
|
||||
|
||||
wxModalShowingStack.Insert((wxObject *)TRUE);
|
||||
|
||||
|
||||
m_modalShowing = TRUE;
|
||||
XtAddGrab((Widget) m_mainWidget, TRUE, FALSE);
|
||||
|
||||
|
||||
XEvent event;
|
||||
|
||||
|
||||
// Loop until we signal that the dialog should be closed
|
||||
while ((wxModalShowingStack.Number() > 0) && ((int)(wxModalShowingStack.First()->Data()) != 0))
|
||||
{
|
||||
// XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
// XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
wxTheApp->ProcessXEvent((WXEvent*) &event);
|
||||
}
|
||||
|
||||
|
||||
// Remove modal dialog flag from stack
|
||||
wxNode *node = wxModalShowingStack.First();
|
||||
if (node)
|
||||
delete node;
|
||||
|
||||
delete node;
|
||||
|
||||
// Now process all events in case they get sent to a destroyed dialog
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
|
||||
{
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
|
||||
|
||||
wxTheApp->ProcessXEvent((WXEvent*) &event);
|
||||
}
|
||||
|
||||
|
||||
// TODO: is it safe to call this, if the dialog may have been deleted
|
||||
// by now? Probably only if we're using delayed deletion of dialogs.
|
||||
return GetReturnCode();
|
||||
@@ -516,41 +516,41 @@ void wxDialog::EndModal(int retCode)
|
||||
{
|
||||
if (!m_modalShowing)
|
||||
return;
|
||||
|
||||
|
||||
SetReturnCode(retCode);
|
||||
|
||||
|
||||
// Strangely, we don't seem to need this now.
|
||||
// XtRemoveGrab((Widget) m_mainWidget);
|
||||
|
||||
|
||||
Show(FALSE);
|
||||
|
||||
|
||||
m_modalShowing = FALSE;
|
||||
|
||||
|
||||
wxNode *node = wxModalShowingStack.First();
|
||||
if (node)
|
||||
node->SetData((wxObject *)FALSE);
|
||||
node->SetData((wxObject *)FALSE);
|
||||
}
|
||||
|
||||
// Standard buttons
|
||||
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
if ( Validate() && TransferDataFromWindow() )
|
||||
{
|
||||
if ( IsModal() )
|
||||
EndModal(wxID_OK);
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_OK);
|
||||
this->Show(FALSE);
|
||||
SetReturnCode(wxID_OK);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
|
||||
{
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
if (Validate())
|
||||
TransferDataFromWindow();
|
||||
// TODO probably need to disable the Apply button until things change again
|
||||
}
|
||||
|
||||
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
@@ -560,30 +560,30 @@ void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
|
||||
else
|
||||
{
|
||||
SetReturnCode(wxID_CANCEL);
|
||||
this->Show(FALSE);
|
||||
this->Show(FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
bool wxDialog::OnClose()
|
||||
{
|
||||
// Behaviour changed in 2.0: we'll send a Cancel message by default,
|
||||
// Behaviour changed in 2.0: we'll send a Cancel message by default,
|
||||
// which may close the dialog.
|
||||
// Check for looping if the Cancel event handler calls Close()
|
||||
|
||||
|
||||
static wxList closing;
|
||||
|
||||
|
||||
if ( closing.Member(this) )
|
||||
return FALSE;
|
||||
|
||||
|
||||
closing.Append(this);
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
|
||||
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
|
||||
cancelEvent.SetEventObject( this );
|
||||
GetEventHandler()->ProcessEvent(cancelEvent);
|
||||
|
||||
closing.DeleteObject(this);
|
||||
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
@@ -598,15 +598,15 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event)
|
||||
// Destroy the window (delayed, if a managed window)
|
||||
bool wxDialog::Destroy()
|
||||
{
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
return TRUE;
|
||||
if (!wxPendingDelete.Member(this))
|
||||
wxPendingDelete.Append(this);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
|
||||
{
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE));
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void wxDialog::Fit()
|
||||
@@ -615,106 +615,106 @@ void wxDialog::Fit()
|
||||
|
||||
// Handle a close event from the window manager
|
||||
static void wxCloseDialogCallback( Widget WXUNUSED(widget), XtPointer client_data,
|
||||
XmAnyCallbackStruct *WXUNUSED(cbs))
|
||||
XmAnyCallbackStruct *WXUNUSED(cbs))
|
||||
{
|
||||
wxDialog *dialog = (wxDialog *)client_data;
|
||||
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
|
||||
closeEvent.SetEventObject(dialog);
|
||||
|
||||
// May delete the dialog (with delayed deletion)
|
||||
dialog->GetEventHandler()->ProcessEvent(closeEvent);
|
||||
wxDialog *dialog = (wxDialog *)client_data;
|
||||
wxCloseEvent closeEvent(wxEVT_CLOSE_WINDOW, dialog->GetId());
|
||||
closeEvent.SetEventObject(dialog);
|
||||
|
||||
// May delete the dialog (with delayed deletion)
|
||||
dialog->GetEventHandler()->ProcessEvent(closeEvent);
|
||||
}
|
||||
|
||||
// TODO: Preferably, we should have a universal repaint proc.
|
||||
// Meanwhile, use a special one for dialogs.
|
||||
static void wxDialogBoxRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *)
|
||||
{
|
||||
Window window;
|
||||
Display *display;
|
||||
|
||||
wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
switch(event -> type)
|
||||
{
|
||||
case Expose :
|
||||
{
|
||||
window = (Window) win -> GetXWindow();
|
||||
display = (Display *) win -> GetXDisplay();
|
||||
|
||||
wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
|
||||
event->xexpose.width, event->xexpose.height);
|
||||
win->m_updateRects.Append((wxObject*) rect);
|
||||
|
||||
if (event -> xexpose.count == 0)
|
||||
{
|
||||
wxPaintEvent event(win->GetId());
|
||||
event.SetEventObject(win);
|
||||
win->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
win->ClearUpdateRects();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
cout << "\n\nNew Event ! is = " << event -> type << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
Window window;
|
||||
Display *display;
|
||||
|
||||
wxWindow* win = (wxWindow *)wxWidgetHashTable->Get((long)w);
|
||||
if (!win)
|
||||
return;
|
||||
|
||||
switch(event -> type)
|
||||
{
|
||||
case Expose :
|
||||
{
|
||||
window = (Window) win -> GetXWindow();
|
||||
display = (Display *) win -> GetXDisplay();
|
||||
|
||||
wxRect* rect = new wxRect(event->xexpose.x, event->xexpose.y,
|
||||
event->xexpose.width, event->xexpose.height);
|
||||
win->m_updateRects.Append((wxObject*) rect);
|
||||
|
||||
if (event -> xexpose.count == 0)
|
||||
{
|
||||
wxPaintEvent event(win->GetId());
|
||||
event.SetEventObject(win);
|
||||
win->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
win->ClearUpdateRects();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default :
|
||||
{
|
||||
cout << "\n\nNew Event ! is = " << event -> type << "\n";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void wxDialogBoxEventHandler (Widget wid,
|
||||
XtPointer WXUNUSED(client_data),
|
||||
XEvent* event,
|
||||
Boolean *continueToDispatch)
|
||||
XtPointer WXUNUSED(client_data),
|
||||
XEvent* event,
|
||||
Boolean *continueToDispatch)
|
||||
{
|
||||
wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
|
||||
if (dialog)
|
||||
{
|
||||
wxMouseEvent wxevent(wxEVT_NULL);
|
||||
if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
|
||||
wxDialog *dialog = (wxDialog *)wxWidgetHashTable->Get((long)wid);
|
||||
if (dialog)
|
||||
{
|
||||
wxevent.SetEventObject(dialog);
|
||||
wxevent.SetId(dialog->GetId());
|
||||
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))
|
||||
wxMouseEvent wxevent(wxEVT_NULL);
|
||||
if (wxTranslateMouseEvent(wxevent, dialog, wid, event))
|
||||
{
|
||||
*continueToDispatch = False;
|
||||
return;
|
||||
wxevent.SetEventObject(dialog);
|
||||
wxevent.SetId(dialog->GetId());
|
||||
dialog->GetEventHandler()->ProcessEvent(wxevent);
|
||||
}
|
||||
else
|
||||
{
|
||||
keyEvent.SetEventType(wxEVT_CHAR);
|
||||
dialog->GetEventHandler()->ProcessEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
// An attempt to implement OnCharHook by calling OnCharHook first;
|
||||
// if this returns TRUE, set continueToDispatch to False
|
||||
// (don't continue processing).
|
||||
// Otherwise set it to True and call OnChar.
|
||||
wxKeyEvent keyEvent(wxEVENT_TYPE_CHAR);
|
||||
if (wxTranslateKeyEvent(keyEvent, dialog, wid, event))
|
||||
{
|
||||
keyEvent.SetEventObject(dialog);
|
||||
keyEvent.SetId(dialog->GetId());
|
||||
keyEvent.SetEventType(wxEVT_CHAR_HOOK);
|
||||
if (dialog->GetEventHandler()->ProcessEvent(keyEvent))
|
||||
{
|
||||
*continueToDispatch = False;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
keyEvent.SetEventType(wxEVT_CHAR);
|
||||
dialog->GetEventHandler()->ProcessEvent(keyEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*continueToDispatch = True;
|
||||
*continueToDispatch = True;
|
||||
}
|
||||
|
||||
static void wxUnmapBulletinBoard(Widget WXUNUSED(dialog), wxDialog *WXUNUSED(client), XtPointer WXUNUSED(call) )
|
||||
{
|
||||
/* This gets called when the dialog is being shown, which
|
||||
* defeats modal showing.
|
||||
client->m_modalShowing = FALSE ;
|
||||
client->m_isShown = FALSE;
|
||||
*/
|
||||
/* This gets called when the dialog is being shown, which
|
||||
* defeats modal showing.
|
||||
client->m_modalShowing = FALSE ;
|
||||
client->m_isShown = FALSE;
|
||||
*/
|
||||
}
|
||||
|
||||
void wxDialog::ChangeFont(bool keepOriginalSize)
|
||||
|
@@ -1,22 +1,29 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Name: dnd.cpp
|
||||
// Purpose: wxDropTarget, wxDropSource, wxDataObject implementation
|
||||
// Purpose: wxDropTarget, wxDropSource classes
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 17/09/98
|
||||
// RCS-ID: $Id$
|
||||
// Id: $Id$
|
||||
// Copyright: (c) 1998 Julian Smart
|
||||
// Licence: wxWindows licence
|
||||
// Licence: wxWindows licence
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "dnd.h"
|
||||
#endif
|
||||
|
||||
#include "wx/setup.h"
|
||||
|
||||
#if wxUSE_DRAG_AND_DROP
|
||||
|
||||
#include "wx/dnd.h"
|
||||
#include "wx/window.h"
|
||||
#include "wx/app.h"
|
||||
#include "wx/gdicmn.h"
|
||||
#include "wx/intl.h"
|
||||
#include "wx/utils.h"
|
||||
#include "wx/log.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// global
|
||||
@@ -28,28 +35,28 @@
|
||||
|
||||
wxDropTarget::wxDropTarget()
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
wxDropTarget::~wxDropTarget()
|
||||
{
|
||||
};
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxTextDropTarget
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxTextDropTarget::OnDrop( long x, long y, const void *pData )
|
||||
bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
|
||||
{
|
||||
OnDropText( x, y, (const char*)pData );
|
||||
OnDropText( x, y, (const char*)data );
|
||||
return TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
|
||||
{
|
||||
printf( "Got dropped text: %s.\n", psz );
|
||||
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
|
||||
wxLogDebug( "Got dropped text: %s.", psz );
|
||||
wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
|
||||
return TRUE;
|
||||
};
|
||||
}
|
||||
|
||||
size_t wxTextDropTarget::GetFormatCount() const
|
||||
{
|
||||
@@ -65,18 +72,41 @@ wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
||||
// wxFileDropTarget
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const WXUNUSED(aszFiles)[] )
|
||||
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
|
||||
{
|
||||
printf( "Got %d dropped files.\n", (int)nFiles );
|
||||
printf( "At x: %d, y: %d.\n", (int)x, (int)y );
|
||||
wxLogDebug( "Got %d dropped files.", (int)nFiles );
|
||||
wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
|
||||
for (size_t i = 0; i < nFiles; i++)
|
||||
{
|
||||
wxLogDebug( aszFiles[i] );
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
bool wxFileDropTarget::OnDrop(long x, long y, const void *WXUNUSED(pData) )
|
||||
bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
|
||||
{
|
||||
char *str = "/this/is/a/path.txt";
|
||||
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
|
||||
@@ -93,41 +123,100 @@ wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
|
||||
// wxDropSource
|
||||
//-------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// drag request
|
||||
|
||||
wxDropSource::wxDropSource( wxWindow *win )
|
||||
{
|
||||
// TODO
|
||||
// m_window = win;
|
||||
m_data = NULL;
|
||||
#if 0
|
||||
m_window = win;
|
||||
m_data = (wxDataObject *) NULL;
|
||||
m_retValue = wxDragCancel;
|
||||
|
||||
// m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||
// m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||
};
|
||||
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||
#endif
|
||||
}
|
||||
|
||||
wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
|
||||
{
|
||||
// TODO
|
||||
// m_window = win;
|
||||
m_data = &data;
|
||||
#if 0
|
||||
g_blockEventsOnDrag = TRUE;
|
||||
|
||||
m_window = win;
|
||||
m_widget = win->m_widget;
|
||||
if (win->m_wxwindow) m_widget = win->m_wxwindow;
|
||||
m_retValue = wxDragCancel;
|
||||
|
||||
m_data = &data;
|
||||
|
||||
// m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||
// m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||
};
|
||||
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
|
||||
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
|
||||
#endif
|
||||
}
|
||||
|
||||
void wxDropSource::SetData( wxDataObject &data )
|
||||
{
|
||||
m_data = &data;
|
||||
};
|
||||
// m_data = &data;
|
||||
}
|
||||
|
||||
wxDropSource::~wxDropSource(void)
|
||||
{
|
||||
};
|
||||
// if (m_data) delete m_data;
|
||||
}
|
||||
|
||||
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
|
||||
{
|
||||
// TODO
|
||||
return wxDragError;
|
||||
};
|
||||
// wxASSERT_MSG( m_data, "wxDragSource: no data" );
|
||||
|
||||
return wxDragNone;
|
||||
#if 0
|
||||
if (!m_data) return (wxDragResult) wxDragNone;
|
||||
if (m_data->GetDataSize() == 0) return (wxDragResult) wxDragNone;
|
||||
|
||||
RegisterWindow();
|
||||
|
||||
// TODO
|
||||
|
||||
UnregisterWindow();
|
||||
|
||||
g_blockEventsOnDrag = FALSE;
|
||||
|
||||
return m_retValue;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if 0
|
||||
void wxDropSource::RegisterWindow(void)
|
||||
{
|
||||
if (!m_data) return;
|
||||
|
||||
wxString formats;
|
||||
|
||||
wxDataFormat df = m_data->GetPreferredFormat();
|
||||
|
||||
switch (df)
|
||||
{
|
||||
case wxDF_TEXT:
|
||||
formats += "text/plain";
|
||||
break;
|
||||
case wxDF_FILENAME:
|
||||
formats += "file:ALL";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
char *str = WXSTRINGCAST formats;
|
||||
|
||||
// TODO
|
||||
}
|
||||
|
||||
void wxDropSource::UnregisterWindow(void)
|
||||
{
|
||||
if (!m_widget) return;
|
||||
|
||||
// TODO
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
// wxUSE_DRAG_AND_DROP
|
||||
|
@@ -36,9 +36,9 @@ IMPLEMENT_CLASS(wxFileDialog, wxDialog)
|
||||
#endif
|
||||
|
||||
#define DEFAULT_FILE_SELECTOR_SIZE 0
|
||||
// Let Motif defines the size of File
|
||||
// Selector Box (if 1), or fix it to
|
||||
// wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
|
||||
// Let Motif defines the size of File
|
||||
// Selector Box (if 1), or fix it to
|
||||
// wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
|
||||
#define wxFSB_WIDTH 600
|
||||
#define wxFSB_HEIGHT 500
|
||||
|
||||
@@ -50,27 +50,27 @@ char *wxFileSelector(const char *title,
|
||||
{
|
||||
// If there's a default extension specified but no filter, we create a suitable
|
||||
// filter.
|
||||
|
||||
|
||||
wxString filter2("");
|
||||
if ( defaultExtension && !filter )
|
||||
filter2 = wxString("*.") + wxString(defaultExtension) ;
|
||||
else if ( filter )
|
||||
filter2 = filter;
|
||||
|
||||
|
||||
wxString defaultDirString;
|
||||
if (defaultDir)
|
||||
defaultDirString = defaultDir;
|
||||
else
|
||||
defaultDirString = "";
|
||||
|
||||
|
||||
wxString defaultFilenameString;
|
||||
if (defaultFileName)
|
||||
defaultFilenameString = defaultFileName;
|
||||
else
|
||||
defaultFilenameString = "";
|
||||
|
||||
|
||||
wxFileDialog fileDialog(parent, title, defaultDirString, defaultFilenameString, filter2, flags, wxPoint(x, y));
|
||||
|
||||
|
||||
if ( fileDialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
strcpy(wxBuffer, (const char *)fileDialog.GetPath());
|
||||
@@ -89,11 +89,11 @@ char *wxFileSelectorEx(const char *title,
|
||||
wxWindow* parent,
|
||||
int x,
|
||||
int y)
|
||||
|
||||
|
||||
{
|
||||
wxFileDialog fileDialog(parent, title ? title : "", defaultDir ? defaultDir : "",
|
||||
defaultFileName ? defaultFileName : "", filter ? filter : "", flags, wxPoint(x, y));
|
||||
|
||||
|
||||
if ( fileDialog.ShowModal() == wxID_OK )
|
||||
{
|
||||
*defaultFilterIndex = fileDialog.GetFilterIndex();
|
||||
@@ -108,30 +108,30 @@ wxString wxFileDialog::m_fileSelectorAnswer = "";
|
||||
bool wxFileDialog::m_fileSelectorReturned = FALSE;
|
||||
|
||||
void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data),
|
||||
XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
|
||||
XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
|
||||
{
|
||||
wxFileDialog::m_fileSelectorAnswer = "";
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
wxFileDialog::m_fileSelectorAnswer = "";
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
}
|
||||
|
||||
void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSelectionBoxCallbackStruct *cbs)
|
||||
{
|
||||
char *filename = NULL;
|
||||
if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
|
||||
wxFileDialog::m_fileSelectorAnswer = "";
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
} else {
|
||||
if (filename) {
|
||||
wxFileDialog::m_fileSelectorAnswer = filename;
|
||||
XtFree(filename);
|
||||
char *filename = NULL;
|
||||
if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
|
||||
wxFileDialog::m_fileSelectorAnswer = "";
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
} else {
|
||||
if (filename) {
|
||||
wxFileDialog::m_fileSelectorAnswer = filename;
|
||||
XtFree(filename);
|
||||
}
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
}
|
||||
wxFileDialog::m_fileSelectorReturned = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
||||
long style, const wxPoint& pos)
|
||||
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
|
||||
long style, const wxPoint& pos)
|
||||
{
|
||||
m_message = message;
|
||||
m_dialogStyle = style;
|
||||
@@ -146,159 +146,159 @@ wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
|
||||
|
||||
int wxFileDialog::ShowModal()
|
||||
{
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// static char fileBuf[512];
|
||||
Widget parentWidget = (Widget) 0;
|
||||
if (m_parent)
|
||||
{
|
||||
parentWidget = (Widget) m_parent->GetTopWidget();
|
||||
}
|
||||
else
|
||||
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
|
||||
|
||||
Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
|
||||
XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
|
||||
|
||||
Widget shell = XtParent(fileSel);
|
||||
|
||||
if (!m_message.IsNull())
|
||||
XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
|
||||
|
||||
wxString entirePath("");
|
||||
|
||||
if ((m_dir != "") && (m_fileName != ""))
|
||||
{
|
||||
entirePath = m_dir + wxString("/") + m_fileName;
|
||||
}
|
||||
else if ((m_dir != "") && (m_fileName == ""))
|
||||
{
|
||||
entirePath = m_dir + wxString("/");
|
||||
}
|
||||
else if ((m_dir == "") && (m_fileName != ""))
|
||||
{
|
||||
entirePath = m_fileName;
|
||||
}
|
||||
|
||||
if (entirePath != "")
|
||||
{
|
||||
Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
|
||||
XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
|
||||
}
|
||||
|
||||
if (m_wildCard != "")
|
||||
{
|
||||
wxString filter("");
|
||||
if (m_dir != "")
|
||||
filter = m_dir + wxString("/") + m_wildCard;
|
||||
wxBeginBusyCursor();
|
||||
|
||||
// static char fileBuf[512];
|
||||
Widget parentWidget = (Widget) 0;
|
||||
if (m_parent)
|
||||
{
|
||||
parentWidget = (Widget) m_parent->GetTopWidget();
|
||||
}
|
||||
else
|
||||
filter = m_wildCard;
|
||||
|
||||
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
|
||||
XmTextSetString(filterWidget, (char*) (const char*) filter);
|
||||
XmFileSelectionDoSearch(fileSel, NULL);
|
||||
}
|
||||
|
||||
// Suggested by Terry Gitnick, 16/9/97, because of change in Motif
|
||||
// file selector on Solaris 1.5.1.
|
||||
if ( m_dir != "" )
|
||||
{
|
||||
XmString thePath = XmStringCreateLtoR ((char*) (const char*) m_dir,
|
||||
XmSTRING_DEFAULT_CHARSET);
|
||||
|
||||
XtVaSetValues (fileSel,
|
||||
XmNdirectory, thePath,
|
||||
NULL);
|
||||
|
||||
XmStringFree(thePath);
|
||||
}
|
||||
|
||||
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
|
||||
XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
|
||||
|
||||
//#if XmVersion > 1000
|
||||
// I'm not sure about what you mean with XmVersion.
|
||||
// If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
|
||||
// (Motif1.1.4 ==> XmVersion 1100 )
|
||||
// Nevertheless, I put here a #define, so anyone can choose in (I)makefile...
|
||||
//
|
||||
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
|
||||
|
||||
Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", NULL, 0);
|
||||
XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
|
||||
|
||||
Widget shell = XtParent(fileSel);
|
||||
|
||||
if (!m_message.IsNull())
|
||||
XtVaSetValues(shell, XmNtitle, (char*) (const char*) m_message, NULL);
|
||||
|
||||
wxString entirePath("");
|
||||
|
||||
if ((m_dir != "") && (m_fileName != ""))
|
||||
{
|
||||
entirePath = m_dir + wxString("/") + m_fileName;
|
||||
}
|
||||
else if ((m_dir != "") && (m_fileName == ""))
|
||||
{
|
||||
entirePath = m_dir + wxString("/");
|
||||
}
|
||||
else if ((m_dir == "") && (m_fileName != ""))
|
||||
{
|
||||
entirePath = m_fileName;
|
||||
}
|
||||
|
||||
if (entirePath != "")
|
||||
{
|
||||
Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
|
||||
XmTextSetString(selectionWidget, (char*) (const char*) entirePath);
|
||||
}
|
||||
|
||||
if (m_wildCard != "")
|
||||
{
|
||||
wxString filter("");
|
||||
if (m_dir != "")
|
||||
filter = m_dir + wxString("/") + m_wildCard;
|
||||
else
|
||||
filter = m_wildCard;
|
||||
|
||||
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
|
||||
XmTextSetString(filterWidget, (char*) (const char*) filter);
|
||||
XmFileSelectionDoSearch(fileSel, NULL);
|
||||
}
|
||||
|
||||
// Suggested by Terry Gitnick, 16/9/97, because of change in Motif
|
||||
// file selector on Solaris 1.5.1.
|
||||
if ( m_dir != "" )
|
||||
{
|
||||
XmString thePath = XmStringCreateLtoR ((char*) (const char*) m_dir,
|
||||
XmSTRING_DEFAULT_CHARSET);
|
||||
|
||||
XtVaSetValues (fileSel,
|
||||
XmNdirectory, thePath,
|
||||
NULL);
|
||||
|
||||
XmStringFree(thePath);
|
||||
}
|
||||
|
||||
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
|
||||
XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
|
||||
|
||||
//#if XmVersion > 1000
|
||||
// I'm not sure about what you mean with XmVersion.
|
||||
// If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
|
||||
// (Motif1.1.4 ==> XmVersion 1100 )
|
||||
// Nevertheless, I put here a #define, so anyone can choose in (I)makefile...
|
||||
//
|
||||
#if !DEFAULT_FILE_SELECTOR_SIZE
|
||||
int width = wxFSB_WIDTH;
|
||||
int height = wxFSB_HEIGHT;
|
||||
XtVaSetValues(fileSel,
|
||||
XmNwidth, width,
|
||||
XmNheight, height,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
int width = wxFSB_WIDTH;
|
||||
int height = wxFSB_HEIGHT;
|
||||
XtVaSetValues(fileSel,
|
||||
XmNwidth, width,
|
||||
XmNheight, height,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
#endif
|
||||
|
||||
XtManageChild(fileSel);
|
||||
|
||||
m_fileSelectorAnswer = "";
|
||||
m_fileSelectorReturned = FALSE;
|
||||
|
||||
wxEndBusyCursor();
|
||||
|
||||
XtAddGrab(XtParent(fileSel), TRUE, FALSE);
|
||||
XEvent event;
|
||||
while (!m_fileSelectorReturned)
|
||||
{
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
}
|
||||
XtRemoveGrab(XtParent(fileSel));
|
||||
|
||||
XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
|
||||
|
||||
// XtDestroyWidget(fileSel);
|
||||
XtUnmapWidget(XtParent(fileSel));
|
||||
XtDestroyWidget(XtParent(fileSel));
|
||||
|
||||
// Now process all events, because otherwise
|
||||
// this might remain on the screen
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
|
||||
{
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
|
||||
m_path = m_fileSelectorAnswer;
|
||||
m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
|
||||
m_dir = wxPathOnly(m_path);
|
||||
|
||||
if (m_fileName == "")
|
||||
return wxID_CANCEL;
|
||||
else
|
||||
return wxID_OK;
|
||||
|
||||
XtManageChild(fileSel);
|
||||
|
||||
m_fileSelectorAnswer = "";
|
||||
m_fileSelectorReturned = FALSE;
|
||||
|
||||
wxEndBusyCursor();
|
||||
|
||||
XtAddGrab(XtParent(fileSel), TRUE, FALSE);
|
||||
XEvent event;
|
||||
while (!m_fileSelectorReturned)
|
||||
{
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
}
|
||||
XtRemoveGrab(XtParent(fileSel));
|
||||
|
||||
XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
|
||||
|
||||
// XtDestroyWidget(fileSel);
|
||||
XtUnmapWidget(XtParent(fileSel));
|
||||
XtDestroyWidget(XtParent(fileSel));
|
||||
|
||||
// Now process all events, because otherwise
|
||||
// this might remain on the screen
|
||||
XSync(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()), FALSE);
|
||||
while (XtAppPending((XtAppContext) wxTheApp->GetAppContext()))
|
||||
{
|
||||
XFlush(XtDisplay((Widget) wxTheApp->GetTopLevelWidget()));
|
||||
XtAppNextEvent((XtAppContext) wxTheApp->GetAppContext(), &event);
|
||||
XtDispatchEvent(&event);
|
||||
}
|
||||
|
||||
m_path = m_fileSelectorAnswer;
|
||||
m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
|
||||
m_dir = wxPathOnly(m_path);
|
||||
|
||||
if (m_fileName == "")
|
||||
return wxID_CANCEL;
|
||||
else
|
||||
return wxID_OK;
|
||||
}
|
||||
|
||||
// Generic file load/save dialog
|
||||
static char *
|
||||
wxDefaultFileSelector(bool load, const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
||||
{
|
||||
char *ext = (char *)extension;
|
||||
|
||||
char prompt[50];
|
||||
wxString str;
|
||||
if (load)
|
||||
str = "Load %s file";
|
||||
else
|
||||
str = "Save %s file";
|
||||
sprintf(prompt, wxGetTranslation(str), what);
|
||||
|
||||
if (*ext == '.') ext++;
|
||||
char wild[60];
|
||||
sprintf(wild, "*.%s", ext);
|
||||
|
||||
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
||||
char *ext = (char *)extension;
|
||||
|
||||
char prompt[50];
|
||||
wxString str;
|
||||
if (load)
|
||||
str = "Load %s file";
|
||||
else
|
||||
str = "Save %s file";
|
||||
sprintf(prompt, wxGetTranslation(str), what);
|
||||
|
||||
if (*ext == '.') ext++;
|
||||
char wild[60];
|
||||
sprintf(wild, "*.%s", ext);
|
||||
|
||||
return wxFileSelector (prompt, NULL, default_name, ext, wild, 0, parent);
|
||||
}
|
||||
|
||||
// Generic file load dialog
|
||||
char *
|
||||
wxLoadFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
||||
{
|
||||
return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
|
||||
return wxDefaultFileSelector(TRUE, what, extension, default_name, parent);
|
||||
}
|
||||
|
||||
|
||||
@@ -306,7 +306,7 @@ wxLoadFileSelector(const char *what, const char *extension, const char *default_
|
||||
char *
|
||||
wxSaveFileSelector(const char *what, const char *extension, const char *default_name, wxWindow *parent)
|
||||
{
|
||||
return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
|
||||
return wxDefaultFileSelector(FALSE, what, extension, default_name, parent);
|
||||
}
|
||||
|
||||
|
||||
|
@@ -37,12 +37,12 @@ wxXFont::~wxXFont()
|
||||
{
|
||||
XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
|
||||
XmFontList fontList = (XmFontList) m_fontList;
|
||||
|
||||
|
||||
XmFontListFree (fontList);
|
||||
|
||||
// TODO: why does freeing the font produce a segv???
|
||||
|
||||
// TODO: why does freeing the font produce a segv???
|
||||
// Note that XFreeFont wasn't called in wxWin 1.68 either.
|
||||
// XFreeFont((Display*) m_display, fontStruct);
|
||||
// XFreeFont((Display*) m_display, fontStruct);
|
||||
}
|
||||
|
||||
wxFontRefData::wxFontRefData()
|
||||
@@ -65,7 +65,7 @@ wxFontRefData::wxFontRefData(const wxFontRefData& data)
|
||||
m_weight = data.m_weight;
|
||||
m_underlined = data.m_underlined;
|
||||
m_faceName = data.m_faceName;
|
||||
|
||||
|
||||
// Don't have to copy actual fonts, because they'll be created
|
||||
// on demand.
|
||||
}
|
||||
@@ -91,7 +91,7 @@ wxFont::wxFont()
|
||||
wxFont::wxFont(int pointSize, int family, int style, int weight, bool underlined, const wxString& faceName)
|
||||
{
|
||||
Create(pointSize, family, style, weight, underlined, faceName);
|
||||
|
||||
|
||||
if ( wxTheFontList )
|
||||
wxTheFontList->Append(this);
|
||||
}
|
||||
@@ -100,16 +100,16 @@ bool wxFont::Create(int pointSize, int family, int style, int weight, bool under
|
||||
{
|
||||
UnRef();
|
||||
m_refData = new wxFontRefData;
|
||||
|
||||
|
||||
M_FONTDATA->m_family = family;
|
||||
M_FONTDATA->m_style = style;
|
||||
M_FONTDATA->m_weight = weight;
|
||||
M_FONTDATA->m_pointSize = pointSize;
|
||||
M_FONTDATA->m_underlined = underlined;
|
||||
M_FONTDATA->m_faceName = faceName;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -127,101 +127,101 @@ bool wxFont::RealizeResource()
|
||||
|
||||
void wxFont::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxFontRefData();
|
||||
}
|
||||
m_refData = new wxFontRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxFont::SetPointSize(int pointSize)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_pointSize = pointSize;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetFamily(int family)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_family = family;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetStyle(int style)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_style = style;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetWeight(int weight)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_weight = weight;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetFaceName(const wxString& faceName)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_faceName = faceName;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxFont::SetUnderlined(bool underlined)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_FONTDATA->m_underlined = underlined;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
wxString wxFont::GetFamilyString() const
|
||||
{
|
||||
wxString fam("");
|
||||
switch (GetFamily())
|
||||
{
|
||||
wxString fam("");
|
||||
switch (GetFamily())
|
||||
{
|
||||
case wxDECORATIVE:
|
||||
fam = "wxDECORATIVE";
|
||||
break;
|
||||
fam = "wxDECORATIVE";
|
||||
break;
|
||||
case wxROMAN:
|
||||
fam = "wxROMAN";
|
||||
break;
|
||||
fam = "wxROMAN";
|
||||
break;
|
||||
case wxSCRIPT:
|
||||
fam = "wxSCRIPT";
|
||||
break;
|
||||
fam = "wxSCRIPT";
|
||||
break;
|
||||
case wxSWISS:
|
||||
fam = "wxSWISS";
|
||||
break;
|
||||
fam = "wxSWISS";
|
||||
break;
|
||||
case wxMODERN:
|
||||
fam = "wxMODERN";
|
||||
break;
|
||||
fam = "wxMODERN";
|
||||
break;
|
||||
case wxTELETYPE:
|
||||
fam = "wxTELETYPE";
|
||||
break;
|
||||
fam = "wxTELETYPE";
|
||||
break;
|
||||
default:
|
||||
fam = "wxDEFAULT";
|
||||
break;
|
||||
}
|
||||
return fam;
|
||||
fam = "wxDEFAULT";
|
||||
break;
|
||||
}
|
||||
return fam;
|
||||
}
|
||||
|
||||
/* New font system */
|
||||
@@ -229,7 +229,7 @@ wxString wxFont::GetFaceName() const
|
||||
{
|
||||
wxString str("");
|
||||
if (M_FONTDATA)
|
||||
str = M_FONTDATA->m_faceName ;
|
||||
str = M_FONTDATA->m_faceName ;
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -238,15 +238,15 @@ wxString wxFont::GetStyleString() const
|
||||
wxString styl("");
|
||||
switch (GetStyle())
|
||||
{
|
||||
case wxITALIC:
|
||||
styl = "wxITALIC";
|
||||
break;
|
||||
case wxSLANT:
|
||||
styl = "wxSLANT";
|
||||
break;
|
||||
default:
|
||||
styl = "wxNORMAL";
|
||||
break;
|
||||
case wxITALIC:
|
||||
styl = "wxITALIC";
|
||||
break;
|
||||
case wxSLANT:
|
||||
styl = "wxSLANT";
|
||||
break;
|
||||
default:
|
||||
styl = "wxNORMAL";
|
||||
break;
|
||||
}
|
||||
return styl;
|
||||
}
|
||||
@@ -256,15 +256,15 @@ wxString wxFont::GetWeightString() const
|
||||
wxString w("");
|
||||
switch (GetWeight())
|
||||
{
|
||||
case wxBOLD:
|
||||
w = "wxBOLD";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
w = "wxLIGHT";
|
||||
break;
|
||||
default:
|
||||
w = "wxNORMAL";
|
||||
break;
|
||||
case wxBOLD:
|
||||
w = "wxBOLD";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
w = "wxLIGHT";
|
||||
break;
|
||||
default:
|
||||
w = "wxNORMAL";
|
||||
break;
|
||||
}
|
||||
return w;
|
||||
}
|
||||
@@ -274,106 +274,106 @@ wxString wxFont::GetWeightString() const
|
||||
// font to list in the private data for future reference.
|
||||
wxXFont* wxFont::GetInternalFont(double scale, WXDisplay* display) const
|
||||
{
|
||||
if (!Ok())
|
||||
return (wxXFont*) NULL;
|
||||
|
||||
long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
|
||||
int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
|
||||
|
||||
wxNode* node = M_FONTDATA->m_fonts.First();
|
||||
while (node)
|
||||
{
|
||||
wxXFont* f = (wxXFont*) node->Data();
|
||||
if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
|
||||
return f;
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
|
||||
M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
|
||||
if (!font)
|
||||
{
|
||||
// search up and down by stepsize 10
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
int i;
|
||||
|
||||
// Search for smaller size (approx.)
|
||||
for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Search for larger size (approx.)
|
||||
for (i=pointSize+10; !font && i <= max_size; i += 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Try default family
|
||||
if (!font && M_FONTDATA->m_family != wxDEFAULT)
|
||||
font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
|
||||
M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Bogus font
|
||||
if (!font)
|
||||
font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
M_FONTDATA->m_underlined);
|
||||
if (!Ok())
|
||||
return (wxXFont*) NULL;
|
||||
|
||||
long intScale = long(scale * 100.0 + 0.5); // key for wxXFont
|
||||
int pointSize = (M_FONTDATA->m_pointSize * 10 * intScale) / 100;
|
||||
|
||||
wxNode* node = M_FONTDATA->m_fonts.First();
|
||||
while (node)
|
||||
{
|
||||
wxXFont* f = (wxXFont*) node->Data();
|
||||
if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
|
||||
return f;
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
WXFontStructPtr font = LoadQueryFont(pointSize, M_FONTDATA->m_family,
|
||||
M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
|
||||
if (!font)
|
||||
{
|
||||
// search up and down by stepsize 10
|
||||
int max_size = pointSize + 20 * (1 + (pointSize/180));
|
||||
int min_size = pointSize - 20 * (1 + (pointSize/180));
|
||||
int i;
|
||||
|
||||
// Search for smaller size (approx.)
|
||||
for (i=pointSize-10; !font && i >= 10 && i >= min_size; i -= 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Search for larger size (approx.)
|
||||
for (i=pointSize+10; !font && i <= max_size; i += 10)
|
||||
font = LoadQueryFont(i, M_FONTDATA->m_family, M_FONTDATA->m_style, M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Try default family
|
||||
if (!font && M_FONTDATA->m_family != wxDEFAULT)
|
||||
font = LoadQueryFont(pointSize, wxDEFAULT, M_FONTDATA->m_style,
|
||||
M_FONTDATA->m_weight, M_FONTDATA->m_underlined);
|
||||
// Bogus font
|
||||
if (!font)
|
||||
font = LoadQueryFont(120, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||
M_FONTDATA->m_underlined);
|
||||
wxASSERT_MSG( (font != (XFontStruct*) NULL), "Could not allocate even a default font -- something is wrong." );
|
||||
}
|
||||
if (font)
|
||||
{
|
||||
wxXFont* f = new wxXFont;
|
||||
f->m_fontStruct = font;
|
||||
f->m_display = ( display ? display : wxGetDisplay() );
|
||||
f->m_scale = intScale;
|
||||
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
|
||||
M_FONTDATA->m_fonts.Append(f);
|
||||
return f;
|
||||
}
|
||||
return (wxXFont*) NULL;
|
||||
}
|
||||
if (font)
|
||||
{
|
||||
wxXFont* f = new wxXFont;
|
||||
f->m_fontStruct = font;
|
||||
f->m_display = ( display ? display : wxGetDisplay() );
|
||||
f->m_scale = intScale;
|
||||
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
|
||||
M_FONTDATA->m_fonts.Append(f);
|
||||
return f;
|
||||
}
|
||||
return (wxXFont*) NULL;
|
||||
}
|
||||
|
||||
WXFontStructPtr wxFont::LoadQueryFont(int pointSize, int family, int style,
|
||||
int weight, bool underlined) const
|
||||
int weight, bool underlined) const
|
||||
{
|
||||
char *xfamily;
|
||||
char *xstyle;
|
||||
char *xweight;
|
||||
switch (family)
|
||||
{
|
||||
case wxDECORATIVE: xfamily = "lucida";
|
||||
break;
|
||||
case wxROMAN: xfamily = "times";
|
||||
break;
|
||||
case wxMODERN: xfamily = "courier";
|
||||
break;
|
||||
case wxSWISS: xfamily = "lucida";
|
||||
break;
|
||||
case wxDEFAULT:
|
||||
default: xfamily = "*";
|
||||
case wxDECORATIVE: xfamily = "lucida";
|
||||
break;
|
||||
case wxROMAN: xfamily = "times";
|
||||
break;
|
||||
case wxMODERN: xfamily = "courier";
|
||||
break;
|
||||
case wxSWISS: xfamily = "lucida";
|
||||
break;
|
||||
case wxDEFAULT:
|
||||
default: xfamily = "*";
|
||||
}
|
||||
switch (style)
|
||||
{
|
||||
case wxITALIC: xstyle = "i";
|
||||
break;
|
||||
case wxSLANT: xstyle = "o";
|
||||
break;
|
||||
case wxNORMAL: xstyle = "r";
|
||||
break;
|
||||
default: xstyle = "*";
|
||||
break;
|
||||
case wxITALIC: xstyle = "i";
|
||||
break;
|
||||
case wxSLANT: xstyle = "o";
|
||||
break;
|
||||
case wxNORMAL: xstyle = "r";
|
||||
break;
|
||||
default: xstyle = "*";
|
||||
break;
|
||||
}
|
||||
switch (weight)
|
||||
{
|
||||
case wxBOLD: xweight = "bold";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = "medium";
|
||||
break;
|
||||
default: xweight = "*";
|
||||
break;
|
||||
case wxBOLD: xweight = "bold";
|
||||
break;
|
||||
case wxLIGHT:
|
||||
case wxNORMAL: xweight = "medium";
|
||||
break;
|
||||
default: xweight = "*";
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
sprintf(wxBuffer, "-*-%s-%s-%s-normal-*-*-%d-*-*-*-*-*-*",
|
||||
xfamily, xweight, xstyle, pointSize);
|
||||
|
||||
xfamily, xweight, xstyle, pointSize);
|
||||
|
||||
Display *dpy = (Display*) wxGetDisplay();
|
||||
XFontStruct* font = XLoadQueryFont(dpy, wxBuffer);
|
||||
|
||||
|
||||
return (WXFontStructPtr) font;
|
||||
}
|
||||
|
1200
src/motif/frame.cpp
1200
src/motif/frame.cpp
File diff suppressed because it is too large
Load Diff
@@ -25,28 +25,28 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
|
||||
// XmGauge copyright notice:
|
||||
|
||||
/*
|
||||
* Copyright 1994 GROUPE BULL
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of GROUPE BULL not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. GROUPE BULL makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* GROUPE BULL disclaims all warranties with regard to this software,
|
||||
* including all implied warranties of merchantability and fitness,
|
||||
* in no event shall GROUPE BULL be liable for any special,
|
||||
* indirect or consequential damages or any damages
|
||||
* whatsoever resulting from loss of use, data or profits,
|
||||
* whether in an action of contract, negligence or other tortious
|
||||
* action, arising out of or in connection with the use
|
||||
* or performance of this software.
|
||||
*
|
||||
*/
|
||||
* Copyright 1994 GROUPE BULL
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software and its
|
||||
* documentation for any purpose and without fee is hereby granted, provided
|
||||
* that the above copyright notice appear in all copies and that both that
|
||||
* copyright notice and this permission notice appear in supporting
|
||||
* documentation, and that the name of GROUPE BULL not be used in advertising
|
||||
* or publicity pertaining to distribution of the software without specific,
|
||||
* written prior permission. GROUPE BULL makes no representations about the
|
||||
* suitability of this software for any purpose. It is provided "as is"
|
||||
* without express or implied warranty.
|
||||
*
|
||||
* GROUPE BULL disclaims all warranties with regard to this software,
|
||||
* including all implied warranties of merchantability and fitness,
|
||||
* in no event shall GROUPE BULL be liable for any special,
|
||||
* indirect or consequential damages or any damages
|
||||
* whatsoever resulting from loss of use, data or profits,
|
||||
* whether in an action of contract, negligence or other tortious
|
||||
* action, arising out of or in connection with the use
|
||||
* or performance of this software.
|
||||
*
|
||||
*/
|
||||
|
||||
//// PUBLIC XMGAUGE DECLARATIONS
|
||||
typedef struct _XmGaugeClassRec* XmGaugeWidgetClass;
|
||||
@@ -74,12 +74,12 @@ XmGaugeGetValue(Widget w);
|
||||
|
||||
|
||||
bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
int range,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
int range,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
@@ -87,16 +87,16 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
m_windowStyle = style;
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
Arg args[4];
|
||||
int count = 4;
|
||||
if (style & wxHORIZONTAL)
|
||||
@@ -113,24 +113,24 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
|
||||
XtSetArg(args[3], XmNmaximum, range);
|
||||
Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
|
||||
m_mainWidget = (WXWidget) gaugeWidget ;
|
||||
|
||||
|
||||
XtManageChild (gaugeWidget);
|
||||
|
||||
|
||||
int x = pos.x; int y = pos.y;
|
||||
int width = size.x; int height = size.y;
|
||||
if (width == -1)
|
||||
width = 150;
|
||||
if (height == -1)
|
||||
height = 80;
|
||||
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -179,15 +179,15 @@ int wxGauge::GetRange() const
|
||||
int r;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
|
||||
return (int)r;
|
||||
// return m_rangeMax;
|
||||
// return m_rangeMax;
|
||||
}
|
||||
|
||||
int wxGauge::GetValue() const
|
||||
{
|
||||
int pos;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
|
||||
return pos;
|
||||
// return m_gaugePos;
|
||||
int pos;
|
||||
XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
|
||||
return pos;
|
||||
// return m_gaugePos;
|
||||
}
|
||||
|
||||
void wxGauge::ChangeFont(bool keepOriginalSize)
|
||||
@@ -227,7 +227,7 @@ typedef struct _XmGaugePart{
|
||||
int maximum;
|
||||
unsigned char orientation;
|
||||
unsigned char processingDirection;
|
||||
|
||||
|
||||
XtCallbackList dragCallback;
|
||||
XtCallbackList valueChangedCallback;
|
||||
|
||||
@@ -261,9 +261,9 @@ GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
|
||||
|
||||
static char translations[] =
|
||||
"<Btn1Down>: GaugePick()\n\
|
||||
<Btn1Motion>: GaugeDrag()\n\
|
||||
<Btn1Up>: GaugeDrop()\n\
|
||||
";
|
||||
<Btn1Motion>: GaugeDrag()\n\
|
||||
<Btn1Up>: GaugeDrop()\n\
|
||||
";
|
||||
|
||||
|
||||
|
||||
@@ -279,100 +279,100 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
|
||||
#define THIS gw->gauge
|
||||
int size, sht;
|
||||
float ratio;
|
||||
/***chubraev
|
||||
/***chubraev
|
||||
char string[20];
|
||||
int len;
|
||||
unsigned long backgr,foregr;
|
||||
XRectangle rects[1];
|
||||
***/
|
||||
***/
|
||||
|
||||
sht = gw->primitive.shadow_thickness;
|
||||
|
||||
|
||||
ratio = (float)THIS.value/
|
||||
(float)(THIS.maximum - THIS.minimum);
|
||||
/***chubraev
|
||||
sprintf(string,"%-d%%",(int)(ratio*100));
|
||||
len=strlen(string);
|
||||
XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
|
||||
***/
|
||||
|
||||
(float)(THIS.maximum - THIS.minimum);
|
||||
/***chubraev
|
||||
sprintf(string,"%-d%%",(int)(ratio*100));
|
||||
len=strlen(string);
|
||||
XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
|
||||
***/
|
||||
|
||||
if(clear) {
|
||||
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
|
||||
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
|
||||
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
|
||||
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
|
||||
}
|
||||
switch(THIS.orientation) {
|
||||
case XmHORIZONTAL:
|
||||
size = (int) ((gw->core.width - 2 * sht)*ratio);
|
||||
/***chubraev
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
|
||||
gw->core.height - 2 * sht, string, len);
|
||||
***/
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, size, gw->core.height - 2 * sht);
|
||||
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = sht;
|
||||
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
|
||||
***/
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
gw->core.width - size - sht, sht,
|
||||
size, gw->core.height - 2 * sht);
|
||||
size = (int) ((gw->core.width - 2 * sht)*ratio);
|
||||
/***chubraev
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
|
||||
gw->core.height - 2 * sht, string, len);
|
||||
***/
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, size, gw->core.height - 2 * sht);
|
||||
|
||||
/***chubraev
|
||||
rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
|
||||
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
|
||||
***/
|
||||
break;
|
||||
}
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = sht;
|
||||
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
|
||||
***/
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
gw->core.width - size - sht, sht,
|
||||
size, gw->core.height - 2 * sht);
|
||||
|
||||
/***chubraev
|
||||
rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
|
||||
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
|
||||
***/
|
||||
break;
|
||||
}
|
||||
/***chubraev
|
||||
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
|
||||
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
|
||||
gw->core.height - 2 * sht, string, len);
|
||||
***/
|
||||
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (int) ((gw->core.height - 2 * sht)*ratio);
|
||||
/***chubraev
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
|
||||
sht+gw->core.height/2, string,len);
|
||||
***/
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, gw->core.width - 2 * sht, size);
|
||||
|
||||
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
|
||||
gw->core.height - 2 * sht, string, len);
|
||||
***/
|
||||
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (int) ((gw->core.height - 2 * sht)*ratio);
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = sht;
|
||||
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
|
||||
***/
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, gw->core.height - size - sht,
|
||||
gw->core.width - 2 * sht, size);
|
||||
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
|
||||
sht+gw->core.height/2, string,len);
|
||||
***/
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, gw->core.width - 2 * sht, size);
|
||||
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = sht;
|
||||
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
|
||||
***/
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, gw->core.height - size - sht,
|
||||
gw->core.width - 2 * sht, size);
|
||||
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
|
||||
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
|
||||
***/
|
||||
}
|
||||
/***chubraev
|
||||
rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
|
||||
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
|
||||
***/
|
||||
}
|
||||
/***chubraev
|
||||
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
|
||||
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
|
||||
sht+gw->core.height/2, string,len);
|
||||
***/
|
||||
break;
|
||||
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
|
||||
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
|
||||
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
|
||||
sht+gw->core.height/2, string,len);
|
||||
***/
|
||||
break;
|
||||
}
|
||||
/***chubraev
|
||||
XSetClipMask(XtDisplay(gw), THIS.gc, None);
|
||||
@@ -382,59 +382,59 @@ sht+gw->core.height/2, string,len);
|
||||
}
|
||||
|
||||
/* Old code
|
||||
*/
|
||||
*/
|
||||
#if 0
|
||||
static void
|
||||
DrawSlider(XmGaugeWidget gw, Boolean clear)
|
||||
{
|
||||
#define THIS gw->gauge
|
||||
int size, sht;
|
||||
/* float ratio; */
|
||||
|
||||
/* float ratio; */
|
||||
|
||||
sht = gw->primitive.shadow_thickness;
|
||||
/* See fix comment below: can cause divide by zero error.
|
||||
/* See fix comment below: can cause divide by zero error.
|
||||
ratio = (float)((float)THIS.maximum -
|
||||
(float)THIS.minimum) / (float)THIS.value;
|
||||
*/
|
||||
(float)THIS.minimum) / (float)THIS.value;
|
||||
*/
|
||||
if(clear) {
|
||||
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
|
||||
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
|
||||
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
|
||||
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
|
||||
}
|
||||
switch(THIS.orientation) {
|
||||
case XmHORIZONTAL:
|
||||
/* size = (gw->core.width - 2 * sht) / ratio; */
|
||||
/* A fix suggested by Dmitri Chubraev */
|
||||
/* size = (gw->core.width - 2 * sht) / ratio; */
|
||||
/* A fix suggested by Dmitri Chubraev */
|
||||
size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, size, gw->core.height - 2 * sht);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
gw->core.width - size - sht, sht,
|
||||
size, gw->core.height - 2 * sht);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
|
||||
/* size = (gw->core.height - 2 * sht)/ ratio; */
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, gw->core.width - 2 * sht, size);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, gw->core.height - size - sht,
|
||||
gw->core.width - 2 * sht, size);
|
||||
}
|
||||
break;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, size, gw->core.height - 2 * sht);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
gw->core.width - size - sht, sht,
|
||||
size, gw->core.height - 2 * sht);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
|
||||
/* size = (gw->core.height - 2 * sht)/ ratio; */
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, sht, gw->core.width - 2 * sht, size);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
|
||||
sht, gw->core.height - size - sht,
|
||||
gw->core.width - 2 * sht, size);
|
||||
}
|
||||
break;
|
||||
}
|
||||
#undef THIS
|
||||
}
|
||||
@@ -446,7 +446,7 @@ Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
|
||||
XmGaugeWidget gw = (XmGaugeWidget)new_w;
|
||||
#define THIS gw->gauge
|
||||
XGCValues values;
|
||||
|
||||
|
||||
values.foreground = gw->primitive.foreground;
|
||||
THIS.gc = XtGetGC(new_w, GCForeground, &values);
|
||||
|
||||
@@ -467,29 +467,29 @@ Destroy(Widget w)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static Boolean
|
||||
SetValues(
|
||||
Widget cw,
|
||||
Widget rw,
|
||||
Widget nw,
|
||||
ArgList args,
|
||||
Cardinal *num_args )
|
||||
Widget cw,
|
||||
Widget rw,
|
||||
Widget nw,
|
||||
ArgList args,
|
||||
Cardinal *num_args )
|
||||
{
|
||||
XmGaugeWidget cgw = (XmGaugeWidget)cw;
|
||||
XmGaugeWidget ngw = (XmGaugeWidget)nw;
|
||||
|
||||
|
||||
Boolean redraw = False;
|
||||
if(cgw->primitive.foreground != ngw->primitive.foreground) {
|
||||
XGCValues values;
|
||||
|
||||
redraw = True;
|
||||
XtReleaseGC(nw, ngw->gauge.gc);
|
||||
values.foreground = ngw->primitive.foreground;
|
||||
ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
|
||||
XGCValues values;
|
||||
|
||||
redraw = True;
|
||||
XtReleaseGC(nw, ngw->gauge.gc);
|
||||
values.foreground = ngw->primitive.foreground;
|
||||
ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
|
||||
}
|
||||
if(cgw->gauge.value != ngw->gauge.value) {
|
||||
redraw = True;
|
||||
redraw = True;
|
||||
}
|
||||
return redraw;
|
||||
}
|
||||
@@ -503,13 +503,13 @@ ExposeProc(Widget w, XEvent *event, Region r)
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
#define THIS gw->gauge
|
||||
int sht;
|
||||
|
||||
|
||||
sht = gw->primitive.shadow_thickness;
|
||||
_XmDrawShadows(XtDisplay(w), XtWindow(w),
|
||||
gw->primitive.top_shadow_GC,
|
||||
gw->primitive.bottom_shadow_GC,
|
||||
0, 0, w->core.width, w->core.height,
|
||||
sht, XmSHADOW_IN);
|
||||
gw->primitive.top_shadow_GC,
|
||||
gw->primitive.bottom_shadow_GC,
|
||||
0, 0, w->core.width, w->core.height,
|
||||
sht, XmSHADOW_IN);
|
||||
DrawSlider(gw, False);
|
||||
#undef THIS
|
||||
}
|
||||
@@ -521,81 +521,81 @@ ExposeProc(Widget w, XEvent *event, Region r)
|
||||
static XtResource
|
||||
resources[] = {
|
||||
#define offset(field) XtOffset(XmGaugeWidget, gauge.field)
|
||||
{XmNvalue, XmCValue, XtRInt, sizeof(int),
|
||||
offset(value), XtRImmediate, (caddr_t)10},
|
||||
|
||||
{XmNminimum, XmCValue, XtRInt, sizeof(int),
|
||||
offset(minimum), XtRImmediate, (caddr_t)0},
|
||||
|
||||
{XmNmaximum, XmCValue, XtRInt, sizeof(int),
|
||||
offset(maximum), XtRImmediate, (caddr_t)100},
|
||||
|
||||
{XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
|
||||
offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
|
||||
|
||||
{XmNprocessingDirection, XmCProcessingDirection,
|
||||
XmRProcessingDirection, sizeof(unsigned char),
|
||||
offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
|
||||
|
||||
{XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
|
||||
offset(dragCallback), XtRImmediate, (caddr_t)NULL},
|
||||
|
||||
{XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
|
||||
offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
|
||||
|
||||
|
||||
{XmNvalue, XmCValue, XtRInt, sizeof(int),
|
||||
offset(value), XtRImmediate, (caddr_t)10},
|
||||
|
||||
{XmNminimum, XmCValue, XtRInt, sizeof(int),
|
||||
offset(minimum), XtRImmediate, (caddr_t)0},
|
||||
|
||||
{XmNmaximum, XmCValue, XtRInt, sizeof(int),
|
||||
offset(maximum), XtRImmediate, (caddr_t)100},
|
||||
|
||||
{XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
|
||||
offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
|
||||
|
||||
{XmNprocessingDirection, XmCProcessingDirection,
|
||||
XmRProcessingDirection, sizeof(unsigned char),
|
||||
offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
|
||||
|
||||
{XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
|
||||
offset(dragCallback), XtRImmediate, (caddr_t)NULL},
|
||||
|
||||
{XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
|
||||
offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
|
||||
|
||||
|
||||
#undef offset
|
||||
};
|
||||
|
||||
|
||||
XmGaugeClassRec xmGaugeClassRec = {
|
||||
{ /* core fields */
|
||||
(WidgetClass) &xmPrimitiveClassRec, /* superclass */
|
||||
"XmGauge", /* class_name */
|
||||
sizeof(XmGaugeRec), /* widget_size */
|
||||
NULL, /* class_initialize */
|
||||
NULL, /* class_part_initialize */
|
||||
FALSE, /* class_inited */
|
||||
Initialize, /* initialize */
|
||||
NULL, /* initialize_hook */
|
||||
XtInheritRealize, /* realize */
|
||||
actions, /* actions */
|
||||
XtNumber(actions), /* num_actions */
|
||||
resources, /* resources */
|
||||
XtNumber(resources), /* num_resources */
|
||||
NULLQUARK, /* xrm_class */
|
||||
TRUE, /* compress_motion */
|
||||
TRUE, /* compress_exposure */
|
||||
TRUE, /* compress_enterleave */
|
||||
FALSE, /* visible_interest */
|
||||
Destroy, /* destroy */
|
||||
NULL, /* resize */
|
||||
ExposeProc, /* expose */
|
||||
SetValues, /* set_values */
|
||||
NULL, /* set_values_hook */
|
||||
XtInheritSetValuesAlmost, /* set_values_almost */
|
||||
NULL, /* get_values_hook */
|
||||
NULL, /* accept_focus */
|
||||
XtVersion, /* version */
|
||||
NULL, /* callback_private */
|
||||
translations, /* tm_table */
|
||||
NULL, /* query_geometry */
|
||||
NULL, /* display_accelerator */
|
||||
NULL /* extension */
|
||||
(WidgetClass) &xmPrimitiveClassRec, /* superclass */
|
||||
"XmGauge", /* class_name */
|
||||
sizeof(XmGaugeRec), /* widget_size */
|
||||
NULL, /* class_initialize */
|
||||
NULL, /* class_part_initialize */
|
||||
FALSE, /* class_inited */
|
||||
Initialize, /* initialize */
|
||||
NULL, /* initialize_hook */
|
||||
XtInheritRealize, /* realize */
|
||||
actions, /* actions */
|
||||
XtNumber(actions), /* num_actions */
|
||||
resources, /* resources */
|
||||
XtNumber(resources), /* num_resources */
|
||||
NULLQUARK, /* xrm_class */
|
||||
TRUE, /* compress_motion */
|
||||
TRUE, /* compress_exposure */
|
||||
TRUE, /* compress_enterleave */
|
||||
FALSE, /* visible_interest */
|
||||
Destroy, /* destroy */
|
||||
NULL, /* resize */
|
||||
ExposeProc, /* expose */
|
||||
SetValues, /* set_values */
|
||||
NULL, /* set_values_hook */
|
||||
XtInheritSetValuesAlmost, /* set_values_almost */
|
||||
NULL, /* get_values_hook */
|
||||
NULL, /* accept_focus */
|
||||
XtVersion, /* version */
|
||||
NULL, /* callback_private */
|
||||
translations, /* tm_table */
|
||||
NULL, /* query_geometry */
|
||||
NULL, /* display_accelerator */
|
||||
NULL /* extension */
|
||||
},
|
||||
/* primitive_class fields */
|
||||
{
|
||||
NULL, /* border_highlight */
|
||||
NULL, /* border_unhighlight */
|
||||
NULL, /* translations */
|
||||
NULL, /* arm_and_activate */
|
||||
NULL, /* syn_resources */
|
||||
0, /* num_syn_resources */
|
||||
NULL /* extension */
|
||||
},
|
||||
{ /* gauge fields */
|
||||
0 /* empty */
|
||||
}
|
||||
NULL, /* border_highlight */
|
||||
NULL, /* border_unhighlight */
|
||||
NULL, /* translations */
|
||||
NULL, /* arm_and_activate */
|
||||
NULL, /* syn_resources */
|
||||
0, /* num_syn_resources */
|
||||
NULL /* extension */
|
||||
},
|
||||
{ /* gauge fields */
|
||||
0 /* empty */
|
||||
}
|
||||
};
|
||||
|
||||
WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
|
||||
@@ -606,7 +606,7 @@ WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
|
||||
void
|
||||
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
{
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
#if 0
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
#define THIS gw->gauge
|
||||
@@ -615,50 +615,50 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
Boolean dragging = False;
|
||||
XButtonEvent *event = (XButtonEvent *)e;
|
||||
int x, y;
|
||||
|
||||
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
sht = gw->primitive.shadow_thickness;
|
||||
_XmDrawShadows(XtDisplay(w), XtWindow(w),
|
||||
gw->primitive.top_shadow_GC,
|
||||
gw->primitive.bottom_shadow_GC,
|
||||
0, 0, w->core.width, w->core.height,
|
||||
sht, XmSHADOW_IN);
|
||||
|
||||
|
||||
gw->primitive.top_shadow_GC,
|
||||
gw->primitive.bottom_shadow_GC,
|
||||
0, 0, w->core.width, w->core.height,
|
||||
sht, XmSHADOW_IN);
|
||||
|
||||
|
||||
ratio = (float)((float)THIS.maximum -
|
||||
(float)THIS.minimum) / (float)THIS.value;
|
||||
(float)THIS.minimum) / (float)THIS.value;
|
||||
switch(THIS.orientation) {
|
||||
case XmHORIZONTAL:
|
||||
size = (w->core.width - 2 * sht) / ratio;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
dragging = (x > sht) && (y > sht) &&
|
||||
(x < sht + size) && (y < w->core.height - sht);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
dragging = (x > w->core.width - size - sht) && (y > sht) &&
|
||||
(x < w->core.width - sht) && (y < w->core.height + sht);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (w->core.height - 2 * sht) / ratio;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
dragging = (x > sht) && (y > sht) &&
|
||||
(x < w->core.width - sht) &&
|
||||
(y < w->core.width - 2 * sht + size);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
dragging = (x > sht) && (y > w->core.height - size - sht) &&
|
||||
(x < w->core.width - sht) && (y < w->core.height - sht);
|
||||
}
|
||||
break;
|
||||
size = (w->core.width - 2 * sht) / ratio;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
dragging = (x > sht) && (y > sht) &&
|
||||
(x < sht + size) && (y < w->core.height - sht);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
dragging = (x > w->core.width - size - sht) && (y > sht) &&
|
||||
(x < w->core.width - sht) && (y < w->core.height + sht);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
size = (w->core.height - 2 * sht) / ratio;
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
dragging = (x > sht) && (y > sht) &&
|
||||
(x < w->core.width - sht) &&
|
||||
(y < w->core.width - 2 * sht + size);
|
||||
break;
|
||||
case XmMAX_ON_LEFT:
|
||||
case XmMAX_ON_TOP:
|
||||
dragging = (x > sht) && (y > w->core.height - size - sht) &&
|
||||
(x < w->core.width - sht) && (y < w->core.height - sht);
|
||||
}
|
||||
break;
|
||||
}
|
||||
THIS.dragging = dragging;
|
||||
THIS.oldx = x;
|
||||
@@ -672,7 +672,7 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
void
|
||||
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
{
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
#if 0
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
#define THIS gw->gauge
|
||||
@@ -681,57 +681,57 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
XMotionEvent *event = (XMotionEvent *)e;
|
||||
|
||||
if( ! THIS.dragging) return;
|
||||
|
||||
|
||||
x = event->x;
|
||||
y = event->y;
|
||||
sht = gw->primitive.shadow_thickness;
|
||||
|
||||
|
||||
ratio = (float)THIS.value / (float)((float)THIS.maximum -
|
||||
(float)THIS.minimum);
|
||||
(float)THIS.minimum);
|
||||
switch(THIS.orientation) {
|
||||
case XmHORIZONTAL:
|
||||
max = (w->core.width - 2 * sht);
|
||||
size = (float)max * ratio;
|
||||
delta = (float)x - (float)THIS.oldx;
|
||||
break;
|
||||
max = (w->core.width - 2 * sht);
|
||||
size = (float)max * ratio;
|
||||
delta = (float)x - (float)THIS.oldx;
|
||||
break;
|
||||
case XmVERTICAL:
|
||||
max = (w->core.height - 2 * sht);
|
||||
size = (float) max * ratio;
|
||||
delta = (float)y - (float)THIS.oldy;
|
||||
break;
|
||||
max = (w->core.height - 2 * sht);
|
||||
size = (float) max * ratio;
|
||||
delta = (float)y - (float)THIS.oldy;
|
||||
break;
|
||||
}
|
||||
switch(THIS.processingDirection) {
|
||||
case XmMAX_ON_RIGHT:
|
||||
case XmMAX_ON_BOTTOM:
|
||||
nsize = size + delta;
|
||||
break;
|
||||
nsize = size + delta;
|
||||
break;
|
||||
default:
|
||||
nsize = size - delta;
|
||||
nsize = size - delta;
|
||||
}
|
||||
if(nsize > (float)max) nsize = (float)max;
|
||||
if(nsize < (float)0 ) nsize = (float)0;
|
||||
nratio = nsize / (float)max;
|
||||
|
||||
fvalue = (int)((float)THIS.maximum -
|
||||
(float)THIS.minimum) * (float)nsize / (float)max;
|
||||
(float)THIS.minimum) * (float)nsize / (float)max;
|
||||
value = round(fvalue);
|
||||
|
||||
|
||||
THIS.value = value;
|
||||
THIS.oldx = x;
|
||||
THIS.oldy = y;
|
||||
|
||||
|
||||
/* clear old slider only if it was larger */
|
||||
DrawSlider(gw, (nsize < size));
|
||||
|
||||
{
|
||||
XmGaugeCallbackStruct call;
|
||||
|
||||
if(NULL != THIS.dragCallback) {
|
||||
call.reason = XmCR_DRAG;
|
||||
call.event = e;
|
||||
call.value = THIS.value;
|
||||
XtCallCallbacks(w, XmNdragCallback, &call);
|
||||
}
|
||||
XmGaugeCallbackStruct call;
|
||||
|
||||
if(NULL != THIS.dragCallback) {
|
||||
call.reason = XmCR_DRAG;
|
||||
call.event = e;
|
||||
call.value = THIS.value;
|
||||
XtCallCallbacks(w, XmNdragCallback, &call);
|
||||
}
|
||||
}
|
||||
#undef THIS
|
||||
#endif
|
||||
@@ -741,18 +741,18 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
void
|
||||
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
|
||||
{
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
/* Commented out for a read-only gauge in wxWindows */
|
||||
#if 0
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
#define THIS gw->gauge
|
||||
if( ! THIS.dragging) return;
|
||||
|
||||
|
||||
if(NULL != THIS.valueChangedCallback) {
|
||||
XmGaugeCallbackStruct call;
|
||||
call.reason = XmCR_VALUE_CHANGED;
|
||||
call.event = e;
|
||||
call.value = THIS.value;
|
||||
XtCallCallbacks(w, XmNvalueChangedCallback, &call);
|
||||
XmGaugeCallbackStruct call;
|
||||
call.reason = XmCR_VALUE_CHANGED;
|
||||
call.event = e;
|
||||
call.value = THIS.value;
|
||||
XtCallCallbacks(w, XmNvalueChangedCallback, &call);
|
||||
}
|
||||
THIS.dragging = False;
|
||||
#undef THIS
|
||||
@@ -763,7 +763,7 @@ void
|
||||
XmGaugeSetValue(Widget w, int value)
|
||||
{
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
|
||||
|
||||
gw->gauge.value = value;
|
||||
DrawSlider(gw, True);
|
||||
XFlush(XtDisplay(w));
|
||||
@@ -773,6 +773,6 @@ int
|
||||
XmGaugeGetValue(Widget w)
|
||||
{
|
||||
XmGaugeWidget gw = (XmGaugeWidget)w;
|
||||
|
||||
|
||||
return gw->gauge.value;
|
||||
}
|
||||
|
@@ -18,5 +18,3 @@
|
||||
#if !USE_SHARED_LIBRARIES
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)
|
||||
#endif
|
||||
|
||||
// TODO: Nothing to do, unless you want to.
|
||||
|
@@ -26,8 +26,8 @@ IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Icons
|
||||
*/
|
||||
* Icons
|
||||
*/
|
||||
|
||||
wxIcon::wxIcon()
|
||||
{
|
||||
@@ -46,8 +46,8 @@ wxIcon::wxIcon(char **data)
|
||||
}
|
||||
|
||||
wxIcon::wxIcon(const wxString& icon_file, long flags,
|
||||
int desiredWidth, int desiredHeight)
|
||||
|
||||
int desiredWidth, int desiredHeight)
|
||||
|
||||
{
|
||||
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
|
||||
}
|
||||
@@ -57,17 +57,17 @@ wxIcon::~wxIcon()
|
||||
}
|
||||
|
||||
bool wxIcon::LoadFile(const wxString& filename, long type,
|
||||
int desiredWidth, int desiredHeight)
|
||||
int desiredWidth, int desiredHeight)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxBitmapRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
||||
else
|
||||
return FALSE;
|
||||
UnRef();
|
||||
|
||||
m_refData = new wxBitmapRefData;
|
||||
|
||||
wxBitmapHandler *handler = FindHandler(type);
|
||||
|
||||
if ( handler )
|
||||
return handler->LoadFile(this, filename, type, desiredWidth, desiredHeight);
|
||||
else
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
@@ -23,11 +23,11 @@
|
||||
#include "wx/motif/private.h"
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
|
||||
#endif
|
||||
|
||||
void wxListBoxCallback (Widget w, XtPointer clientData,
|
||||
XmListCallbackStruct * cbs);
|
||||
XmListCallbackStruct * cbs);
|
||||
|
||||
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs);
|
||||
|
||||
@@ -56,16 +56,16 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
// m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_backgroundColour = * wxWHITE;
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
m_windowId = ( id == -1 ) ? (int)NewControlId() : id;
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
Arg args[3];
|
||||
int count;
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
@@ -82,39 +82,39 @@ bool wxListBox::Create(wxWindow *parent, wxWindowID id,
|
||||
}
|
||||
else
|
||||
count = 2;
|
||||
|
||||
|
||||
Widget listWidget = XmCreateScrolledList (parentWidget, (char*) (const char*) name, args, count);
|
||||
|
||||
|
||||
m_mainWidget = (WXWidget) listWidget;
|
||||
|
||||
|
||||
Set(n, choices);
|
||||
|
||||
|
||||
XtManageChild (listWidget);
|
||||
|
||||
|
||||
long width = size.x;
|
||||
long height = size.y;
|
||||
if (width == -1)
|
||||
width = 150;
|
||||
if (height == -1)
|
||||
height = 80;
|
||||
|
||||
|
||||
XtAddCallback (listWidget, XmNbrowseSelectionCallback, (XtCallbackProc) wxListBoxCallback,
|
||||
(XtPointer) this);
|
||||
(XtPointer) this);
|
||||
XtAddCallback (listWidget, XmNextendedSelectionCallback, (XtCallbackProc) wxListBoxCallback,
|
||||
(XtPointer) this);
|
||||
(XtPointer) this);
|
||||
XtAddCallback (listWidget, XmNmultipleSelectionCallback, (XtCallbackProc) wxListBoxCallback,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
XtAddCallback (listWidget, XmNdefaultActionCallback, (XtCallbackProc) wxListBoxDefaultActionProc,
|
||||
(XtPointer) this);
|
||||
|
||||
(XtPointer) this);
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, width, height);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -124,297 +124,297 @@ wxListBox::~wxListBox()
|
||||
|
||||
void wxListBox::SetFirstItem(int N)
|
||||
{
|
||||
int count, length;
|
||||
|
||||
if (N < 0)
|
||||
return;
|
||||
XtVaGetValues ((Widget) m_mainWidget,
|
||||
XmNvisibleItemCount, &count,
|
||||
XmNitemCount, &length,
|
||||
NULL);
|
||||
if ((N + count) >= length)
|
||||
N = length - count;
|
||||
XmListSetPos ((Widget) m_mainWidget, N + 1);
|
||||
int count, length;
|
||||
|
||||
if (N < 0)
|
||||
return;
|
||||
XtVaGetValues ((Widget) m_mainWidget,
|
||||
XmNvisibleItemCount, &count,
|
||||
XmNitemCount, &length,
|
||||
NULL);
|
||||
if ((N + count) >= length)
|
||||
N = length - count;
|
||||
XmListSetPos ((Widget) m_mainWidget, N + 1);
|
||||
}
|
||||
|
||||
void wxListBox::SetFirstItem(const wxString& s)
|
||||
{
|
||||
int N = FindString (s);
|
||||
|
||||
if (N >= 0)
|
||||
SetFirstItem (N);
|
||||
int N = FindString (s);
|
||||
|
||||
if (N >= 0)
|
||||
SetFirstItem (N);
|
||||
}
|
||||
|
||||
void wxListBox::Delete(int N)
|
||||
{
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
|
||||
XmListDeletePos (listBox, N + 1);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
// (JDH) need to add code here to take care of clientDataList
|
||||
wxNode *node = m_clientDataList.Find((long)N); // get item from list
|
||||
if (node) m_clientDataList.DeleteNode(node); // if existed then delete from list
|
||||
node = m_clientDataList.First(); // we now have to adjust all keys that
|
||||
while (node) // are >=N+1
|
||||
{ if (node->GetKeyInteger() >= (long)(N+1))
|
||||
node->SetKeyInteger(node->GetKeyInteger() - 1);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
m_noItems --;
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
|
||||
XmListDeletePos (listBox, N + 1);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
// (JDH) need to add code here to take care of clientDataList
|
||||
wxNode *node = m_clientDataList.Find((long)N); // get item from list
|
||||
if (node) m_clientDataList.DeleteNode(node); // if existed then delete from list
|
||||
node = m_clientDataList.First(); // we now have to adjust all keys that
|
||||
while (node) // are >=N+1
|
||||
{ if (node->GetKeyInteger() >= (long)(N+1))
|
||||
node->SetKeyInteger(node->GetKeyInteger() - 1);
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
m_noItems --;
|
||||
}
|
||||
|
||||
void wxListBox::Append(const wxString& item)
|
||||
{
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
int n;
|
||||
XtVaGetValues (listBox, XmNitemCount, &n, NULL);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
// XmListAddItem(listBox, text, n + 1);
|
||||
XmListAddItemUnselected (listBox, text, 0);
|
||||
XmStringFree (text);
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
m_noItems ++;
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
int n;
|
||||
XtVaGetValues (listBox, XmNitemCount, &n, NULL);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
// XmListAddItem(listBox, text, n + 1);
|
||||
XmListAddItemUnselected (listBox, text, 0);
|
||||
XmStringFree (text);
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
m_noItems ++;
|
||||
}
|
||||
|
||||
void wxListBox::Append(const wxString& item, char *clientData)
|
||||
{
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
|
||||
GetSize (&width1, &height1);
|
||||
Bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
|
||||
int n;
|
||||
XtVaGetValues (listBox, XmNitemCount, &n, NULL);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
// XmListAddItem(listBox, text, n + 1);
|
||||
XmListAddItemUnselected (listBox, text, 0);
|
||||
XmStringFree (text);
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
m_clientDataList.Append ((long) n, (wxObject *) clientData);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems ++;
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
|
||||
GetSize (&width1, &height1);
|
||||
Bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
|
||||
int n;
|
||||
XtVaGetValues (listBox, XmNitemCount, &n, NULL);
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) item);
|
||||
// XmListAddItem(listBox, text, n + 1);
|
||||
XmListAddItemUnselected (listBox, text, 0);
|
||||
XmStringFree (text);
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
m_clientDataList.Append ((long) n, (wxObject *) clientData);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems ++;
|
||||
}
|
||||
|
||||
void wxListBox::Set(int n, const wxString *choices, char** clientData)
|
||||
{
|
||||
m_clientDataList.Clear();
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
/***
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
XmString text = XmStringCreateSimple(choices[i]);
|
||||
XmListAddItemUnselected(listBox, text, 0);
|
||||
XmStringFree(text);
|
||||
}
|
||||
***/
|
||||
XmString *text = new XmString[n];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
|
||||
|
||||
if ( clientData )
|
||||
m_clientDataList.Clear();
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (listBox);
|
||||
/***
|
||||
for (int i=0; i<n; i++)
|
||||
{
|
||||
XmString text = XmStringCreateSimple(choices[i]);
|
||||
XmListAddItemUnselected(listBox, text, 0);
|
||||
XmStringFree(text);
|
||||
}
|
||||
***/
|
||||
XmString *text = new XmString[n];
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
|
||||
|
||||
XmListAddItems (listBox, text, n, 0);
|
||||
for (i = 0; i < n; i++)
|
||||
XmStringFree (text[i]);
|
||||
delete[]text;
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems = n;
|
||||
text[i] = XmStringCreateSimple ((char*) (const char*) choices[i]);
|
||||
|
||||
if ( clientData )
|
||||
for (i = 0; i < n; i++)
|
||||
m_clientDataList.Append ((long) i, (wxObject *) clientData[i]);
|
||||
|
||||
XmListAddItems (listBox, text, n, 0);
|
||||
for (i = 0; i < n; i++)
|
||||
XmStringFree (text[i]);
|
||||
delete[]text;
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (listBox);
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems = n;
|
||||
}
|
||||
|
||||
int wxListBox::FindString(const wxString& s) const
|
||||
{
|
||||
XmString str = XmStringCreateSimple ((char*) (const char*) s);
|
||||
int *positions = NULL;
|
||||
int no_positions = 0;
|
||||
bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
|
||||
XmStringFree (str);
|
||||
if (success)
|
||||
XmString str = XmStringCreateSimple ((char*) (const char*) s);
|
||||
int *positions = NULL;
|
||||
int no_positions = 0;
|
||||
bool success = XmListGetMatchPos ((Widget) m_mainWidget, str, &positions, &no_positions);
|
||||
XmStringFree (str);
|
||||
if (success)
|
||||
{
|
||||
int pos = positions[0];
|
||||
if (positions)
|
||||
XtFree ((char *) positions);
|
||||
return pos - 1;
|
||||
int pos = positions[0];
|
||||
if (positions)
|
||||
XtFree ((char *) positions);
|
||||
return pos - 1;
|
||||
}
|
||||
else
|
||||
return -1;
|
||||
else
|
||||
return -1;
|
||||
}
|
||||
|
||||
void wxListBox::Clear()
|
||||
{
|
||||
if (m_noItems <= 0)
|
||||
return;
|
||||
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
XmListDeleteAllItems (listBox);
|
||||
m_clientDataList.Clear ();
|
||||
GetSize (&width2, &height2);
|
||||
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems = 0;
|
||||
if (m_noItems <= 0)
|
||||
return;
|
||||
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
XmListDeleteAllItems (listBox);
|
||||
m_clientDataList.Clear ();
|
||||
GetSize (&width2, &height2);
|
||||
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
SetSize (-1, -1, width1, height1);
|
||||
|
||||
m_noItems = 0;
|
||||
}
|
||||
|
||||
void wxListBox::SetSelection(int N, bool select)
|
||||
{
|
||||
m_inSetValue = TRUE;
|
||||
if (select)
|
||||
m_inSetValue = TRUE;
|
||||
if (select)
|
||||
{
|
||||
/*
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
/*
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
{
|
||||
int *selections = NULL;
|
||||
int n = GetSelections (&selections);
|
||||
|
||||
int *selections = NULL;
|
||||
int n = GetSelections (&selections);
|
||||
|
||||
// This hack is supposed to work, to make it possible to select more
|
||||
// than one item, but it DOESN'T under Motif 1.1.
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
|
||||
|
||||
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmMULTIPLE_SELECT, NULL);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < n; i++)
|
||||
XmListSelectPos ((Widget) m_mainWidget, selections[i] + 1, FALSE);
|
||||
|
||||
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNselectionPolicy, XmEXTENDED_SELECT, NULL);
|
||||
}
|
||||
else
|
||||
*/
|
||||
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
|
||||
|
||||
}
|
||||
else
|
||||
*/
|
||||
XmListSelectPos ((Widget) m_mainWidget, N + 1, FALSE);
|
||||
|
||||
}
|
||||
else
|
||||
XmListDeselectPos ((Widget) m_mainWidget, N + 1);
|
||||
|
||||
m_inSetValue = FALSE;
|
||||
else
|
||||
XmListDeselectPos ((Widget) m_mainWidget, N + 1);
|
||||
|
||||
m_inSetValue = FALSE;
|
||||
}
|
||||
|
||||
bool wxListBox::Selected(int N) const
|
||||
{
|
||||
// In Motif, no simple way to determine if the item is selected.
|
||||
wxArrayInt theSelections;
|
||||
int count = GetSelections (theSelections);
|
||||
if (count == 0)
|
||||
// In Motif, no simple way to determine if the item is selected.
|
||||
wxArrayInt theSelections;
|
||||
int count = GetSelections (theSelections);
|
||||
if (count == 0)
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < count; j++)
|
||||
if (theSelections[j] == N)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
else
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < count; j++)
|
||||
if (theSelections[j] == N)
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void wxListBox::Deselect(int N)
|
||||
@@ -443,30 +443,30 @@ void wxListBox::SetClientData(int N, char *Client_data)
|
||||
// Return number of selections and an array of selected integers
|
||||
int wxListBox::GetSelections(wxArrayInt& aSelections) const
|
||||
{
|
||||
aSelections.Empty();
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
int *posList = NULL;
|
||||
int posCnt = 0;
|
||||
bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
|
||||
if (flag)
|
||||
{
|
||||
if (posCnt > 0)
|
||||
{
|
||||
aSelections.Alloc(posCnt);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < posCnt; i++)
|
||||
aSelections.Add(posList[i] - 1);
|
||||
|
||||
XtFree ((char *) posList);
|
||||
return posCnt;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
aSelections.Empty();
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
int *posList = NULL;
|
||||
int posCnt = 0;
|
||||
bool flag = XmListGetSelectedPos (listBox, &posList, &posCnt);
|
||||
if (flag)
|
||||
{
|
||||
if (posCnt > 0)
|
||||
{
|
||||
aSelections.Alloc(posCnt);
|
||||
|
||||
int i;
|
||||
for (i = 0; i < posCnt; i++)
|
||||
aSelections.Add(posList[i] - 1);
|
||||
|
||||
XtFree ((char *) posList);
|
||||
return posCnt;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
return 0;
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Get single selection, for single choice list items
|
||||
@@ -514,15 +514,15 @@ wxString wxListBox::GetString(int N) const
|
||||
void wxListBox::SetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxWindow::SetSize(x, y, width, height, sizeFlags);
|
||||
|
||||
|
||||
// Check resulting size is correct
|
||||
int tempW, tempH;
|
||||
GetSize (&tempW, &tempH);
|
||||
|
||||
|
||||
/*
|
||||
if (tempW != width || tempH != height)
|
||||
{
|
||||
cout << "wxListBox::SetSize sizes not set correctly.");
|
||||
cout << "wxListBox::SetSize sizes not set correctly.");
|
||||
}
|
||||
*/
|
||||
}
|
||||
@@ -531,21 +531,21 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
|
||||
{
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
|
||||
|
||||
GetSize(&width1, &height1);
|
||||
|
||||
|
||||
bool managed = XtIsManaged(listBox);
|
||||
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild(listBox);
|
||||
|
||||
|
||||
XmString *text = new XmString[nItems];
|
||||
int i;
|
||||
// Steve Hammes: Motif 1.1 compatibility
|
||||
// #if XmVersion > 1100
|
||||
// Corrected by Sergey Krasnov from Steve Hammes' code
|
||||
// Steve Hammes: Motif 1.1 compatibility
|
||||
// #if XmVersion > 1100
|
||||
// Corrected by Sergey Krasnov from Steve Hammes' code
|
||||
#if XmVersion > 1001
|
||||
for (i = 0; i < nItems; i++)
|
||||
text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
|
||||
@@ -554,15 +554,15 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
|
||||
for (i = 0; i < nItems; i++)
|
||||
{
|
||||
text[i] = XmStringCreateSimple((char*) (const char*) items[i]);
|
||||
// XmListAddItemUnselected(listBox, text[i], i);
|
||||
// XmListAddItemUnselected(listBox, text[i], i);
|
||||
XmListAddItemUnselected(listBox, text[i], pos+i+1); // Another Sergey correction
|
||||
}
|
||||
#endif
|
||||
for (i = 0; i < nItems; i++)
|
||||
XmStringFree(text[i]);
|
||||
|
||||
|
||||
delete[] text;
|
||||
|
||||
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
@@ -573,15 +573,15 @@ void wxListBox::InsertItems(int nItems, const wxString items[], int pos)
|
||||
XtSetArg(args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else XtSetArg(args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues(listBox,args,2) ;
|
||||
|
||||
|
||||
if (managed)
|
||||
XtManageChild(listBox);
|
||||
|
||||
|
||||
GetSize(&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 /*|| height1 != height2*/)
|
||||
SetSize(-1, -1, width1, height1);
|
||||
|
||||
|
||||
m_noItems += nItems;
|
||||
}
|
||||
|
||||
@@ -589,34 +589,34 @@ void wxListBox::SetString(int N, const wxString& s)
|
||||
{
|
||||
int width1, height1;
|
||||
int width2, height2;
|
||||
|
||||
|
||||
Widget listBox = (Widget) m_mainWidget;
|
||||
GetSize (&width1, &height1);
|
||||
|
||||
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) s);
|
||||
|
||||
|
||||
// WHAT'S THE MOTIF CALL TO SET THE TEXT OF AN EXISTING
|
||||
// ITEM???
|
||||
// There isn't one, so delete the item and add it again.
|
||||
XmListDeletePos (listBox, N+1);
|
||||
XmListAddItem (listBox, text, N+1);
|
||||
|
||||
|
||||
XmStringFree(text);
|
||||
|
||||
/*
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
|
||||
/*
|
||||
// It seems that if the list is cleared, we must re-ask for
|
||||
// selection policy!!
|
||||
Arg args[3];
|
||||
XtSetArg (args[0], XmNlistSizePolicy, XmCONSTANT);
|
||||
if (m_windowStyle & wxLB_MULTIPLE)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmMULTIPLE_SELECT);
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
else if (m_windowStyle & wxLB_EXTENDED)
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmEXTENDED_SELECT);
|
||||
else
|
||||
else
|
||||
XtSetArg (args[1], XmNselectionPolicy, XmBROWSE_SELECT);
|
||||
XtSetValues (listBox, args, 2);
|
||||
*/
|
||||
|
||||
XtSetValues (listBox, args, 2);
|
||||
*/
|
||||
|
||||
GetSize (&width2, &height2);
|
||||
// Correct for randomly resized listbox - bad boy, Motif!
|
||||
if (width1 != width2 || height1 != height2)
|
||||
@@ -663,7 +663,7 @@ void wxListBox::Command (wxCommandEvent & event)
|
||||
}
|
||||
|
||||
void wxListBoxCallback (Widget w, XtPointer clientData,
|
||||
XmListCallbackStruct * cbs)
|
||||
XmListCallbackStruct * cbs)
|
||||
{
|
||||
/*
|
||||
if (cbs->reason == XmCR_EXTENDED_SELECT)
|
||||
@@ -681,18 +681,18 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
|
||||
cout << "*** Initial\n";
|
||||
else if (cbs->selection_type == XmADDITION)
|
||||
cout << "*** Addition\n";
|
||||
*/
|
||||
|
||||
*/
|
||||
|
||||
wxListBox *item = (wxListBox *) clientData;
|
||||
|
||||
|
||||
if (item->InSetValue())
|
||||
return;
|
||||
|
||||
|
||||
wxCommandEvent event (wxEVT_COMMAND_LISTBOX_SELECTED, item->GetId());
|
||||
switch (cbs->reason)
|
||||
{
|
||||
case XmCR_MULTIPLE_SELECT:
|
||||
case XmCR_BROWSE_SELECT:
|
||||
case XmCR_MULTIPLE_SELECT:
|
||||
case XmCR_BROWSE_SELECT:
|
||||
{
|
||||
event.m_clientData = item->GetClientData (cbs->item_position - 1);
|
||||
//event.commandString = item->GetStringSelection();
|
||||
@@ -703,13 +703,13 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
|
||||
//delete[] event.commandString; // Let's not store the command string any more
|
||||
break;
|
||||
}
|
||||
case XmCR_EXTENDED_SELECT:
|
||||
case XmCR_EXTENDED_SELECT:
|
||||
{
|
||||
switch (cbs->selection_type)
|
||||
{
|
||||
case XmINITIAL:
|
||||
case XmADDITION:
|
||||
case XmMODIFICATION:
|
||||
case XmINITIAL:
|
||||
case XmADDITION:
|
||||
case XmMODIFICATION:
|
||||
{
|
||||
event.m_clientData = item->GetClientData (cbs->item_position - 1);
|
||||
event.m_commandInt = cbs->item_position - 1;
|
||||
@@ -725,13 +725,13 @@ void wxListBoxCallback (Widget w, XtPointer clientData,
|
||||
}
|
||||
|
||||
/* Respond by getting the
|
||||
* designated "default button" in the action area and activate it
|
||||
* as if the user had selected it.
|
||||
*/
|
||||
* designated "default button" in the action area and activate it
|
||||
* as if the user had selected it.
|
||||
*/
|
||||
void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCallbackStruct * cbs)
|
||||
{
|
||||
wxListBox *lbox = (wxListBox *) client_data;
|
||||
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, lbox->GetId());
|
||||
event.SetEventObject( lbox );
|
||||
lbox->GetEventHandler()->ProcessEvent(event) ;
|
||||
@@ -739,7 +739,7 @@ void wxListBoxDefaultActionProc (Widget list_w, XtPointer client_data, XmListCal
|
||||
|
||||
WXWidget wxListBox::GetTopWidget() const
|
||||
{
|
||||
return (WXWidget) XtParent( (Widget) m_mainWidget );
|
||||
return (WXWidget) XtParent( (Widget) m_mainWidget );
|
||||
}
|
||||
|
||||
void wxListBox::ChangeFont(bool keepOriginalSize)
|
||||
@@ -750,41 +750,41 @@ void wxListBox::ChangeFont(bool keepOriginalSize)
|
||||
void wxListBox::ChangeBackgroundColour()
|
||||
{
|
||||
wxWindow::ChangeBackgroundColour();
|
||||
|
||||
|
||||
Widget parent = XtParent ((Widget) m_mainWidget);
|
||||
Widget hsb, vsb;
|
||||
|
||||
|
||||
XtVaGetValues (parent,
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
*/
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
*/
|
||||
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
|
||||
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
|
||||
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
|
||||
|
||||
|
||||
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
|
||||
}
|
||||
|
||||
void wxListBox::ChangeForegroundColour()
|
||||
{
|
||||
wxWindow::ChangeForegroundColour();
|
||||
|
||||
|
||||
Widget parent = XtParent ((Widget) m_mainWidget);
|
||||
Widget hsb, vsb;
|
||||
|
||||
|
||||
XtVaGetValues (parent,
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
|
||||
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
|
||||
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
|
||||
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
|
||||
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
|
||||
*/
|
||||
}
|
||||
|
||||
|
@@ -13,6 +13,6 @@
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
{
|
||||
return wxEntry(argc, argv);
|
||||
return wxEntry(argc, argv);
|
||||
}
|
||||
|
||||
|
@@ -87,6 +87,7 @@ LIB_CPP_SRC=\
|
||||
combobox.cpp \
|
||||
cursor.cpp \
|
||||
data.cpp \
|
||||
dataobj.cpp \
|
||||
dc.cpp \
|
||||
dcclient.cpp \
|
||||
dcmemory.cpp \
|
||||
|
@@ -34,7 +34,7 @@ extern wxList wxModelessWindows;
|
||||
|
||||
// Implemented in frame.cpp
|
||||
extern void wxFrameFocusProc(Widget workArea, XtPointer clientData,
|
||||
XmAnyCallbackStruct *cbs);
|
||||
XmAnyCallbackStruct *cbs);
|
||||
|
||||
#define wxID_NOTEBOOK_CLIENT_AREA wxID_HIGHEST + 100
|
||||
|
||||
@@ -44,14 +44,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxMDIChildFrame, wxFrame)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMDIClientWindow, wxNotebook)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxMDIParentFrame, wxFrame)
|
||||
EVT_SIZE(wxMDIParentFrame::OnSize)
|
||||
EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
|
||||
EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
|
||||
EVT_SIZE(wxMDIParentFrame::OnSize)
|
||||
EVT_ACTIVATE(wxMDIParentFrame::OnActivate)
|
||||
EVT_SYS_COLOUR_CHANGED(wxMDIParentFrame::OnSysColourChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(wxMDIClientWindow, wxNotebook)
|
||||
EVT_SCROLL(wxMDIClientWindow::OnScroll)
|
||||
EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged)
|
||||
EVT_SCROLL(wxMDIClientWindow::OnScroll)
|
||||
EVT_NOTEBOOK_PAGE_CHANGED(wxID_NOTEBOOK_CLIENT_AREA, wxMDIClientWindow::OnPageChanged)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
#endif
|
||||
@@ -66,29 +66,29 @@ wxMDIParentFrame::wxMDIParentFrame()
|
||||
}
|
||||
|
||||
bool wxMDIParentFrame::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
m_clientWindow = (wxMDIClientWindow*) NULL;
|
||||
m_activeChild = (wxMDIChildFrame*) NULL;
|
||||
m_activeMenuBar = (wxMenuBar*) NULL;
|
||||
|
||||
|
||||
bool success = wxFrame::Create(parent, id, title, pos, size, style, name);
|
||||
if (success)
|
||||
{
|
||||
// TODO: app cannot override OnCreateClient since
|
||||
// wxMDIParentFrame::OnCreateClient will still be called
|
||||
// (we're in the constructor). How to resolve?
|
||||
|
||||
|
||||
m_clientWindow = OnCreateClient();
|
||||
|
||||
|
||||
// Uses own style for client style
|
||||
m_clientWindow->CreateClient(this, GetWindowStyleFlag());
|
||||
|
||||
|
||||
int w, h;
|
||||
GetClientSize(& w, & h);
|
||||
m_clientWindow->SetSize(0, 0, w, h);
|
||||
@@ -102,9 +102,9 @@ wxMDIParentFrame::~wxMDIParentFrame()
|
||||
{
|
||||
// Make sure we delete the client window last of all
|
||||
RemoveChild(m_clientWindow);
|
||||
|
||||
|
||||
DestroyChildren();
|
||||
|
||||
|
||||
delete m_clientWindow;
|
||||
m_clientWindow = NULL;
|
||||
}
|
||||
@@ -118,7 +118,7 @@ void wxMDIParentFrame::GetClientSize(int *x, int *y) const
|
||||
void wxMDIParentFrame::SetMenuBar(wxMenuBar *menu_bar)
|
||||
{
|
||||
m_frameMenuBar = menu_bar;
|
||||
|
||||
|
||||
SetChildMenuBar((wxMDIChildFrame*) NULL);
|
||||
}
|
||||
|
||||
@@ -126,20 +126,20 @@ void wxMDIParentFrame::OnSize(wxSizeEvent& event)
|
||||
{
|
||||
#if wxUSE_CONSTRAINTS
|
||||
if (GetAutoLayout())
|
||||
Layout();
|
||||
Layout();
|
||||
#endif
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
int width, height;
|
||||
GetClientSize(&width, &height);
|
||||
|
||||
|
||||
if ( GetClientWindow() )
|
||||
GetClientWindow()->SetSize(x, y, width, height);
|
||||
}
|
||||
|
||||
void wxMDIParentFrame::OnActivate(wxActivateEvent& event)
|
||||
{
|
||||
// Do nothing
|
||||
// Do nothing
|
||||
}
|
||||
|
||||
// Returns the active MDI child window
|
||||
@@ -152,63 +152,63 @@ wxMDIChildFrame *wxMDIParentFrame::GetActiveChild() const
|
||||
// just return a new class)
|
||||
wxMDIClientWindow *wxMDIParentFrame::OnCreateClient()
|
||||
{
|
||||
return new wxMDIClientWindow ;
|
||||
return new wxMDIClientWindow ;
|
||||
}
|
||||
|
||||
// Set the child's menu into the parent frame
|
||||
void wxMDIParentFrame::SetChildMenuBar(wxMDIChildFrame* child)
|
||||
{
|
||||
wxMenuBar* oldMenuBar = m_activeMenuBar;
|
||||
|
||||
|
||||
if (child == (wxMDIChildFrame*) NULL) // No child: use parent frame
|
||||
{
|
||||
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
|
||||
{
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
|
||||
m_activeMenuBar = GetMenuBar();
|
||||
m_activeMenuBar->CreateMenuBar(this);
|
||||
/*
|
||||
/*
|
||||
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
if (oldMenuBar && oldMenuBar->GetMainWidget())
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
|
||||
}
|
||||
}
|
||||
else if (child->GetMenuBar() == (wxMenuBar*) NULL) // No child menu bar: use parent frame
|
||||
{
|
||||
if (GetMenuBar() && (GetMenuBar() != m_activeMenuBar))
|
||||
{
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
m_activeMenuBar = GetMenuBar();
|
||||
m_activeMenuBar->CreateMenuBar(this);
|
||||
/*
|
||||
/*
|
||||
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
if (oldMenuBar && oldMenuBar->GetMainWidget())
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
}
|
||||
}
|
||||
else // The child has a menubar
|
||||
{
|
||||
if (child->GetMenuBar() != m_activeMenuBar)
|
||||
{
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
|
||||
// if (m_activeMenuBar)
|
||||
// m_activeMenuBar->DestroyMenuBar();
|
||||
|
||||
m_activeMenuBar = child->GetMenuBar();
|
||||
m_activeMenuBar->CreateMenuBar(this);
|
||||
/*
|
||||
/*
|
||||
if (oldMenuBar && XtIsManaged((Widget) oldMenuBar->GetMainWidget()))
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
XtUnmanageChild((Widget) oldMenuBar->GetMainWidget());
|
||||
*/
|
||||
if (oldMenuBar && oldMenuBar->GetMainWidget())
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
XtUnmapWidget((Widget) oldMenuBar->GetMainWidget());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -220,20 +220,20 @@ bool wxMDIParentFrame::ProcessEvent(wxEvent& event)
|
||||
static wxEventType inEvent = wxEVT_NULL;
|
||||
if (inEvent == event.GetEventType())
|
||||
return FALSE;
|
||||
|
||||
|
||||
inEvent = event.GetEventType();
|
||||
|
||||
bool res = FALSE;
|
||||
if (m_activeChild && event.IsKindOf(CLASSINFO(wxCommandEvent)))
|
||||
{
|
||||
res = m_activeChild->GetEventHandler()->ProcessEvent(event);
|
||||
res = m_activeChild->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
if (!res)
|
||||
res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
|
||||
|
||||
res = GetEventHandler()->wxEvtHandler::ProcessEvent(event);
|
||||
|
||||
inEvent = wxEVT_NULL;
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ bool wxMDIParentFrame::ProcessEvent(wxEvent& event)
|
||||
void wxMDIParentFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
|
||||
{
|
||||
// TODO
|
||||
|
||||
|
||||
// Propagate the event to the non-top-level children
|
||||
wxFrame::OnSysColourChanged(event);
|
||||
}
|
||||
@@ -280,39 +280,39 @@ wxMDIChildFrame::wxMDIChildFrame()
|
||||
}
|
||||
|
||||
bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
wxWindowID id,
|
||||
const wxString& title,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size,
|
||||
long style,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
|
||||
|
||||
m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
|
||||
m_foregroundColour = *wxBLACK;
|
||||
m_windowFont = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT);
|
||||
|
||||
|
||||
if ( id > -1 )
|
||||
m_windowId = id;
|
||||
else
|
||||
m_windowId = (int)NewControlId();
|
||||
|
||||
|
||||
wxMDIClientWindow* clientWindow = parent->GetClientWindow();
|
||||
|
||||
|
||||
wxASSERT_MSG( (clientWindow != (wxWindow*) NULL), "Missing MDI client window.");
|
||||
|
||||
|
||||
if (clientWindow) clientWindow->AddChild(this);
|
||||
|
||||
|
||||
SetMDIParentFrame(parent);
|
||||
|
||||
|
||||
int x = pos.x; int y = pos.y;
|
||||
int width = size.x; int height = size.y;
|
||||
if (width == -1)
|
||||
width = 200; // TODO: give reasonable default
|
||||
if (height == -1)
|
||||
height = 200; // TODO: give reasonable default
|
||||
|
||||
|
||||
// We're deactivating the old child
|
||||
wxMDIChildFrame* oldActiveChild = parent->GetActiveChild();
|
||||
if (oldActiveChild)
|
||||
@@ -321,104 +321,41 @@ bool wxMDIChildFrame::Create(wxMDIParentFrame *parent,
|
||||
event.SetEventObject( oldActiveChild );
|
||||
oldActiveChild->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
// This is the currently active child
|
||||
parent->SetActiveChild((wxMDIChildFrame*) this);
|
||||
|
||||
|
||||
// This time we'll try a bog-standard bulletin board for
|
||||
// the 'frame'. A main window doesn't seem to work.
|
||||
|
||||
|
||||
m_mainWidget = (WXWidget) XtVaCreateWidget("client",
|
||||
xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
|
||||
XmNmarginWidth, 0,
|
||||
XmNmarginHeight, 0,
|
||||
/*
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
*/
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
xmBulletinBoardWidgetClass, (Widget) clientWindow->GetTopWidget(),
|
||||
XmNmarginWidth, 0,
|
||||
XmNmarginHeight, 0,
|
||||
/*
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
*/
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
// Old stuff
|
||||
#if 0
|
||||
|
||||
m_frameWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
|
||||
xmMainWindowWidgetClass, (Widget) clientWindow->GetTopWidget(),
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
|
||||
// TODO: make sure this doesn't cause problems.
|
||||
// I think ~wxFrame will do the right thing since it deletes m_frameWidget,
|
||||
// then sets the main widget to NULL.
|
||||
m_mainWidget = m_frameWidget;
|
||||
|
||||
m_workArea = (WXWidget) XtVaCreateWidget("form",
|
||||
xmFormWidgetClass, (Widget) m_frameWidget,
|
||||
XmNresizePolicy, XmRESIZE_NONE,
|
||||
NULL);
|
||||
|
||||
m_clientArea = (WXWidget) XtVaCreateWidget("client",
|
||||
xmBulletinBoardWidgetClass, (Widget) m_workArea,
|
||||
XmNmarginWidth, 0,
|
||||
XmNmarginHeight, 0,
|
||||
XmNrightAttachment, XmATTACH_FORM,
|
||||
XmNleftAttachment, XmATTACH_FORM,
|
||||
XmNtopAttachment, XmATTACH_FORM,
|
||||
XmNbottomAttachment, XmATTACH_FORM,
|
||||
// XmNresizePolicy, XmRESIZE_ANY,
|
||||
NULL);
|
||||
|
||||
XtVaSetValues((Widget) m_frameWidget,
|
||||
XmNworkWindow, (Widget) m_workArea,
|
||||
NULL);
|
||||
|
||||
XtManageChild((Widget) m_clientArea);
|
||||
XtManageChild((Widget) m_workArea);
|
||||
|
||||
wxASSERT_MSG ((wxWidgetHashTable->Get((long)m_workArea) == (wxObject*) NULL), "Widget table clash in frame.cpp") ;
|
||||
|
||||
wxAddWindowToTable((Widget) m_workArea, this);
|
||||
|
||||
XtTranslations ptr ;
|
||||
|
||||
XtOverrideTranslations((Widget) m_workArea,
|
||||
ptr = XtParseTranslationTable("<Configure>: resize()"));
|
||||
|
||||
XtFree((char *)ptr);
|
||||
|
||||
XtAddCallback((Widget) m_workArea, XmNfocusCallback,
|
||||
(XtCallbackProc)wxFrameFocusProc, (XtPointer)this);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
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);
|
||||
|
||||
|
||||
clientWindow->AddPage(this, title, TRUE);
|
||||
clientWindow->Refresh();
|
||||
|
||||
|
||||
// Positions the toolbar and status bar -- but we don't have any.
|
||||
// PreResize();
|
||||
|
||||
|
||||
wxModelessWindows.Append(this);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -429,15 +366,15 @@ wxMDIChildFrame::~wxMDIChildFrame()
|
||||
if (GetMDIParentFrame())
|
||||
{
|
||||
wxMDIParentFrame* parentFrame = GetMDIParentFrame();
|
||||
|
||||
|
||||
if (parentFrame->GetActiveChild() == this)
|
||||
parentFrame->SetActiveChild((wxMDIChildFrame*) NULL);
|
||||
wxMDIClientWindow* clientWindow = parentFrame->GetClientWindow();
|
||||
|
||||
|
||||
// Remove page if still there
|
||||
if (clientWindow->RemovePage(this))
|
||||
clientWindow->Refresh();
|
||||
|
||||
clientWindow->Refresh();
|
||||
|
||||
// Set the selection to the first remaining page
|
||||
if (clientWindow->GetPageCount() > 0)
|
||||
{
|
||||
@@ -460,14 +397,14 @@ void wxMDIChildFrame::OnRaise()
|
||||
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
|
||||
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
|
||||
parentFrame->SetActiveChild(this);
|
||||
|
||||
|
||||
if (oldActiveChild)
|
||||
{
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
|
||||
event.SetEventObject( oldActiveChild );
|
||||
oldActiveChild->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, this->GetId());
|
||||
event.SetEventObject( this );
|
||||
this->GetEventHandler()->ProcessEvent(event);
|
||||
@@ -477,7 +414,7 @@ void wxMDIChildFrame::OnLower()
|
||||
{
|
||||
wxMDIParentFrame* parentFrame = (wxMDIParentFrame*) GetParent() ;
|
||||
wxMDIChildFrame* oldActiveChild = parentFrame->GetActiveChild();
|
||||
|
||||
|
||||
if (oldActiveChild == this)
|
||||
{
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, FALSE, oldActiveChild->GetId());
|
||||
@@ -494,7 +431,7 @@ void wxMDIChildFrame::OnLower()
|
||||
// to wxWindows)
|
||||
void wxMDIChildFrame::SetClientSize(int width, int height)
|
||||
{
|
||||
wxWindow::SetClientSize(width, height);
|
||||
wxWindow::SetClientSize(width, height);
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::GetClientSize(int* width, int* height) const
|
||||
@@ -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)
|
||||
{
|
||||
wxWindow::SetSize(x, y, width, height, sizeFlags);
|
||||
wxWindow::SetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
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
|
||||
// it every time the child is activated.
|
||||
m_frameMenuBar = menuBar;
|
||||
|
||||
|
||||
// We make the assumption that if you're setting the menubar,
|
||||
// this is the currently active child.
|
||||
GetMDIParentFrame()->SetChildMenuBar(this);
|
||||
@@ -540,10 +477,8 @@ void wxMDIChildFrame::SetIcon(const wxIcon& icon)
|
||||
m_icon = icon;
|
||||
if (m_icon.Ok())
|
||||
{
|
||||
/* TODO: doesn't work yet (crashes in XCopyArea)
|
||||
Pixmap pixmap = (Pixmap) m_icon.GetPixmap();
|
||||
m_mdiWindow->setPixmap(pixmap);
|
||||
*/
|
||||
// Not appropriate since there are no icons in
|
||||
// a tabbed window
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,7 +499,7 @@ void wxMDIChildFrame::Maximize()
|
||||
|
||||
void wxMDIChildFrame::Iconize(bool iconize)
|
||||
{
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
bool wxMDIChildFrame::IsIconized() const
|
||||
@@ -591,22 +526,22 @@ void wxMDIChildFrame::Activate()
|
||||
|
||||
void wxMDIChildFrame::CaptureMouse()
|
||||
{
|
||||
wxWindow::CaptureMouse();
|
||||
wxWindow::CaptureMouse();
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::ReleaseMouse()
|
||||
{
|
||||
wxWindow::ReleaseMouse();
|
||||
wxWindow::ReleaseMouse();
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::Raise()
|
||||
{
|
||||
wxWindow::Raise();
|
||||
wxWindow::Raise();
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::Lower(void)
|
||||
{
|
||||
wxWindow::Raise();
|
||||
wxWindow::Raise();
|
||||
}
|
||||
|
||||
void wxMDIChildFrame::SetSizeHints(int WXUNUSED(minW), int WXUNUSED(minH), int WXUNUSED(maxW), int WXUNUSED(maxH), int WXUNUSED(incW), int WXUNUSED(incH))
|
||||
@@ -622,17 +557,17 @@ wxMDIClientWindow::wxMDIClientWindow()
|
||||
wxMDIClientWindow::~wxMDIClientWindow()
|
||||
{
|
||||
// By the time this destructor is called, the child frames will have been
|
||||
// deleted and removed from the notebook/client window.
|
||||
// deleted and removed from the notebook/client window.
|
||||
DestroyChildren();
|
||||
|
||||
|
||||
m_mainWidget = (WXWidget) 0;
|
||||
}
|
||||
|
||||
bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
|
||||
{
|
||||
// m_windowParent = parent;
|
||||
// m_windowParent = parent;
|
||||
// m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE);
|
||||
|
||||
|
||||
bool success = wxNotebook::Create(parent, wxID_NOTEBOOK_CLIENT_AREA, wxPoint(0, 0), wxSize(100, 100), 0);
|
||||
if (success)
|
||||
{
|
||||
@@ -645,7 +580,7 @@ bool wxMDIClientWindow::CreateClient(wxMDIParentFrame *parent, long style)
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
|
||||
if (activeChild)
|
||||
{
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
|
||||
event.SetEventObject( activeChild );
|
||||
activeChild->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
if (activeChild->GetMDIParentFrame())
|
||||
wxMDIChildFrame* activeChild = (wxMDIChildFrame*) GetPage(event.GetSelection());
|
||||
if (activeChild)
|
||||
{
|
||||
activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
|
||||
activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
|
||||
wxActivateEvent event(wxEVT_ACTIVATE, TRUE, activeChild->GetId());
|
||||
event.SetEventObject( activeChild );
|
||||
activeChild->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
if (activeChild->GetMDIParentFrame())
|
||||
{
|
||||
activeChild->GetMDIParentFrame()->SetActiveChild(activeChild);
|
||||
activeChild->GetMDIParentFrame()->SetChildMenuBar(activeChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
event.Skip();
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -31,11 +31,11 @@
|
||||
#include "wx/motif/private.h"
|
||||
|
||||
void wxMenuItemCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
XtPointer ptr);
|
||||
void wxMenuItemArmCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
XtPointer ptr);
|
||||
void wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr);
|
||||
XtPointer ptr);
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
@@ -46,7 +46,7 @@ void wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxMenuItem, wxObject)
|
||||
#endif //USE_SHARED_LIBRARY
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -60,22 +60,22 @@ wxMenuItem::wxMenuItem(wxMenu *pParentMenu, int id,
|
||||
const wxString& strName, const wxString& strHelp,
|
||||
bool bCheckable,
|
||||
wxMenu *pSubMenu) :
|
||||
m_strHelp(strHelp),
|
||||
m_bCheckable(bCheckable),
|
||||
m_strName(strName)
|
||||
m_strHelp(strHelp),
|
||||
m_bCheckable(bCheckable),
|
||||
m_strName(strName)
|
||||
{
|
||||
wxASSERT( pParentMenu != NULL );
|
||||
|
||||
m_pParentMenu = pParentMenu;
|
||||
m_pSubMenu = pSubMenu;
|
||||
m_idItem = id;
|
||||
m_bEnabled = TRUE;
|
||||
m_bChecked = FALSE;
|
||||
|
||||
//// Motif-specific
|
||||
m_menuBar = NULL;
|
||||
m_buttonWidget = (WXWidget) NULL;
|
||||
m_topMenu = NULL;
|
||||
wxASSERT( pParentMenu != NULL );
|
||||
|
||||
m_pParentMenu = pParentMenu;
|
||||
m_pSubMenu = pSubMenu;
|
||||
m_idItem = id;
|
||||
m_bEnabled = TRUE;
|
||||
m_bChecked = FALSE;
|
||||
|
||||
//// Motif-specific
|
||||
m_menuBar = NULL;
|
||||
m_buttonWidget = (WXWidget) NULL;
|
||||
m_topMenu = NULL;
|
||||
}
|
||||
|
||||
wxMenuItem::~wxMenuItem()
|
||||
@@ -88,10 +88,10 @@ wxMenuItem::~wxMenuItem()
|
||||
// delete the sub menu
|
||||
void wxMenuItem::DeleteSubMenu()
|
||||
{
|
||||
wxASSERT( m_pSubMenu != NULL );
|
||||
|
||||
delete m_pSubMenu;
|
||||
m_pSubMenu = NULL;
|
||||
wxASSERT( m_pSubMenu != NULL );
|
||||
|
||||
delete m_pSubMenu;
|
||||
m_pSubMenu = NULL;
|
||||
}
|
||||
|
||||
// change item state
|
||||
@@ -99,266 +99,265 @@ void wxMenuItem::DeleteSubMenu()
|
||||
|
||||
void wxMenuItem::Enable(bool bDoEnable)
|
||||
{
|
||||
if ( m_bEnabled != bDoEnable )
|
||||
{
|
||||
if ( m_pSubMenu == NULL )
|
||||
{ // normal menu item
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
|
||||
}
|
||||
else // submenu
|
||||
if ( m_bEnabled != bDoEnable )
|
||||
{
|
||||
// Maybe we should apply this to all items in the submenu?
|
||||
// Or perhaps it works anyway.
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
|
||||
if ( m_pSubMenu == NULL )
|
||||
{ // normal menu item
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
|
||||
}
|
||||
else // submenu
|
||||
{
|
||||
// Maybe we should apply this to all items in the submenu?
|
||||
// Or perhaps it works anyway.
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
|
||||
}
|
||||
|
||||
m_bEnabled = bDoEnable;
|
||||
}
|
||||
|
||||
m_bEnabled = bDoEnable;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMenuItem::Check(bool bDoCheck)
|
||||
{
|
||||
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
||||
|
||||
if ( m_bChecked != bDoCheck )
|
||||
{
|
||||
if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
|
||||
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
|
||||
|
||||
if ( m_bChecked != bDoCheck )
|
||||
{
|
||||
XtVaSetValues ( (Widget) m_buttonWidget, XmNset, (Boolean) bDoCheck, NULL);
|
||||
if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
|
||||
{
|
||||
XtVaSetValues ( (Widget) m_buttonWidget, XmNset, (Boolean) bDoCheck, NULL);
|
||||
}
|
||||
m_bChecked = bDoCheck;
|
||||
}
|
||||
m_bChecked = bDoCheck;
|
||||
}
|
||||
}
|
||||
|
||||
//// Motif-specific
|
||||
|
||||
void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu)
|
||||
{
|
||||
m_menuBar = menuBar;
|
||||
m_topMenu = topMenu;
|
||||
|
||||
if (GetId() == -2)
|
||||
m_menuBar = menuBar;
|
||||
m_topMenu = topMenu;
|
||||
|
||||
if (GetId() == -2)
|
||||
{
|
||||
// Id=-2 identifies a Title item.
|
||||
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmLabelGadgetClass, (Widget) menu, NULL);
|
||||
// Id=-2 identifies a Title item.
|
||||
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmLabelGadgetClass, (Widget) menu, NULL);
|
||||
}
|
||||
else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
|
||||
else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
|
||||
{
|
||||
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
|
||||
if (IsCheckable())
|
||||
{
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmToggleButtonGadgetClass, (Widget) menu,
|
||||
NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
|
||||
}
|
||||
else
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmPushButtonGadgetClass, (Widget) menu,
|
||||
NULL);
|
||||
char mnem = wxFindMnemonic (m_strName);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
|
||||
|
||||
//// TODO: proper accelerator treatment. What does wxFindAccelerator
|
||||
//// look for?
|
||||
strcpy(wxBuffer, (char*) (const char*) m_strName);
|
||||
char *accel = wxFindAccelerator (wxBuffer);
|
||||
if (accel)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
|
||||
|
||||
// TODO: What does this do?
|
||||
strcpy(wxBuffer, (char*) (const char*) m_strName);
|
||||
XmString accel_str = wxFindAcceleratorText (wxBuffer);
|
||||
if (accel_str)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
|
||||
XmStringFree (accel_str);
|
||||
}
|
||||
|
||||
if (IsCheckable())
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNvalueChangedCallback,
|
||||
(XtCallbackProc) wxMenuItemCallback,
|
||||
(XtPointer) this);
|
||||
else
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNactivateCallback,
|
||||
(XtCallbackProc) wxMenuItemCallback,
|
||||
(XtPointer) this);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNarmCallback,
|
||||
(XtCallbackProc) wxMenuItemArmCallback,
|
||||
(XtPointer) this);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNdisarmCallback,
|
||||
(XtCallbackProc) wxMenuItemDisarmCallback,
|
||||
(XtPointer) this);
|
||||
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
|
||||
if (IsCheckable())
|
||||
{
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmToggleButtonGadgetClass, (Widget) menu,
|
||||
NULL);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
|
||||
}
|
||||
else
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
|
||||
xmPushButtonGadgetClass, (Widget) menu,
|
||||
NULL);
|
||||
char mnem = wxFindMnemonic (m_strName);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
|
||||
|
||||
//// TODO: proper accelerator treatment. What does wxFindAccelerator
|
||||
//// look for?
|
||||
strcpy(wxBuffer, (char*) (const char*) m_strName);
|
||||
char *accel = wxFindAccelerator (wxBuffer);
|
||||
if (accel)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
|
||||
|
||||
// TODO: What does this do?
|
||||
strcpy(wxBuffer, (char*) (const char*) m_strName);
|
||||
XmString accel_str = wxFindAcceleratorText (wxBuffer);
|
||||
if (accel_str)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
|
||||
XmStringFree (accel_str);
|
||||
}
|
||||
|
||||
if (IsCheckable())
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNvalueChangedCallback,
|
||||
(XtCallbackProc) wxMenuItemCallback,
|
||||
(XtPointer) this);
|
||||
else
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNactivateCallback,
|
||||
(XtCallbackProc) wxMenuItemCallback,
|
||||
(XtPointer) this);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNarmCallback,
|
||||
(XtCallbackProc) wxMenuItemArmCallback,
|
||||
(XtPointer) this);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNdisarmCallback,
|
||||
(XtCallbackProc) wxMenuItemDisarmCallback,
|
||||
(XtPointer) this);
|
||||
}
|
||||
else if (GetId() == -1)
|
||||
else if (GetId() == -1)
|
||||
{
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
|
||||
xmSeparatorGadgetClass, (Widget) menu, NULL);
|
||||
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget ("separator",
|
||||
xmSeparatorGadgetClass, (Widget) menu, NULL);
|
||||
}
|
||||
else if (m_pSubMenu)
|
||||
else if (m_pSubMenu)
|
||||
{
|
||||
m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE);
|
||||
m_pSubMenu->SetButtonWidget(m_buttonWidget);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNcascadingCallback,
|
||||
(XtCallbackProc) wxMenuItemArmCallback,
|
||||
(XtPointer) this);
|
||||
m_buttonWidget = m_pSubMenu->CreateMenu (menuBar, menu, topMenu, m_strName, TRUE);
|
||||
m_pSubMenu->SetButtonWidget(m_buttonWidget);
|
||||
XtAddCallback ((Widget) m_buttonWidget,
|
||||
XmNcascadingCallback,
|
||||
(XtCallbackProc) wxMenuItemArmCallback,
|
||||
(XtPointer) this);
|
||||
}
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
|
||||
if (m_buttonWidget)
|
||||
XtSetSensitive ((Widget) m_buttonWidget, (Boolean) IsEnabled());
|
||||
}
|
||||
|
||||
void wxMenuItem::DestroyItem(bool full)
|
||||
{
|
||||
if (GetId() == -2)
|
||||
if (GetId() == -2)
|
||||
{
|
||||
; // Nothing
|
||||
|
||||
; // Nothing
|
||||
|
||||
}
|
||||
else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
|
||||
else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
|
||||
{
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
if (IsCheckable())
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
|
||||
wxMenuItemCallback, (XtPointer) this);
|
||||
else
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
|
||||
wxMenuItemCallback, (XtPointer) this);
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
|
||||
wxMenuItemArmCallback, (XtPointer) this);
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
|
||||
wxMenuItemDisarmCallback, (XtPointer) this);
|
||||
}
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
if (IsCheckable())
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNvalueChangedCallback,
|
||||
wxMenuItemCallback, (XtPointer) this);
|
||||
else
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNactivateCallback,
|
||||
wxMenuItemCallback, (XtPointer) this);
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNarmCallback,
|
||||
wxMenuItemArmCallback, (XtPointer) this);
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNdisarmCallback,
|
||||
wxMenuItemDisarmCallback, (XtPointer) this);
|
||||
}
|
||||
}
|
||||
else if (GetId() == -1)
|
||||
else if (GetId() == -1)
|
||||
{
|
||||
; // Nothing
|
||||
|
||||
; // Nothing
|
||||
|
||||
}
|
||||
else if (GetSubMenu())
|
||||
else if (GetSubMenu())
|
||||
{
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
|
||||
wxMenuItemArmCallback, (XtPointer) this);
|
||||
}
|
||||
m_pSubMenu->DestroyMenu(full);
|
||||
if (full)
|
||||
m_buttonWidget = NULL;
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
XtRemoveCallback ((Widget) m_buttonWidget, XmNcascadingCallback,
|
||||
wxMenuItemArmCallback, (XtPointer) this);
|
||||
}
|
||||
m_pSubMenu->DestroyMenu(full);
|
||||
if (full)
|
||||
m_buttonWidget = NULL;
|
||||
}
|
||||
|
||||
if (m_buttonWidget && full)
|
||||
|
||||
if (m_buttonWidget && full)
|
||||
{
|
||||
XtDestroyWidget ((Widget) m_buttonWidget);
|
||||
m_buttonWidget = (WXWidget) 0;
|
||||
XtDestroyWidget ((Widget) m_buttonWidget);
|
||||
m_buttonWidget = (WXWidget) 0;
|
||||
}
|
||||
}
|
||||
|
||||
void wxMenuItem::SetLabel(const wxString& label)
|
||||
{
|
||||
char mnem = wxFindMnemonic (label);
|
||||
wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
|
||||
|
||||
m_strName = label;
|
||||
|
||||
if (m_buttonWidget)
|
||||
char mnem = wxFindMnemonic (label);
|
||||
wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
|
||||
|
||||
m_strName = label;
|
||||
|
||||
if (m_buttonWidget)
|
||||
{
|
||||
XmString label_str = XmStringCreateSimple (wxBuffer);
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
XmStringFree (label_str);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
|
||||
strcpy(wxBuffer, (char*) (const char*) label);
|
||||
char *accel = wxFindAccelerator (wxBuffer);
|
||||
if (accel)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
|
||||
|
||||
strcpy(wxBuffer, (char*) (const char*) label);
|
||||
XmString accel_str = wxFindAcceleratorText (wxBuffer);
|
||||
if (accel_str)
|
||||
XmString label_str = XmStringCreateSimple (wxBuffer);
|
||||
XtVaSetValues ((Widget) m_buttonWidget,
|
||||
XmNlabelString, label_str,
|
||||
NULL);
|
||||
XmStringFree (label_str);
|
||||
if (mnem != 0)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
|
||||
strcpy(wxBuffer, (char*) (const char*) label);
|
||||
char *accel = wxFindAccelerator (wxBuffer);
|
||||
if (accel)
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
|
||||
|
||||
strcpy(wxBuffer, (char*) (const char*) label);
|
||||
XmString accel_str = wxFindAcceleratorText (wxBuffer);
|
||||
if (accel_str)
|
||||
{
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
|
||||
XmStringFree (accel_str);
|
||||
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
|
||||
XmStringFree (accel_str);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxMenuItemCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
XtPointer ptr)
|
||||
{
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
{
|
||||
if (item->IsCheckable())
|
||||
{
|
||||
Boolean isChecked = FALSE;
|
||||
XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
|
||||
item->SetChecked(isChecked);
|
||||
}
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
|
||||
commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
commandEvent.SetInt( item->GetId() );
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
|
||||
}
|
||||
else if (item->GetTopMenu())
|
||||
{
|
||||
wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
|
||||
event.SetEventObject(item->GetTopMenu());
|
||||
event.SetInt( item->GetId() );
|
||||
|
||||
item->GetTopMenu()->ProcessCommand (event);
|
||||
}
|
||||
if (item->IsCheckable())
|
||||
{
|
||||
Boolean isChecked = FALSE;
|
||||
XtVaGetValues ((Widget) item->GetButtonWidget(), XmNset, & isChecked, NULL);
|
||||
item->SetChecked(isChecked);
|
||||
}
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
|
||||
commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
commandEvent.SetInt( item->GetId() );
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
|
||||
}
|
||||
else if (item->GetTopMenu())
|
||||
{
|
||||
wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
|
||||
event.SetEventObject(item->GetTopMenu());
|
||||
event.SetInt( item->GetId() );
|
||||
|
||||
item->GetTopMenu()->ProcessCommand (event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxMenuItemArmCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
void wxMenuItemArmCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
{
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
{
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
|
||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
|
||||
}
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
|
||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
|
||||
XtPointer ptr)
|
||||
XtPointer ptr)
|
||||
{
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
wxMenuItem *item = (wxMenuItem *) clientData;
|
||||
if (item)
|
||||
{
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
// TODO: not sure this is correct, since -1 means something
|
||||
// special to event system
|
||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
|
||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
|
||||
}
|
||||
if (item->GetMenuBar() && item->GetMenuBar()->GetMenuBarFrame())
|
||||
{
|
||||
// TODO: not sure this is correct, since -1 means something
|
||||
// special to event system
|
||||
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
|
||||
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
|
||||
|
||||
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -52,9 +52,9 @@ IMPLEMENT_DYNAMIC_CLASS(wxXPalette, wxObject)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Palette
|
||||
*
|
||||
*/
|
||||
* Palette
|
||||
*
|
||||
*/
|
||||
|
||||
wxXPalette::wxXPalette()
|
||||
{
|
||||
@@ -71,39 +71,39 @@ wxPaletteRefData::wxPaletteRefData()
|
||||
|
||||
wxPaletteRefData::~wxPaletteRefData()
|
||||
{
|
||||
XColor xcol;
|
||||
Display *display = (Display*) NULL;
|
||||
|
||||
wxNode *node, *next;
|
||||
|
||||
for (node = m_palettes.First(); node; node = next) {
|
||||
wxXPalette *c = (wxXPalette *)node->Data();
|
||||
unsigned long *pix_array = c->m_pix_array;
|
||||
Colormap cmap = (Colormap) c->m_cmap;
|
||||
bool destroyable = c->m_destroyable;
|
||||
int pix_array_n = c->m_pix_array_n;
|
||||
display = (Display*) c->m_display;
|
||||
|
||||
if (pix_array_n > 0)
|
||||
{
|
||||
// XFreeColors(display, cmap, pix_array, pix_array_n, 0);
|
||||
// Be careful not to free '0' pixels...
|
||||
int i, j;
|
||||
for(i=j=0; i<pix_array_n; i=j) {
|
||||
while(j<pix_array_n && pix_array[j]!=0) j++;
|
||||
if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
|
||||
while(j<pix_array_n && pix_array[j]==0) j++;
|
||||
}
|
||||
delete [] pix_array;
|
||||
XColor xcol;
|
||||
Display *display = (Display*) NULL;
|
||||
|
||||
wxNode *node, *next;
|
||||
|
||||
for (node = m_palettes.First(); node; node = next) {
|
||||
wxXPalette *c = (wxXPalette *)node->Data();
|
||||
unsigned long *pix_array = c->m_pix_array;
|
||||
Colormap cmap = (Colormap) c->m_cmap;
|
||||
bool destroyable = c->m_destroyable;
|
||||
int pix_array_n = c->m_pix_array_n;
|
||||
display = (Display*) c->m_display;
|
||||
|
||||
if (pix_array_n > 0)
|
||||
{
|
||||
// XFreeColors(display, cmap, pix_array, pix_array_n, 0);
|
||||
// Be careful not to free '0' pixels...
|
||||
int i, j;
|
||||
for(i=j=0; i<pix_array_n; i=j) {
|
||||
while(j<pix_array_n && pix_array[j]!=0) j++;
|
||||
if(j > i) XFreeColors(display, cmap, &pix_array[i], j-i, 0);
|
||||
while(j<pix_array_n && pix_array[j]==0) j++;
|
||||
}
|
||||
delete [] pix_array;
|
||||
}
|
||||
|
||||
if (destroyable)
|
||||
XFreeColormap(display, cmap);
|
||||
|
||||
next = node->Next();
|
||||
m_palettes.DeleteNode(node);
|
||||
delete c;
|
||||
}
|
||||
|
||||
if (destroyable)
|
||||
XFreeColormap(display, cmap);
|
||||
|
||||
next = node->Next();
|
||||
m_palettes.DeleteNode(node);
|
||||
delete c;
|
||||
}
|
||||
}
|
||||
|
||||
wxPalette::wxPalette()
|
||||
@@ -121,53 +121,53 @@ wxPalette::~wxPalette()
|
||||
|
||||
bool wxPalette::Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
if (!n) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
XColor xcol;
|
||||
Display* display = (Display*) wxGetDisplay();
|
||||
|
||||
unsigned long *pix_array;
|
||||
Colormap cmap;
|
||||
int pix_array_n;
|
||||
|
||||
cmap = (Colormap) wxTheApp->GetMainColormap(display);
|
||||
|
||||
pix_array = new unsigned long[n];
|
||||
if (!pix_array)
|
||||
return FALSE;
|
||||
|
||||
pix_array_n = n;
|
||||
xcol.flags = DoRed | DoGreen | DoBlue;
|
||||
for(int i = 0; i < n; i++) {
|
||||
xcol.red = (unsigned short)red[i] << 8;
|
||||
xcol.green = (unsigned short)green[i] << 8;
|
||||
xcol.blue = (unsigned short)blue[i] << 8;
|
||||
pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
|
||||
}
|
||||
|
||||
wxXPalette *c = new wxXPalette;
|
||||
|
||||
c->m_pix_array_n = pix_array_n;
|
||||
c->m_pix_array = pix_array;
|
||||
c->m_cmap = (WXColormap) cmap;
|
||||
c->m_display = (WXDisplay*) display;
|
||||
c->m_destroyable = FALSE;
|
||||
M_PALETTEDATA->m_palettes.Append(c);
|
||||
|
||||
return TRUE;
|
||||
UnRef();
|
||||
|
||||
if (!n) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
XColor xcol;
|
||||
Display* display = (Display*) wxGetDisplay();
|
||||
|
||||
unsigned long *pix_array;
|
||||
Colormap cmap;
|
||||
int pix_array_n;
|
||||
|
||||
cmap = (Colormap) wxTheApp->GetMainColormap(display);
|
||||
|
||||
pix_array = new unsigned long[n];
|
||||
if (!pix_array)
|
||||
return FALSE;
|
||||
|
||||
pix_array_n = n;
|
||||
xcol.flags = DoRed | DoGreen | DoBlue;
|
||||
for(int i = 0; i < n; i++) {
|
||||
xcol.red = (unsigned short)red[i] << 8;
|
||||
xcol.green = (unsigned short)green[i] << 8;
|
||||
xcol.blue = (unsigned short)blue[i] << 8;
|
||||
pix_array[i] = (XAllocColor(display, cmap, &xcol) == 0) ? 0 : xcol.pixel;
|
||||
}
|
||||
|
||||
wxXPalette *c = new wxXPalette;
|
||||
|
||||
c->m_pix_array_n = pix_array_n;
|
||||
c->m_pix_array = pix_array;
|
||||
c->m_cmap = (WXColormap) cmap;
|
||||
c->m_display = (WXDisplay*) display;
|
||||
c->m_destroyable = FALSE;
|
||||
M_PALETTEDATA->m_palettes.Append(c);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
|
||||
{
|
||||
if ( !m_refData )
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
@@ -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
|
||||
{
|
||||
if ( !m_refData )
|
||||
return FALSE;
|
||||
|
||||
return FALSE;
|
||||
|
||||
if (index < 0 || index > 255)
|
||||
return FALSE;
|
||||
|
||||
|
||||
// TODO
|
||||
return FALSE;
|
||||
}
|
||||
@@ -188,7 +188,7 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
|
||||
{
|
||||
if (!M_PALETTEDATA || (M_PALETTEDATA->m_palettes.Number() == 0))
|
||||
return wxTheApp->GetMainColormap(display);
|
||||
|
||||
|
||||
wxNode* node = M_PALETTEDATA->m_palettes.First();
|
||||
if (!display && node)
|
||||
{
|
||||
@@ -200,22 +200,22 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
|
||||
wxXPalette* p = (wxXPalette*) node->Data();
|
||||
if (p->m_display == display)
|
||||
return p->m_cmap;
|
||||
|
||||
|
||||
node = node->Next();
|
||||
}
|
||||
|
||||
|
||||
/* Make a new one: */
|
||||
wxXPalette *c = new wxXPalette;
|
||||
wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data();
|
||||
XColor xcol;
|
||||
int pix_array_n = first->m_pix_array_n;
|
||||
|
||||
|
||||
c->m_pix_array_n = pix_array_n;
|
||||
c->m_pix_array = new unsigned long[pix_array_n];
|
||||
c->m_display = display;
|
||||
c->m_cmap = wxTheApp->GetMainColormap(display);
|
||||
c->m_destroyable = FALSE;
|
||||
|
||||
|
||||
xcol.flags = DoRed | DoGreen | DoBlue;
|
||||
int i;
|
||||
for (i = 0; i < pix_array_n; i++)
|
||||
@@ -225,87 +225,87 @@ WXColormap wxPalette::GetXColormap(WXDisplay* display) const
|
||||
c->m_pix_array[i] =
|
||||
(XAllocColor((Display*) display, (Colormap) c->m_cmap, &xcol) == 0) ? 0 : xcol.pixel;
|
||||
}
|
||||
|
||||
|
||||
// wxPalette* nonConstThis = (wxPalette*) this;
|
||||
|
||||
|
||||
M_PALETTEDATA->m_palettes.Append(c);
|
||||
|
||||
|
||||
return c->m_cmap;
|
||||
}
|
||||
|
||||
bool wxPalette::TransferBitmap(void *data, int depth, int size)
|
||||
{
|
||||
switch(depth) {
|
||||
case 8:
|
||||
{
|
||||
unsigned char *uptr = (unsigned char *)data;
|
||||
int pix_array_n;
|
||||
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
|
||||
while(size-- > 0)
|
||||
{
|
||||
if((int)*uptr < pix_array_n)
|
||||
*uptr = (unsigned char)pix_array[*uptr];
|
||||
uptr++;
|
||||
switch(depth) {
|
||||
case 8:
|
||||
{
|
||||
unsigned char *uptr = (unsigned char *)data;
|
||||
int pix_array_n;
|
||||
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
|
||||
while(size-- > 0)
|
||||
{
|
||||
if((int)*uptr < pix_array_n)
|
||||
*uptr = (unsigned char)pix_array[*uptr];
|
||||
uptr++;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
|
||||
void *dest, unsigned int bpp)
|
||||
void *dest, unsigned int bpp)
|
||||
{
|
||||
int pix_array_n;
|
||||
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
|
||||
int pix_array_n;
|
||||
unsigned long *pix_array = GetXPixArray((Display*) wxGetDisplay(), &pix_array_n);
|
||||
switch(bpp) {
|
||||
case 8: {
|
||||
unsigned char *dptr = (unsigned char *)dest;
|
||||
while(sz-- > 0) {
|
||||
if((int)*data < pix_array_n)
|
||||
*dptr = (unsigned char)pix_array[*data];
|
||||
data++;
|
||||
dptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
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;
|
||||
unsigned char *dptr = (unsigned char *)dest;
|
||||
while(sz-- > 0) {
|
||||
if((int)*data < pix_array_n)
|
||||
*dptr = (unsigned char)pix_array[*data];
|
||||
data++;
|
||||
dptr++;
|
||||
}
|
||||
data++;
|
||||
dptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
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++;
|
||||
dptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 32: {
|
||||
unsigned long *dptr = (unsigned long *)dest;
|
||||
while(sz-- > 0) {
|
||||
if((int)*data < pix_array_n)
|
||||
*dptr = pix_array[*data];
|
||||
data++;
|
||||
dptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
unsigned long *dptr = (unsigned long *)dest;
|
||||
while(sz-- > 0) {
|
||||
if((int)*data < pix_array_n)
|
||||
*dptr = pix_array[*data];
|
||||
data++;
|
||||
dptr++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
|
||||
if (!M_PALETTEDATA)
|
||||
return (unsigned long*) 0;
|
||||
wxNode *node;
|
||||
|
||||
|
||||
for (node = M_PALETTEDATA->m_palettes.First(); node; node = node->Next())
|
||||
{
|
||||
wxXPalette *c = (wxXPalette *)node->Data();
|
||||
@@ -326,7 +326,7 @@ unsigned long *wxPalette::GetXPixArray(WXDisplay *display, int *n)
|
||||
return c->m_pix_array;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Not found; call GetXColormap, which will create it, then this again */
|
||||
if (GetXColormap(display))
|
||||
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)
|
||||
{
|
||||
UnRef();
|
||||
|
||||
|
||||
m_refData = new wxPaletteRefData;
|
||||
|
||||
|
||||
wxXPalette *c = new wxXPalette;
|
||||
|
||||
|
||||
c->m_pix_array_n = 0;
|
||||
c->m_pix_array = (unsigned long*) NULL;
|
||||
c->m_display = display;
|
||||
c->m_cmap = cm;
|
||||
c->m_destroyable = dp;
|
||||
|
||||
|
||||
M_PALETTEDATA->m_palettes.Append(c);
|
||||
}
|
||||
|
||||
|
@@ -64,7 +64,7 @@ wxPen::~wxPen()
|
||||
wxPen::wxPen(const wxColour& col, int Width, int Style)
|
||||
{
|
||||
m_refData = new wxPenRefData;
|
||||
|
||||
|
||||
M_PENDATA->m_colour = col;
|
||||
M_PENDATA->m_width = Width;
|
||||
M_PENDATA->m_style = Style;
|
||||
@@ -72,9 +72,9 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
|
||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
|
||||
|
||||
if ( wxThePenList )
|
||||
wxThePenList->AddPen(this);
|
||||
}
|
||||
@@ -82,7 +82,7 @@ wxPen::wxPen(const wxColour& col, int Width, int Style)
|
||||
wxPen::wxPen(const wxBitmap& stipple, int Width)
|
||||
{
|
||||
m_refData = new wxPenRefData;
|
||||
|
||||
|
||||
M_PENDATA->m_stipple = stipple;
|
||||
M_PENDATA->m_width = Width;
|
||||
M_PENDATA->m_style = wxSTIPPLE;
|
||||
@@ -90,99 +90,99 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
|
||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
||||
M_PENDATA->m_nbDash = 0 ;
|
||||
M_PENDATA->m_dash = 0 ;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
|
||||
|
||||
if ( wxThePenList )
|
||||
wxThePenList->AddPen(this);
|
||||
}
|
||||
|
||||
void wxPen::Unshare()
|
||||
{
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
// Don't change shared data
|
||||
if (!m_refData)
|
||||
{
|
||||
m_refData = new wxPenRefData();
|
||||
}
|
||||
m_refData = new wxPenRefData();
|
||||
}
|
||||
else
|
||||
{
|
||||
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
|
||||
UnRef();
|
||||
m_refData = ref;
|
||||
}
|
||||
}
|
||||
|
||||
void wxPen::SetColour(const wxColour& col)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_colour = col;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_colour.Set(r, g, b);
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetWidth(int Width)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_width = Width;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetStyle(int Style)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_style = Style;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetStipple(const wxBitmap& Stipple)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_stipple = Stipple;
|
||||
M_PENDATA->m_style = wxSTIPPLE;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_nbDash = nb_dashes;
|
||||
M_PENDATA->m_dash = (wxDash *)Dash;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetJoin(int Join)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_join = Join;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
void wxPen::SetCap(int Cap)
|
||||
{
|
||||
Unshare();
|
||||
|
||||
|
||||
M_PENDATA->m_cap = Cap;
|
||||
|
||||
|
||||
RealizeResource();
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,7 @@
|
||||
#include <wx/motif/private.h>
|
||||
|
||||
void wxRadioButtonCallback (Widget w, XtPointer clientData,
|
||||
XmToggleButtonCallbackStruct * cbs);
|
||||
XmToggleButtonCallbackStruct * cbs);
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxRadioButton, wxControl)
|
||||
@@ -37,60 +37,60 @@ wxRadioButton::wxRadioButton()
|
||||
}
|
||||
|
||||
bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxString& label,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
m_windowFont = parent->GetFont();
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
m_windowStyle = style ;
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
wxString label1(wxStripMenuCodes(label));
|
||||
|
||||
|
||||
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
|
||||
|
||||
|
||||
XmFontList fontList = (XmFontList) m_windowFont.GetFontList(1.0, XtDisplay(parentWidget));
|
||||
|
||||
|
||||
Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle",
|
||||
#if wxUSE_GADGETS
|
||||
xmToggleButtonGadgetClass, parentWidget,
|
||||
xmToggleButtonGadgetClass, parentWidget,
|
||||
#else
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
xmToggleButtonWidgetClass, parentWidget,
|
||||
#endif
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
XmNfillOnSelect, True,
|
||||
XmNindicatorType, XmONE_OF_MANY, // diamond-shape
|
||||
NULL);
|
||||
XmNfontList, fontList,
|
||||
XmNlabelString, text,
|
||||
XmNfillOnSelect, True,
|
||||
XmNindicatorType, XmONE_OF_MANY, // diamond-shape
|
||||
NULL);
|
||||
XmStringFree (text);
|
||||
|
||||
|
||||
XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback,
|
||||
(XtCallbackProc) this);
|
||||
|
||||
(XtCallbackProc) this);
|
||||
|
||||
m_mainWidget = (WXWidget) radioButtonWidget;
|
||||
|
||||
|
||||
XtManageChild (radioButtonWidget);
|
||||
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -109,8 +109,8 @@ bool wxRadioButton::GetValue() const
|
||||
|
||||
void wxRadioButton::Command (wxCommandEvent & event)
|
||||
{
|
||||
SetValue ( (event.m_commandInt != 0) );
|
||||
ProcessCommand (event);
|
||||
SetValue ( (event.m_commandInt != 0) );
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxRadioButton::ChangeFont(bool keepOriginalSize)
|
||||
@@ -129,18 +129,18 @@ void wxRadioButton::ChangeForegroundColour()
|
||||
}
|
||||
|
||||
void wxRadioButtonCallback (Widget w, XtPointer clientData,
|
||||
XmToggleButtonCallbackStruct * cbs)
|
||||
XmToggleButtonCallbackStruct * cbs)
|
||||
{
|
||||
if (!cbs->set)
|
||||
return;
|
||||
|
||||
wxRadioButton *item = (wxRadioButton *) clientData;
|
||||
if (item->InSetValue())
|
||||
return;
|
||||
|
||||
wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
|
||||
event.SetEventObject(item);
|
||||
|
||||
item->ProcessCommand (event);
|
||||
if (!cbs->set)
|
||||
return;
|
||||
|
||||
wxRadioButton *item = (wxRadioButton *) clientData;
|
||||
if (item->InSetValue())
|
||||
return;
|
||||
|
||||
wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
|
||||
event.SetEventObject(item);
|
||||
|
||||
item->ProcessCommand (event);
|
||||
}
|
||||
|
||||
|
@@ -38,75 +38,75 @@ END_EVENT_TABLE()
|
||||
// Slider
|
||||
wxSlider::wxSlider()
|
||||
{
|
||||
m_pageSize = 1;
|
||||
m_lineSize = 1;
|
||||
m_rangeMax = 0;
|
||||
m_rangeMin = 0;
|
||||
m_tickFreq = 0;
|
||||
m_pageSize = 1;
|
||||
m_lineSize = 1;
|
||||
m_rangeMax = 0;
|
||||
m_rangeMin = 0;
|
||||
m_tickFreq = 0;
|
||||
}
|
||||
|
||||
bool wxSlider::Create(wxWindow *parent, wxWindowID id,
|
||||
int value, int minValue, int maxValue,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
int value, int minValue, int maxValue,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
m_lineSize = 1;
|
||||
m_windowStyle = style;
|
||||
m_tickFreq = 0;
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
m_rangeMax = maxValue;
|
||||
m_rangeMin = minValue;
|
||||
|
||||
|
||||
// Not used in Motif, I think
|
||||
m_pageSize = (int)((maxValue-minValue)/10);
|
||||
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget",
|
||||
xmScaleWidgetClass, parentWidget,
|
||||
XmNorientation,
|
||||
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL),
|
||||
XmNprocessingDirection,
|
||||
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT),
|
||||
XmNmaximum, maxValue,
|
||||
XmNminimum, minValue,
|
||||
XmNvalue, value,
|
||||
XmNshowValue, True,
|
||||
NULL);
|
||||
|
||||
xmScaleWidgetClass, parentWidget,
|
||||
XmNorientation,
|
||||
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmVERTICAL : XmHORIZONTAL),
|
||||
XmNprocessingDirection,
|
||||
(((m_windowStyle & wxSL_VERTICAL) == wxSL_VERTICAL) ? XmMAX_ON_TOP : XmMAX_ON_RIGHT),
|
||||
XmNmaximum, maxValue,
|
||||
XmNminimum, minValue,
|
||||
XmNvalue, value,
|
||||
XmNshowValue, True,
|
||||
NULL);
|
||||
|
||||
m_mainWidget = (WXWidget) sliderWidget;
|
||||
|
||||
|
||||
if(style & wxSL_NOTIFY_DRAG)
|
||||
XtAddCallback (sliderWidget, XmNdragCallback,
|
||||
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
|
||||
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
|
||||
else
|
||||
XtAddCallback (sliderWidget, XmNvalueChangedCallback,
|
||||
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
|
||||
|
||||
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
|
||||
|
||||
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
|
||||
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
|
||||
|
||||
ChangeFont(FALSE);
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
Widget widget = (Widget) m_mainWidget;
|
||||
|
||||
bool managed = XtIsManaged(widget);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (widget);
|
||||
|
||||
if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
|
||||
{
|
||||
XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
|
||||
}
|
||||
|
||||
if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
|
||||
{
|
||||
XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
|
||||
}
|
||||
|
||||
int xx = x; int yy = y;
|
||||
AdjustForParentClientOrigin(xx, yy, sizeFlags);
|
||||
|
||||
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
XtVaSetValues (widget, XmNx, xx, NULL);
|
||||
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
XtVaSetValues (widget, XmNy, yy, NULL);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (widget);
|
||||
Widget widget = (Widget) m_mainWidget;
|
||||
|
||||
bool managed = XtIsManaged(widget);
|
||||
|
||||
if (managed)
|
||||
XtUnmanageChild (widget);
|
||||
|
||||
if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
|
||||
{
|
||||
XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
|
||||
}
|
||||
|
||||
if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
|
||||
{
|
||||
XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
|
||||
}
|
||||
|
||||
int xx = x; int yy = y;
|
||||
AdjustForParentClientOrigin(xx, yy, sizeFlags);
|
||||
|
||||
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
XtVaSetValues (widget, XmNx, xx, NULL);
|
||||
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
|
||||
XtVaSetValues (widget, XmNy, yy, NULL);
|
||||
|
||||
if (managed)
|
||||
XtManageChild (widget);
|
||||
}
|
||||
|
||||
void wxSlider::SetRange(int minValue, int maxValue)
|
||||
{
|
||||
m_rangeMin = minValue;
|
||||
m_rangeMax = maxValue;
|
||||
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL);
|
||||
}
|
||||
|
||||
@@ -245,8 +245,8 @@ void wxSlider::SetTick(int WXUNUSED(tickPos))
|
||||
|
||||
void wxSlider::Command (wxCommandEvent & event)
|
||||
{
|
||||
SetValue (event.GetInt());
|
||||
ProcessCommand (event);
|
||||
SetValue (event.GetInt());
|
||||
ProcessCommand (event);
|
||||
}
|
||||
|
||||
void wxSlider::ChangeFont(bool keepOriginalSize)
|
||||
@@ -269,19 +269,19 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc
|
||||
wxSlider *slider = (wxSlider *) clientData;
|
||||
switch (cbs->reason)
|
||||
{
|
||||
case XmCR_VALUE_CHANGED:
|
||||
case XmCR_DRAG:
|
||||
default:
|
||||
case XmCR_VALUE_CHANGED:
|
||||
case XmCR_DRAG:
|
||||
default:
|
||||
{
|
||||
// TODO: the XmCR_VALUE_CHANGED case should be handled
|
||||
// differently (it's not sent continually as the slider moves).
|
||||
// In which case we need a similar behaviour for other platforms.
|
||||
|
||||
|
||||
wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId());
|
||||
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
|
||||
event.SetEventObject(slider);
|
||||
slider->ProcessCommand(event);
|
||||
|
||||
|
||||
// Also send a wxCommandEvent for compatibility.
|
||||
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
|
||||
event2.SetEventObject(slider);
|
||||
|
@@ -46,21 +46,21 @@ wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *
|
||||
static void
|
||||
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs);
|
||||
static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
|
||||
XmAnyCallbackStruct *ptr);
|
||||
XmAnyCallbackStruct *ptr);
|
||||
|
||||
#if !USE_SHARED_LIBRARY
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxTextCtrl, wxControl)
|
||||
|
||||
BEGIN_EVENT_TABLE(wxTextCtrl, wxControl)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
EVT_DROP_FILES(wxTextCtrl::OnDropFiles)
|
||||
EVT_CHAR(wxTextCtrl::OnChar)
|
||||
END_EVENT_TABLE()
|
||||
#endif
|
||||
|
||||
// Text item
|
||||
wxTextCtrl::wxTextCtrl()
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
:streambuf()
|
||||
:streambuf()
|
||||
#endif
|
||||
{
|
||||
m_fileName = "";
|
||||
@@ -70,11 +70,11 @@ wxTextCtrl::wxTextCtrl()
|
||||
}
|
||||
|
||||
bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
const wxString& value,
|
||||
const wxPoint& pos,
|
||||
const wxSize& size, long style,
|
||||
const wxValidator& validator,
|
||||
const wxString& name)
|
||||
{
|
||||
m_tempCallbackStruct = (void*) NULL;
|
||||
m_modified = FALSE;
|
||||
@@ -83,75 +83,75 @@ bool wxTextCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||
// m_backgroundColour = parent->GetBackgroundColour();
|
||||
m_backgroundColour = * wxWHITE;
|
||||
m_foregroundColour = parent->GetForegroundColour();
|
||||
|
||||
|
||||
SetName(name);
|
||||
SetValidator(validator);
|
||||
if (parent) parent->AddChild(this);
|
||||
|
||||
|
||||
m_windowStyle = style;
|
||||
|
||||
|
||||
if ( id == -1 )
|
||||
m_windowId = (int)NewControlId();
|
||||
m_windowId = (int)NewControlId();
|
||||
else
|
||||
m_windowId = id;
|
||||
|
||||
m_windowId = id;
|
||||
|
||||
Widget parentWidget = (Widget) parent->GetClientWidget();
|
||||
|
||||
|
||||
bool wantHorizScrolling = ((m_windowStyle & wxHSCROLL) != 0);
|
||||
|
||||
|
||||
// If we don't have horizontal scrollbars, we want word wrap.
|
||||
bool wantWordWrap = !wantHorizScrolling;
|
||||
|
||||
|
||||
if (m_windowStyle & wxTE_MULTILINE)
|
||||
{
|
||||
Arg args[2];
|
||||
XtSetArg (args[0], XmNscrollHorizontal, wantHorizScrolling ? True : False);
|
||||
XtSetArg (args[1], XmNwordWrap, wantWordWrap ? True : False);
|
||||
|
||||
|
||||
m_mainWidget = (WXWidget) XmCreateScrolledText (parentWidget, (char*) (const char*) name, args, 2);
|
||||
|
||||
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
NULL);
|
||||
XmNeditable, ((style & wxTE_READONLY) ? False : True),
|
||||
XmNeditMode, XmMULTI_LINE_EDIT,
|
||||
NULL);
|
||||
XtManageChild ((Widget) m_mainWidget);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
|
||||
xmTextWidgetClass, parentWidget,
|
||||
NULL);
|
||||
|
||||
xmTextWidgetClass, parentWidget,
|
||||
NULL);
|
||||
|
||||
// TODO: Is this relevant? What does it do?
|
||||
int noCols = 2;
|
||||
if (!value.IsNull() && (value.Length() > (unsigned int) noCols))
|
||||
noCols = value.Length();
|
||||
XtVaSetValues ((Widget) m_mainWidget,
|
||||
XmNcolumns, noCols,
|
||||
NULL);
|
||||
XmNcolumns, noCols,
|
||||
NULL);
|
||||
}
|
||||
|
||||
|
||||
if (!value.IsNull())
|
||||
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
|
||||
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc)wxTextWindowChangedProc, (XtPointer)this);
|
||||
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNmodifyVerifyCallback, (XtCallbackProc)wxTextWindowModifyProc, (XtPointer)this);
|
||||
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNactivateCallback, (XtCallbackProc)wxTextWindowActivateProc, (XtPointer)this);
|
||||
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNfocusCallback, (XtCallbackProc)wxTextWindowGainFocusProc, (XtPointer)this);
|
||||
|
||||
|
||||
XtAddCallback((Widget) m_mainWidget, XmNlosingFocusCallback, (XtCallbackProc)wxTextWindowLoseFocusProc, (XtPointer)this);
|
||||
|
||||
|
||||
m_windowFont = parent->GetFont();
|
||||
ChangeFont(FALSE);
|
||||
|
||||
|
||||
SetCanAddEventHandler(TRUE);
|
||||
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
|
||||
|
||||
|
||||
ChangeBackgroundColour();
|
||||
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -169,11 +169,11 @@ wxString wxTextCtrl::GetValue() const
|
||||
char *s = XmTextGetString ((Widget) m_mainWidget);
|
||||
if (s)
|
||||
{
|
||||
wxString str(s);
|
||||
wxString str(s);
|
||||
XtFree (s);
|
||||
return str;
|
||||
}
|
||||
else
|
||||
return str;
|
||||
}
|
||||
else
|
||||
{
|
||||
return wxEmptyString;
|
||||
}
|
||||
@@ -182,13 +182,13 @@ wxString wxTextCtrl::GetValue() const
|
||||
|
||||
void wxTextCtrl::SetValue(const wxString& value)
|
||||
{
|
||||
// This assert is wrong -- means that you can't set an empty
|
||||
// string (IsNull == IsEmpty).
|
||||
// wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
|
||||
// This assert is wrong -- means that you can't set an empty
|
||||
// string (IsNull == IsEmpty).
|
||||
// wxASSERT_MSG( (!value.IsNull()), "Must not pass a null string to wxTextCtrl::SetValue." ) ;
|
||||
m_inSetValue = TRUE;
|
||||
|
||||
|
||||
XmTextSetString ((Widget) m_mainWidget, (char*) (const char*) value);
|
||||
|
||||
|
||||
m_inSetValue = FALSE;
|
||||
}
|
||||
|
||||
@@ -237,7 +237,7 @@ long wxTextCtrl::GetLastPosition() const
|
||||
void wxTextCtrl::Replace(long from, long to, const wxString& value)
|
||||
{
|
||||
XmTextReplace ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
|
||||
(char*) (const char*) value);
|
||||
(char*) (const char*) value);
|
||||
}
|
||||
|
||||
void wxTextCtrl::Remove(long from, long to)
|
||||
@@ -257,40 +257,40 @@ bool wxTextCtrl::LoadFile(const wxString& file)
|
||||
{
|
||||
if (!wxFileExists(file))
|
||||
return FALSE;
|
||||
|
||||
|
||||
m_fileName = file;
|
||||
|
||||
|
||||
Clear();
|
||||
|
||||
|
||||
Widget textWidget = (Widget) m_mainWidget;
|
||||
FILE *fp;
|
||||
|
||||
|
||||
struct stat statb;
|
||||
if ((stat ((char*) (const char*) file, &statb) == -1) || (statb.st_mode & S_IFMT) != S_IFREG ||
|
||||
!(fp = fopen ((char*) (const char*) file, "r")))
|
||||
!(fp = fopen ((char*) (const char*) file, "r")))
|
||||
{
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
long len = statb.st_size;
|
||||
char *text;
|
||||
if (!(text = XtMalloc ((unsigned) (len + 1))))
|
||||
{
|
||||
fclose (fp);
|
||||
return FALSE;
|
||||
}
|
||||
if (fread (text, sizeof (char), len, fp) != (size_t) len)
|
||||
{
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
text[len] = 0;
|
||||
XmTextSetString (textWidget, text);
|
||||
// m_textPosition = len;
|
||||
XtFree (text);
|
||||
m_modified = FALSE;
|
||||
return TRUE;
|
||||
long len = statb.st_size;
|
||||
char *text;
|
||||
if (!(text = XtMalloc ((unsigned) (len + 1))))
|
||||
{
|
||||
fclose (fp);
|
||||
return FALSE;
|
||||
}
|
||||
if (fread (text, sizeof (char), len, fp) != (size_t) len)
|
||||
{
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
text[len] = 0;
|
||||
XmTextSetString (textWidget, text);
|
||||
// m_textPosition = len;
|
||||
XtFree (text);
|
||||
m_modified = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,31 +304,31 @@ bool wxTextCtrl::SaveFile(const wxString& file)
|
||||
if (theFile == "")
|
||||
return FALSE;
|
||||
m_fileName = theFile;
|
||||
|
||||
Widget textWidget = (Widget) m_mainWidget;
|
||||
FILE *fp;
|
||||
|
||||
if (!(fp = fopen ((char*) (const char*) theFile, "w")))
|
||||
|
||||
Widget textWidget = (Widget) m_mainWidget;
|
||||
FILE *fp;
|
||||
|
||||
if (!(fp = fopen ((char*) (const char*) theFile, "w")))
|
||||
{
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
char *text = XmTextGetString (textWidget);
|
||||
long len = XmTextGetLastPosition (textWidget);
|
||||
|
||||
if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
|
||||
{
|
||||
// Did not write whole file
|
||||
}
|
||||
// Make sure newline terminates the file
|
||||
if (text[len - 1] != '\n')
|
||||
fputc ('\n', fp);
|
||||
|
||||
fclose (fp);
|
||||
XtFree (text);
|
||||
m_modified = FALSE;
|
||||
return TRUE;
|
||||
char *text = XmTextGetString (textWidget);
|
||||
long len = XmTextGetLastPosition (textWidget);
|
||||
|
||||
if (fwrite (text, sizeof (char), len, fp) != (size_t) len)
|
||||
{
|
||||
// Did not write whole file
|
||||
}
|
||||
// Make sure newline terminates the file
|
||||
if (text[len - 1] != '\n')
|
||||
fputc ('\n', fp);
|
||||
|
||||
fclose (fp);
|
||||
XtFree (text);
|
||||
m_modified = FALSE;
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,27 +366,27 @@ int wxTextCtrl::GetNumberOfLines() const
|
||||
char *s = XmTextGetString ((Widget) m_mainWidget);
|
||||
if (s)
|
||||
{
|
||||
long i = 0;
|
||||
int currentLine = 0;
|
||||
bool finished = FALSE;
|
||||
while (!finished)
|
||||
{
|
||||
int ch = s[i];
|
||||
if (ch == '\n')
|
||||
{
|
||||
currentLine++;
|
||||
i++;
|
||||
}
|
||||
else if (ch == 0)
|
||||
{
|
||||
finished = TRUE;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
XtFree (s);
|
||||
return currentLine;
|
||||
long i = 0;
|
||||
int currentLine = 0;
|
||||
bool finished = FALSE;
|
||||
while (!finished)
|
||||
{
|
||||
int ch = s[i];
|
||||
if (ch == '\n')
|
||||
{
|
||||
currentLine++;
|
||||
i++;
|
||||
}
|
||||
else if (ch == 0)
|
||||
{
|
||||
finished = TRUE;
|
||||
}
|
||||
else
|
||||
i++;
|
||||
}
|
||||
|
||||
XtFree (s);
|
||||
return currentLine;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -394,11 +394,11 @@ int wxTextCtrl::GetNumberOfLines() const
|
||||
long wxTextCtrl::XYToPosition(long x, long y) const
|
||||
{
|
||||
/* It seems, that there is a bug in some versions of the Motif library,
|
||||
so the original wxWin-Code doesn't work. */
|
||||
/*
|
||||
Widget textWidget = (Widget) handle;
|
||||
return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y);
|
||||
*/
|
||||
so the original wxWin-Code doesn't work. */
|
||||
/*
|
||||
Widget textWidget = (Widget) handle;
|
||||
return (long) XmTextXYToPos (textWidget, (Position) x, (Position) y);
|
||||
*/
|
||||
/* Now a little workaround: */
|
||||
long r=0;
|
||||
for (int i=0; i<y; i++) r+=(GetLineLength(i)+1);
|
||||
@@ -427,31 +427,31 @@ wxString wxTextCtrl::GetLineText(long lineNo) const
|
||||
{
|
||||
// HIDEOUSLY inefficient, but we have no choice.
|
||||
char *s = XmTextGetString ((Widget) m_mainWidget);
|
||||
|
||||
|
||||
if (s)
|
||||
{
|
||||
wxString buf("");
|
||||
long i;
|
||||
int currentLine = 0;
|
||||
for (i = 0; currentLine != lineNo && s[i]; i++ )
|
||||
if (s[i] == '\n')
|
||||
currentLine++;
|
||||
// Now get the text
|
||||
int j;
|
||||
for (j = 0; s[i] && s[i] != '\n'; i++, j++ )
|
||||
buf += s[i];
|
||||
|
||||
XtFree(s);
|
||||
return buf;
|
||||
}
|
||||
else
|
||||
return wxEmptyString;
|
||||
if (s[i] == '\n')
|
||||
currentLine++;
|
||||
// Now get the text
|
||||
int j;
|
||||
for (j = 0; s[i] && s[i] != '\n'; i++, j++ )
|
||||
buf += s[i];
|
||||
|
||||
XtFree(s);
|
||||
return buf;
|
||||
}
|
||||
else
|
||||
return wxEmptyString;
|
||||
}
|
||||
|
||||
/*
|
||||
* Text item
|
||||
*/
|
||||
|
||||
* Text item
|
||||
*/
|
||||
|
||||
void wxTextCtrl::Command(wxCommandEvent & event)
|
||||
{
|
||||
SetValue (event.GetString());
|
||||
@@ -479,62 +479,62 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
|
||||
#ifndef NO_TEXT_WINDOW_STREAM
|
||||
int wxTextCtrl::overflow(int c)
|
||||
{
|
||||
// Make sure there is a holding area
|
||||
if ( allocate()==EOF )
|
||||
{
|
||||
wxError("Streambuf allocation failed","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
// Verify that there are no characters in get area
|
||||
if ( gptr() && gptr() < egptr() )
|
||||
{
|
||||
wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
// Reset get area
|
||||
setg(0,0,0);
|
||||
|
||||
// Make sure there is a put area
|
||||
if ( ! pptr() )
|
||||
{
|
||||
/* This doesn't seem to be fatal so comment out error message */
|
||||
// wxError("Put area not opened","Internal error");
|
||||
setp( base(), base() );
|
||||
}
|
||||
|
||||
// Determine how many characters have been inserted but no consumed
|
||||
int plen = pptr() - pbase();
|
||||
|
||||
// Now Jerry relies on the fact that the buffer is at least 2 chars
|
||||
// long, but the holding area "may be as small as 1" ???
|
||||
// And we need an additional \0, so let's keep this inefficient but
|
||||
// safe copy.
|
||||
|
||||
// If c!=EOF, it is a character that must also be comsumed
|
||||
int xtra = c==EOF? 0 : 1;
|
||||
|
||||
// Write temporary C-string to wxTextWindow
|
||||
{
|
||||
char *txt = new char[plen+xtra+1];
|
||||
memcpy(txt, pbase(), plen);
|
||||
txt[plen] = (char)c; // append c
|
||||
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
|
||||
// If the put area already contained \0, output will be truncated there
|
||||
WriteText(txt);
|
||||
delete[] txt;
|
||||
}
|
||||
|
||||
// Reset put area
|
||||
setp(pbase(), epptr());
|
||||
|
||||
// Make sure there is a holding area
|
||||
if ( allocate()==EOF )
|
||||
{
|
||||
wxError("Streambuf allocation failed","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
// Verify that there are no characters in get area
|
||||
if ( gptr() && gptr() < egptr() )
|
||||
{
|
||||
wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
// Reset get area
|
||||
setg(0,0,0);
|
||||
|
||||
// Make sure there is a put area
|
||||
if ( ! pptr() )
|
||||
{
|
||||
/* This doesn't seem to be fatal so comment out error message */
|
||||
// wxError("Put area not opened","Internal error");
|
||||
setp( base(), base() );
|
||||
}
|
||||
|
||||
// Determine how many characters have been inserted but no consumed
|
||||
int plen = pptr() - pbase();
|
||||
|
||||
// Now Jerry relies on the fact that the buffer is at least 2 chars
|
||||
// long, but the holding area "may be as small as 1" ???
|
||||
// And we need an additional \0, so let's keep this inefficient but
|
||||
// safe copy.
|
||||
|
||||
// If c!=EOF, it is a character that must also be comsumed
|
||||
int xtra = c==EOF? 0 : 1;
|
||||
|
||||
// Write temporary C-string to wxTextWindow
|
||||
{
|
||||
char *txt = new char[plen+xtra+1];
|
||||
memcpy(txt, pbase(), plen);
|
||||
txt[plen] = (char)c; // append c
|
||||
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
|
||||
// If the put area already contained \0, output will be truncated there
|
||||
WriteText(txt);
|
||||
delete[] txt;
|
||||
}
|
||||
|
||||
// Reset put area
|
||||
setp(pbase(), epptr());
|
||||
|
||||
#if defined(__WATCOMC__)
|
||||
return __NOT_EOF;
|
||||
return __NOT_EOF;
|
||||
#elif defined(zapeof) // HP-UX (all cfront based?)
|
||||
return zapeof(c);
|
||||
return zapeof(c);
|
||||
#else
|
||||
return c!=EOF ? c : 0; // this should make everybody happy
|
||||
return c!=EOF ? c : 0; // this should make everybody happy
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -543,26 +543,26 @@ int wxTextCtrl::overflow(int c)
|
||||
//=========================================================================
|
||||
int wxTextCtrl::sync()
|
||||
{
|
||||
// Verify that there are no characters in get area
|
||||
if ( gptr() && gptr() < egptr() )
|
||||
{
|
||||
wxError("Who's trespassing my get area?","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
|
||||
|
||||
return 0;
|
||||
/* OLD CODE
|
||||
int len = pptr() - pbase();
|
||||
char *txt = new char[len+1];
|
||||
strncpy(txt, pbase(), len);
|
||||
txt[len] = '\0';
|
||||
(*this) << txt;
|
||||
setp(pbase(), epptr());
|
||||
delete[] txt;
|
||||
return 0;
|
||||
*/
|
||||
// Verify that there are no characters in get area
|
||||
if ( gptr() && gptr() < egptr() )
|
||||
{
|
||||
wxError("Who's trespassing my get area?","Internal error");
|
||||
return EOF;
|
||||
}
|
||||
|
||||
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
|
||||
|
||||
return 0;
|
||||
/* OLD CODE
|
||||
int len = pptr() - pbase();
|
||||
char *txt = new char[len+1];
|
||||
strncpy(txt, pbase(), len);
|
||||
txt[len] = '\0';
|
||||
(*this) << txt;
|
||||
setp(pbase(), epptr());
|
||||
delete[] txt;
|
||||
return 0;
|
||||
*/
|
||||
}
|
||||
|
||||
//=========================================================================
|
||||
@@ -570,7 +570,7 @@ int wxTextCtrl::sync()
|
||||
//=========================================================================
|
||||
int wxTextCtrl::underflow()
|
||||
{
|
||||
return EOF;
|
||||
return EOF;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -615,7 +615,7 @@ wxTextCtrl& wxTextCtrl::operator<<(long i)
|
||||
wxTextCtrl& wxTextCtrl::operator<<(const char c)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
|
||||
buf[0] = c;
|
||||
buf[1] = 0;
|
||||
WriteText(buf);
|
||||
@@ -624,21 +624,21 @@ wxTextCtrl& wxTextCtrl::operator<<(const char c)
|
||||
|
||||
void wxTextCtrl::OnChar(wxKeyEvent& event)
|
||||
{
|
||||
// Indicates that we should generate a normal command, because
|
||||
// we're letting default behaviour happen (otherwise it's vetoed
|
||||
// by virtue of overriding OnChar)
|
||||
m_processedDefault = TRUE;
|
||||
|
||||
if (m_tempCallbackStruct)
|
||||
{
|
||||
XmTextVerifyCallbackStruct *textStruct =
|
||||
(XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
|
||||
textStruct->doit = True;
|
||||
if (isascii(event.m_keyCode) && (textStruct->text->length == 1))
|
||||
// Indicates that we should generate a normal command, because
|
||||
// we're letting default behaviour happen (otherwise it's vetoed
|
||||
// by virtue of overriding OnChar)
|
||||
m_processedDefault = TRUE;
|
||||
|
||||
if (m_tempCallbackStruct)
|
||||
{
|
||||
textStruct->text->ptr[0] = ((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
|
||||
XmTextVerifyCallbackStruct *textStruct =
|
||||
(XmTextVerifyCallbackStruct *) m_tempCallbackStruct;
|
||||
textStruct->doit = True;
|
||||
if (isascii(event.m_keyCode) && (textStruct->text->length == 1))
|
||||
{
|
||||
textStruct->text->ptr[0] = ((event.m_keyCode == WXK_RETURN) ? 10 : event.m_keyCode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void wxTextCtrl::ChangeFont(bool keepOriginalSize)
|
||||
@@ -649,25 +649,25 @@ void wxTextCtrl::ChangeFont(bool keepOriginalSize)
|
||||
void wxTextCtrl::ChangeBackgroundColour()
|
||||
{
|
||||
wxWindow::ChangeBackgroundColour();
|
||||
|
||||
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
*/
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
*/
|
||||
if (m_windowStyle & wxTE_MULTILINE)
|
||||
{
|
||||
Widget parent = XtParent ((Widget) m_mainWidget);
|
||||
Widget hsb, vsb;
|
||||
|
||||
|
||||
XtVaGetValues (parent,
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE);
|
||||
if (hsb)
|
||||
DoChangeBackgroundColour((WXWidget) hsb, backgroundColour, TRUE);
|
||||
if (vsb)
|
||||
DoChangeBackgroundColour((WXWidget) vsb, backgroundColour, TRUE);
|
||||
|
||||
|
||||
DoChangeBackgroundColour((WXWidget) parent, m_backgroundColour, TRUE);
|
||||
}
|
||||
}
|
||||
@@ -675,36 +675,36 @@ void wxTextCtrl::ChangeBackgroundColour()
|
||||
void wxTextCtrl::ChangeForegroundColour()
|
||||
{
|
||||
wxWindow::ChangeForegroundColour();
|
||||
|
||||
|
||||
if (m_windowStyle & wxTE_MULTILINE)
|
||||
{
|
||||
Widget parent = XtParent ((Widget) m_mainWidget);
|
||||
Widget hsb, vsb;
|
||||
|
||||
|
||||
XtVaGetValues (parent,
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
if (hsb)
|
||||
XmNhorizontalScrollBar, &hsb,
|
||||
XmNverticalScrollBar, &vsb,
|
||||
NULL);
|
||||
|
||||
/* TODO: should scrollbars be affected? Should probably have separate
|
||||
* function to change them (by default, taken from wxSystemSettings)
|
||||
if (hsb)
|
||||
DoChangeForegroundColour((WXWidget) hsb, m_foregroundColour);
|
||||
if (vsb)
|
||||
if (vsb)
|
||||
DoChangeForegroundColour((WXWidget) vsb, m_foregroundColour);
|
||||
*/
|
||||
*/
|
||||
DoChangeForegroundColour((WXWidget) parent, m_foregroundColour);
|
||||
}
|
||||
}
|
||||
|
||||
static void wxTextWindowChangedProc (Widget w, XtPointer clientData, XtPointer ptr)
|
||||
{
|
||||
if (!wxGetWindowFromTable(w))
|
||||
// Widget has been deleted!
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
tw->SetModified(TRUE);
|
||||
if (!wxGetWindowFromTable(w))
|
||||
// Widget has been deleted!
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
tw->SetModified(TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -712,23 +712,23 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
|
||||
{
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
tw->m_processedDefault = FALSE;
|
||||
|
||||
|
||||
// First, do some stuff if it's a password control.
|
||||
// (What does this do exactly?)
|
||||
|
||||
|
||||
if (tw->GetWindowStyleFlag() & wxTE_PASSWORD)
|
||||
{
|
||||
/* _sm_
|
||||
* At least on my system (SunOS 4.1.3 + Motif 1.2), you need to think of
|
||||
* every event as a replace event. cbs->text->ptr gives the replacement
|
||||
* text, cbs->startPos gives the index of the first char affected by the
|
||||
* replace, and cbs->endPos gives the index one more than the last char
|
||||
* affected by the replace (startPos == endPos implies an empty range).
|
||||
* Hence, a deletion is represented by replacing all input text with a
|
||||
* blank string ("", *not* NULL!). A simple insertion that does not
|
||||
* overwrite any text has startPos == endPos.
|
||||
*/
|
||||
|
||||
/* _sm_
|
||||
* At least on my system (SunOS 4.1.3 + Motif 1.2), you need to think of
|
||||
* every event as a replace event. cbs->text->ptr gives the replacement
|
||||
* text, cbs->startPos gives the index of the first char affected by the
|
||||
* replace, and cbs->endPos gives the index one more than the last char
|
||||
* affected by the replace (startPos == endPos implies an empty range).
|
||||
* Hence, a deletion is represented by replacing all input text with a
|
||||
* blank string ("", *not* NULL!). A simple insertion that does not
|
||||
* overwrite any text has startPos == endPos.
|
||||
*/
|
||||
|
||||
if (tw->m_value.IsNull())
|
||||
{
|
||||
tw->m_value = cbs->text->ptr;
|
||||
@@ -736,33 +736,33 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
|
||||
else
|
||||
{
|
||||
char * passwd = (char*) (const char*) tw->m_value; // Set up a more convenient alias.
|
||||
|
||||
|
||||
int len = passwd ? strlen(passwd) : 0; // Enough room for old text
|
||||
len += strlen(cbs->text->ptr) + 1; // + new text (if any) + NUL
|
||||
len -= cbs->endPos - cbs->startPos; // - text from affected region.
|
||||
|
||||
|
||||
char * newS = new char [len];
|
||||
char * p = passwd, * dest = newS, * insert = cbs->text->ptr;
|
||||
|
||||
|
||||
// Copy (old) text from passwd, up to the start posn of the change.
|
||||
int i;
|
||||
for (i = 0; i < cbs->startPos; ++i)
|
||||
*dest++ = *p++;
|
||||
|
||||
|
||||
// Copy the text to be inserted).
|
||||
while (*insert)
|
||||
*dest++ = *insert++;
|
||||
|
||||
*dest++ = *insert++;
|
||||
|
||||
// Finally, copy into newS any remaining text from passwd[endPos] on.
|
||||
for (p = passwd + cbs->endPos; *p; )
|
||||
*dest++ = *p++;
|
||||
*dest = 0;
|
||||
|
||||
|
||||
tw->m_value = newS;
|
||||
|
||||
|
||||
delete[] newS;
|
||||
}
|
||||
|
||||
|
||||
if (cbs->text->length>0)
|
||||
{
|
||||
int i;
|
||||
@@ -771,70 +771,70 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
|
||||
cbs->text->ptr[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// If we're already within an OnChar, return: probably
|
||||
// a programmatic insertion.
|
||||
if (tw->m_tempCallbackStruct)
|
||||
return;
|
||||
|
||||
|
||||
// Check for a backspace
|
||||
if (cbs->startPos == (cbs->currInsert - 1))
|
||||
{
|
||||
tw->m_tempCallbackStruct = (void*) cbs;
|
||||
|
||||
|
||||
wxKeyEvent event (wxEVT_CHAR);
|
||||
event.SetId(tw->GetId());
|
||||
event.m_keyCode = WXK_DELETE;
|
||||
event.SetEventObject(tw);
|
||||
|
||||
|
||||
// Only if wxTextCtrl::OnChar is called
|
||||
// will this be set to True (and the character
|
||||
// passed through)
|
||||
cbs->doit = False;
|
||||
|
||||
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
|
||||
tw->m_tempCallbackStruct = NULL;
|
||||
|
||||
|
||||
if (tw->InSetValue())
|
||||
return;
|
||||
|
||||
|
||||
if (tw->m_processedDefault)
|
||||
{
|
||||
// Can generate a command
|
||||
wxCommandEvent commandEvent(wxEVT_COMMAND_TEXT_UPDATED, tw->GetId());
|
||||
commandEvent.SetEventObject(tw);
|
||||
commandEvent.SetEventObject(tw);
|
||||
tw->ProcessCommand(commandEvent);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// Pasting operation: let it through without
|
||||
// calling OnChar
|
||||
if (cbs->text->length > 1)
|
||||
return;
|
||||
|
||||
|
||||
// Something other than text
|
||||
if (cbs->text->ptr == NULL)
|
||||
return;
|
||||
|
||||
|
||||
tw->m_tempCallbackStruct = (void*) cbs;
|
||||
|
||||
|
||||
wxKeyEvent event (wxEVT_CHAR);
|
||||
event.SetId(tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
event.m_keyCode = (cbs->text->ptr[0] == 10 ? 13 : cbs->text->ptr[0]);
|
||||
|
||||
|
||||
// Only if wxTextCtrl::OnChar is called
|
||||
// will this be set to True (and the character
|
||||
// passed through)
|
||||
cbs->doit = False;
|
||||
|
||||
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
|
||||
|
||||
tw->m_tempCallbackStruct = NULL;
|
||||
|
||||
|
||||
if (tw->InSetValue())
|
||||
return;
|
||||
|
||||
@@ -850,49 +850,49 @@ wxTextWindowModifyProc (Widget w, XtPointer clientData, XmTextVerifyCallbackStru
|
||||
static void
|
||||
wxTextWindowGainFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
|
||||
{
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
wxFocusEvent event(wxEVT_SET_FOCUS, tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
static void
|
||||
wxTextWindowLoseFocusProc (Widget w, XtPointer clientData, XmAnyCallbackStruct *cbs)
|
||||
{
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
wxFocusEvent event(wxEVT_KILL_FOCUS, tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
static void wxTextWindowActivateProc(Widget w, XtPointer clientData,
|
||||
XmAnyCallbackStruct *ptr)
|
||||
XmAnyCallbackStruct *ptr)
|
||||
{
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
/*
|
||||
case XmCR_ACTIVATE:
|
||||
if (!wxGetWindowFromTable(w))
|
||||
return;
|
||||
|
||||
wxTextCtrl *tw = (wxTextCtrl *) clientData;
|
||||
/*
|
||||
case XmCR_ACTIVATE:
|
||||
type_event = wxEVENT_TYPE_TEXT_ENTER_COMMAND ;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
type_event = wxEVENT_TYPE_TEXT_COMMAND ;
|
||||
break;
|
||||
}
|
||||
*/
|
||||
|
||||
if (tw->InSetValue())
|
||||
return;
|
||||
}
|
||||
*/
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
|
||||
event.SetId(tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->ProcessCommand(event);
|
||||
if (tw->InSetValue())
|
||||
return;
|
||||
|
||||
wxCommandEvent event(wxEVT_COMMAND_TEXT_ENTER);
|
||||
event.SetId(tw->GetId());
|
||||
event.SetEventObject(tw);
|
||||
tw->ProcessCommand(event);
|
||||
}
|
||||
|
1476
src/motif/utils.cpp
1476
src/motif/utils.cpp
File diff suppressed because it is too large
Load Diff
@@ -53,15 +53,15 @@
|
||||
#endif
|
||||
|
||||
#ifdef __SVR4__
|
||||
#include <sys/systeminfo.h>
|
||||
#include <sys/systeminfo.h>
|
||||
#endif
|
||||
|
||||
#ifdef __SOLARIS__
|
||||
// somehow missing from sys/wait.h but in the system's docs
|
||||
extern "C"
|
||||
{
|
||||
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
|
||||
*rusage);
|
||||
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
|
||||
*rusage);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -72,146 +72,146 @@ extern "C"
|
||||
|
||||
struct wxLocalProcessData
|
||||
{
|
||||
int pid, end_process;
|
||||
wxProcess *process;
|
||||
int pid, end_process;
|
||||
wxProcess *process;
|
||||
};
|
||||
|
||||
#ifdef __SOLARIS__
|
||||
// somehow missing from sys/wait.h but in the system's docs
|
||||
extern "C"
|
||||
{
|
||||
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
|
||||
*rusage);
|
||||
pid_t wait4(pid_t pid, int *statusp, int options, struct rusage
|
||||
*rusage);
|
||||
}
|
||||
#endif
|
||||
|
||||
void xt_notify_end_process(XtPointer client, int *fid,
|
||||
XtInputId *id)
|
||||
XtInputId *id)
|
||||
{
|
||||
wxLocalProcessData *process_data = (wxLocalProcessData *)client;
|
||||
|
||||
int pid;
|
||||
|
||||
pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid);
|
||||
|
||||
/* wait4 is not part of any standard, use at own risk
|
||||
* not sure what wait4 does, but wait3 seems to be closest, whats a digit ;-)
|
||||
* --- offer@sgi.com */
|
||||
wxLocalProcessData *process_data = (wxLocalProcessData *)client;
|
||||
|
||||
int pid;
|
||||
|
||||
pid = (process_data->pid > 0) ? process_data->pid : -(process_data->pid);
|
||||
|
||||
/* wait4 is not part of any standard, use at own risk
|
||||
* not sure what wait4 does, but wait3 seems to be closest, whats a digit ;-)
|
||||
* --- offer@sgi.com */
|
||||
#if !defined(__sgi) && !defined(__SGI__) && !defined(__ALPHA__) && !defined(__SUNCC__)
|
||||
wait4(process_data->pid, NULL, 0, NULL);
|
||||
wait4(process_data->pid, NULL, 0, NULL);
|
||||
#else
|
||||
wait3((int *) NULL, 0, (rusage *) NULL);
|
||||
wait3((int *) NULL, 0, (rusage *) NULL);
|
||||
#endif
|
||||
|
||||
XtRemoveInput(*id);
|
||||
if (process_data->process)
|
||||
process_data->process->OnTerminate(process_data->pid);
|
||||
|
||||
process_data->end_process = TRUE;
|
||||
|
||||
if (process_data->pid > 0)
|
||||
delete process_data;
|
||||
else
|
||||
process_data->pid = 0;
|
||||
|
||||
XtRemoveInput(*id);
|
||||
if (process_data->process)
|
||||
process_data->process->OnTerminate(process_data->pid);
|
||||
|
||||
process_data->end_process = TRUE;
|
||||
|
||||
if (process_data->pid > 0)
|
||||
delete process_data;
|
||||
else
|
||||
process_data->pid = 0;
|
||||
}
|
||||
|
||||
long wxExecute(char **argv, bool sync, wxProcess *handler)
|
||||
{
|
||||
#ifdef VMS
|
||||
return(0);
|
||||
return(0);
|
||||
#else
|
||||
if (*argv == NULL)
|
||||
return 0; // Nothing???
|
||||
|
||||
int proc_link[2];
|
||||
if (pipe(proc_link))
|
||||
return 0;
|
||||
|
||||
/* fork the process */
|
||||
if (*argv == NULL)
|
||||
return 0; // Nothing???
|
||||
|
||||
int proc_link[2];
|
||||
if (pipe(proc_link))
|
||||
return 0;
|
||||
|
||||
/* fork the process */
|
||||
#if defined(sun) || defined(__ultrix) || defined(__bsdi__)
|
||||
pid_t pid = vfork ();
|
||||
pid_t pid = vfork ();
|
||||
#else
|
||||
pid_t pid = fork ();
|
||||
pid_t pid = fork ();
|
||||
#endif
|
||||
|
||||
if (pid == -1)
|
||||
|
||||
if (pid == -1)
|
||||
{
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
else if (pid == 0)
|
||||
else if (pid == 0)
|
||||
{
|
||||
/* GUILHEM: Close all fds when sync == 0 */
|
||||
if (sync == 0)
|
||||
for (int fd=0;fd<FD_SETSIZE;fd++) {
|
||||
if (proc_link[1] != fd)
|
||||
close(fd);
|
||||
}
|
||||
/* child */
|
||||
/* GUILHEM: Close all fds when sync == 0 */
|
||||
if (sync == 0)
|
||||
for (int fd=0;fd<FD_SETSIZE;fd++) {
|
||||
if (proc_link[1] != fd)
|
||||
close(fd);
|
||||
}
|
||||
/* child */
|
||||
#ifdef _AIX
|
||||
execvp ((const char *)*argv, (const char **)argv);
|
||||
execvp ((const char *)*argv, (const char **)argv);
|
||||
#else
|
||||
execvp (*argv, argv);
|
||||
execvp (*argv, argv);
|
||||
#endif
|
||||
/* GUILHEM: Reopen output stream */
|
||||
// open("/dev/console", O_WRONLY);
|
||||
/* GUILHEM: End */
|
||||
if (errno == ENOENT)
|
||||
printf ("%s: command not found\n", *argv);
|
||||
else
|
||||
perror (*argv);
|
||||
printf ("wxWindows: could not execute '%s'\n", *argv);
|
||||
_exit (-1);
|
||||
/* GUILHEM: Reopen output stream */
|
||||
// open("/dev/console", O_WRONLY);
|
||||
/* GUILHEM: End */
|
||||
if (errno == ENOENT)
|
||||
printf ("%s: command not found\n", *argv);
|
||||
else
|
||||
perror (*argv);
|
||||
printf ("wxWindows: could not execute '%s'\n", *argv);
|
||||
_exit (-1);
|
||||
}
|
||||
|
||||
wxLocalProcessData *process_data = new wxLocalProcessData;
|
||||
|
||||
process_data->end_process = 0;
|
||||
process_data->process = handler;
|
||||
process_data->pid = (sync) ? pid : -pid;
|
||||
|
||||
close(proc_link[1]);
|
||||
XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0],
|
||||
(XtPointer *) XtInputReadMask,
|
||||
(XtInputCallbackProc) xt_notify_end_process,
|
||||
(XtPointer) process_data);
|
||||
|
||||
if (sync) {
|
||||
while (!process_data->end_process)
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
if (WIFEXITED(process_data->end_process) != 0)
|
||||
return WEXITSTATUS(process_data->end_process);
|
||||
}
|
||||
|
||||
delete process_data;
|
||||
|
||||
return pid;
|
||||
|
||||
wxLocalProcessData *process_data = new wxLocalProcessData;
|
||||
|
||||
process_data->end_process = 0;
|
||||
process_data->process = handler;
|
||||
process_data->pid = (sync) ? pid : -pid;
|
||||
|
||||
close(proc_link[1]);
|
||||
XtAppAddInput((XtAppContext) wxTheApp->GetAppContext(), proc_link[0],
|
||||
(XtPointer *) XtInputReadMask,
|
||||
(XtInputCallbackProc) xt_notify_end_process,
|
||||
(XtPointer) process_data);
|
||||
|
||||
if (sync) {
|
||||
while (!process_data->end_process)
|
||||
XtAppProcessEvent((XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
|
||||
|
||||
if (WIFEXITED(process_data->end_process) != 0)
|
||||
return WEXITSTATUS(process_data->end_process);
|
||||
}
|
||||
|
||||
delete process_data;
|
||||
|
||||
return pid;
|
||||
#endif
|
||||
// end VMS
|
||||
// end VMS
|
||||
}
|
||||
|
||||
long wxExecute (const wxString& command, bool sync, wxProcess* handler)
|
||||
{
|
||||
#ifdef VMS
|
||||
return(0);
|
||||
return(0);
|
||||
#else
|
||||
if (command.IsNull() || command == "")
|
||||
return 0; // Nothing to do
|
||||
|
||||
// Run a program the recomended way under X (XView)
|
||||
int argc = 0;
|
||||
char *argv[127];
|
||||
char tmp[1024];
|
||||
const char *IFS = " \t\n";
|
||||
|
||||
// Build argument vector
|
||||
strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1);
|
||||
tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
while ((argv[argc++] = strtok (NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
|
||||
return wxExecute(argv, sync, handler);
|
||||
if (command.IsNull() || command == "")
|
||||
return 0; // Nothing to do
|
||||
|
||||
// Run a program the recomended way under X (XView)
|
||||
int argc = 0;
|
||||
char *argv[127];
|
||||
char tmp[1024];
|
||||
const char *IFS = " \t\n";
|
||||
|
||||
// Build argument vector
|
||||
strncpy (tmp, (const char*) command, sizeof (tmp) / sizeof (char) - 1);
|
||||
tmp[sizeof (tmp) / sizeof (char) - 1] = '\0';
|
||||
argv[argc++] = strtok (tmp, IFS);
|
||||
while ((argv[argc++] = strtok (NULL, IFS)) != NULL)
|
||||
/* loop */ ;
|
||||
|
||||
return wxExecute(argv, sync, handler);
|
||||
#endif
|
||||
// VMS
|
||||
// VMS
|
||||
}
|
||||
|
4040
src/motif/window.cpp
4040
src/motif/window.cpp
File diff suppressed because it is too large
Load Diff
@@ -323,10 +323,6 @@ bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int max
|
||||
return (::GetClipboardFormatName((int) dataFormat, formatName, maxCount) > 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* wxClipboard
|
||||
*/
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxClipboard
|
||||
//-----------------------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user