Reformatted Motif headers; added __WXX11__ symbol support to common headers;

added place-holding src/x11 and include/wx/x11 files.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14015 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2002-02-05 16:34:33 +00:00
parent a4e17da546
commit 83df96d63a
162 changed files with 22793 additions and 2176 deletions

View File

@@ -75,7 +75,7 @@ public:
bool operator!=(const wxAcceleratorEntry& entry) const
{ return !(*this == entry); }
#ifdef __WXMOTIF__
#if defined(__WXMOTIF__) || defined(__WXX11__)
// Implementation use only
bool MatchesEvent(const wxKeyEvent& event) const ;
#endif
@@ -105,6 +105,8 @@ private:
#include "wx/motif/accel.h"
#elif defined(__WXGTK__)
#include "wx/gtk/accel.h"
#elif defined(__WXX11__)
#include "wx/x11/accel.h"
#elif defined(__WXMAC__)
#include "wx/mac/accel.h"
#elif defined(__WXPM__)

View File

@@ -375,6 +375,8 @@ protected:
#include "wx/mgl/app.h"
#elif defined(__WXGTK__)
#include "wx/gtk/app.h"
#elif defined(__WXX11__)
#include "wx/x11/app.h"
#elif defined(__WXMAC__)
#include "wx/mac/app.h"
#elif defined(__WXPM__)

View File

@@ -159,6 +159,8 @@ protected:
#include "wx/motif/bitmap.h"
#elif defined(__WXGTK__)
#include "wx/gtk/bitmap.h"
#elif defined(__WXX11__)
#include "wx/x11/bitmap.h"
#elif defined(__WXMGL__)
#include "wx/mgl/bitmap.h"
#elif defined(__WXMAC__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/brush.h"
#elif defined(__WXGTK__)
#include "wx/gtk/brush.h"
#elif defined(__WXX11__)
#include "wx/x11/brush.h"
#elif defined(__WXMGL__)
#include "wx/mgl/brush.h"
#elif defined(__WXMAC__)

View File

@@ -88,6 +88,8 @@ public:
#include "wx/motif/clipbrd.h"
#elif defined(__WXGTK__)
#include "wx/gtk/clipbrd.h"
#elif defined(__WXX11__)
#include "wx/x11/clipbrd.h"
#elif defined(__WXMGL__)
#include "wx/mgl/clipbrd.h"
#elif defined(__WXMAC__)

View File

@@ -9,6 +9,8 @@
#include "wx/gtk/colour.h"
#elif defined(__WXMGL__)
#include "wx/mgl/colour.h"
#elif defined(__WXX11__)
#include "wx/x11/colour.h"
#elif defined(__WXMAC__)
#include "wx/mac/colour.h"
#elif defined(__WXPM__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/cursor.h"
#elif defined(__WXGTK__)
#include "wx/gtk/cursor.h"
#elif defined(__WXX11__)
#include "wx/x11/cursor.h"
#elif defined(__WXMGL__)
#include "wx/mgl/cursor.h"
#elif defined(__WXMAC__)

View File

@@ -79,6 +79,8 @@ public:
#include "wx/motif/dataform.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dataform.h"
#elif defined(__WXX11__)
#include "wx/x11/dataform.h"
#elif defined(__WXMAC__)
#include "wx/mac/dataform.h"
#elif defined(__WXPM__)

View File

@@ -758,6 +758,8 @@ private:
#include "wx/motif/dc.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dc.h"
#elif defined(__WXX11__)
#include "wx/x11/dc.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dc.h"
#elif defined(__WXMAC__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/dcclient.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcclient.h"
#elif defined(__WXX11__)
#include "wx/x11/dcclient.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcclient.h"
#elif defined(__WXMAC__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/dcmemory.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcmemory.h"
#elif defined(__WXX11__)
#include "wx/x11/dcmemory.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcmemory.h"
#elif defined(__WXMAC__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/dcscreen.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dcscreen.h"
#elif defined(__WXX11__)
#include "wx/x11/dcscreen.h"
#elif defined(__WXMGL__)
#include "wx/mgl/dcscreen.h"
#elif defined(__WXMAC__)

View File

@@ -27,7 +27,7 @@
#error "Target can't be both X and Windows"
#elif !defined(__WXMOTIF__) && !defined(__WXMSW__) && !defined(__WXGTK__) && \
!defined(__WXPM__) && !defined(__WXMAC__) && !defined(__X__) && \
!defined(__WXMGL__) && wxUSE_GUI
!defined(__WXMGL__) && !defined(__WXX11__) && wxUSE_GUI
#ifdef __UNIX__
#error "No Target! You should use wx-config program for compilation flags!"
#else // !Unix
@@ -424,6 +424,7 @@ enum
wxGEOS, // GEOS
wxOS2_PM, // OS/2 Workplace
wxWINDOWS, // Windows or WfW
wxMICROWINDOWS, // MicroWindows
wxPENWINDOWS, // Windows for Pen Computing
wxWINDOWS_NT, // Windows NT
wxWIN32S, // Windows 32S API
@@ -435,7 +436,8 @@ enum
wxMGL_OS2, // MGL on OS/2
wxMGL_DOS, // MGL on MS-DOS
wxWINDOWS_OS2, // Native OS/2 PM
wxUNIX // wxBase under Unix
wxUNIX, // wxBase under Unix
wxX11 // Plain X11 and Universal widgets
};
// ----------------------------------------------------------------------------
@@ -1852,7 +1854,7 @@ typedef WXRESULT (_System *WXFARPROC)(WXHWND, WXMSGID, WXWPARAM, WXLPARAM);
#endif //__WXPM__
#ifdef __WXMOTIF__
#if defined(__WXMOTIF__) || defined(__WXX11__)
/* Stand-ins for X/Xt/Motif types */
typedef void* WXWindow;
typedef void* WXWidget;

View File

@@ -21,6 +21,8 @@ WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
#include "wx/generic/dirdlgg.h"
#elif defined(__WXGTK__)
#include "wx/generic/dirdlgg.h"
#elif defined(__WXX11__)
#include "wx/generic/dirdlgg.h"
#elif defined(__WXMGL__)
#include "wx/generic/dirdlgg.h"
#elif defined(__WXMAC__)

View File

@@ -187,6 +187,8 @@ protected:
#include "wx/msw/ole/droptgt.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dnd.h"
#elif defined(__WXX11__)
#include "wx/x11/dnd.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dnd.h"
#elif defined(__WXMAC__)

View File

@@ -22,6 +22,11 @@
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXX11__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage
#define sm_classwxDragImage sm_classwxGenericDragImage
#elif defined(__WXMAC__)
#include "wx/generic/dragimgg.h"
#define wxDragImage wxGenericDragImage

View File

@@ -20,6 +20,8 @@ enum
#include "wx/motif/filedlg.h"
#elif defined(__WXGTK__)
#include "wx/generic/filedlgg.h"
#elif defined(__WXX11__)
#include "wx/generic/filedlg.h"
#elif defined(__WXMGL__)
#include "wx/generic/filedlgg.h"
#elif defined(__WXMAC__)

View File

@@ -166,6 +166,8 @@ private:
#include "wx/motif/font.h"
#elif defined(__WXGTK__)
#include "wx/gtk/font.h"
#elif defined(__WXX11__)
#include "wx/x11/font.h"
#elif defined(__WXMGL__)
#include "wx/mgl/font.h"
#elif defined(__WXMAC__)

View File

@@ -166,6 +166,9 @@ enum wxStockCursor
#elif defined(__WXMOTIF__)
// Initialize from an included XPM
#define wxICON(X) wxIcon( X##_xpm )
#elif defined(__WXX11__)
// Initialize from an included XPM
#define wxICON(X) wxIcon( X##_xpm )
#else
// This will usually mean something on any platform
#define wxICON(X) wxIcon("" #X "")
@@ -177,7 +180,7 @@ enum wxStockCursor
#if defined(__WXMSW__) || defined(__WXPM__)
#define wxBITMAP(name) wxBitmap(#name, wxBITMAP_TYPE_RESOURCE)
#elif defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__)
#elif defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXX11__) || defined(__WXMAC__) || defined(__WXMGL__)
// Initialize from an included XPM
#define wxBITMAP(name) wxBitmap( (const char**) name##_xpm )
#else // other platforms
@@ -213,8 +216,7 @@ public:
wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); }
// accessors
void Set(int xx, int yy) { x = xx; y = yy; }
// accessors void Set(int xx, int yy) { x = xx; y = yy; }
void SetWidth(int w) { x = w; }
void SetHeight(int h) { y = h; }

View File

@@ -7,6 +7,8 @@
#include "wx/motif/gdiobj.h"
#elif defined(__WXGTK__)
#include "wx/gtk/gdiobj.h"
#elif defined(__WXX11__)
#include "wx/x11/gdiobj.h"
#elif defined(__WXMGL__)
#include "wx/mgl/gdiobj.h"
#elif defined(__WXMAC__)

View File

@@ -11,6 +11,8 @@
#include "wx/motif/glcanvas.h"
#elif defined(__WXGTK__)
#include "wx/gtk/glcanvas.h"
#elif defined(__WXX11__)
#include "wx/x11/glcanvas.h"
#elif defined(__WXMAC__)
#include "wx/mac/glcanvas.h"
#elif defined(__WXPM__)

View File

@@ -13,6 +13,8 @@
#include "wx/motif/icon.h"
#elif defined(__WXGTK__)
#include "wx/gtk/icon.h"
#elif defined(__WXX11__)
#include "wx/x11/icon.h"
#elif defined(__WXMGL__)
#include "wx/mgl/icon.h"
#elif defined(__WXMAC__)

View File

@@ -9,6 +9,8 @@
#include "wx/motif/joystick.h"
#elif defined(__WXGTK__)
#include "wx/gtk/joystick.h"
#elif defined(__WXX11__)
#include "wx/x11/joystick.h"
#elif defined(__WXMAC__)
#include "wx/mac/joystick.h"
#elif defined(__WXPM__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/mdi.h"
#elif defined(__WXGTK__)
#include "wx/gtk/mdi.h"
#elif defined(__WXX11__)
#include "wx/x11/mdi.h"
#elif defined(__WXMAC__)
#include "wx/mac/mdi.h"
#elif defined(__WXPM__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/minifram.h"
#elif defined(__WXGTK__)
#include "wx/gtk/minifram.h"
#elif defined(__WXX11__)
#include "wx/x11/minifram.h"
#elif defined(__WXMAC__)
#include "wx/mac/minifram.h"
#elif defined(__WXPM__)

View File

@@ -20,55 +20,6 @@
#include "wx/string.h"
#include "wx/event.h"
class WXDLLEXPORT wxAcceleratorTable;
#if 0
// Hold Ctrl key down
#define wxACCEL_ALT 0x01
// Hold Ctrl key down
#define wxACCEL_CTRL 0x02
// Hold Shift key down
#define wxACCEL_SHIFT 0x04
// Hold no key down
#define wxACCEL_NORMAL 0x00
class WXDLLEXPORT wxAcceleratorEntry
{
public:
wxAcceleratorEntry(const wxAcceleratorEntry& entry)
{
m_flags = entry.m_flags; m_keyCode = entry.m_keyCode; m_command = entry.m_command;
}
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0)
{
m_flags = flags; m_keyCode = keyCode; m_command = cmd;
}
void Set(int flags, int keyCode, int cmd)
{ m_flags = flags; m_keyCode = keyCode; m_command = cmd; }
int GetFlags() const { return m_flags; }
int GetKeyCode() const { return m_keyCode; }
int GetCommand() const { return m_command; }
void operator = (const wxAcceleratorEntry& entry)
{
m_flags = entry.m_flags; m_keyCode = entry.m_keyCode; m_command = entry.m_command;
}
// Implementation use only
bool MatchesEvent(const wxKeyEvent& event) const;
public:
int m_flags;
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
};
#endif
class WXDLLEXPORT wxAcceleratorTable: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)

View File

@@ -98,7 +98,6 @@ protected:
wxStringList m_stringList;
wxList m_clientList; // contains the client data for the items
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);

View File

@@ -18,18 +18,6 @@
#include "wx/bitmap.h"
/*
// Same as for wxBitmap
class WXDLLEXPORT wxIconRefData: public wxBitmapRefData
{
friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxIcon;
public:
wxIconRefData();
~wxIconRefData();
};
*/
#define M_ICONDATA ((wxBitmapRefData *)m_refData)
#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())

View File

@@ -11,7 +11,6 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_METAFIILE_H_
#define _WX_METAFIILE_H_
@@ -42,13 +41,6 @@ class WXDLLEXPORT wxMetaFile: public wxObject
// TODO
inline bool Ok() { return FALSE; };
/* TODO: Implementation
inline WXHANDLE GetHMETAFILE() { return m_metaFile; }
inline void SetHMETAFILE(WXHANDLE mf) { m_metaFile = mf; }
protected:
WXHANDLE m_metaFile;
*/
};
class WXDLLEXPORT wxMetaFileDC: public wxDC

View File

@@ -65,8 +65,6 @@ protected:
int m_pageSize;
int m_viewSize;
int m_objectSize;
// DECLARE_EVENT_TABLE()
};
#endif

View File

@@ -41,7 +41,6 @@ public:
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton");
// accessors
int GetValue() const;
int GetMin() const { return m_min; }

View File

@@ -12,6 +12,8 @@
#include "wx/motif/palette.h"
#elif defined(__WXGTK__)
#include "wx/generic/paletteg.h"
#elif defined(__WXX11__)
#include "wx/x11/palette.h"
#elif defined(__WXMGL__)
#include "wx/mgl/palette.h"
#elif defined(__WXMAC__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/pen.h"
#elif defined(__WXGTK__)
#include "wx/gtk/pen.h"
#elif defined(__WXX11__)
#include "wx/x11/pen.h"
#elif defined(__WXMGL__)
#include "wx/mgl/pen.h"
#elif defined(__WXMAC__)

View File

@@ -55,6 +55,8 @@ public:
#include "wx/os2/popupwin.h"
#elif __WXGTK__
#include "wx/gtk/popupwin.h"
#ifdef __WXX11__
#include "wx/x11/popupwin.h"
#elif __WXMGL__
#include "wx/mgl/popupwin.h"
#else

View File

@@ -7,6 +7,8 @@
#include "wx/generic/prntdlgg.h"
#elif defined(__WXGTK__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXX11__)
#include "wx/generic/prntdlgg.h"
#elif defined(__WXMAC__)
#include "wx/mac/printdlg.h"
#elif defined(__WXPM__)

View File

@@ -7,6 +7,8 @@
#include "wx/motif/region.h"
#elif defined(__WXGTK__)
#include "wx/gtk/region.h"
#elif defined(__WXX11__)
#include "wx/x11/region.h"
#elif defined(__WXMGL__)
#include "wx/mgl/region.h"
#elif defined(__WXMAC__)

View File

@@ -107,6 +107,8 @@ protected:
#include "wx/motif/timer.h"
#elif defined(__WXGTK__)
#include "wx/gtk/timer.h"
#elif defined(__WXX11__)
#include "wx/x11/timer.h"
#elif defined(__WXMGL__)
#include "wx/mgl/timer.h"
#elif defined(__WXMAC__)

View File

@@ -43,6 +43,8 @@
#include "wx/motif/toolbar.h"
#elif defined(__WXGTK__)
#include "wx/gtk/tbargtk.h"
#elif defined(__WXX11__)
#include "wx/x11/toolbar.h"
#elif defined(__WXMAC__)
#include "wx/mac/toolbar.h"
#elif defined(__WXPM__)

View File

@@ -158,6 +158,9 @@ protected:
#elif defined(__WXGTK__)
#include "wx/gtk/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowGTK
#elif defined(__WXX11__)
#include "wx/x11/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowX11
#elif defined(__WXMGL__)
#include "wx/mgl/toplevel.h"
#define wxTopLevelWindowNative wxTopLevelWindowMGL

View File

@@ -977,6 +977,14 @@ private:
#define sm_classwxWindowGTK sm_classwxWindow
#endif // wxUniv
#include "wx/gtk/window.h"
#elif defined(__WXX11__)
#ifdef __WXUNIVERSAL__
#define wxWindowNative wxWindowX11
#else // !wxUniv
#define wxWindowX11 wxWindow
#define sm_classwxWindowX11 sm_classwxWindow
#endif // wxUniv
#include "wx/x11/window.h"
#elif defined(__WXMGL__)
#ifdef __WXUNIVERSAL__
#define wxWindowNative wxWindowMGL

51
include/wx/x11/accel.h Normal file
View File

@@ -0,0 +1,51 @@
/////////////////////////////////////////////////////////////////////////////
// Name: accel.h
// Purpose: wxAcceleratorTable class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_
#define _WX_ACCEL_H_
#ifdef __GNUG__
#pragma interface "accel.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
#include "wx/event.h"
class WXDLLEXPORT wxAcceleratorTable: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
public:
wxAcceleratorTable();
wxAcceleratorTable(const wxString& resource); // Load from .rc resource
wxAcceleratorTable(int n, wxAcceleratorEntry entries[]); // Load from array
// Copy constructors
wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); }
wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); }
~wxAcceleratorTable();
wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if (*this == accel) return (*this); Ref(accel); return *this; }
bool operator == (const wxAcceleratorTable& accel) { return m_refData == accel.m_refData; }
bool operator != (const wxAcceleratorTable& accel) { return m_refData != accel.m_refData; }
bool Ok() const;
// Implementation only
int GetCount() const;
wxAcceleratorEntry* GetEntries() const;
};
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;
#endif
// _WX_ACCEL_H_

131
include/wx/x11/app.h Normal file
View File

@@ -0,0 +1,131 @@
/////////////////////////////////////////////////////////////////////////////
// Name: app.h
// Purpose: wxApp class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_APP_H_
#define _WX_APP_H_
#ifdef __GNUG__
#pragma interface "app.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/gdicmn.h"
#include "wx/event.h"
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxApp;
class WXDLLEXPORT wxKeyEvent;
class WXDLLEXPORT wxLog;
// ----------------------------------------------------------------------------
// the wxApp class for Motif - see wxAppBase for more details
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxApp : public wxAppBase
{
DECLARE_DYNAMIC_CLASS(wxApp)
public:
wxApp();
~wxApp() {}
// override base class (pure) virtuals
// -----------------------------------
virtual int MainLoop();
virtual void ExitMainLoop();
virtual bool Initialized();
virtual bool Pending();
virtual void Dispatch();
virtual bool Yield(bool onlyIfNeeded = FALSE);
virtual bool OnInitGui();
virtual wxIcon GetStdIcon(int which) const;
// implementation from now on
// --------------------------
void OnIdle(wxIdleEvent& event);
// Send idle event to all top-level windows.
// Returns TRUE if more idle time is requested.
bool SendIdleEvents();
// Send idle event to window and all subwindows
// Returns TRUE if more idle time is requested.
bool SendIdleEvents(wxWindow* win);
// Motif implementation.
// Processes an X event.
virtual void ProcessXEvent(WXEvent* event);
// Returns TRUE if an accelerator has been processed
virtual bool CheckForAccelerator(WXEvent* event);
// Returns TRUE if a key down event has been processed
virtual bool CheckForKeyDown(WXEvent* event);
// Returns TRUE if a key up event has been processed
virtual bool CheckForKeyUp(WXEvent* event);
protected:
bool m_showOnInit;
public:
// Implementation
static bool Initialize();
static void CleanUp();
void DeletePendingObjects();
bool ProcessIdle();
// Motif-specific
WXAppContext GetAppContext() const { return m_appContext; }
WXWidget GetTopLevelWidget() const { return m_topLevelWidget; }
WXColormap GetMainColormap(WXDisplay* display);
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
long GetMaxRequestSize() const { return m_maxRequestSize; }
// This handler is called when a property change event occurs
virtual void HandlePropertyChange(WXEvent *event);
public:
static long sm_lastMessageTime;
int m_nCmdShow;
protected:
bool m_keepGoing;
// Motif-specific
WXAppContext m_appContext;
WXWidget m_topLevelWidget;
WXColormap m_mainColormap;
WXDisplay* m_initialDisplay;
long m_maxRequestSize;
DECLARE_EVENT_TABLE()
};
int WXDLLEXPORT wxEntry( int argc, char *argv[] );
#endif
// _WX_APP_H_

230
include/wx/x11/bitmap.h Normal file
View File

@@ -0,0 +1,230 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bitmap.h
// Purpose: wxBitmap class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BITMAP_H_
#define _WX_BITMAP_H_
#ifdef __GNUG__
#pragma interface "bitmap.h"
#endif
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
#include "wx/palette.h"
// Bitmap
class WXDLLEXPORT wxDC;
class WXDLLEXPORT wxControl;
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxBitmapHandler;
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxCursor;
class WXDLLEXPORT wxImage;
// A mask is a mono bitmap used for drawing bitmaps
// transparently.
class WXDLLEXPORT wxMask: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxMask)
public:
wxMask();
// Construct a mask from a bitmap and a colour indicating
// the transparent area
wxMask(const wxBitmap& bitmap, const wxColour& colour);
// Construct a mask from a bitmap and a palette index indicating
// the transparent area
wxMask(const wxBitmap& bitmap, int paletteIndex);
// Construct a mask from a mono bitmap (copies the bitmap).
wxMask(const wxBitmap& bitmap);
~wxMask();
bool Create(const wxBitmap& bitmap, const wxColour& colour);
bool Create(const wxBitmap& bitmap, int paletteIndex);
bool Create(const wxBitmap& bitmap);
WXPixmap GetPixmap() const { return m_pixmap; }
void SetPixmap(WXPixmap pixmap) { m_pixmap = pixmap; }
protected:
WXPixmap m_pixmap;
};
class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxIcon;
friend class WXDLLEXPORT wxCursor;
public:
wxBitmapRefData();
~wxBitmapRefData();
public:
int m_width;
int m_height;
int m_depth;
bool m_ok;
int m_numColors;
wxPalette m_bitmapPalette;
int m_quality;
wxMask * m_bitmapMask; // Optional mask
// Motif implementation
public:
WXPixmap m_pixmap;
WXDisplay* m_display;
bool m_freePixmap;
unsigned long* m_freeColors;
long m_freeColorsCount;
// These 5 variables are for wxControl
WXPixmap m_insensPixmap ;
WXPixmap m_labelPixmap ;
WXPixmap m_armPixmap ;
WXImage* m_image ;
WXImage* m_insensImage ;
};
#define M_BITMAPDATA ((wxBitmapRefData *)m_refData)
class WXDLLEXPORT wxBitmapHandler: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxBitmapHandler)
public:
wxBitmapHandler() { m_name = ""; m_extension = ""; m_type = 0; };
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight);
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
void SetName(const wxString& name) { m_name = name; }
void SetExtension(const wxString& ext) { m_extension = ext; }
void SetType(long type) { m_type = type; }
wxString GetName() const { return m_name; }
wxString GetExtension() const { return m_extension; }
long GetType() const { return m_type; }
protected:
wxString m_name;
wxString m_extension;
long m_type;
};
#define M_BITMAPHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
class WXDLLEXPORT wxBitmap: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxBitmap)
friend class WXDLLEXPORT wxBitmapHandler;
public:
wxBitmap(); // Platform-specific
// Copy constructors
wxBitmap(const wxBitmap& bitmap)
{ Ref(bitmap); }
// Initialize with raw XBM data
wxBitmap(const char bits[], int width, int height, int depth = 1);
// from XPM
wxBitmap(const char **data) { (void)CreateFromXpm(data); }
wxBitmap(char **data) { (void)CreateFromXpm((const char **)data); }
// Initialize with XPM data -- deprecated
wxBitmap(char **data, wxControl* control);
// Load a file or resource
wxBitmap(const wxString& name, long type = wxBITMAP_TYPE_XPM);
// Constructor for generalised creation from data
wxBitmap(void *data, long type, int width, int height, int depth = 1);
// If depth is omitted, will create a bitmap compatible with the display
wxBitmap(int width, int height, int depth = -1);
// Convert from wxImage:
wxBitmap(const wxImage& image, int depth = -1) { (void)CreateFromImage(image, depth); }
~wxBitmap();
virtual bool Create(int width, int height, int depth = -1);
virtual bool Create(void *data, long type, int width, int height, int depth = 1);
wxBitmap GetSubBitmap( const wxRect& rect ) const;
virtual bool LoadFile(const wxString& name, long type = wxBITMAP_TYPE_XPM);
virtual bool SaveFile(const wxString& name, int type, const wxPalette *cmap = NULL);
wxImage ConvertToImage() const;
bool Ok() const { return (M_BITMAPDATA && M_BITMAPDATA->m_ok); }
int GetWidth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_width : 0); }
int GetHeight() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_height : 0); }
int GetDepth() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_depth : 0); }
int GetQuality() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_quality : 0); }
void SetWidth(int w);
void SetHeight(int h);
void SetDepth(int d);
void SetQuality(int q);
void SetOk(bool isOk);
wxPalette* GetPalette() const { return (M_BITMAPDATA ? (& M_BITMAPDATA->m_bitmapPalette) : (wxPalette*) NULL); }
void SetPalette(const wxPalette& palette);
wxMask *GetMask() const { return (M_BITMAPDATA ? M_BITMAPDATA->m_bitmapMask : (wxMask*) NULL); }
void SetMask(wxMask *mask) ;
wxBitmap& operator = (const wxBitmap& bitmap) { if (*this == bitmap) return (*this); Ref(bitmap); return *this; }
bool operator == (const wxBitmap& bitmap) const { return m_refData == bitmap.m_refData; }
bool operator != (const wxBitmap& bitmap) const { return m_refData != bitmap.m_refData; }
// Format handling
static wxList& GetHandlers() { return sm_handlers; }
static void AddHandler(wxBitmapHandler *handler);
static void InsertHandler(wxBitmapHandler *handler);
static bool RemoveHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& name);
static wxBitmapHandler *FindHandler(const wxString& extension, long bitmapType);
static wxBitmapHandler *FindHandler(long bitmapType);
static void InitStandardHandlers();
static void CleanUpHandlers();
// Motif implementation
public:
WXDisplay* GetDisplay() const { return M_BITMAPDATA->m_display; }
WXPixmap GetPixmap() const { return (WXPixmap) M_BITMAPDATA->m_pixmap; }
virtual WXPixmap GetLabelPixmap(WXWidget w) ;
virtual WXPixmap GetArmPixmap(WXWidget w) ;
virtual WXPixmap GetInsensPixmap(WXWidget w = (WXWidget) 0) ;
void SetPixmapNull() { M_BITMAPDATA->m_pixmap = 0; }
protected:
static wxList sm_handlers;
protected:
bool CreateFromXpm(const char **bits);
bool CreateFromImage(const wxImage& image, int depth);
};
// Creates a bitmap with transparent areas drawn in
// the given colour.
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour);
#endif
// _WX_BITMAP_H_

79
include/wx/x11/brush.h Normal file
View File

@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////
// Name: brush.h
// Purpose: wxBrush class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BRUSH_H_
#define _WX_BRUSH_H_
#ifdef __GNUG__
#pragma interface "brush.h"
#endif
#include "wx/gdicmn.h"
#include "wx/gdiobj.h"
#include "wx/bitmap.h"
class WXDLLEXPORT wxBrush;
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxBrush;
public:
wxBrushRefData();
wxBrushRefData(const wxBrushRefData& data);
~wxBrushRefData();
protected:
int m_style;
wxBitmap m_stipple ;
wxColour m_colour;
};
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
// Brush
class WXDLLEXPORT wxBrush: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxBrush)
public:
wxBrush();
wxBrush(const wxColour& col, int style);
wxBrush(const wxBitmap& stipple);
inline wxBrush(const wxBrush& brush) { Ref(brush); }
~wxBrush();
virtual void SetColour(const wxColour& col) ;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
virtual void SetStyle(int style) ;
virtual void SetStipple(const wxBitmap& stipple) ;
inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; }
inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; }
inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; }
inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); };
inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); };
inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); };
virtual bool Ok() const { return (m_refData != NULL) ; }
// Implementation
// Useful helper: create the brush resource
bool RealizeResource();
// When setting properties, we must make sure we're not changing
// another object
void Unshare();
};
#endif
// _WX_BRUSH_H_

84
include/wx/x11/clipbrd.h Normal file
View File

@@ -0,0 +1,84 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.h
// Purpose: Clipboard functionality.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CLIPBRD_H_
#define _WX_CLIPBRD_H_
#ifdef __GNUG__
#pragma interface "clipbrd.h"
#endif
#if wxUSE_CLIPBOARD
#include "wx/list.h"
bool WXDLLEXPORT wxOpenClipboard();
bool WXDLLEXPORT wxClipboardOpen();
bool WXDLLEXPORT wxCloseClipboard();
bool WXDLLEXPORT wxEmptyClipboard();
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 wxClipboard : public wxClipboardBase
{
public:
wxClipboard();
~wxClipboard();
// open the clipboard before SetData() and GetData()
virtual bool Open();
// close the clipboard after SetData() and GetData()
virtual void Close();
// opened?
virtual bool IsOpened() const { return m_open; }
// replaces the data on the clipboard with data
virtual bool SetData( wxDataObject *data );
// adds data to the clipboard
virtual bool AddData( wxDataObject *data );
// format available on the clipboard ?
virtual bool IsSupported( const wxDataFormat& format );
// 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();
virtual void UsePrimarySelection(bool primary = TRUE)
{ m_usePrimary = primary; }
// implementation from now on
bool m_open;
wxList m_data;
bool m_usePrimary;
private:
DECLARE_DYNAMIC_CLASS(wxClipboard)
};
#endif // wxUSE_CLIPBOARD
#endif
// _WX_CLIPBRD_H_

92
include/wx/x11/colour.h Normal file
View File

@@ -0,0 +1,92 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colour.h
// Purpose: wxColour class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COLOUR_H_
#define _WX_COLOUR_H_
#ifdef __GNUG__
#pragma interface "colour.h"
#endif
#include "wx/object.h"
#include "wx/string.h"
// Colour
class WXDLLEXPORT wxColour : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxColour)
public:
// ctors
// default
wxColour();
// from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); }
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour& operator = ( const wxColour& col );
// dtor
~wxColour();
// Set() functions
void Set( unsigned char red, unsigned char green, unsigned char blue );
void Set( unsigned long colRGB )
{
// we don't need to know sizeof(long) here because we assume that the three
// least significant bytes contain the R, G and B values
Set((unsigned char)colRGB,
(unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16));
}
// accessors
bool Ok() const {return m_isInit; }
unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; }
int GetPixel() const { return m_pixel; };
void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; };
inline bool operator == (const wxColour& colour) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
inline bool operator != (const wxColour& colour) const { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
// Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return
// the existing one.
// Returns the allocated pixel.
// TODO: can this handle mono displays? If not, we should have an extra
// flag to specify whether this should be black or white by default.
int AllocColour(WXDisplay* display, bool realloc = FALSE);
void InitFromName(const wxString& col);
private:
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
public:
int m_pixel;
};
#endif
// _WX_COLOUR_H_

84
include/wx/x11/cursor.h Normal file
View File

@@ -0,0 +1,84 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.h
// Purpose: wxCursor class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CURSOR_H_
#define _WX_CURSOR_H_
#ifdef __GNUG__
#pragma interface "cursor.h"
#endif
#include "wx/bitmap.h"
/* Cursor for one display, so we can choose the correct one for
* the current display.
*/
class wxXCursor : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxXCursor)
public:
WXDisplay* m_display;
WXCursor m_cursor;
};
class WXDLLEXPORT wxCursorRefData: public wxBitmapRefData
{
friend class WXDLLEXPORT wxBitmap;
friend class WXDLLEXPORT wxCursor;
public:
wxCursorRefData();
~wxCursorRefData();
wxList m_cursors; // wxXCursor objects, one per display
wxStockCursor m_cursorId; // wxWindows standard cursor id
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
// Cursor
class WXDLLEXPORT wxCursor: public wxBitmap
{
DECLARE_DYNAMIC_CLASS(wxCursor)
public:
wxCursor();
// Copy constructors
wxCursor(const wxCursor& cursor) { Ref(cursor); }
wxCursor(const char bits[], int width, int height, int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
wxCursor(const wxString& name, long flags = wxBITMAP_TYPE_XBM,
int hotSpotX = 0, int hotSpotY = 0);
wxCursor(wxStockCursor id);
~wxCursor();
virtual bool Ok() const { return ((m_refData != NULL) && M_CURSORDATA->m_ok); }
wxCursor& operator = (const wxCursor& cursor) { if (*this == cursor) return (*this); Ref(cursor); return *this; }
bool operator == (const wxCursor& cursor) const { return m_refData == cursor.m_refData; }
bool operator != (const wxCursor& cursor) const { return m_refData != cursor.m_refData; }
// Motif-specific.
// Create/get a cursor for the current display
WXCursor GetXCursor(WXDisplay* display) ;
// Make a cursor from standard id
WXCursor MakeCursor(WXDisplay* display, wxStockCursor id);
};
extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);
#endif
// _WX_CURSOR_H_

66
include/wx/x11/dataform.h Normal file
View File

@@ -0,0 +1,66 @@
///////////////////////////////////////////////////////////////////////////////
// Name: motif/dataform.h
// Purpose: declaration of the wxDataFormat class
// Author: Robert Roebling
// Modified by:
// Created: 19.10.99 (extracted from motif/dataobj.h)
// RCS-ID: $Id$
// Copyright: (c) 1999 Robert Roebling
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_DATAFORM_H
#define _WX_MOTIF_DATAFORM_H
class wxDataFormat
{
public:
// the clipboard formats under Xt are Atoms
typedef Atom NativeFormat;
wxDataFormat();
wxDataFormat( wxDataFormatId type );
wxDataFormat( const wxString &id );
wxDataFormat( const wxChar *id );
wxDataFormat( NativeFormat format );
wxDataFormat& operator=(NativeFormat format)
{ SetId(format); return *this; }
// comparison (must have both versions)
bool operator==(NativeFormat format) const
{ return m_format == (NativeFormat)format; }
bool operator!=(NativeFormat format) const
{ return m_format != (NativeFormat)format; }
bool operator==(wxDataFormatId format) const
{ return m_type == (wxDataFormatId)format; }
bool operator!=(wxDataFormatId format) const
{ return m_type != (wxDataFormatId)format; }
// explicit and implicit conversions to NativeFormat which is one of
// standard data types (implicit conversion is useful for preserving the
// compatibility with old code)
NativeFormat GetFormatId() const { return m_format; }
operator NativeFormat() const { return m_format; }
void SetId( NativeFormat format );
// string ids are used for custom types - this SetId() must be used for
// application-specific formats
wxString GetId() const;
void SetId( const wxChar *id );
// implementation
wxDataFormatId GetType() const;
private:
wxDataFormatId m_type;
NativeFormat m_format;
void PrepareFormats();
void SetType( wxDataFormatId type );
};
#endif // _WX_MOTIF_DATAFORM_H

30
include/wx/x11/dataobj.h Normal file
View File

@@ -0,0 +1,30 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/dataobj.h
// Purpose: declaration of the wxDataObject class for Motif
// Author: Julian Smart
// RCS-ID: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_DATAOBJ_H_
#define _WX_MOTIF_DATAOBJ_H_
#ifdef __GNUG__
#pragma interface "dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxDataObject is the same as wxDataObjectBase under wxMotif
// ----------------------------------------------------------------------------
class wxDataObject : public wxDataObjectBase
{
public:
#ifdef __DARWIN__
~wxDataObject() { }
#endif
};
#endif //_WX_MOTIF_DATAOBJ_H_

168
include/wx/x11/dc.h Normal file
View File

@@ -0,0 +1,168 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dc.h
// Purpose: wxDC class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DC_H_
#define _WX_DC_H_
#ifdef __GNUG__
#pragma interface "dc.h"
#endif
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/icon.h"
#include "wx/font.h"
#include "wx/gdicmn.h"
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#ifndef MM_TEXT
#define MM_TEXT 0
#define MM_ISOTROPIC 1
#define MM_ANISOTROPIC 2
#define MM_LOMETRIC 3
#define MM_HIMETRIC 4
#define MM_TWIPS 5
#define MM_POINTS 6
#define MM_METRIC 7
#endif
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxDC : public wxDCBase
{
DECLARE_DYNAMIC_CLASS(wxDC)
public:
wxDC();
~wxDC() { }
// implement base class pure virtuals
// ----------------------------------
virtual void DestroyClippingRegion();
virtual wxSize GetPPI() const;
virtual void SetMapMode(int mode);
virtual void SetUserScale(double x, double y);
virtual void SetLogicalScale(double x, double y);
virtual void SetLogicalOrigin(wxCoord x, wxCoord y);
virtual void SetDeviceOrigin(wxCoord x, wxCoord y);
virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp);
protected:
virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y);
virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
bool useMask = FALSE);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetSizeMM(int* width, int* height) const;
public:
void ComputeScaleAndOrigin();
wxCoord XDEV2LOG(wxCoord x) const
{
wxCoord new_x = x - m_deviceOriginX;
if (new_x > 0)
return (wxCoord)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX;
else
return (wxCoord)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX;
}
wxCoord XDEV2LOGREL(wxCoord x) const
{
if (x > 0)
return (wxCoord)((double)(x) / m_scaleX + 0.5);
else
return (wxCoord)((double)(x) / m_scaleX - 0.5);
}
wxCoord YDEV2LOG(wxCoord y) const
{
wxCoord new_y = y - m_deviceOriginY;
if (new_y > 0)
return (wxCoord)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY;
else
return (wxCoord)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY;
}
wxCoord YDEV2LOGREL(wxCoord y) const
{
if (y > 0)
return (wxCoord)((double)(y) / m_scaleY + 0.5);
else
return (wxCoord)((double)(y) / m_scaleY - 0.5);
}
wxCoord XLOG2DEV(wxCoord x) const
{
wxCoord new_x = x - m_logicalOriginX;
if (new_x > 0)
return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX;
else
return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX;
}
// Without device translation, for backing pixmap purposes
wxCoord XLOG2DEV_2(wxCoord x) const
{
wxCoord new_x = x - m_logicalOriginX;
if (new_x > 0)
return (wxCoord)((double)(new_x) * m_scaleX + 0.5) * m_signX;
else
return (wxCoord)((double)(new_x) * m_scaleX - 0.5) * m_signX;
}
wxCoord XLOG2DEVREL(wxCoord x) const
{
if (x > 0)
return (wxCoord)((double)(x) * m_scaleX + 0.5);
else
return (wxCoord)((double)(x) * m_scaleX - 0.5);
}
wxCoord YLOG2DEV(wxCoord y) const
{
wxCoord new_y = y - m_logicalOriginY;
if (new_y > 0)
return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY;
else
return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY;
}
// Without device translation, for backing pixmap purposes
wxCoord YLOG2DEV_2(wxCoord y) const
{
wxCoord new_y = y - m_logicalOriginY;
if (new_y > 0)
return (wxCoord)((double)(new_y) * m_scaleY + 0.5) * m_signY;
else
return (wxCoord)((double)(new_y) * m_scaleY - 0.5) * m_signY;
}
wxCoord YLOG2DEVREL(wxCoord y) const
{
if (y > 0)
return (wxCoord)((double)(y) * m_scaleY + 0.5);
else
return (wxCoord)((double)(y) * m_scaleY - 0.5);
}
public:
// not sure what for, but what is a mm on a screen you don't know the size of?
double m_mm_to_pix_x,m_mm_to_pix_y;
// recompute scale?
bool m_needComputeScaleX, m_needComputeScaleY;
};
#endif
// _WX_DC_H_

177
include/wx/x11/dcclient.h Normal file
View File

@@ -0,0 +1,177 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcclient.h
// Purpose: wxClientDC, wxPaintDC and wxWindowDC classes
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCCLIENT_H_
#define _WX_DCCLIENT_H_
#ifdef __GNUG__
#pragma interface "dcclient.h"
#endif
#include "wx/dc.h"
// -----------------------------------------------------------------------------
// fwd declarations
// -----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowDC;
class WXDLLEXPORT wxWindow;
// Under Windows, wxClientDC, wxPaintDC and wxWindowDC are implemented
// differently. On many platforms, however, they will be the same.
//-----------------------------------------------------------------------------
// wxWindowDC
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxWindowDC : public wxDC
{
DECLARE_DYNAMIC_CLASS(wxWindowDC)
public:
wxWindowDC();
wxWindowDC( wxWindow *win );
~wxWindowDC();
// TODO this function is Motif-only for now - should it go into base class?
void Clear(const wxRect& rect);
// implement base class pure virtuals
// ----------------------------------
virtual void Clear();
virtual void SetFont(const wxFont& font);
virtual void SetPen(const wxPen& pen);
virtual void SetBrush(const wxBrush& brush);
virtual void SetBackground(const wxBrush& brush);
virtual void SetBackgroundMode(int mode);
virtual void SetPalette(const wxPalette& palette);
virtual void SetLogicalFunction( int function );
virtual void SetTextForeground(const wxColour& colour);
virtual void SetTextBackground(const wxColour& colour);
virtual wxCoord GetCharHeight() const;
virtual wxCoord GetCharWidth() const;
virtual void DoGetTextExtent(const wxString& string,
wxCoord *x, wxCoord *y,
wxCoord *descent = NULL,
wxCoord *externalLeading = NULL,
wxFont *theFont = NULL) const;
virtual bool CanDrawBitmap() const;
virtual bool CanGetTextExtent() const;
virtual int GetDepth() const;
virtual wxSize GetPPI() const;
virtual void DestroyClippingRegion();
// Helper function for setting clipping
void SetDCClipping();
// implementation from now on
// --------------------------
WXGC GetGC() const { return m_gc; }
WXGC GetBackingGC() const { return m_gcBacking; }
WXDisplay* GetDisplay() const { return m_display; }
bool GetAutoSetting() const { return m_autoSetting; }
void SetAutoSetting(bool flag) { m_autoSetting = flag; }
protected:
virtual void DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
int style = wxFLOOD_SURFACE);
virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const;
virtual void DoDrawPoint(wxCoord x, wxCoord y);
virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
virtual void DoDrawArc(wxCoord x1, wxCoord y1,
wxCoord x2, wxCoord y2,
wxCoord xc, wxCoord yc);
virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
double sa, double ea);
virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
wxCoord width, wxCoord height,
double radius);
virtual void DoDrawEllipse(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
virtual void DoCrossHair(wxCoord x, wxCoord y);
virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y);
virtual void DoDrawRotatedText(const wxString &text, wxCoord x, wxCoord y, double angle);
virtual bool DoBlit(wxCoord xdest, wxCoord ydest, wxCoord width, wxCoord height,
wxDC *source, wxCoord xsrc, wxCoord ysrc,
int rop = wxCOPY, bool useMask = FALSE, wxCoord xsrcMask = -1, wxCoord ysrcMask = -1);
virtual void DoSetClippingRegionAsRegion(const wxRegion& region);
virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
wxCoord width, wxCoord height);
virtual void DoDrawLines(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset);
virtual void DoDrawPolygon(int n, wxPoint points[],
wxCoord xoffset, wxCoord yoffset,
int fillStyle = wxODDEVEN_RULE);
WXGC m_gc;
WXGC m_gcBacking;
WXDisplay* m_display;
wxWindow* m_window;
WXRegion m_currentRegion; // Current clipping region (incl. paint clip region)
WXRegion m_userRegion; // User-defined clipping region
WXPixmap m_pixmap; // Pixmap for drawing on
// Not sure if we'll need all of these
int m_backgroundPixel;
wxColour m_currentColour;
// int m_currentBkMode;
int m_currentPenWidth ;
int m_currentPenJoin ;
int m_currentPenCap ;
int m_currentPenDashCount ;
wxMOTIFDash* m_currentPenDash ;
wxBitmap m_currentStipple ;
int m_currentStyle ;
int m_currentFill ;
int m_autoSetting ; // See comment in dcclient.cpp
WXFont m_oldFont;
};
class WXDLLEXPORT wxPaintDC: public wxWindowDC
{
DECLARE_DYNAMIC_CLASS(wxPaintDC)
public:
wxPaintDC() { }
wxPaintDC(wxWindow* win);
~wxPaintDC();
};
class WXDLLEXPORT wxClientDC: public wxWindowDC
{
DECLARE_DYNAMIC_CLASS(wxClientDC)
public:
wxClientDC() { }
wxClientDC(wxWindow* win) : wxWindowDC(win) { }
};
#endif
// _WX_DCCLIENT_H_

43
include/wx/x11/dcmemory.h Normal file
View File

@@ -0,0 +1,43 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcmemory.h
// Purpose: wxMemoryDC class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCMEMORY_H_
#define _WX_DCMEMORY_H_
#ifdef __GNUG__
#pragma interface "dcmemory.h"
#endif
#include "wx/dcclient.h"
class wxMemoryDC : public wxWindowDC
{
DECLARE_DYNAMIC_CLASS(wxMemoryDC)
public:
wxMemoryDC();
wxMemoryDC( wxDC *dc ); // Create compatible DC
~wxMemoryDC();
virtual void SelectObject( const wxBitmap& bitmap );
void DoGetSize( int *width, int *height ) const;
wxBitmap& GetBitmap() const { return (wxBitmap&) m_bitmap; }
private:
friend class wxPaintDC;
wxBitmap m_bitmap;
};
#endif
// _WX_DCMEMORY_H_

34
include/wx/x11/dcprint.h Normal file
View File

@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcprint.h
// Purpose: wxPrinterDC class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCPRINT_H_
#define _WX_DCPRINT_H_
#ifdef __GNUG__
#pragma interface "dcprint.h"
#endif
#include "wx/dc.h"
class WXDLLEXPORT wxPrinterDC: public wxDC
{
public:
DECLARE_CLASS(wxPrinterDC)
// Create a printer DC
wxPrinterDC(const wxString& driver, const wxString& device, const wxString& output, bool interactive = TRUE, int orientation = wxPORTRAIT);
~wxPrinterDC();
};
#endif
// _WX_DCPRINT_H_

48
include/wx/x11/dcscreen.h Normal file
View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcscreen.h
// Purpose: wxScreenDC class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DCSCREEN_H_
#define _WX_DCSCREEN_H_
#ifdef __GNUG__
#pragma interface "dcscreen.h"
#endif
#include "wx/dcclient.h"
class WXDLLEXPORT wxScreenDC: public wxWindowDC
{
DECLARE_DYNAMIC_CLASS(wxScreenDC)
public:
// Create a DC representing the whole screen
wxScreenDC();
~wxScreenDC();
// Compatibility with X's requirements for
// drawing on top of all windows
static bool StartDrawingOnTop(wxWindow* window);
static bool StartDrawingOnTop(wxRect* rect = NULL);
static bool EndDrawingOnTop();
private:
static WXWindow sm_overlayWindow;
// If we have started transparent drawing at a non-(0,0) point
// then we will have to adjust the device origin in the
// constructor.
static int sm_overlayWindowX;
static int sm_overlayWindowY;
};
#endif
// _WX_DCSCREEN_H_

178
include/wx/x11/dnd.h Normal file
View File

@@ -0,0 +1,178 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.h
// Purpose: declaration of wxDropTarget, wxDropSource classes
// Author: Julian Smart
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling, Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DND_H_
#define _WX_DND_H_
#ifdef __GNUG__
#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"
//-------------------------------------------------------------------------
// classes
//-------------------------------------------------------------------------
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxDropTarget;
class WXDLLEXPORT wxTextDropTarget;
class WXDLLEXPORT wxFileDropTarget;
class WXDLLEXPORT wxPrivateDropTarget;
class WXDLLEXPORT wxDropSource;
//-------------------------------------------------------------------------
// wxDropTarget
//-------------------------------------------------------------------------
class WXDLLEXPORT wxDropTarget: public wxObject
{
public:
wxDropTarget();
~wxDropTarget();
virtual void OnEnter() { }
virtual void OnLeave() { }
virtual bool OnDrop( long x, long y, const void *data, size_t size ) = 0;
// 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
};
//-------------------------------------------------------------------------
// wxTextDropTarget
//-------------------------------------------------------------------------
class WXDLLEXPORT wxTextDropTarget: public wxDropTarget
{
public:
wxTextDropTarget() {};
virtual bool OnDrop( long x, long y, const void *data, size_t size );
virtual bool OnDropText( long x, long y, const char *psz );
protected:
virtual size_t GetFormatCount() const;
virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
// wxPrivateDropTarget
//-------------------------------------------------------------------------
class WXDLLEXPORT wxPrivateDropTarget: public wxDropTarget
{
public:
wxPrivateDropTarget();
// you have to override OnDrop to get at the data
// the string ID identifies the format of clipboard or DnD data. a word
// processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
// to the clipboard - the latter with the Id "WXWORD_FORMAT".
void SetId( const wxString& id )
{ m_id = id; }
wxString GetId()
{ return m_id; }
private:
virtual size_t GetFormatCount() const;
virtual wxDataFormat GetFormat(size_t n) const;
wxString m_id;
};
// ----------------------------------------------------------------------------
// A drop target which accepts files (dragged from File Manager or Explorer)
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFileDropTarget: public wxDropTarget
{
public:
wxFileDropTarget() {};
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[] );
protected:
virtual size_t GetFormatCount() const;
virtual wxDataFormat GetFormat(size_t n) const;
};
//-------------------------------------------------------------------------
// 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)
};
class WXDLLEXPORT wxDropSource: public wxObject
{
public:
wxDropSource( wxWindow *win );
wxDropSource( wxDataObject &data, wxWindow *win );
~wxDropSource(void);
void SetData( wxDataObject &data );
wxDragResult DoDragDrop( bool bAllowMove = FALSE );
virtual bool GiveFeedback( wxDragResult WXUNUSED(effect), bool WXUNUSED(bScrolling) ) { return TRUE; };
// 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_

117
include/wx/x11/font.h Normal file
View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: font.h
// Purpose: wxFont class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONT_H_
#define _WX_FONT_H_
#ifdef __GNUG__
#pragma interface "font.h"
#endif
class wxXFont;
// Font
class wxFont : public wxFontBase
{
public:
// ctors and such
wxFont() { Init(); }
wxFont(const wxFont& font) { Init(); Ref(font); }
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Init();
(void)Create(size, family, style, weight, underlined, face, encoding);
}
wxFont(const wxNativeFontInfo& info);
bool Create(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
// wxMOTIF-specific
bool Create(const wxString& fontname,
wxFontEncoding fontenc = wxFONTENCODING_DEFAULT);
bool Create(const wxNativeFontInfo& fontinfo);
virtual ~wxFont();
// assignment
wxFont& operator=(const wxFont& font);
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual int GetFamily() const;
virtual int GetStyle() const;
virtual int GetWeight() const;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
virtual wxNativeFontInfo *GetNativeFontInfo() const;
virtual void SetPointSize(int pointSize);
virtual void SetFamily(int family);
virtual void SetStyle(int style);
virtual void SetWeight(int weight);
virtual void SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
virtual void SetNativeFontInfo( const wxNativeFontInfo& info );
// Implementation
// Find an existing, or create a new, XFontStruct
// based on this wxFont and the given scale. Append the
// font to list in the private data for future reference.
// TODO This is a fairly basic implementation, that doesn't
// allow for different facenames, and also doesn't do a mapping
// between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
// and the fonts that are available on a particular system.
// Maybe we need to scan the user's machine to build up a profile
// of the fonts and a mapping file.
// Return font struct, and optionally the Motif font list
wxXFont *GetInternalFont(double scale = 1.0,
WXDisplay* display = NULL) const;
// These two are helper functions for convenient access of the above.
WXFontStructPtr GetFontStruct(double scale = 1.0,
WXDisplay* display = NULL) const;
WXFontList GetFontList(double scale = 1.0,
WXDisplay* display = NULL) const;
protected:
// common part of all ctors
void Init();
// VZ: IMHO, we don't need it at all...
bool RealizeResource() { return TRUE; }
void Unshare();
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
#endif
// _WX_FONT_H_

48
include/wx/x11/gdiobj.h Normal file
View File

@@ -0,0 +1,48 @@
/////////////////////////////////////////////////////////////////////////////
// Name: gdiobj.h
// Purpose: wxGDIObject class: base class for other GDI classes
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GDIOBJ_H_
#define _WX_GDIOBJ_H_
#include "wx/object.h"
#ifdef __GNUG__
#pragma interface "gdiobj.h"
#endif
class WXDLLEXPORT wxGDIRefData: public wxObjectRefData {
public:
inline wxGDIRefData()
{
}
};
#define M_GDIDATA ((wxGDIRefData *)m_refData)
class WXDLLEXPORT wxGDIObject: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxGDIObject)
public:
inline wxGDIObject() { m_visible = FALSE; };
inline ~wxGDIObject() {};
inline bool IsNull() const { return (m_refData == 0); }
virtual bool GetVisible() { return m_visible; }
virtual void SetVisible(bool v) { m_visible = v; }
protected:
bool m_visible; // Can a pointer to this object be safely taken?
// - only if created within FindOrCreate...
};
#endif
// _WX_GDIOBJ_H_

161
include/wx/x11/glcanvas.h Normal file
View File

@@ -0,0 +1,161 @@
/////////////////////////////////////////////////////////////////////////////
// Name: glcanvas.h
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
// Uses the GLX extension.
// Author: Julian Smart and Wolfram Gloger
// Modified by:
// Created: 1995, 1999
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Wolfram Gloger
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma interface "glcanvas.h"
#endif
#ifndef _WX_GLCANVAS_H_
#define _WX_GLCANVAS_H_
#include "wx/setup.h"
#if wxUSE_GLCANVAS
#include "wx/gdicmn.h"
#include "wx/palette.h"
#include "wx/scrolwin.h"
#include <GL/glx.h>
enum
{
WX_GL_RGBA=1, /* use true color palette */
WX_GL_BUFFER_SIZE, /* bits for buffer if not WX_GL_RGBA */
WX_GL_LEVEL, /* 0 for main buffer, >0 for overlay, <0 for underlay */
WX_GL_DOUBLEBUFFER, /* use doublebuffer */
WX_GL_STEREO, /* use stereoscopic display */
WX_GL_AUX_BUFFERS, /* number of auxiliary buffers */
WX_GL_MIN_RED, /* use red buffer with most bits (> MIN_RED bits) */
WX_GL_MIN_GREEN, /* use green buffer with most bits (> MIN_GREEN bits) */
WX_GL_MIN_BLUE, /* use blue buffer with most bits (> MIN_BLUE bits) */
WX_GL_MIN_ALPHA, /* use blue buffer with most bits (> MIN_ALPHA bits) */
WX_GL_DEPTH_SIZE, /* bits for Z-buffer (0,16,32) */
WX_GL_STENCIL_SIZE, /* bits for stencil buffer */
WX_GL_MIN_ACCUM_RED, /* use red accum buffer with most bits (> MIN_ACCUM_RED bits) */
WX_GL_MIN_ACCUM_GREEN, /* use green buffer with most bits (> MIN_ACCUM_GREEN bits) */
WX_GL_MIN_ACCUM_BLUE, /* use blue buffer with most bits (> MIN_ACCUM_BLUE bits) */
WX_GL_MIN_ACCUM_ALPHA /* use blue buffer with most bits (> MIN_ACCUM_ALPHA bits) */
};
//---------------------------------------------------------------------------
// classes
//---------------------------------------------------------------------------
class WXDLLEXPORT wxGLContext: public wxObject
{
public:
wxGLContext( bool isRGB, wxWindow *win,
const wxPalette& palette = wxNullPalette );
wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
);
~wxGLContext();
void SetCurrent();
void SetColour(const char *colour);
void SwapBuffers();
void SetupPixelFormat();
void SetupPalette(const wxPalette& palette);
wxPalette CreateDefaultPalette();
inline wxPalette* GetPalette() const { return (wxPalette*) & m_palette; }
inline wxWindow* GetWindow() const { return m_window; }
// inline GtkWidget* GetWidget() const { return m_widget; }
inline GLXContext GetContext() const { return m_glContext; }
public:
GLXContext m_glContext;
// GtkWidget *m_widget;
wxPalette m_palette;
wxWindow* m_window;
DECLARE_CLASS(wxGLContext)
};
class WXDLLEXPORT wxGLCanvas: public wxScrolledWindow
{
public:
inline wxGLCanvas() {
m_glContext = (wxGLContext*) NULL;
m_sharedContext = (wxGLContext*) NULL;
// m_glWidget = (GtkWidget*) NULL;
m_vi = (void*) NULL;
// m_exposed = FALSE;
}
wxGLCanvas( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
wxGLCanvas( wxWindow *parent, const wxGLContext *shared = (wxGLContext *)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
wxGLCanvas( wxWindow *parent, const wxGLCanvas *shared = (wxGLCanvas *)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
bool Create( wxWindow *parent,
const wxGLContext *shared = (wxGLContext*)NULL,
const wxGLCanvas *shared_context_of = (wxGLCanvas*)NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0, const wxString& name = "GLCanvas",
int *attribList = (int*) NULL,
const wxPalette& palette = wxNullPalette );
~wxGLCanvas();
void SetCurrent();
void SetColour(const char *colour);
void SwapBuffers();
// void OnSize(wxSizeEvent& event);
// void OnInternalIdle();
inline wxGLContext* GetContext() const { return m_glContext; }
// implementation
wxGLContext *m_glContext,
*m_sharedContext;
wxGLCanvas *m_sharedContextOf;
void *m_vi;
// GtkWidget *m_glWidget;
// bool m_exposed;
DECLARE_EVENT_TABLE()
DECLARE_CLASS(wxGLCanvas)
};
#endif
// wxUSE_GLCANVAS
#endif
// _WX_GLCANVAS_H_

57
include/wx/x11/icon.h Normal file
View File

@@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////
// Name: icon.h
// Purpose: wxIcon class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ICON_H_
#define _WX_ICON_H_
#ifdef __GNUG__
#pragma interface "icon.h"
#endif
#include "wx/bitmap.h"
#define M_ICONDATA ((wxBitmapRefData *)m_refData)
#define M_ICONHANDLERDATA ((wxBitmapRefData *)bitmap->GetRefData())
// Icon
class WXDLLEXPORT wxIcon: public wxBitmap
{
DECLARE_DYNAMIC_CLASS(wxIcon)
public:
wxIcon();
// Copy constructors
inline wxIcon(const wxIcon& icon) { Ref(icon); }
// Initialize with XBM data
wxIcon(const char bits[], int width, int height);
// Initialize with XPM data
wxIcon(const char **data);
wxIcon(char **data);
wxIcon(const wxString& name, long flags = wxBITMAP_TYPE_XPM,
int desiredWidth = -1, int desiredHeight = -1);
~wxIcon();
bool LoadFile(const wxString& name, long flags = wxBITMAP_TYPE_XPM,
int desiredWidth = -1, int desiredHeight = -1);
inline wxIcon& operator = (const wxIcon& icon) { if (*this == icon) return (*this); Ref(icon); return *this; }
inline bool operator == (const wxIcon& icon) const { return m_refData == icon.m_refData; }
inline bool operator != (const wxIcon& icon) const { return m_refData != icon.m_refData; }
virtual bool Ok() const { return ((m_refData != NULL) && (M_ICONDATA->m_ok)); }
};
#endif
// _WX_ICON_H_

93
include/wx/x11/joystick.h Normal file
View File

@@ -0,0 +1,93 @@
/////////////////////////////////////////////////////////////////////////////
// Name: joystick.h
// Purpose: wxJoystick class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_JOYSTICK_H_
#define _WX_JOYSTICK_H_
#ifdef __GNUG__
#pragma interface "joystick.h"
#endif
#include "wx/event.h"
class WXDLLEXPORT wxJoystick: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxJoystick)
public:
/*
* Public interface
*/
wxJoystick(int joystick = wxJOYSTICK1) { m_joystick = joystick; };
// Attributes
////////////////////////////////////////////////////////////////////////////
wxPoint GetPosition() const;
int GetZPosition() const;
int GetButtonState() const;
int GetPOVPosition() const;
int GetPOVCTSPosition() const;
int GetRudderPosition() const;
int GetUPosition() const;
int GetVPosition() const;
int GetMovementThreshold() const;
void SetMovementThreshold(int threshold) ;
// Capabilities
////////////////////////////////////////////////////////////////////////////
bool IsOk() const; // Checks that the joystick is functioning
int GetNumberJoysticks() const ;
int GetManufacturerId() const ;
int GetProductId() const ;
wxString GetProductName() const ;
int GetXMin() const;
int GetYMin() const;
int GetZMin() const;
int GetXMax() const;
int GetYMax() const;
int GetZMax() const;
int GetNumberButtons() const;
int GetNumberAxes() const;
int GetMaxButtons() const;
int GetMaxAxes() const;
int GetPollingMin() const;
int GetPollingMax() const;
int GetRudderMin() const;
int GetRudderMax() const;
int GetUMin() const;
int GetUMax() const;
int GetVMin() const;
int GetVMax() const;
bool HasRudder() const;
bool HasZ() const;
bool HasU() const;
bool HasV() const;
bool HasPOV() const;
bool HasPOV4Dir() const;
bool HasPOVCTS() const;
// Operations
////////////////////////////////////////////////////////////////////////////
// pollingFreq = 0 means that movement events are sent when above the threshold.
// If pollingFreq > 0, events are received every this many milliseconds.
bool SetCapture(wxWindow* win, int pollingFreq = 0);
bool ReleaseCapture();
protected:
int m_joystick;
};
#endif
// _WX_JOYSTICK_H_

250
include/wx/x11/mdi.h Normal file
View File

@@ -0,0 +1,250 @@
/////////////////////////////////////////////////////////////////////////////
// Name: mdi.h
// Purpose: MDI (Multiple Document Interface) classes.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MDI_H_
#define _WX_MDI_H_
#ifdef __GNUG__
#pragma interface "mdi.h"
#endif
/*
New MDI scheme using tabs. We can use a wxNotebook to implement the client
window. wxMDIChildFrame can be implemented as an XmMainWindow widget
as before, and is a child of the notebook _and_ of the parent frame...
but wxMDIChildFrame::GetParent should return the parent frame.
*/
#include "wx/frame.h"
#include "wx/notebook.h"
WXDLLEXPORT_DATA(extern const char*) wxFrameNameStr;
WXDLLEXPORT_DATA(extern const char*) wxStatusLineNameStr;
class WXDLLEXPORT wxMDIClientWindow;
class WXDLLEXPORT wxMDIChildFrame;
class WXDLLEXPORT wxMDIParentFrame: public wxFrame
{
DECLARE_DYNAMIC_CLASS(wxMDIParentFrame)
friend class WXDLLEXPORT wxMDIChildFrame;
public:
wxMDIParentFrame();
inline wxMDIParentFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL, // Scrolling refers to client window
const wxString& name = wxFrameNameStr)
{
Create(parent, id, title, pos, size, style, name);
}
~wxMDIParentFrame();
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE | wxVSCROLL | wxHSCROLL,
const wxString& name = wxFrameNameStr);
void OnSize(wxSizeEvent& event);
void OnActivate(wxActivateEvent& event);
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnMenuHighlight(wxMenuEvent& event);
void SetMenuBar(wxMenuBar *menu_bar);
// Get the active MDI child window
wxMDIChildFrame *GetActiveChild() const ;
// Get the client window
wxMDIClientWindow *GetClientWindow() const { return m_clientWindow; };
// Create the client window class (don't Create the window,
// just return a new class)
virtual wxMDIClientWindow *OnCreateClient() ;
// MDI operations
virtual void Cascade();
virtual void Tile();
virtual void ArrangeIcons();
virtual void ActivateNext();
virtual void ActivatePrevious();
// Implementation
// Set the active child
inline void SetActiveChild(wxMDIChildFrame* child) { m_activeChild = child; }
// Set the child's menubar into the parent frame
void SetChildMenuBar(wxMDIChildFrame* frame);
inline wxMenuBar* GetActiveMenuBar() const { return m_activeMenuBar; }
// Redirect events to active child first
virtual bool ProcessEvent(wxEvent& event);
protected:
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
// Gets the size available for subwindows after menu size, toolbar size
// and status bar size have been subtracted. If you want to manage your own
// toolbar(s), don't call SetToolBar.
void DoGetClientSize(int *width, int *height) const;
protected:
wxMDIClientWindow* m_clientWindow;
wxMDIChildFrame* m_activeChild;
wxMenuBar* m_activeMenuBar;
DECLARE_EVENT_TABLE()
};
class WXDLLEXPORT wxMDIChildFrame: public wxFrame
{
DECLARE_DYNAMIC_CLASS(wxMDIChildFrame)
public:
wxMDIChildFrame();
wxMDIChildFrame(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
Create(parent, id, title, pos, size, style, name);
}
~wxMDIChildFrame();
bool Create(wxMDIParentFrame *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
void SetTitle(const wxString& title);
// Set icon
virtual void SetIcon(const wxIcon& icon);
// Override wxFrame operations
void CaptureMouse();
void ReleaseMouse();
void Raise();
void Lower(void);
void SetSizeHints(int minW = -1, int minH = -1, int maxW = -1, int maxH = -1, int incW = -1, int incH = -1);
// MDI operations
virtual void Maximize();
virtual void Maximize(bool WXUNUSED(maximize)) { };
inline void Minimize() { Iconize(TRUE); };
virtual void Iconize(bool iconize);
virtual void Restore();
virtual void Activate();
virtual bool IsIconized() const ;
virtual bool IsTopLevel() const { return FALSE; }
// Is the frame maximized? Returns TRUE for
// wxMDIChildFrame due to the tabbed implementation.
virtual bool IsMaximized(void) const ;
bool Show(bool show);
WXWidget GetMainWidget() const { return m_mainWidget; };
WXWidget GetTopWidget() const { return m_mainWidget; };
WXWidget GetClientWidget() const { return m_mainWidget; };
/*
virtual void OnRaise();
virtual void OnLower();
*/
void SetMDIParentFrame(wxMDIParentFrame* parentFrame) { m_mdiParentFrame = parentFrame; }
wxMDIParentFrame* GetMDIParentFrame() const { return m_mdiParentFrame; }
protected:
wxMDIParentFrame* m_mdiParentFrame;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
void DoGetClientSize(int *width, int *height) const;
void DoGetSize(int *width, int *height) const;
void DoGetPosition(int *x, int *y) const ;
};
/* The client window is a child of the parent MDI frame, and itself
* contains the child MDI frames.
* However, you create the MDI children as children of the MDI parent:
* only in the implementation does the client window become the parent
* of the children. Phew! So the children are sort of 'adopted'...
*/
class WXDLLEXPORT wxMDIClientWindow: public wxNotebook
{
DECLARE_DYNAMIC_CLASS(wxMDIClientWindow)
public:
wxMDIClientWindow() ;
wxMDIClientWindow(wxMDIParentFrame *parent, long style = 0)
{
CreateClient(parent, style);
}
~wxMDIClientWindow();
// Note: this is virtual, to allow overridden behaviour.
virtual bool CreateClient(wxMDIParentFrame *parent, long style = wxVSCROLL | wxHSCROLL);
// Explicitly call default scroll behaviour
void OnScroll(wxScrollEvent& event);
// Implementation
void OnPageChanged(wxNotebookEvent& event);
protected:
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
void DoGetClientSize(int *width, int *height) const;
void DoGetSize(int *width, int *height) const ;
void DoGetPosition(int *x, int *y) const ;
private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_MDI_H_

46
include/wx/x11/minifram.h Normal file
View File

@@ -0,0 +1,46 @@
/////////////////////////////////////////////////////////////////////////////
// Name: minifram.h
// Purpose: wxMiniFrame class. A small frame for e.g. floating toolbars.
// If there is no equivalent on your platform, just make it a
// normal frame.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MINIFRAM_H_
#define _WX_MINIFRAM_H_
#ifdef __GNUG__
#pragma interface "minifram.h"
#endif
#include "wx/frame.h"
class WXDLLEXPORT wxMiniFrame: public wxFrame {
DECLARE_DYNAMIC_CLASS(wxMiniFrame)
public:
inline wxMiniFrame() {}
inline wxMiniFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE|wxTINY_CAPTION_HORIZ,
const wxString& name = wxFrameNameStr)
{
// Use wxFrame constructor in absence of more specific code.
Create(parent, id, title, pos, size, style, name);
}
~wxMiniFrame() {}
protected:
};
#endif
// _WX_MINIFRAM_H_

81
include/wx/x11/palette.h Normal file
View File

@@ -0,0 +1,81 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.h
// Purpose: wxPalette class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PALETTE_H_
#define _WX_PALETTE_H_
#ifdef __GNUG__
#pragma interface "palette.h"
#endif
#include "wx/gdiobj.h"
#include "wx/list.h"
class WXDLLEXPORT wxPalette;
// Palette for one display
class wxXPalette : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxXPalette)
public:
wxXPalette();
WXDisplay* m_display;
int m_pix_array_n;
unsigned long* m_pix_array;
WXColormap m_cmap;
bool m_destroyable;
};
class WXDLLEXPORT wxPaletteRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxPalette;
public:
wxPaletteRefData();
~wxPaletteRefData();
protected:
wxList m_palettes;
};
#define M_PALETTEDATA ((wxPaletteRefData *)m_refData)
class WXDLLEXPORT wxPalette: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxPalette)
public:
wxPalette();
wxPalette(const wxPalette& palette) { Ref(palette); }
wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
~wxPalette();
bool Create(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue);
int GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const;
bool GetRGB(int pixel, unsigned char *red, unsigned char *green, unsigned char *blue) const;
virtual bool Ok() const { return (m_refData != NULL) ; }
wxPalette& operator = (const wxPalette& palette) { if (*this == palette) return (*this); Ref(palette); return *this; }
bool operator == (const wxPalette& palette) const { return m_refData == palette.m_refData; }
bool operator != (const wxPalette& palette) const { return m_refData != palette.m_refData; }
// Motif-specific
WXColormap GetXColormap(WXDisplay* display = NULL) const;
bool TransferBitmap(void *data, int depth, int size);
bool TransferBitmap8(unsigned char *data, unsigned long size, void *dest, unsigned int bpp);
unsigned long *GetXPixArray(WXDisplay* display, int *pix_array_n);
void PutXColormap(WXDisplay* display, WXColormap cmap, bool destroyable);
};
#endif
// _WX_PALETTE_H_

102
include/wx/x11/pen.h Normal file
View File

@@ -0,0 +1,102 @@
/////////////////////////////////////////////////////////////////////////////
// Name: pen.h
// Purpose: wxPen class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PEN_H_
#define _WX_PEN_H_
#ifdef __GNUG__
#pragma interface "pen.h"
#endif
#include "wx/gdiobj.h"
#include "wx/colour.h"
#include "wx/bitmap.h"
typedef char wxMOTIFDash;
class WXDLLEXPORT wxPen;
class WXDLLEXPORT wxPenRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxPen;
public:
wxPenRefData();
wxPenRefData(const wxPenRefData& data);
~wxPenRefData();
protected:
int m_width;
int m_style;
int m_join ;
int m_cap ;
wxBitmap m_stipple ;
int m_nbDash ;
wxMOTIFDash *m_dash ;
wxColour m_colour;
};
#define M_PENDATA ((wxPenRefData *)m_refData)
// Pen
class WXDLLEXPORT wxPen: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxPen)
public:
wxPen();
wxPen(const wxColour& col, int width, int style);
wxPen(const wxBitmap& stipple, int width);
inline wxPen(const wxPen& pen) { Ref(pen); }
~wxPen();
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; }
inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; }
virtual bool Ok() const { return (m_refData != NULL) ; }
// Override in order to recreate the pen
void SetColour(const wxColour& col) ;
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
void SetWidth(int width) ;
void SetStyle(int style) ;
void SetStipple(const wxBitmap& stipple) ;
void SetDashes(int nb_dashes, const wxDash *dash) ;
void SetJoin(int join) ;
void SetCap(int cap) ;
inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
inline int GetDashes(wxDash **ptr) const
{
*ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
}
inline int GetDashCount() const { return (M_PENDATA->m_nbDash); }
inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; }
inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
// Implementation
// Useful helper: create the brush resource
bool RealizeResource();
// When setting properties, we must make sure we're not changing
// another object
void Unshare();
};
#endif
// _WX_PEN_H_

50
include/wx/x11/popupwin.h Normal file
View File

@@ -0,0 +1,50 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/msw/popupwin.h
// Purpose: wxPopupWindow class for wxMSW
// Author: Vadim Zeitlin
// Modified by:
// Created: 06.01.01
// RCS-ID: $Id$
// Copyright: (c) 2001 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_POPUPWIN_H_
#define _WX_MSW_POPUPWIN_H_
// ----------------------------------------------------------------------------
// wxPopupWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxPopupWindow : public wxPopupWindowBase
{
public:
wxPopupWindow() { }
wxPopupWindow(wxWindow *parent, int flags = wxBORDER_NONE)
{ (void)Create(parent, flags); }
bool Create(wxWindow *parent, int flags = wxBORDER_NONE)
{
return wxPopupWindowBase::Create(parent) &&
wxWindow::Create(parent, -1,
wxDefaultPosition, wxDefaultSize,
(flags & wxBORDER_MASK) | wxPOPUP_WINDOW);
}
protected:
virtual void DoGetPosition(int *x, int *y) const
{
// the position of a "top level" window such as this should be in
// screen coordinates, not in the client ones which MSW gives us
// (because we are a child window)
wxPopupWindowBase::DoGetPosition(x, y);
GetParent()->ClientToScreen(x, y);
}
DECLARE_DYNAMIC_CLASS(wxPopupWindow)
};
#endif // _WX_MSW_POPUPWIN_H_

56
include/wx/x11/print.h Normal file
View File

@@ -0,0 +1,56 @@
/////////////////////////////////////////////////////////////////////////////
// Name: print.h
// Purpose: wxPrinter, wxPrintPreview classes
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRINT_H_
#define _WX_PRINT_H_
#ifdef __GNUG__
#pragma interface "print.h"
#endif
#include "wx/prntbase.h"
/*
* Represents the printer: manages printing a wxPrintout object
*/
class WXDLLEXPORT wxPrinter: public wxPrinterBase
{
DECLARE_DYNAMIC_CLASS(wxPrinter)
public:
wxPrinter(wxPrintData *data = NULL);
~wxPrinter();
virtual bool Print(wxWindow *parent, wxPrintout *printout, bool prompt = TRUE);
virtual bool PrintDialog(wxWindow *parent);
virtual bool Setup(wxWindow *parent);
};
/*
* wxPrintPreview
* Programmer creates an object of this class to preview a wxPrintout.
*/
class WXDLLEXPORT wxPrintPreview: public wxPrintPreviewBase
{
DECLARE_CLASS(wxPrintPreview)
public:
wxPrintPreview(wxPrintout *printout, wxPrintout *printoutForPrinting = NULL, wxPrintData *data = NULL);
~wxPrintPreview();
virtual bool Print(bool interactive);
virtual void DetermineScaling();
};
#endif
// _WX_PRINT_H_

120
include/wx/x11/private.h Normal file
View File

@@ -0,0 +1,120 @@
/////////////////////////////////////////////////////////////////////////////
// Name: private.h
// Purpose: Private declarations for wxMotif port
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_PRIVATE_H_
#define _WX_PRIVATE_H_
#include "wx/defs.h"
class wxMouseEvent;
class wxKeyEvent;
// Put any private declarations here: native Motif types may be used because
// this header is included after Xm/Xm.h
// ----------------------------------------------------------------------------
// common callbacks
// ----------------------------------------------------------------------------
// All widgets should have this as their resize proc.
extern void wxWidgetResizeProc(Widget w, XConfigureEvent *event, String args[], int *num_args);
// For repainting arbitrary windows
void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *);
// ----------------------------------------------------------------------------
// we maintain a hash table which contains the mapping from Widget to wxWindow
// corresponding to the window for this widget
// ----------------------------------------------------------------------------
extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win);
// ----------------------------------------------------------------------------
// key events related functions
// ----------------------------------------------------------------------------
extern char wxFindMnemonic(const char* s);
extern char * wxFindAccelerator (const char *s);
extern XmString wxFindAcceleratorText (const char *s);
extern int wxCharCodeXToWX(KeySym keySym);
extern KeySym wxCharCodeWXToX(int id);
// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions - translate Motif event to wxWindow one
// ----------------------------------------------------------------------------
extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent);
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap);
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
extern XColor g_itemColors[];
extern int wxComputeColours (Display *display, wxColour * back, wxColour * fore);
extern void wxDoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
#define wxNO_COLORS 0x00
#define wxBACK_COLORS 0x01
#define wxFORE_COLORS 0x02
extern XColor itemColors[5] ;
#define wxBACK_INDEX 0
#define wxFORE_INDEX 1
#define wxSELE_INDEX 2
#define wxTOPS_INDEX 3
#define wxBOTS_INDEX 4
// ----------------------------------------------------------------------------
// utility classes
// ----------------------------------------------------------------------------
// XmString made easy to use in wxWindows (and has an added benefit of
// cleaning up automatically)
class wxXmString
{
public:
wxXmString(const wxString& str)
{
m_string = XmStringCreateLtoR((char *)str.c_str(),
XmSTRING_DEFAULT_CHARSET);
}
~wxXmString() { XmStringFree(m_string); }
// semi-implicit conversion to XmString (shouldn't rely on implicit
// conversion because many of Motif functions are macros)
XmString operator()() const { return m_string; }
private:
XmString m_string;
};
// ----------------------------------------------------------------------------
// macros to avoid casting WXFOO to Foo all the time
// ----------------------------------------------------------------------------
// argument is of type "wxWindow *"
#define GetWidget(w) ((Widget)(w)->GetHandle())
// ----------------------------------------------------------------------------
// accessors for C modules
// ----------------------------------------------------------------------------
extern "C" XtAppContext wxGetAppContext();
#endif
// _WX_PRIVATE_H_

155
include/wx/x11/region.h Normal file
View File

@@ -0,0 +1,155 @@
/////////////////////////////////////////////////////////////////////////////
// Name: region.h
// Purpose: wxRegion class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_REGION_H_
#define _WX_REGION_H_
#ifdef __GNUG__
#pragma interface "region.h"
#endif
#include "wx/list.h"
#include "wx/gdiobj.h"
#include "wx/gdicmn.h"
// ----------------------------------------------------------------------------
// A list of rectangles type used by wxRegion and wxWindow
// ----------------------------------------------------------------------------
WX_DECLARE_LIST(wxRect, wxRectList);
enum wxRegionContain {
wxOutRegion = 0, wxPartRegion = 1, wxInRegion = 2
};
// So far, for internal use only
enum wxRegionOp {
wxRGN_AND, // Creates the intersection of the two combined regions.
wxRGN_COPY, // Creates a copy of the region identified by hrgnSrc1.
wxRGN_DIFF, // Combines the parts of hrgnSrc1 that are not part of hrgnSrc2.
wxRGN_OR, // Creates the union of two combined regions.
wxRGN_XOR // Creates the union of two combined regions except for any overlapping areas.
};
class WXDLLEXPORT wxRegion : public wxGDIObject {
DECLARE_DYNAMIC_CLASS(wxRegion)
friend class WXDLLEXPORT wxRegionIterator;
public:
wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h);
wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight);
wxRegion(const wxRect& rect);
wxRegion();
~wxRegion();
//# Copying
inline wxRegion(const wxRegion& r)
{ Ref(r); }
inline wxRegion& operator = (const wxRegion& r)
{ Ref(r); return (*this); }
//# Modify region
// Clear current region
void Clear();
// Union rectangle or region with this.
inline bool Union(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_OR); }
inline bool Union(const wxRect& rect) { return Combine(rect, wxRGN_OR); }
inline bool Union(const wxRegion& region) { return Combine(region, wxRGN_OR); }
// Intersect rectangle or region with this.
inline bool Intersect(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_AND); }
inline bool Intersect(const wxRect& rect) { return Combine(rect, wxRGN_AND); }
inline bool Intersect(const wxRegion& region) { return Combine(region, wxRGN_AND); }
// Subtract rectangle or region from this:
// Combines the parts of 'this' that are not part of the second region.
inline bool Subtract(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_DIFF); }
inline bool Subtract(const wxRect& rect) { return Combine(rect, wxRGN_DIFF); }
inline bool Subtract(const wxRegion& region) { return Combine(region, wxRGN_DIFF); }
// XOR: the union of two combined regions except for any overlapping areas.
inline bool Xor(wxCoord x, wxCoord y, wxCoord width, wxCoord height) { return Combine(x, y, width, height, wxRGN_XOR); }
inline bool Xor(const wxRect& rect) { return Combine(rect, wxRGN_XOR); }
inline bool Xor(const wxRegion& region) { return Combine(region, wxRGN_XOR); }
//# Information on region
// Outer bounds of region
void GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const;
wxRect GetBox() const ;
// Is region empty?
bool Empty() const;
inline bool IsEmpty() const { return Empty(); }
bool Ok() const { return (m_refData != NULL) ; }
//# Tests
// Does the region contain the point (x,y)?
wxRegionContain Contains(wxCoord x, wxCoord y) const;
// Does the region contain the point pt?
wxRegionContain Contains(const wxPoint& pt) const;
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const;
// Does the region contain the rectangle rect?
wxRegionContain Contains(const wxRect& rect) const;
// Internal
bool Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op);
bool Combine(const wxRegion& region, wxRegionOp op);
bool Combine(const wxRect& rect, wxRegionOp op);
// Get the internal Region handle
WXRegion GetXRegion() const;
// 'Naughty' functions that allow wxWindows to use a list of rects
// instead of the region, in certain circumstances (e.g. when
// making a region out of the update rectangles).
// These are used by wxPaintDC::wxPaintDC and wxRegionIterator::Reset.
bool UsingRects() const;
wxRect* GetRects();
int GetRectCount() const;
void SetRects(const wxRectList& rectList);
void SetRects(int count, const wxRect* rects);
};
class WXDLLEXPORT wxRegionIterator : public wxObject {
DECLARE_DYNAMIC_CLASS(wxRegionIterator)
public:
wxRegionIterator();
wxRegionIterator(const wxRegion& region);
~wxRegionIterator();
void Reset() { m_current = 0; }
void Reset(const wxRegion& region);
operator bool () const { return m_current < m_numRects; }
bool HaveRects() const { return m_current < m_numRects; }
void operator ++ ();
void operator ++ (int);
wxCoord GetX() const;
wxCoord GetY() const;
wxCoord GetW() const;
wxCoord GetWidth() const { return GetW(); }
wxCoord GetH() const;
wxCoord GetHeight() const { return GetH(); }
wxRect GetRect() const { return wxRect(GetX(), GetY(), GetWidth(), GetHeight()); }
private:
size_t m_current;
size_t m_numRects;
wxRegion m_region;
wxRect* m_rects;
};
#endif
// _WX_REGION_H_

44
include/wx/x11/timer.h Normal file
View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: timer.h
// Purpose: wxTimer class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TIMER_H_
#define _WX_TIMER_H_
#ifdef __GNUG__
#pragma interface "timer.h"
#endif
class WXDLLEXPORT wxTimer : public wxTimerBase
{
friend void wxTimerCallback(wxTimer * timer);
public:
wxTimer() { Init(); }
wxTimer(wxEvtHandler *owner, int id = -1) : wxTimerBase(owner, id)
{ Init(); }
~wxTimer();
virtual bool Start(int milliseconds = -1, bool oneShot = FALSE);
virtual void Stop();
virtual bool IsRunning() const { return m_id != 0; }
protected:
void Init();
long m_id;
private:
DECLARE_DYNAMIC_CLASS(wxTimer)
};
#endif
// _WX_TIMER_H_

82
include/wx/x11/toolbar.h Normal file
View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/toolbar.h
// Purpose: wxToolBar class
// Author: Julian Smart
// Modified by: 13.12.99 by VZ during toolbar classes reorganization
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOOLBAR_H_
#define _WX_TOOLBAR_H_
#ifdef __GNUG__
#pragma interface "toolbar.h"
#endif
class WXDLLEXPORT wxToolBar : public wxToolBarBase
{
public:
// ctors and dtor
wxToolBar() { Init(); }
wxToolBar(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr)
{
Init();
Create(parent, id, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxNO_BORDER | wxTB_HORIZONTAL,
const wxString& name = wxToolBarNameStr);
virtual ~wxToolBar();
// override/implement base class virtuals
virtual wxToolBarToolBase *FindToolForPosition(wxCoord x, wxCoord y) const;
virtual bool Realize();
// implementation from now on
// find tool by widget
wxToolBarToolBase *FindToolByWidget(WXWidget w) const;
protected:
// common part of all ctors
void Init();
// implement base class pure virtuals
virtual bool DoInsertTool(size_t pos, wxToolBarToolBase *tool);
virtual bool DoDeleteTool(size_t pos, wxToolBarToolBase *tool);
virtual void DoEnableTool(wxToolBarToolBase *tool, bool enable);
virtual void DoToggleTool(wxToolBarToolBase *tool, bool toggle);
virtual void DoSetToggle(wxToolBarToolBase *tool, bool toggle);
virtual wxToolBarToolBase *CreateTool(int id,
const wxBitmap& bitmap1,
const wxBitmap& bitmap2,
bool toggle,
wxObject *clientData,
const wxString& shortHelpString,
const wxString& longHelpString);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
private:
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#endif
// _WX_TOOLBAR_H_

134
include/wx/x11/toplevel.h Normal file
View File

@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/frame.h
// Purpose: wxFrame class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_FRAME_H_
#define _WX_MOTIF_FRAME_H_
#ifdef __GNUG__
#pragma interface "frame.h"
#endif
class WXDLLEXPORT wxFrame : public wxFrameBase
{
public:
wxFrame() { Init(); }
wxFrame(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr)
{
Init();
Create(parent, id, title, pos, size, style, name);
}
bool Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_FRAME_STYLE,
const wxString& name = wxFrameNameStr);
virtual ~wxFrame();
virtual bool Show(bool show = TRUE);
// Set menu bar
void SetMenuBar(wxMenuBar *menu_bar);
// Set title
void SetTitle(const wxString& title);
wxString GetTitle() const { return m_title; }
// Set icon
virtual void SetIcon(const wxIcon& icon);
#if wxUSE_STATUSBAR
virtual void PositionStatusBar();
#endif // wxUSE_STATUSBAR
// Create toolbar
#if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = wxNO_BORDER|wxTB_HORIZONTAL, wxWindowID id = -1, const wxString& name = wxToolBarNameStr);
virtual void PositionToolBar();
#endif // wxUSE_TOOLBAR
// Iconize
virtual void Iconize(bool iconize);
virtual bool IsIconized() const;
// Is the frame maximized? Returns FALSE under Motif (but TRUE for
// wxMDIChildFrame due to the tabbed implementation).
virtual bool IsMaximized() const;
virtual void Maximize(bool maximize);
virtual void Raise();
virtual void Lower();
virtual void Restore();
// Implementation only from now on
// -------------------------------
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnActivate(wxActivateEvent& event);
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
WXWidget GetMenuBarWidget() const;
WXWidget GetShellWidget() const { return m_frameShell; }
WXWidget GetWorkAreaWidget() const { return m_workArea; }
WXWidget GetClientAreaWidget() const { return m_clientArea; }
WXWidget GetTopWidget() const { return m_frameShell; }
virtual WXWidget GetMainWidget() const { return m_frameWidget; }
// The widget that can have children on it
WXWidget GetClientWidget() const;
bool GetVisibleStatus() const { return m_visibleStatus; }
bool PreResize();
protected:
// common part of all ctors
void Init();
//// Motif-specific
WXWidget m_frameShell;
WXWidget m_frameWidget;
WXWidget m_workArea;
WXWidget m_clientArea;
wxString m_title;
bool m_visibleStatus;
bool m_iconized;
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoGetSize(int *width, int *height) const;
virtual void DoGetPosition(int *x, int *y) const;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame)
};
#endif
// _WX_MOTIF_FRAME_H_

358
include/wx/x11/window.h Normal file
View File

@@ -0,0 +1,358 @@
/////////////////////////////////////////////////////////////////////////////
// Name: window.h
// Purpose: wxWindow class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_WINDOW_H_
#define _WX_WINDOW_H_
#ifdef __GNUG__
#pragma interface "window.h"
#endif
#include "wx/region.h"
// ----------------------------------------------------------------------------
// wxWindow class for Motif - see also wxWindowBase
// ----------------------------------------------------------------------------
class wxWindow : public wxWindowBase
{
friend class WXDLLEXPORT wxDC;
friend class WXDLLEXPORT wxWindowDC;
public:
wxWindow() { Init(); }
wxWindow(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr)
{
Init();
Create(parent, id, pos, size, style, name);
}
virtual ~wxWindow();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
// implement base class pure virtuals
virtual void SetTitle( const wxString& title);
virtual wxString GetTitle() const;
virtual void Raise();
virtual void Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual void SetFocus();
virtual void WarpPointer(int x, int y);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Clear();
virtual bool SetBackgroundColour( const wxColour &colour );
virtual bool SetForegroundColour( const wxColour &colour );
virtual bool SetCursor( const wxCursor &cursor );
virtual bool SetFont( const wxFont &font );
virtual int GetCharHeight() const;
virtual int GetCharWidth() const;
virtual void GetTextExtent(const wxString& string,
int *x, int *y,
int *descent = (int *) NULL,
int *externalLeading = (int *) NULL,
const wxFont *theFont = (const wxFont *) NULL)
const;
virtual void SetScrollbar( int orient, int pos, int thumbVisible,
int range, bool refresh = TRUE );
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual int GetScrollPos( int orient ) const;
virtual int GetScrollThumb( int orient ) const;
virtual int GetScrollRange( int orient ) const;
virtual void ScrollWindow( int dx, int dy,
const wxRect* rect = (wxRect *) NULL );
virtual void SetSizeHints(int minW, int minH,
int maxW = -1, int maxH = -1,
int incW = -1, int incH = -1);
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP
// Accept files for dragging
virtual void DragAcceptFiles(bool accept);
// Get the unique identifier of a window
virtual WXWidget GetHandle() const { return GetMainWidget(); }
// implementation from now on
// --------------------------
// accessors
// ---------
// Get main widget for this window, e.g. a text widget
virtual WXWidget GetMainWidget() const;
// Get the widget that corresponds to the label (for font setting, label setting etc.)
virtual WXWidget GetLabelWidget() const;
// Get the client widget for this window (something we can create other
// windows on)
virtual WXWidget GetClientWidget() const;
// Get the top widget for this window, e.g. the scrolled widget parent of a
// multi-line text widget. Top means, top in the window hierarchy that
// implements this window.
virtual WXWidget GetTopWidget() const;
// Get the underlying X window and display
WXWindow GetXWindow() const;
WXDisplay *GetXDisplay() const;
// called from Motif callbacks - and should only be called from there
void SetButton1(bool pressed) { m_button1Pressed = pressed; }
void SetButton2(bool pressed) { m_button2Pressed = pressed; }
void SetButton3(bool pressed) { m_button3Pressed = pressed; }
void SetLastClick(int button, long timestamp)
{ m_lastButton = button; m_lastTS = timestamp; }
int GetLastClickedButton() const { return m_lastButton; }
long GetLastClickTime() const { return m_lastTS; }
// Gives window a chance to do something in response to a size message, e.g.
// arrange status bar, toolbar etc.
virtual bool PreResize();
// Generates a paint event
virtual void DoPaint();
// update rectangle/region manipulation
// (for wxWindowDC and Motif callbacks only)
// -----------------------------------------
// read/write access to the update rect list
const wxRectList& GetUpdateRects() const { return m_updateRects; }
// Adds a recangle to the updates list
void AddUpdateRect(int x, int y, int w, int h)
{ m_updateRects.Append(new wxRect(x, y, w, h)); }
// Empties the m_updateRects list
void ClearUpdateRects();
void ClearUpdateRegion() { m_updateRegion.Clear(); }
void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; }
// sets the fore/background colour for the given widget
static void DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour);
static void DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour = FALSE);
// For implementation purposes - sometimes decorations make the client area
// smaller
virtual wxPoint GetClientAreaOrigin() const;
protected:
// event handlers (not virtual by design)
void OnIdle(wxIdleEvent& event);
// Makes an adjustment to the window position (for example, a frame that has
// a toolbar that it manages itself).
virtual void AdjustForParentClientOrigin(int& x, int& y, int sizeFlags);
wxWindow *GetChild(int number) const
{ return GetChildren().Item(number)->GetData(); }
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Motif-specific
// CanvasXXXSiize functions
void CanvasGetSize(int* width, int* height) const; // If have drawing area
void CanvasGetClientSize(int *width, int *height) const;
void CanvasGetPosition(int *x, int *y) const; // If have drawing area
void CanvasSetClientSize(int width, int size);
void CanvasSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
void SetMainWidget(WXWidget w) { m_mainWidget = w; }
bool CanAddEventHandler() const { return m_canAddEventHandler; }
void SetCanAddEventHandler(bool flag) { m_canAddEventHandler = flag; }
public:
WXPixmap GetBackingPixmap() const { return m_backingPixmap; }
void SetBackingPixmap(WXPixmap pixmap) { m_backingPixmap = pixmap; }
int GetPixmapWidth() const { return m_pixmapWidth; }
int GetPixmapHeight() const { return m_pixmapHeight; }
void SetPixmapWidth(int w) { m_pixmapWidth = w; }
void SetPixmapHeight(int h) { m_pixmapHeight = h; }
// Change properties
virtual void ChangeFont(bool keepOriginalSize = TRUE); // Change to the current font (often overridden)
// Change background and foreground colour using current background colour
// setting (Motif generates foreground based on background)
virtual void ChangeBackgroundColour();
// Change foreground colour using current foreground colour setting
virtual void ChangeForegroundColour();
protected:
// Adds the widget to the hash table and adds event handlers.
bool AttachWidget(wxWindow* parent, WXWidget mainWidget,
WXWidget formWidget, int x, int y, int width, int height);
bool DetachWidget(WXWidget widget);
// How to implement accelerators. If we find a key event, translate to
// wxWindows wxKeyEvent form. Find a widget for the window. Now find a
// wxWindow for the widget. If there isn't one, go up the widget hierarchy
// trying to find one. Once one is found, call ProcessAccelerator for the
// window. If it returns TRUE (processed the event), skip the X event,
// otherwise carry on up the wxWindows window hierarchy calling
// ProcessAccelerator. If all return FALSE, process the X event as normal.
// Eventually we can implement OnCharHook the same way, but concentrate on
// accelerators for now. ProcessAccelerator must look at the current
// accelerator table, and try to find what menu id or window (beneath it)
// has this ID. Then construct an appropriate command
// event and send it.
public:
virtual bool ProcessAccelerator(wxKeyEvent& event);
protected:
// unmanage and destroy an X widget f it's !NULL (passing NULL is ok)
void UnmanageAndDestroy(WXWidget widget);
// map or unmap an X widget (passing NULL is ok), returns TRUE if widget was
// mapped/unmapped
bool MapOrUnmap(WXWidget widget, bool map);
// scrolling stuff
// ---------------
// create/destroy window scrollbars
void CreateScrollbar(wxOrientation orientation);
void DestroyScrollbar(wxOrientation orientation);
// get either hor or vert scrollbar widget
WXWidget GetScrollbar(wxOrientation orient) const
{ return orient == wxHORIZONTAL ? m_hScrollBar : m_vScrollBar; }
// set the scroll pos
void SetInternalScrollPos(wxOrientation orient, int pos)
{
if ( orient == wxHORIZONTAL )
m_scrollPosX = pos;
else
m_scrollPosY = pos;
}
// Motif-specific flags
// --------------------
bool m_needsRefresh:1; // repaint backing store?
bool m_canAddEventHandler:1; // ???
bool m_button1Pressed:1;
bool m_button2Pressed:1;
bool m_button3Pressed:1;
// For double-click detection
long m_lastTS; // last timestamp
int m_lastButton; // last pressed button
// List of wxRects representing damaged region
wxRectList m_updateRects;
protected:
WXWidget m_mainWidget;
WXWidget m_hScrollBar;
WXWidget m_vScrollBar;
WXWidget m_borderWidget;
WXWidget m_scrolledWindow;
WXWidget m_drawingArea;
bool m_winCaptured;
bool m_hScroll;
bool m_vScroll;
WXPixmap m_backingPixmap;
int m_pixmapWidth;
int m_pixmapHeight;
int m_pixmapOffsetX;
int m_pixmapOffsetY;
// Store the last scroll pos, since in wxWin the pos isn't set automatically
// by system
int m_scrollPosX;
int m_scrollPosY;
// implement the base class pure virtuals
virtual void DoClientToScreen( int *x, int *y ) const;
virtual void DoScreenToClient( int *x, int *y ) const;
virtual void DoGetPosition( int *x, int *y ) const;
virtual void DoGetSize( int *width, int *height ) const;
virtual void DoGetClientSize( int *width, int *height ) const;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoSetClientSize(int width, int height);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual bool DoPopupMenu(wxMenu *menu, int x, int y);
virtual void DoCaptureMouse();
virtual void DoReleaseMouse();
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
private:
// common part of all ctors
void Init();
DECLARE_DYNAMIC_CLASS(wxWindow)
DECLARE_NO_COPY_CLASS(wxWindow)
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// A little class to switch off `size optimization' while an instance of the
// object exists: this may be useful to temporarily disable the optimisation
// which consists to do nothing when the new size is equal to the old size -
// although quite useful usually to avoid flicker, sometimes it leads to
// undesired effects.
//
// Usage: create an instance of this class on the stack to disable the size
// optimisation, it will be reenabled as soon as the object goes out from scope.
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNoOptimize
{
public:
wxNoOptimize() { ms_count++; }
~wxNoOptimize() { ms_count--; }
static bool CanOptimize() { return ms_count == 0; }
protected:
static int ms_count;
};
#endif
// _WX_WINDOW_H_

116
src/x11/accel.cpp Normal file
View File

@@ -0,0 +1,116 @@
/////////////////////////////////////////////////////////////////////////////
// Name: accel.cpp
// Purpose: wxAcceleratorTable
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "accel.h"
#endif
#include "wx/setup.h"
#include "wx/accel.h"
#include "wx/string.h"
#include "wx/utils.h"
#include <ctype.h>
IMPLEMENT_DYNAMIC_CLASS(wxAcceleratorTable, wxObject)
class WXDLLEXPORT wxAcceleratorRefData: public wxObjectRefData
{
friend class WXDLLEXPORT wxAcceleratorTable;
public:
wxAcceleratorRefData();
~wxAcceleratorRefData();
public:
int m_count;
wxAcceleratorEntry* m_entries;
};
#define M_ACCELDATA ((wxAcceleratorRefData *)m_refData)
wxAcceleratorRefData::wxAcceleratorRefData()
{
m_count = 0;
m_entries = (wxAcceleratorEntry*) NULL;
}
wxAcceleratorRefData::~wxAcceleratorRefData()
{
delete[] m_entries;
m_entries = (wxAcceleratorEntry*) NULL;
m_count = 0;
}
wxAcceleratorTable::wxAcceleratorTable()
{
m_refData = (wxAcceleratorRefData*) NULL;
}
wxAcceleratorTable::~wxAcceleratorTable()
{
// Data deleted in ~wxObject
}
// Load from .rc resource
wxAcceleratorTable::wxAcceleratorTable(const wxString& WXUNUSED(resource))
{
m_refData = new wxAcceleratorRefData;
}
// Create from an array
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
{
return (m_refData != (wxAcceleratorRefData*) NULL);
}
int wxAcceleratorTable::GetCount() const
{
return M_ACCELDATA->m_count;
}
wxAcceleratorEntry* wxAcceleratorTable::GetEntries() const
{
return M_ACCELDATA->m_entries;
}
// Implementation use only
bool wxAcceleratorEntry::MatchesEvent(const wxKeyEvent& event) const
{
bool eventAltDown = event.AltDown();
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 = tolower(accKeyCode2);
return ((eventAltDown == accAltDown) && (eventCtrlDown == accCtrlDown) &&
(eventShiftDown == accShiftDown) &&
((eventKeyCode == accKeyCode || eventKeyCode == accKeyCode2))) ;
}

796
src/x11/app.cpp Normal file
View File

@@ -0,0 +1,796 @@
/////////////////////////////////////////////////////////////////////////////
// Name: app.cpp
// Purpose: wxApp
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "app.h"
#endif
#ifdef __VMS
#define XtParent XTPARENT
#define XtDisplay XTDISPLAY
#endif
#include "wx/frame.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/gdicmn.h"
#include "wx/pen.h"
#include "wx/brush.h"
#include "wx/cursor.h"
#include "wx/icon.h"
#include "wx/palette.h"
#include "wx/dc.h"
#include "wx/dialog.h"
#include "wx/msgdlg.h"
#include "wx/log.h"
#include "wx/module.h"
#include "wx/memory.h"
#include "wx/log.h"
#include "wx/intl.h"
#if wxUSE_THREADS
#include "wx/thread.h"
#endif
#if wxUSE_WX_RESOURCES
#include "wx/resource.h"
#endif
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <X11/Xatom.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
#include <string.h>
extern char *wxBuffer;
extern wxList wxPendingDelete;
wxApp *wxTheApp = NULL;
wxHashTable *wxWidgetHashTable = NULL;
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxApp::OnIdle)
END_EVENT_TABLE()
#ifdef __WXDEBUG__
typedef int (*XErrorHandlerFunc)(Display *, XErrorEvent *);
XErrorHandlerFunc gs_pfnXErrorHandler = 0;
static int wxXErrorHandler(Display *dpy, XErrorEvent *xevent)
{
// just forward to the default handler for now
return gs_pfnXErrorHandler(dpy, xevent);
}
#endif // __WXDEBUG__
long wxApp::sm_lastMessageTime = 0;
bool wxApp::Initialize()
{
wxBuffer = new char[BUFSIZ + 512];
wxClassInfo::InitializeClasses();
// GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
#if wxUSE_THREADS
wxPendingEventsLocker = new wxCriticalSection();
#endif
wxTheColourDatabase = new wxColourDatabase(wxKEY_STRING);
wxTheColourDatabase->Initialize();
wxInitializeStockLists();
wxInitializeStockObjects();
#if wxUSE_WX_RESOURCES
wxInitializeResourceSystem();
#endif
// For PostScript printing
#if wxUSE_POSTSCRIPT
/* 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;
}
void wxApp::CleanUp()
{
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
wxModule::CleanUpModules();
#if wxUSE_WX_RESOURCES
wxCleanUpResourceSystem();
#endif
wxDeleteStockObjects() ;
// Destroy all GDI lists, etc.
wxDeleteStockLists();
delete wxTheColourDatabase;
wxTheColourDatabase = NULL;
#if wxUSE_POSTSCRIPT
/* Done using wxModule now
wxInitializePrintSetupData(FALSE);
delete wxThePrintPaperDatabase;
wxThePrintPaperDatabase = NULL;
*/
#endif
wxBitmap::CleanUpHandlers();
delete[] wxBuffer;
wxBuffer = NULL;
wxClassInfo::CleanUpClasses();
delete wxTheApp;
wxTheApp = NULL;
// GL: I'm annoyed ... I don't know where to put this and I don't want to
// create a module for that as it's part of the core.
#if wxUSE_THREADS
delete wxPendingEvents;
delete wxPendingEventsLocker;
#endif
#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,
// as a special case. Then when dumping we need to ignore
// wxDebugContext, too.
if (wxDebugContext::CountObjectsLeft(TRUE) > 0)
{
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
delete wxLog::SetActiveTarget(NULL);
}
int wxEntry( int argc, char *argv[] )
{
#if (defined(__WXDEBUG__) && wxUSE_MEMORY_TRACING) || wxUSE_DEBUG_CONTEXT
// This seems to be necessary since there are 'rogue'
// objects present at this point (perhaps global objects?)
// Setting a checkpoint will ignore them as far as the
// memory checking facility is concerned.
// Of course you may argue that memory allocated in globals should be
// 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 (!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();
}
// flush the logged messages if any
wxLog *pLog = wxLog::GetActiveTarget();
if ( pLog != NULL && pLog->HasPendingMessages() )
pLog->Flush();
delete wxLog::SetActiveTarget(new wxLogStderr); // So dialog boxes aren't used
// for further messages
if (wxTheApp->GetTopWindow())
{
delete wxTheApp->GetTopWindow();
wxTheApp->SetTopWindow(NULL);
}
wxTheApp->DeletePendingObjects();
wxTheApp->OnExit();
wxApp::CleanUp();
return retValue;
};
// Static member initialization
wxAppInitializerFunction wxAppBase::m_appInitFn = (wxAppInitializerFunction) NULL;
wxApp::wxApp()
{
m_topWindow = NULL;
wxTheApp = this;
m_className = "";
m_wantDebugOutput = TRUE ;
m_appName = "";
argc = 0;
argv = NULL;
m_exitOnFrameDelete = TRUE;
m_mainColormap = (WXColormap) NULL;
m_appContext = (WXAppContext) NULL;
m_topLevelWidget = (WXWidget) NULL;
m_maxRequestSize = 0;
m_initialDisplay = (WXDisplay*) 0;
}
bool wxApp::Initialized()
{
if (GetTopWindow())
return TRUE;
else
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);
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())
{
#if wxUSE_THREADS
// leave the main loop to give other threads a chance to
// perform their GUI work
wxMutexGuiLeave();
wxUsleep(20);
wxMutexGuiEnter();
#endif
}
}
}
return 0;
}
// Processes an X event.
void wxApp::ProcessXEvent(WXEvent* _event)
{
XEvent* event = (XEvent*) _event;
if (event->type == KeyPress)
{
#if 0 // def __WXDEBUG__
Widget widget = XtWindowToWidget(event->xany.display, event->xany.window);
wxLogDebug("Got key press event for 0x%08x (parent = 0x%08x)",
widget, XtParent(widget));
#endif // DEBUG
if (CheckForAccelerator(_event))
{
// Do nothing! We intercepted and processed the event as an
// accelerator.
return;
}
#if 1
// It seemed before that this hack was redundant and
// key down events were being generated by wxCanvasInputEvent.
// But no longer - why ???
//
else if (CheckForKeyDown(_event))
{
// We intercepted and processed the key down event
return;
}
#endif
else
{
XtDispatchEvent(event);
return;
}
}
else if (event->type == KeyRelease)
{
// TODO: work out why we still need this ! -michael
//
if (CheckForKeyUp(_event))
{
// We intercepted and processed the key up event
return;
}
else
{
XtDispatchEvent(event);
return;
}
}
else if (event->type == PropertyNotify)
{
HandlePropertyChange(_event);
return;
}
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.
*/
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
{
XtDispatchEvent(event);
}
}
// Returns TRUE if more time is needed.
bool wxApp::ProcessIdle()
{
wxIdleEvent event;
event.SetEventObject(this);
ProcessEvent(event);
return event.MoreRequested();
}
void wxApp::ExitMainLoop()
{
m_keepGoing = FALSE;
}
// Is a message/event pending?
bool wxApp::Pending()
{
XFlush(XtDisplay( (Widget) wxTheApp->GetTopLevelWidget() ));
// Fix by Doug from STI, to prevent a stall if non-X event
// is found.
return ((XtAppPending( (XtAppContext) GetAppContext() ) & XtIMXEvent) != 0) ;
}
// Dispatch a message.
void wxApp::Dispatch()
{
// XtAppProcessEvent( (XtAppContext) wxTheApp->GetAppContext(), XtIMAll);
XEvent event;
XtAppNextEvent((XtAppContext) GetAppContext(), &event);
ProcessXEvent((WXEvent*) & event);
}
// This should be redefined in a derived class for
// handling property change events for XAtom IPC.
void wxApp::HandlePropertyChange(WXEvent *event)
{
// by default do nothing special
XtDispatchEvent((XEvent*) event); /* let Motif do the work */
}
void wxApp::OnIdle(wxIdleEvent& event)
{
static bool inOnIdle = FALSE;
// Avoid recursion (via ProcessEvent default case)
if (inOnIdle)
return;
inOnIdle = TRUE;
// If there are pending events, we must process them: pending events
// are either events to the threads other than main or events posted
// with wxPostEvent() functions
// GRG: I have moved this here so that all pending events are processed
// before starting to delete any objects. This behaves better (in
// particular, wrt wxPostEvent) and is coherent with wxGTK's current
// behaviour. Also removed the '#if wxUSE_THREADS' around it.
// Changed Mar/2000 before 2.1.14
// Flush pending events.
ProcessPendingEvents();
// '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();
// Send OnIdle events to all windows
bool needMore = SendIdleEvents();
if (needMore)
event.RequestMore(TRUE);
inOnIdle = FALSE;
}
void wxWakeUpIdle()
{
// **** please implement me! ****
// Wake up the idle handler processor, even if it is in another thread...
}
// Send idle event to all top-level windows
bool wxApp::SendIdleEvents()
{
bool needMore = FALSE;
wxWindowList::Node* node = wxTopLevelWindows.GetFirst();
while (node)
{
wxWindow* win = node->GetData();
if (SendIdleEvents(win))
needMore = TRUE;
node = node->GetNext();
}
return needMore;
}
// Send idle event to window and all subwindows
bool wxApp::SendIdleEvents(wxWindow* win)
{
bool needMore = FALSE;
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))
needMore = TRUE;
node = node->Next();
}
return needMore ;
}
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();
}
}
// Create an application context
bool wxApp::OnInitGui()
{
XtToolkitInitialize() ;
wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext() ;
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
(const char*) wxTheApp->GetClassName(), NULL, 0,
# if XtSpecificationRelease < 5
(Cardinal*) &argc,
# else
&argc,
# endif
argv);
if (!dpy) {
wxString className(wxTheApp->GetClassName());
wxLogError(_("wxWindows could not open display for '%s': exiting."),
(const char*) className);
exit(-1);
}
m_initialDisplay = (WXDisplay*) dpy;
#ifdef __WXDEBUG__
// install the X error handler
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
#endif // __WXDEBUG__
wxTheApp->m_topLevelWidget = (WXWidget) XtAppCreateShell((String)NULL, (const char*) wxTheApp->GetClassName(),
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;
int defaultScreen = DefaultScreen((Display*) display);
Screen* screen = XScreenOfDisplay((Display*) display, defaultScreen);
Colormap c = DefaultColormapOfScreen(screen);
if (!m_mainColormap)
m_mainColormap = (WXColormap) c;
return (WXColormap) c;
}
// Returns TRUE if an accelerator has been processed
bool wxApp::CheckForAccelerator(WXEvent* event)
{
XEvent* xEvent = (XEvent*) event;
if (xEvent->xany.type == KeyPress)
{
// Find a wxWindow for this window
// 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.
while (win)
{
if (win->ProcessAccelerator(keyEvent))
return TRUE;
win = win->GetParent();
}
return FALSE;
}
return FALSE;
}
bool wxApp::CheckForKeyDown(WXEvent* event)
{
XEvent* xEvent = (XEvent*) event;
if (xEvent->xany.type == KeyPress)
{
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
xEvent->xany.window);
wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window
while (widget && !(win = wxGetWindowFromTable(widget)))
widget = XtParent(widget);
if (!widget || !win)
return FALSE;
wxKeyEvent keyEvent(wxEVT_KEY_DOWN);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
return win->ProcessEvent( keyEvent );
}
return FALSE;
}
bool wxApp::CheckForKeyUp(WXEvent* event)
{
XEvent* xEvent = (XEvent*) event;
if (xEvent->xany.type == KeyRelease)
{
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
xEvent->xany.window);
wxWindow* win = NULL;
// Find the first wxWindow that corresponds to this event window
while (widget && !(win = wxGetWindowFromTable(widget)))
widget = XtParent(widget);
if (!widget || !win)
return FALSE;
wxKeyEvent keyEvent(wxEVT_KEY_UP);
wxTranslateKeyEvent(keyEvent, win, (Widget) 0, xEvent);
return win->ProcessEvent( keyEvent );
}
return FALSE;
}
void wxExit()
{
int retValue = 0;
if (wxTheApp)
retValue = wxTheApp->OnExit();
wxApp::CleanUp();
/*
* Exit in some platform-specific way. Not recommended that the app calls this:
* only for emergencies.
*/
exit(retValue);
}
// Yield to other processes
bool wxApp::Yield(bool onlyIfNeeded)
{
bool s_inYield = FALSE;
if ( s_inYield )
{
if ( !onlyIfNeeded )
{
wxFAIL_MSG( wxT("wxYield called recursively" ) );
}
return FALSE;
}
s_inYield = TRUE;
while (wxTheApp && wxTheApp->Pending())
wxTheApp->Dispatch();
s_inYield = FALSE;
return TRUE;
}
// TODO use XmGetPixmap (?) to get the really standard icons!
// XPM hack: make the arrays const
#define static static const
#include "wx/generic/info.xpm"
#include "wx/generic/error.xpm"
#include "wx/generic/question.xpm"
#include "wx/generic/warning.xpm"
#undef static
wxIcon
wxApp::GetStdIcon(int which) const
{
switch(which)
{
case wxICON_INFORMATION:
return wxIcon(info_xpm);
case wxICON_QUESTION:
return wxIcon(question_xpm);
case wxICON_EXCLAMATION:
return wxIcon(warning_xpm);
default:
wxFAIL_MSG("requested non existent standard icon");
// still fall through
case wxICON_HAND:
return wxIcon(error_xpm);
}
}
// ----------------------------------------------------------------------------
// accessors for C modules
// ----------------------------------------------------------------------------
extern "C" XtAppContext wxGetAppContext()
{
return (XtAppContext)wxTheApp->GetAppContext();
}

1558
src/x11/bitmap.cpp Normal file

File diff suppressed because it is too large Load Diff

123
src/x11/brush.cpp Normal file
View File

@@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/motif/brush.cpp
// Purpose: wxBrush
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "brush.h"
#endif
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/brush.h"
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
wxBrushRefData::wxBrushRefData()
{
m_style = wxSOLID;
}
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
wxBrushRefData::~wxBrushRefData()
{
}
// Brushes
wxBrush::wxBrush()
{
}
wxBrush::~wxBrush()
{
}
wxBrush::wxBrush(const wxColour& col, int Style)
{
m_refData = new wxBrushRefData;
M_BRUSHDATA->m_colour = col;
M_BRUSHDATA->m_style = Style;
RealizeResource();
}
wxBrush::wxBrush(const wxBitmap& stipple)
{
m_refData = new wxBrushRefData;
M_BRUSHDATA->m_style = wxSTIPPLE;
M_BRUSHDATA->m_stipple = stipple;
RealizeResource();
}
void wxBrush::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
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();
}
bool wxBrush::RealizeResource()
{
// Nothing more to do
return TRUE;
}

525
src/x11/clipbrd.cpp Normal file
View File

@@ -0,0 +1,525 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.cpp
// Purpose: Clipboard functionality
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
#pragma implementation "clipbrd.h"
#endif
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/bitmap.h"
#include "wx/utils.h"
#include "wx/metafile.h"
#include "wx/clipbrd.h"
#include "wx/dataobj.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <Xm/CutPaste.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include <string.h>
// IMPLEMENT_DYNAMIC_CLASS(wxClipboard, wxObject)
// IMPLEMENT_ABSTRACT_CLASS(wxClipboardClient, wxObject)
static bool gs_clipboardIsOpen = FALSE;
bool wxOpenClipboard()
{
if (!gs_clipboardIsOpen)
{
gs_clipboardIsOpen = TRUE;
return TRUE;
}
else
return FALSE;
}
bool wxCloseClipboard()
{
if (gs_clipboardIsOpen)
{
gs_clipboardIsOpen = FALSE;
return TRUE;
}
else
return FALSE;
}
bool wxEmptyClipboard()
{
// No equivalent in Motif
return TRUE;
}
bool wxClipboardOpen()
{
return gs_clipboardIsOpen;
}
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
// 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(wxDataFormat dataFormat, wxObject *obj, int WXUNUSED(width), int WXUNUSED(height))
{
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(wxDataFormat dataFormat, long *len)
{
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;
}
wxDataFormat wxEnumClipboardFormats(wxDataFormat dataFormat)
{
// Only wxDF_TEXT supported
if (dataFormat == wxDF_TEXT)
return wxDF_TEXT;
else
return wxDF_INVALID;
}
wxDataFormat wxRegisterClipboardFormat(char *WXUNUSED(formatName))
{
// Not supported
return (wxDataFormat) wxDF_INVALID;
}
bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName, int WXUNUSED(maxCount))
{
// Only wxDF_TEXT supported
if (dataFormat == wxDF_TEXT)
{
strcpy(formatName, "TEXT");
return TRUE;
}
else
return FALSE;
}
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
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" );
Clear();
return AddData( data );
}
bool wxClipboard::AddData( wxDataObject *data )
{
wxCHECK_MSG( data, FALSE, "data is invalid" );
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
wxDataFormat::NativeFormat format = data->GetPreferredFormat().GetType();
switch ( format )
{
case wxDF_TEXT:
case wxDF_OEMTEXT:
{
wxTextDataObject* textDataObject = (wxTextDataObject*) data;
wxString str(textDataObject->GetText());
return wxSetClipboardData(format, (wxObject*) (const char*) str);
}
#if 0
case wxDF_BITMAP:
case wxDF_DIB:
{
wxBitmapDataObject* bitmapDataObject = (wxBitmapDataObject*) data;
wxBitmap bitmap(bitmapDataObject->GetBitmap());
return wxSetClipboardData(data->GetType(), & bitmap);
break;
}
#endif // 0
}
return FALSE;
}
void wxClipboard::Close()
{
wxCHECK_RET( m_open, "clipboard not open" );
m_open = FALSE;
wxCloseClipboard();
}
bool wxClipboard::IsSupported( const wxDataFormat& format)
{
return wxIsClipboardFormatAvailable(format);
}
bool wxClipboard::GetData( wxDataObject& data )
{
wxCHECK_MSG( m_open, FALSE, "clipboard not open" );
wxDataFormat::NativeFormat format = data.GetPreferredFormat().GetType();
switch ( format )
{
case wxDF_TEXT:
case wxDF_OEMTEXT:
{
wxTextDataObject& textDataObject = (wxTextDataObject &) data;
char* s = (char*) wxGetClipboardData(format);
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->GetType());
if (bitmap)
{
bitmapDataObject->SetBitmap(* bitmap);
delete bitmap;
return TRUE;
}
else
return FALSE;
break;
}
*/
default:
{
return FALSE;
}
}
return FALSE;
}
#if 0
/*
* Old clipboard implementation by Matthew Flatt
*/
wxClipboard *wxTheClipboard = NULL;
void wxInitClipboard()
{
if (!wxTheClipboard)
wxTheClipboard = new wxClipboard;
}
wxClipboard::wxClipboard()
{
clipOwner = NULL;
cbString = NULL;
}
wxClipboard::~wxClipboard()
{
if (clipOwner)
clipOwner->BeingReplaced();
if (cbString)
delete[] cbString;
}
static int FormatStringToID(char *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;
}
}
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;
}
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;
}
}
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 *wxClipboard::GetClipboardData(char *format, long *length, long time)
{
if (clipOwner) {
if (clipOwner->formats.Member(format))
return clipOwner->GetData(format, length);
else
return NULL;
} else if (cbString) {
if (!strcmp(format, "TEXT"))
return copystring(cbString);
else
return NULL;
} else {
if (wxOpenClipboard()) {
receivedString = (char *)wxGetClipboardData(FormatStringToID(format),
length);
wxCloseClipboard();
} else
receivedString = NULL;
return receivedString;
}
}
#endif
#endif // wxUSE_CLIPBOARD

214
src/x11/colour.cpp Normal file
View File

@@ -0,0 +1,214 @@
/////////////////////////////////////////////////////////////////////////////
// Name: colour.cpp
// Purpose: wxColour class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//// TODO: make wxColour a ref-counted object,
//// so pixel values get shared.
#ifdef __GNUG__
#pragma implementation "colour.h"
#endif
#include "wx/gdicmn.h"
#include "wx/colour.h"
#include "wx/app.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour
wxColour::wxColour ()
{
m_isInit = FALSE;
m_red = m_blue = m_green = 0;
m_pixel = -1;
}
wxColour::wxColour (unsigned char r, unsigned char g, unsigned char b)
{
m_red = r;
m_green = g;
m_blue = b;
m_isInit = TRUE;
m_pixel = -1;
}
wxColour::wxColour (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;
}
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;
}
void wxColour::InitFromName(const wxString& col)
{
wxColour *the_colour = wxTheColourDatabase->FindColour (col);
if (the_colour)
{
m_red = the_colour->Red ();
m_green = the_colour->Green ();
m_blue = the_colour->Blue ();
m_pixel = the_colour->m_pixel;
m_isInit = TRUE;
}
else
{
m_red = 0;
m_green = 0;
m_blue = 0;
m_isInit = FALSE;
}
}
wxColour::~wxColour ()
{
}
void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
{
m_red = r;
m_green = g;
m_blue = b;
m_isInit = TRUE;
m_pixel = -1;
}
// Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return
// the existing one.
// Returns the old or allocated pixel.
// TODO: can this handle mono displays? If not, we should have an extra
// flag to specify whether this should be black or white by default.
int wxColour::AllocColour(WXDisplay* display, bool realloc)
{
if ((m_pixel != -1) && !realloc)
return m_pixel;
XColor color;
color.red = (unsigned short) Red ();
color.red |= color.red << 8;
color.green = (unsigned short) Green ();
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;
}
else
{
m_pixel = (int) color.pixel;
return m_pixel;
}
}
/*-------------------------------------------
Markus Emmenegger <mege@iqe.ethz.ch>
Find the pixel value with an assigned color closest to the desired color
Used if color cell allocation fails
As the returned pixel value may be in use by another application,
the color might change anytime.
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.
2) Attempt to allocate a read-only colour when a close match is found.
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.
-------------------------------------------*/
int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap)
{
if (cmap == (Colormap) NULL)
cmap = (Colormap) wxTheApp->GetMainColormap(display);
int numPixVals = XDisplayCells(display, DefaultScreen (display));
int mindist = 256 * 256 * 3;
int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
int red = desiredColor->red >> 8;
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;
if (dist <= threshold)
{
// try to allocate a read-only colour...
if (XAllocColor (display, cmap, &matching_color))
{
return matching_color.pixel;
}
}
if (dist < mindist)
{
bestpixel = pixelcount;
mindist = dist;
}
}
return bestpixel;
}

440
src/x11/cursor.cpp Normal file
View File

@@ -0,0 +1,440 @@
/////////////////////////////////////////////////////////////////////////////
// Name: cursor.cpp
// Purpose: wxCursor class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "cursor.h"
#endif
#include "wx/cursor.h"
#include "wx/gdicmn.h"
#include "wx/icon.h"
#include "wx/app.h"
#include "wx/utils.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/cursorfont.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxBitmap)
IMPLEMENT_DYNAMIC_CLASS(wxXCursor, wxObject)
wxCursorRefData::wxCursorRefData()
{
m_width = 32; m_height = 32;
m_cursorId = wxCURSOR_NONE;
}
wxCursorRefData::~wxCursorRefData()
{
wxNode* node = m_cursors.First();
while (node)
{
wxXCursor* c = (wxXCursor*) node->Data();
// TODO: how to delete cursor?
// XDestroyCursor((Display*) c->m_display, (Cursor) c->m_cursor); // ??
delete c;
node = node->Next();
}
}
wxCursor::wxCursor()
{
}
wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, const char maskBits[])
{
m_refData = new wxCursorRefData;
Display *dpy = (Display*) wxGetDisplay();
int screen_num = DefaultScreen (dpy);
Pixmap pixmap = XCreatePixmapFromBitmapData (dpy,
RootWindow (dpy, DefaultScreen(dpy)),
(char*) bits, width, height,
1 , 0 , 1);
Pixmap mask_pixmap = None;
if (maskBits != NULL)
{
mask_pixmap = XCreatePixmapFromBitmapData (dpy,
RootWindow (dpy, DefaultScreen(dpy)),
(char*) maskBits, width, height,
1 , 0 , 1);
}
XColor foreground_color;
XColor background_color;
foreground_color.pixel = BlackPixel(dpy, screen_num);
background_color.pixel = WhitePixel(dpy, screen_num);
Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
XQueryColor(dpy, cmap, &foreground_color);
XQueryColor(dpy, cmap, &background_color);
Cursor cursor = XCreatePixmapCursor (dpy,
pixmap,
mask_pixmap,
&foreground_color,
&background_color,
hotSpotX ,
hotSpotY);
XFreePixmap( dpy, pixmap );
if (mask_pixmap != None)
{
XFreePixmap( dpy, mask_pixmap );
}
if (cursor)
{
wxXCursor *c = new wxXCursor;
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
else
{
M_CURSORDATA->m_ok = TRUE;
}
}
wxCursor::wxCursor(const wxString& name, long flags, int hotSpotX, int hotSpotY)
{
// Must be an XBM file
if (flags != wxBITMAP_TYPE_XBM)
return;
m_refData = new wxCursorRefData;
int hotX = -1, hotY = -1;
unsigned int w, h;
Pixmap pixmap;
Display *dpy = (Display*) wxGetDisplay();
int screen_num = DefaultScreen (dpy);
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
(char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;
M_BITMAPDATA->m_depth = 1;
if ((value == BitmapFileInvalid) ||
(value == BitmapOpenFailed) ||
(value == BitmapNoMemory))
{
}
else
{
XColor foreground_color;
XColor background_color;
foreground_color.pixel = BlackPixel(dpy, screen_num);
background_color.pixel = WhitePixel(dpy, screen_num);
Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy);
XQueryColor(dpy, cmap, &foreground_color);
XQueryColor(dpy, cmap, &background_color);
// TODO: how do we determine whether hotX, hotY were read correctly?
if (hotX < 0 || hotY < 0)
{
hotX = hotSpotX;
hotY = hotSpotY;
}
if (hotX < 0 || hotY < 0)
{
hotX = 0;
hotY = 0;
}
Pixmap mask_pixmap = None;
Cursor cursor = XCreatePixmapCursor (dpy,
pixmap,
mask_pixmap,
&foreground_color,
&background_color,
hotX,
hotY);
XFreePixmap( dpy, pixmap );
if (cursor)
{
wxXCursor *c = new wxXCursor;
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
}
}
// Cursors by stock number
wxCursor::wxCursor(wxStockCursor id)
{
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursorId = id;
M_CURSORDATA->m_ok = TRUE;
WXDisplay* display = wxGetDisplay();
if (!display)
return;
WXCursor cursor = GetXCursor(display);
if (cursor)
{
wxXCursor* c = new wxXCursor;
c->m_cursor = cursor;
c->m_display = wxGetDisplay();
M_CURSORDATA->m_cursors.Append(c);
M_CURSORDATA->m_ok = TRUE;
}
}
wxCursor::~wxCursor()
{
}
// Motif-specific: create/get a cursor for the current display
WXCursor wxCursor::GetXCursor(WXDisplay* display)
{
if (!M_CURSORDATA)
return (WXCursor) 0;
wxNode* node = M_CURSORDATA->m_cursors.First();
while (node)
{
wxXCursor* c = (wxXCursor*) node->Data();
if (c->m_display == display)
return c->m_cursor;
node = node->Next();
}
// No cursor for this display, so let's see if we're an id-type cursor.
if (M_CURSORDATA->m_cursorId != wxCURSOR_NONE)
{
WXCursor cursor = MakeCursor(display, M_CURSORDATA->m_cursorId);
if (cursor)
{
wxXCursor* c = new wxXCursor;
c->m_cursor = cursor;
c->m_display = display;
M_CURSORDATA->m_cursors.Append(c);
return cursor;
}
else
return (WXCursor) 0;
}
// Not an id-type cursor, so we don't know how to create it.
return (WXCursor) 0;
}
// Make a cursor from standard id
WXCursor wxCursor::MakeCursor(WXDisplay* display, wxStockCursor id)
{
Display* dpy = (Display*) display;
Cursor cursor = (Cursor) 0;
switch (id)
{
case wxCURSOR_WAIT:
{
cursor = XCreateFontCursor (dpy, XC_watch);
break;
}
case wxCURSOR_CROSS:
{
cursor = XCreateFontCursor (dpy, XC_crosshair);
break;
}
case wxCURSOR_CHAR:
{
// Nothing
break;
}
case wxCURSOR_HAND:
{
cursor = XCreateFontCursor (dpy, XC_hand1);
break;
}
case wxCURSOR_BULLSEYE:
{
cursor = XCreateFontCursor (dpy, XC_target);
break;
}
case wxCURSOR_PENCIL:
{
cursor = XCreateFontCursor (dpy, XC_pencil);
break;
}
case wxCURSOR_MAGNIFIER:
{
cursor = XCreateFontCursor (dpy, XC_sizing);
break;
}
case wxCURSOR_IBEAM:
{
cursor = XCreateFontCursor (dpy, XC_xterm);
break;
}
case wxCURSOR_NO_ENTRY:
{
cursor = XCreateFontCursor (dpy, XC_pirate);
break;
}
case wxCURSOR_LEFT_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_leftbutton);
break;
}
case wxCURSOR_RIGHT_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_rightbutton);
break;
}
case wxCURSOR_MIDDLE_BUTTON:
{
cursor = XCreateFontCursor (dpy, XC_middlebutton);
break;
}
case wxCURSOR_QUESTION_ARROW:
{
cursor = XCreateFontCursor (dpy, XC_question_arrow);
break;
}
case wxCURSOR_SIZING:
{
cursor = XCreateFontCursor (dpy, XC_sizing);
break;
}
case wxCURSOR_WATCH:
{
cursor = XCreateFontCursor (dpy, XC_watch);
break;
}
case wxCURSOR_SPRAYCAN:
{
cursor = XCreateFontCursor (dpy, XC_spraycan);
break;
}
case wxCURSOR_PAINT_BRUSH:
{
cursor = XCreateFontCursor (dpy, XC_spraycan);
break;
}
case wxCURSOR_SIZENWSE:
case wxCURSOR_SIZENESW:
{
// Not available in X
cursor = XCreateFontCursor (dpy, XC_crosshair);
break;
}
case wxCURSOR_SIZEWE:
{
cursor = XCreateFontCursor (dpy, XC_sb_h_double_arrow);
break;
}
case wxCURSOR_SIZENS:
{
cursor = XCreateFontCursor (dpy, XC_sb_v_double_arrow);
break;
}
case wxCURSOR_POINT_LEFT:
{
cursor = XCreateFontCursor (dpy, XC_sb_left_arrow);
break;
}
case wxCURSOR_POINT_RIGHT:
{
cursor = XCreateFontCursor (dpy, XC_sb_right_arrow);
break;
}
// (JD Huggins) added more stock cursors for X
// X-only cursors BEGIN
case wxCURSOR_CROSS_REVERSE:
{
cursor = XCreateFontCursor(dpy, XC_cross_reverse);
break;
}
case wxCURSOR_DOUBLE_ARROW:
{
cursor = XCreateFontCursor(dpy, XC_double_arrow);
break;
}
case wxCURSOR_BASED_ARROW_UP:
{
cursor = XCreateFontCursor(dpy, XC_based_arrow_up);
break;
}
case wxCURSOR_BASED_ARROW_DOWN:
{
cursor = XCreateFontCursor(dpy, XC_based_arrow_down);
break;
}
default:
case wxCURSOR_ARROW:
{
cursor = XCreateFontCursor (dpy, XC_top_left_arrow);
break;
}
case wxCURSOR_BLANK:
{
GC gc;
XGCValues gcv;
Pixmap empty_pixmap;
XColor blank_color;
empty_pixmap = XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
16, 16, 1);
gcv.function = GXxor;
gc = XCreateGC (dpy,
empty_pixmap,
GCFunction,
&gcv);
XCopyArea (dpy,
empty_pixmap,
empty_pixmap,
gc,
0, 0,
16, 16,
0, 0);
XFreeGC (dpy, gc);
cursor = XCreatePixmapCursor (dpy,
empty_pixmap,
empty_pixmap,
&blank_color,
&blank_color,
8, 8);
break;
}
}
return (WXCursor) cursor;
}
// Global cursor setting
void wxSetCursor(const wxCursor& WXUNUSED(cursor))
{
// Nothing to do for Motif (no global cursor)
}

138
src/x11/data.cpp Normal file
View File

@@ -0,0 +1,138 @@
/////////////////////////////////////////////////////////////////////////////
// Name: data.cpp
// Purpose: Various data
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation
#endif
#include "wx/wx.h"
#include "wx/dcps.h"
#define _MAXPATHLEN 500
// Useful buffer, initialized in CommonInit
char *wxBuffer = NULL;
// Windows List
wxWindowList wxTopLevelWindows;
// List of windows pending deletion
wxList wxPendingDelete;
int wxPageNumber;
// GDI Object Lists
wxBrushList *wxTheBrushList = NULL;
wxPenList *wxThePenList = NULL;
wxFontList *wxTheFontList = NULL;
wxBitmapList *wxTheBitmapList = NULL;
wxColourDatabase *wxTheColourDatabase = NULL;
// Stock objects
wxFont *wxNORMAL_FONT;
wxFont *wxSMALL_FONT;
wxFont *wxITALIC_FONT;
wxFont *wxSWISS_FONT;
wxPen *wxRED_PEN;
wxPen *wxCYAN_PEN;
wxPen *wxGREEN_PEN;
wxPen *wxBLACK_PEN;
wxPen *wxWHITE_PEN;
wxPen *wxTRANSPARENT_PEN;
wxPen *wxBLACK_DASHED_PEN;
wxPen *wxGREY_PEN;
wxPen *wxMEDIUM_GREY_PEN;
wxPen *wxLIGHT_GREY_PEN;
wxBrush *wxBLUE_BRUSH;
wxBrush *wxGREEN_BRUSH;
wxBrush *wxWHITE_BRUSH;
wxBrush *wxBLACK_BRUSH;
wxBrush *wxTRANSPARENT_BRUSH;
wxBrush *wxCYAN_BRUSH;
wxBrush *wxRED_BRUSH;
wxBrush *wxGREY_BRUSH;
wxBrush *wxMEDIUM_GREY_BRUSH;
wxBrush *wxLIGHT_GREY_BRUSH;
wxColour *wxBLACK;
wxColour *wxWHITE;
wxColour *wxRED;
wxColour *wxBLUE;
wxColour *wxGREEN;
wxColour *wxCYAN;
wxColour *wxLIGHT_GREY;
wxCursor *wxSTANDARD_CURSOR = NULL;
wxCursor *wxHOURGLASS_CURSOR = NULL;
wxCursor *wxCROSS_CURSOR = NULL;
// 'Null' objects
wxAcceleratorTable wxNullAcceleratorTable;
wxBitmap wxNullBitmap;
wxIcon wxNullIcon;
wxCursor wxNullCursor;
wxPen wxNullPen;
wxBrush wxNullBrush;
wxPalette wxNullPalette;
wxFont wxNullFont;
wxColour wxNullColour;
// Default window names
const char *wxButtonNameStr = "button";
const char *wxCanvasNameStr = "canvas";
const char *wxCheckBoxNameStr = "check";
const char *wxChoiceNameStr = "choice";
const char *wxComboBoxNameStr = "comboBox";
const char *wxDialogNameStr = "dialog";
const char *wxFrameNameStr = "frame";
const char *wxGaugeNameStr = "gauge";
const char *wxStaticBoxNameStr = "groupBox";
const char *wxListBoxNameStr = "listBox";
const char *wxStaticTextNameStr = "message";
const char *wxStaticBitmapNameStr = "message";
const char *wxMultiTextNameStr = "multitext";
const char *wxPanelNameStr = "panel";
const char *wxRadioBoxNameStr = "radioBox";
const char *wxRadioButtonNameStr = "radioButton";
const char *wxBitmapRadioButtonNameStr = "radioButton";
const char *wxScrollBarNameStr = "scrollBar";
const char *wxSliderNameStr = "slider";
const char *wxStaticNameStr = "static";
const char *wxTextCtrlWindowNameStr = "textWindow";
const char *wxTextCtrlNameStr = "text";
const char *wxVirtListBoxNameStr = "virtListBox";
const char *wxButtonBarNameStr = "buttonbar";
const char *wxEnhDialogNameStr = "Shell";
const char *wxToolBarNameStr = "toolbar";
const char *wxStatusLineNameStr = "status_line";
#if 0 // this is defined in string.cpp
const char *wxEmptyString = "";
#endif
const char *wxGetTextFromUserPromptStr = "Input Text";
const char *wxMessageBoxCaptionStr = "Message";
const char *wxFileSelectorPromptStr = "Select a file";
const char *wxFileSelectorDefaultWildcardStr = "*.*";
const char *wxInternalErrorStr = "wxWindows Internal Error";
const char *wxFatalErrorStr = "wxWindows Fatal Error";
const char *wxDirDialogNameStr = "wxDirCtrl";
const char *wxDirDialogDefaultFolderStr = "/";
const wxChar *wxTreeCtrlNameStr = wxT("wxTreeCtrl");
// See wx/utils.h
const char *wxFloatToStringStr = "%.2f";
const char *wxDoubleToStringStr = "%.2f";
const wxSize wxDefaultSize(-1, -1);
const wxPoint wxDefaultPosition(-1, -1);

200
src/x11/dataobj.cpp Normal file
View File

@@ -0,0 +1,200 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dataobj.cpp
// Purpose: wxDataObject class
// Author: Julian Smart
// Id: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dataobj.h"
#endif
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/dataobj.h"
#include "wx/app.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/utils.h"
//-------------------------------------------------------------------------
// global data
//-------------------------------------------------------------------------
Atom g_textAtom = 0;
Atom g_pngAtom = 0;
Atom g_fileAtom = 0;
//-------------------------------------------------------------------------
// wxDataFormat
//-------------------------------------------------------------------------
wxDataFormat::wxDataFormat()
{
// do *not* call PrepareFormats() from here for 2 reasons:
//
// 1. we will have time to do it later because some other Set function
// must be called before we really need them
//
// 2. doing so prevents us from declaring global wxDataFormats because
// calling PrepareFormats (and thus gdk_atom_intern) before GDK is
// initialised will result in a crash
m_type = wxDF_INVALID;
m_format = (Atom) 0;
}
wxDataFormat::wxDataFormat( wxDataFormatId type )
{
PrepareFormats();
SetType( type );
}
wxDataFormat::wxDataFormat( const wxChar *id )
{
PrepareFormats();
SetId( id );
}
wxDataFormat::wxDataFormat( const wxString &id )
{
PrepareFormats();
SetId( id );
}
wxDataFormat::wxDataFormat( NativeFormat format )
{
PrepareFormats();
SetId( format );
}
void wxDataFormat::SetType( wxDataFormatId type )
{
PrepareFormats();
m_type = type;
if (m_type == wxDF_TEXT)
m_format = g_textAtom;
else
if (m_type == wxDF_BITMAP)
m_format = g_pngAtom;
else
if (m_type == wxDF_FILENAME)
m_format = g_fileAtom;
else
{
wxFAIL_MSG( wxT("invalid dataformat") );
}
}
wxDataFormatId wxDataFormat::GetType() const
{
return m_type;
}
wxString wxDataFormat::GetId() const
{
char *t = XGetAtomName ((Display*) wxGetDisplay(), m_format);
wxString ret( t ); // this will convert from ascii to Unicode
if (t)
XFree( t );
return ret;
}
void wxDataFormat::SetId( NativeFormat format )
{
PrepareFormats();
m_format = format;
if (m_format == g_textAtom)
m_type = wxDF_TEXT;
else
if (m_format == g_pngAtom)
m_type = wxDF_BITMAP;
else
if (m_format == g_fileAtom)
m_type = wxDF_FILENAME;
else
m_type = wxDF_PRIVATE;
}
void wxDataFormat::SetId( const wxChar *id )
{
PrepareFormats();
m_type = wxDF_PRIVATE;
wxString tmp( id );
m_format = XInternAtom( (Display*) wxGetDisplay(), wxMBSTRINGCAST tmp.mbc_str(), FALSE ); // what is the string cast for?
}
void wxDataFormat::PrepareFormats()
{
if (!g_textAtom)
g_textAtom = XInternAtom( (Display*) wxGetDisplay(), "STRING", FALSE );
if (!g_pngAtom)
g_pngAtom = XInternAtom( (Display*) wxGetDisplay(), "image/png", FALSE );
if (!g_fileAtom)
g_fileAtom = XInternAtom( (Display*) wxGetDisplay(), "file:ALL", FALSE );
}
#if 0
// ----------------------------------------------------------------------------
// wxPrivateDataObject
// ----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS( wxPrivateDataObject, wxDataObject )
void wxPrivateDataObject::Free()
{
if ( m_data )
free(m_data);
}
wxPrivateDataObject::wxPrivateDataObject()
{
wxString id = wxT("application/");
id += wxTheApp->GetAppName();
m_format.SetId( id );
m_size = 0;
m_data = (void *)NULL;
}
void wxPrivateDataObject::SetData( const void *data, size_t size )
{
Free();
m_size = size;
m_data = malloc(size);
memcpy( m_data, data, size );
}
void wxPrivateDataObject::WriteData( void *dest ) const
{
WriteData( m_data, dest );
}
size_t wxPrivateDataObject::GetSize() const
{
return m_size;
}
void wxPrivateDataObject::WriteData( const void *data, void *dest ) const
{
memcpy( dest, data, GetSize() );
}
#endif // 0
#endif // wxUSE_CLIPBOARD

232
src/x11/dc.cpp Normal file
View File

@@ -0,0 +1,232 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dc.cpp
// Purpose: wxDC class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dc.h"
#endif
#include "wx/dc.h"
#include "wx/dcmemory.h"
#include "wx/defs.h"
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
//-----------------------------------------------------------------------------
// constants
//-----------------------------------------------------------------------------
#define mm2inches 0.0393700787402
#define inches2mm 25.4
#define mm2twips 56.6929133859
#define twips2mm 0.0176388888889
#define mm2pt 2.83464566929
#define pt2mm 0.352777777778
//-----------------------------------------------------------------------------
// wxDC
//-----------------------------------------------------------------------------
wxDC::wxDC()
{
m_ok = FALSE;
m_mm_to_pix_x = 1.0;
m_mm_to_pix_y = 1.0;
m_backgroundMode = wxTRANSPARENT;
m_isInteractive = FALSE;
}
void wxDC::DoDrawIcon( const wxIcon &icon, wxCoord x, wxCoord y)
{
wxCHECK_RET( Ok(), "invalid dc" );
wxCHECK_RET( icon.Ok(), "invalid icon" );
DoDrawBitmap(icon, x, y, TRUE);
}
void wxDC::DoDrawBitmap( const wxBitmap& bitmap, wxCoord x, wxCoord y, bool useMask )
{
wxCHECK_RET( bitmap.Ok(), "invalid bitmap" );
wxMemoryDC memDC;
memDC.SelectObject(bitmap);
#if 0
// 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();
}
#endif // 0
Blit(x, y, bitmap.GetWidth(), bitmap.GetHeight(), &memDC, 0, 0, wxCOPY, useMask);
memDC.SelectObject(wxNullBitmap);
}
void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
{
m_clipping = TRUE;
m_clipX1 = x;
m_clipY1 = y;
m_clipX2 = x + width;
m_clipY2 = y + height;
}
void wxDC::DestroyClippingRegion()
{
m_clipping = FALSE;
}
void wxDC::DoGetSize( int* width, int* height ) const
{
if ( width )
*width = m_maxX - m_minX;
if ( height )
*height = m_maxY - m_minY;
}
void wxDC::DoGetSizeMM( int* width, int* height ) const
{
int w, h;
GetSize( &w, &h );
if ( width )
*width = int( double(w) / (m_scaleX*m_mm_to_pix_x) );
if ( height )
*height = int( double(h) / (m_scaleY*m_mm_to_pix_y) );
}
// Resolution in pixels per logical inch
wxSize wxDC::GetPPI() const
{
// TODO (should probably be pure virtual)
return wxSize(0, 0);
}
void wxDC::SetMapMode( int mode )
{
switch (mode)
{
case wxMM_TWIPS:
SetLogicalScale( twips2mm*m_mm_to_pix_x, twips2mm*m_mm_to_pix_y );
break;
case wxMM_POINTS:
SetLogicalScale( pt2mm*m_mm_to_pix_x, pt2mm*m_mm_to_pix_y );
break;
case wxMM_METRIC:
SetLogicalScale( m_mm_to_pix_x, m_mm_to_pix_y );
break;
case wxMM_LOMETRIC:
SetLogicalScale( m_mm_to_pix_x/10.0, m_mm_to_pix_y/10.0 );
break;
default:
case wxMM_TEXT:
SetLogicalScale( 1.0, 1.0 );
break;
}
if (mode != wxMM_TEXT)
{
m_needComputeScaleX = TRUE;
m_needComputeScaleY = TRUE;
}
}
void wxDC::SetUserScale( double x, double y )
{
// allow negative ? -> no
m_userScaleX = x;
m_userScaleY = y;
ComputeScaleAndOrigin();
}
void wxDC::SetLogicalScale( double x, double y )
{
// allow negative ?
m_logicalScaleX = x;
m_logicalScaleY = y;
ComputeScaleAndOrigin();
}
void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
{
m_logicalOriginX = x * m_signX; // is this still correct ?
m_logicalOriginY = y * m_signY;
ComputeScaleAndOrigin();
}
void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
{
// only wxPostScripDC has m_signX = -1, we override SetDeviceOrigin there
m_deviceOriginX = x;
m_deviceOriginY = y;
ComputeScaleAndOrigin();
}
void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
{
m_signX = xLeftRight ? 1 : -1;
m_signY = yBottomUp ? -1 : 1;
ComputeScaleAndOrigin();
}
wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOG(x);
}
wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOG(y);
}
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{
return ((wxDC *)this)->XDEV2LOGREL(x);
}
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{
return ((wxDC *)this)->YDEV2LOGREL(y);
}
wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEV(x);
}
wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEV(y);
}
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{
return ((wxDC *)this)->XLOG2DEVREL(x);
}
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{
return ((wxDC *)this)->YLOG2DEVREL(y);
}
void wxDC::ComputeScaleAndOrigin()
{
m_scaleX = m_logicalScaleX * m_userScaleX;
m_scaleY = m_logicalScaleY * m_userScaleY;
}

2408
src/x11/dcclient.cpp Normal file

File diff suppressed because it is too large Load Diff

159
src/x11/dcmemory.cpp Normal file
View File

@@ -0,0 +1,159 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcmemory.cpp
// Purpose: wxMemoryDC class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dcmemory.h"
#endif
#include "wx/dcmemory.h"
#include "wx/settings.h"
#include "wx/utils.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
//-----------------------------------------------------------------------------
// wxMemoryDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
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));
gcvalues.graphics_exposures = False;
gcvalues.subwindow_mode = IncludeInferiors;
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
&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;
SetBrush (* wxWHITE_BRUSH);
SetPen (* wxBLACK_PEN);
SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
};
wxMemoryDC::wxMemoryDC( wxDC* dc )
{
m_ok = TRUE;
if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
m_display = ((wxWindowDC*)dc)->GetDisplay();
else
m_display = wxGetDisplay();
Display* display = (Display*) m_display;
XGCValues gcvalues;
gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
gcvalues.background = WhitePixel (display, DefaultScreen (display));
gcvalues.graphics_exposures = False;
gcvalues.subwindow_mode = IncludeInferiors;
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
&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;
SetBrush (* wxWHITE_BRUSH);
SetPen (* wxBLACK_PEN);
};
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.subwindow_mode = IncludeInferiors;
gcvalues.line_width = 1;
m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
&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::DoGetSize( 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;
};
};

134
src/x11/dcscreen.cpp Normal file
View File

@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dcscreen.cpp
// Purpose: wxScreenDC class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dcscreen.h"
#endif
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/dcscreen.h"
#include "wx/utils.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
WXWindow wxScreenDC::sm_overlayWindow = 0;
int wxScreenDC::sm_overlayWindowX = 0;
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;
}
wxScreenDC::~wxScreenDC()
{
EndDrawingOnTop();
}
bool wxScreenDC::StartDrawingOnTop(wxWindow* window)
{
wxRect rect;
int x, y, width, height;
window->GetPosition(& x, & y);
if (window->GetParent() && !window->IsKindOf(CLASSINFO(wxFrame)))
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;
}
bool wxScreenDC::EndDrawingOnTop()
{
if (sm_overlayWindow)
{
XDestroyWindow((Display*) wxGetDisplay(), (Window) sm_overlayWindow);
sm_overlayWindow = 0;
return TRUE;
}
else
return FALSE;
}

238
src/x11/dnd.cpp Normal file
View File

@@ -0,0 +1,238 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp
// Purpose: wxDropTarget, wxDropSource classes
// Author: Julian Smart
// Id: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "dnd.h"
#endif
#include "wx/setup.h"
#if wxUSE_DRAG_AND_DROP
#include "wx/dnd.h"
#include "wx/window.h"
#include "wx/app.h"
#include "wx/gdicmn.h"
#include "wx/intl.h"
#include "wx/utils.h"
#include "wx/log.h"
#include <X11/Xlib.h>
// ----------------------------------------------------------------------------
// global
// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// wxDropTarget
// ----------------------------------------------------------------------------
wxDropTarget::wxDropTarget()
{
}
wxDropTarget::~wxDropTarget()
{
}
// ----------------------------------------------------------------------------
// wxTextDropTarget
// ----------------------------------------------------------------------------
bool wxTextDropTarget::OnDrop( long x, long y, const void *data, size_t WXUNUSED(size) )
{
OnDropText( x, y, (const char*)data );
return TRUE;
}
bool wxTextDropTarget::OnDropText( long x, long y, const char *psz )
{
wxLogDebug( "Got dropped text: %s.", psz );
wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
return TRUE;
}
size_t wxTextDropTarget::GetFormatCount() const
{
return 1;
}
wxDataFormat wxTextDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return wxDF_TEXT;
}
// ----------------------------------------------------------------------------
// wxFileDropTarget
// ----------------------------------------------------------------------------
bool wxFileDropTarget::OnDropFiles( long x, long y, size_t nFiles, const char * const aszFiles[] )
{
wxLogDebug( "Got %d dropped files.", (int)nFiles );
wxLogDebug( "At x: %d, y: %d.", (int)x, (int)y );
size_t i;
for (i = 0; i < nFiles; i++)
{
wxLogDebug( aszFiles[i] );
}
return TRUE;
}
bool wxFileDropTarget::OnDrop(long x, long y, const void *data, size_t size )
{
size_t number = 0;
char *text = (char*) data;
size_t i;
for (i = 0; i < size; i++)
if (text[i] == 0) number++;
if (number == 0) return TRUE;
char **files = new char*[number];
text = (char*) data;
for ( 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
{
return 1;
}
wxDataFormat wxFileDropTarget::GetFormat(size_t WXUNUSED(n)) const
{
return wxDF_FILENAME;
}
//-------------------------------------------------------------------------
// wxDropSource
//-------------------------------------------------------------------------
wxDropSource::wxDropSource( wxWindow *win )
{
#if 0
m_window = win;
m_data = (wxDataObject *) NULL;
m_retValue = wxDragCancel;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
#endif
}
wxDropSource::wxDropSource( wxDataObject &data, wxWindow *win )
{
#if 0
g_blockEventsOnDrag = TRUE;
m_window = win;
m_widget = win->m_widget;
if (win->m_wxwindow) m_widget = win->m_wxwindow;
m_retValue = wxDragCancel;
m_data = &data;
m_defaultCursor = wxCursor( wxCURSOR_NO_ENTRY );
m_goaheadCursor = wxCursor( wxCURSOR_HAND );
#endif
}
void wxDropSource::SetData( wxDataObject &data )
{
// m_data = &data;
}
wxDropSource::~wxDropSource(void)
{
// if (m_data) delete m_data;
}
wxDragResult wxDropSource::DoDragDrop( bool WXUNUSED(bAllowMove) )
{
// 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
wxPrivateDropTarget::wxPrivateDropTarget()
{
m_id = wxTheApp->GetAppName();
}
size_t wxPrivateDropTarget::GetFormatCount() const
{
return 1;
}
wxDataFormat wxPrivateDropTarget::GetFormat(size_t n) const
{
return wxDF_INVALID;
}
#endif
// wxUSE_DRAG_AND_DROP

551
src/x11/font.cpp Normal file
View File

@@ -0,0 +1,551 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/motif/font.cpp
// Purpose: wxFont class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma implementation "font.h"
#endif
#ifdef __VMS
#pragma message disable nosimpint
#include "wx/vms_x_fix.h"
#endif
#include <Xm/Xm.h>
#ifdef __VMS
#pragma message enable nosimpint
#endif
#include "wx/defs.h"
#include "wx/string.h"
#include "wx/font.h"
#include "wx/gdicmn.h"
#include "wx/utils.h" // for wxGetDisplay()
#include "wx/fontutil.h" // for wxNativeFontInfo
#include "wx/tokenzr.h"
#include "wx/settings.h"
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
// For every wxFont, there must be a font for each display and scale requested.
// So these objects are stored in wxFontRefData::m_fonts
class wxXFont : public wxObject
{
public:
wxXFont();
~wxXFont();
WXFontStructPtr m_fontStruct; // XFontStruct
WXFontList m_fontList; // Motif XmFontList
WXDisplay* m_display; // XDisplay
int m_scale; // Scale * 100
};
class wxFontRefData: public wxGDIRefData
{
friend class wxFont;
public:
wxFontRefData(int size = wxDEFAULT,
int family = wxDEFAULT,
int style = wxDEFAULT,
int weight = wxDEFAULT,
bool underlined = FALSE,
const wxString& faceName = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Init(size, family, style, weight, underlined, faceName, encoding);
}
wxFontRefData(const wxFontRefData& data)
{
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
data.m_underlined, data.m_faceName, data.m_encoding);
}
~wxFontRefData();
protected:
// common part of all ctors
void Init(int size,
int family,
int style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding);
// font attributes
int m_pointSize;
int m_family;
int m_style;
int m_weight;
bool m_underlined;
wxString m_faceName;
wxFontEncoding m_encoding;
wxNativeFontInfo m_nativeFontInfo;
// A list of wxXFonts
wxList m_fonts;
};
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxXFont
// ----------------------------------------------------------------------------
wxXFont::wxXFont()
{
m_fontStruct = (WXFontStructPtr) 0;
m_fontList = (WXFontList) 0;
m_display = (WXDisplay*) 0;
m_scale = 100;
}
wxXFont::~wxXFont()
{
XmFontList fontList = (XmFontList) m_fontList;
XmFontListFree (fontList);
// TODO: why does freeing the font produce a segv???
// Note that XFreeFont wasn't called in wxWin 1.68 either.
// XFontStruct* fontStruct = (XFontStruct*) m_fontStruct;
// XFreeFont((Display*) m_display, fontStruct);
}
// ----------------------------------------------------------------------------
// wxFontRefData
// ----------------------------------------------------------------------------
void wxFontRefData::Init(int pointSize,
int family,
int style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{
if (family == wxDEFAULT)
m_family = wxSWISS;
else
m_family = family;
m_faceName = faceName;
if (style == wxDEFAULT)
m_style = wxNORMAL;
else
m_style = style;
if (weight == wxDEFAULT)
m_weight = wxNORMAL;
else
m_weight = weight;
if (pointSize == wxDEFAULT)
m_pointSize = 12;
else
m_pointSize = pointSize;
m_underlined = underlined;
m_encoding = encoding;
}
wxFontRefData::~wxFontRefData()
{
wxNode* node = m_fonts.First();
while (node)
{
wxXFont* f = (wxXFont*) node->Data();
delete f;
node = node->Next();
}
m_fonts.Clear();
}
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
wxFont::wxFont(const wxNativeFontInfo& info)
{
Init();
(void)Create(info.GetXFontName());
}
void wxFont::Init()
{
}
bool wxFont::Create(int pointSize,
int family,
int style,
int weight,
bool underlined,
const wxString& faceName,
wxFontEncoding encoding)
{
UnRef();
m_refData = new wxFontRefData(pointSize, family, style, weight,
underlined, faceName, encoding);
RealizeResource();
return TRUE;
}
bool wxFont::Create(const wxString& fontname, wxFontEncoding enc)
{
if( !fontname )
{
*this = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT);
return TRUE;
}
m_refData = new wxFontRefData();
M_FONTDATA->m_nativeFontInfo.SetXFontName(fontname); // X font name
wxString tmp;
wxStringTokenizer tn( fontname, wxT("-") );
tn.GetNextToken(); // skip initial empty token
tn.GetNextToken(); // foundry
M_FONTDATA->m_faceName = tn.GetNextToken(); // family
tmp = tn.GetNextToken().MakeUpper(); // weight
if (tmp == wxT("BOLD")) M_FONTDATA->m_weight = wxBOLD;
if (tmp == wxT("BLACK")) M_FONTDATA->m_weight = wxBOLD;
if (tmp == wxT("EXTRABOLD")) M_FONTDATA->m_weight = wxBOLD;
if (tmp == wxT("DEMIBOLD")) M_FONTDATA->m_weight = wxBOLD;
if (tmp == wxT("ULTRABOLD")) M_FONTDATA->m_weight = wxBOLD;
if (tmp == wxT("LIGHT")) M_FONTDATA->m_weight = wxLIGHT;
if (tmp == wxT("THIN")) M_FONTDATA->m_weight = wxLIGHT;
tmp = tn.GetNextToken().MakeUpper(); // slant
if (tmp == wxT("I")) M_FONTDATA->m_style = wxITALIC;
if (tmp == wxT("O")) M_FONTDATA->m_style = wxITALIC;
tn.GetNextToken(); // set width
tn.GetNextToken(); // add. style
tn.GetNextToken(); // pixel size
tmp = tn.GetNextToken(); // pointsize
if (tmp != wxT("*"))
{
long num = wxStrtol (tmp.c_str(), (wxChar **) NULL, 10);
M_FONTDATA->m_pointSize = (int)(num / 10);
}
tn.GetNextToken(); // x-res
tn.GetNextToken(); // y-res
tmp = tn.GetNextToken().MakeUpper(); // spacing
if (tmp == wxT("M"))
M_FONTDATA->m_family = wxMODERN;
else if (M_FONTDATA->m_faceName == wxT("TIMES"))
M_FONTDATA->m_family = wxROMAN;
else if (M_FONTDATA->m_faceName == wxT("HELVETICA"))
M_FONTDATA->m_family = wxSWISS;
else if (M_FONTDATA->m_faceName == wxT("LUCIDATYPEWRITER"))
M_FONTDATA->m_family = wxTELETYPE;
else if (M_FONTDATA->m_faceName == wxT("LUCIDA"))
M_FONTDATA->m_family = wxDECORATIVE;
else if (M_FONTDATA->m_faceName == wxT("UTOPIA"))
M_FONTDATA->m_family = wxSCRIPT;
tn.GetNextToken(); // avg width
// deal with font encoding
M_FONTDATA->m_encoding = enc;
if ( M_FONTDATA->m_encoding == wxFONTENCODING_SYSTEM )
{
wxString registry = tn.GetNextToken().MakeUpper(),
encoding = tn.GetNextToken().MakeUpper();
if ( registry == _T("ISO8859") )
{
int cp;
if ( wxSscanf(encoding, wxT("%d"), &cp) == 1 )
{
M_FONTDATA->m_encoding =
(wxFontEncoding)(wxFONTENCODING_ISO8859_1 + cp - 1);
}
}
else if ( registry == _T("MICROSOFT") )
{
int cp;
if ( wxSscanf(encoding, wxT("cp125%d"), &cp) == 1 )
{
M_FONTDATA->m_encoding =
(wxFontEncoding)(wxFONTENCODING_CP1250 + cp);
}
}
else if ( registry == _T("KOI8") )
{
M_FONTDATA->m_encoding = wxFONTENCODING_KOI8;
}
//else: unknown encoding - may be give a warning here?
else
return FALSE;
}
return TRUE;
}
wxFont::~wxFont()
{
}
// ----------------------------------------------------------------------------
// change the font attributes
// ----------------------------------------------------------------------------
void wxFont::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxFontRefData();
}
else
{
wxFontRefData* ref = new wxFontRefData(*(wxFontRefData*)m_refData);
UnRef();
m_refData = ref;
}
}
void wxFont::SetPointSize(int pointSize)
{
Unshare();
M_FONTDATA->m_pointSize = pointSize;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetFamily(int family)
{
Unshare();
M_FONTDATA->m_family = family;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetStyle(int style)
{
Unshare();
M_FONTDATA->m_style = style;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetWeight(int weight)
{
Unshare();
M_FONTDATA->m_weight = weight;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetFaceName(const wxString& faceName)
{
Unshare();
M_FONTDATA->m_faceName = faceName;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetUnderlined(bool underlined)
{
Unshare();
M_FONTDATA->m_underlined = underlined;
RealizeResource();
}
void wxFont::SetEncoding(wxFontEncoding encoding)
{
Unshare();
M_FONTDATA->m_encoding = encoding;
M_FONTDATA->m_nativeFontInfo.GetXFontName().Clear(); // invalid now
RealizeResource();
}
void wxFont::SetNativeFontInfo(const wxNativeFontInfo& info)
{
Unshare();
M_FONTDATA->m_nativeFontInfo = info;
}
// ----------------------------------------------------------------------------
// query font attributes
// ----------------------------------------------------------------------------
int wxFont::GetPointSize() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_pointSize;
}
wxString wxFont::GetFaceName() const
{
wxCHECK_MSG( Ok(), wxT(""), wxT("invalid font") );
return M_FONTDATA->m_faceName ;
}
int wxFont::GetFamily() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_family;
}
int wxFont::GetStyle() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_style;
}
int wxFont::GetWeight() const
{
wxCHECK_MSG( Ok(), 0, wxT("invalid font") );
return M_FONTDATA->m_weight;
}
bool wxFont::GetUnderlined() const
{
wxCHECK_MSG( Ok(), FALSE, wxT("invalid font") );
return M_FONTDATA->m_underlined;
}
wxFontEncoding wxFont::GetEncoding() const
{
wxCHECK_MSG( Ok(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
return M_FONTDATA->m_encoding;
}
wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty())
GetInternalFont();
return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo);
}
// ----------------------------------------------------------------------------
// real implementation
// ----------------------------------------------------------------------------
// Find an existing, or create a new, XFontStruct
// based on this wxFont and the given scale. Append the
// 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;
// search existing fonts first
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();
}
// not found, create a new one
XFontStruct *font = (XFontStruct *)
wxLoadQueryNearestFont(pointSize,
M_FONTDATA->m_family,
M_FONTDATA->m_style,
M_FONTDATA->m_weight,
M_FONTDATA->m_underlined,
wxT(""),
M_FONTDATA->m_encoding);
if ( !font )
{
wxFAIL_MSG( wxT("Could not allocate even a default font -- something is wrong.") );
return (wxXFont*) NULL;
}
wxXFont* f = new wxXFont;
f->m_fontStruct = (WXFontStructPtr)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;
}
WXFontStructPtr wxFont::GetFontStruct(double scale, WXDisplay* display) const
{
wxXFont* f = GetInternalFont(scale, display);
return (f ? f->m_fontStruct : (WXFontStructPtr) 0);
}
WXFontList wxFont::GetFontList(double scale, WXDisplay* display) const
{
wxXFont* f = GetInternalFont(scale, display);
return (f ? f->m_fontList : (WXFontList) 0);
}

18
src/x11/gdiobj.cpp Normal file
View File

@@ -0,0 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: gdiobj.cpp
// Purpose: wxGDIObject class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "gdiobj.h"
#endif
#include "wx/gdiobj.h"
IMPLEMENT_DYNAMIC_CLASS(wxGDIObject, wxObject)

395
src/x11/glcanvas.cpp Normal file
View File

@@ -0,0 +1,395 @@
/////////////////////////////////////////////////////////////////////////////
// Name: glcanvas.cpp
// Purpose: wxGLCanvas, for using OpenGL with wxWindows 2.0 for Motif.
// Uses the GLX extension.
// Author: Julian Smart and Wolfram Gloger
// Modified by:
// Created: 1995, 1999
// RCS-ID: $Id$
// Copyright: (c) Julian Smart, Wolfram Gloger
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "glcanvas.h"
#endif
#include "wx/setup.h"
#if wxUSE_GLCANVAS
#include "wx/glcanvas.h"
#include "wx/utils.h"
#include "wx/app.h"
#ifdef __VMS
# pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS
# pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
#ifdef OLD_MESA
// workaround for bug in Mesa's glx.c
static int bitcount( unsigned long n )
{
int bits;
for (bits=0; n>0;) {
if(n & 1) bits++;
n = n >> 1;
}
return bits;
}
#endif
/*
* GLContext implementation
*/
IMPLEMENT_CLASS(wxGLContext,wxObject)
wxGLContext::wxGLContext( bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette) )
{
m_window = win;
// m_widget = win->m_wxwindow;
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
None, GL_TRUE);
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
}
wxGLContext::wxGLContext(
bool WXUNUSED(isRGB), wxWindow *win,
const wxPalette& WXUNUSED(palette),
const wxGLContext *other /* for sharing display lists */
)
{
m_window = win;
// m_widget = win->m_wxwindow;
wxGLCanvas *gc = (wxGLCanvas*) win;
XVisualInfo *vi = (XVisualInfo *) gc->m_vi;
wxCHECK_RET( vi, "invalid visual for OpenGl" );
if( other != 0 )
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
other->m_glContext, GL_TRUE );
else
m_glContext = glXCreateContext( (Display *)m_window->GetXDisplay(), vi,
None, GL_TRUE );
wxCHECK_RET( m_glContext, "Couldn't create OpenGl context" );
}
wxGLContext::~wxGLContext()
{
if (!m_glContext) return;
if (m_glContext == glXGetCurrentContext())
{
glXMakeCurrent( (Display*) m_window->GetXDisplay(), None, NULL);
}
glXDestroyContext( (Display*) m_window->GetXDisplay(), m_glContext );
}
void wxGLContext::SwapBuffers()
{
if (m_glContext)
{
Display* display = (Display*) m_window->GetXDisplay();
glXSwapBuffers(display, (Window) m_window->GetXWindow());
}
}
void wxGLContext::SetCurrent()
{
if (m_glContext)
{
Display* display = (Display*) m_window->GetXDisplay();
glXMakeCurrent(display, (Window) m_window->GetXWindow(),
m_glContext );;
}
}
void wxGLContext::SetColour(const char *colour)
{
wxColour *the_colour = wxTheColourDatabase->FindColour(colour);
if(the_colour) {
GLboolean b;
glGetBooleanv(GL_RGBA_MODE, &b);
if(b) {
glColor3ub(the_colour->Red(),
the_colour->Green(),
the_colour->Blue());
} else {
GLint pix = (GLint)the_colour->m_pixel;
if(pix == -1) {
XColor exact_def;
exact_def.red = (unsigned short)the_colour->Red() << 8;
exact_def.green = (unsigned short)the_colour->Green() << 8;
exact_def.blue = (unsigned short)the_colour->Blue() << 8;
exact_def.flags = DoRed | DoGreen | DoBlue;
if(!XAllocColor((Display*) m_window->GetXDisplay(),
(Colormap) wxTheApp->GetMainColormap(m_window->GetXDisplay()),
&exact_def)) {
wxDebugMsg("wxGLCanvas: cannot allocate color\n");
return;
}
pix = the_colour->m_pixel = exact_def.pixel;
}
glIndexi(pix);
}
}
}
void wxGLContext::SetupPixelFormat()
{
}
void wxGLContext::SetupPalette( const wxPalette& WXUNUSED(palette) )
{
}
wxPalette wxGLContext::CreateDefaultPalette()
{
return wxNullPalette;
}
/*
* GLCanvas implementation
*/
IMPLEMENT_CLASS(wxGLCanvas, wxScrolledWindow)
BEGIN_EVENT_TABLE(wxGLCanvas, wxScrolledWindow)
// EVT_SIZE(wxGLCanvas::OnSize)
END_EVENT_TABLE()
wxGLCanvas::wxGLCanvas( wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, NULL, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLContext *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, shared, NULL, id, pos, size, style, name, attribList, palette );
}
wxGLCanvas::wxGLCanvas( wxWindow *parent,
const wxGLCanvas *shared,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette )
: wxScrolledWindow(parent, id, pos, size, style, name)
{
Create( parent, NULL, shared, id, pos, size, style, name, attribList, palette );
}
/*
bool wxGLCanvas::Create(wxWindow *parent,
const wxGLContext *shared, const wxGLCanvas *shared_context_of,
wxWindowID id = -1, const wxPoint& pos,
const wxSize& size, long style,
const wxString& name, int *attribList, const wxPalette& palette):
wxScrolledWindow(parent, id, pos, size, style, name)
*/
bool wxGLCanvas::Create( wxWindow *parent,
const wxGLContext *shared,
const wxGLCanvas *shared_context_of,
wxWindowID id,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name,
int *attribList,
const wxPalette& palette)
{
XVisualInfo *vi, vi_templ;
XWindowAttributes xwa;
int val, n;
m_sharedContext = (wxGLContext*)shared; // const_cast
m_sharedContextOf = (wxGLCanvas*)shared_context_of; // const_cast
m_glContext = (wxGLContext*) NULL;
Display* display = (Display*) GetXDisplay();
// Check for the presence of the GLX extension
if(!glXQueryExtension(display, NULL, NULL)) {
wxDebugMsg("wxGLCanvas: GLX extension is missing\n");
return false;
}
if(attribList) {
int data[512], arg=0, p=0;
while( (attribList[arg]!=0) && (p<512) )
{
switch( attribList[arg++] )
{
case WX_GL_RGBA: data[p++] = GLX_RGBA; break;
case WX_GL_BUFFER_SIZE:
data[p++]=GLX_BUFFER_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_LEVEL:
data[p++]=GLX_LEVEL; data[p++]=attribList[arg++]; break;
case WX_GL_DOUBLEBUFFER: data[p++] = GLX_DOUBLEBUFFER; break;
case WX_GL_STEREO: data[p++] = GLX_STEREO; break;
case WX_GL_AUX_BUFFERS:
data[p++]=GLX_AUX_BUFFERS; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_RED:
data[p++]=GLX_RED_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_GREEN:
data[p++]=GLX_GREEN_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_BLUE:
data[p++]=GLX_BLUE_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ALPHA:
data[p++]=GLX_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_DEPTH_SIZE:
data[p++]=GLX_DEPTH_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_STENCIL_SIZE:
data[p++]=GLX_STENCIL_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_RED:
data[p++]=GLX_ACCUM_RED_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_GREEN:
data[p++]=GLX_ACCUM_GREEN_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_BLUE:
data[p++]=GLX_ACCUM_BLUE_SIZE; data[p++]=attribList[arg++]; break;
case WX_GL_MIN_ACCUM_ALPHA:
data[p++]=GLX_ACCUM_ALPHA_SIZE; data[p++]=attribList[arg++]; break;
default:
break;
}
}
data[p] = 0;
attribList = (int*) data;
// Get an appropriate visual
vi = glXChooseVisual(display, DefaultScreen(display), attribList);
if(!vi) return false;
// Here we should make sure that vi is the same visual as the
// one used by the xwindow drawable in wxCanvas. However,
// there is currently no mechanism for this in wx_canvs.cc.
} else {
// By default, we use the visual of xwindow
// NI: is this really senseful ? opengl in e.g. color index mode ?
XGetWindowAttributes(display, (Window) GetXWindow(), &xwa);
vi_templ.visualid = XVisualIDFromVisual(xwa.visual);
vi = XGetVisualInfo(display, VisualIDMask, &vi_templ, &n);
if(!vi) return false;
glXGetConfig(display, vi, GLX_USE_GL, &val);
if(!val) return false;
// Basically, this is it. It should be possible to use vi
// in glXCreateContext() below. But this fails with Mesa.
// I notified the Mesa author about it; there may be a fix.
#ifdef OLD_MESA
// Construct an attribute list matching the visual
int a_list[32];
n = 0;
if(vi->c_class==TrueColor || vi->c_class==DirectColor) { // RGBA visual
a_list[n++] = GLX_RGBA;
a_list[n++] = GLX_RED_SIZE;
a_list[n++] = bitcount(vi->red_mask);
a_list[n++] = GLX_GREEN_SIZE;
a_list[n++] = bitcount(vi->green_mask);
a_list[n++] = GLX_BLUE_SIZE;
a_list[n++] = bitcount(vi->blue_mask);
glXGetConfig(display, vi, GLX_ALPHA_SIZE, &val);
a_list[n++] = GLX_ALPHA_SIZE;
a_list[n++] = val;
} else { // Color index visual
glXGetConfig(display, vi, GLX_BUFFER_SIZE, &val);
a_list[n++] = GLX_BUFFER_SIZE;
a_list[n++] = val;
}
a_list[n] = None;
// XFree(vi);
vi = glXChooseVisual(display, DefaultScreen(display), a_list);
if(!vi) return false;
#endif /* OLD_MESA */
}
m_vi = vi; // safe for later use
wxCHECK_MSG( m_vi, FALSE, "required visual couldn't be found" );
// Create the GLX context and make it current
wxGLContext *share= m_sharedContext;
if (share==NULL && m_sharedContextOf)
share = m_sharedContextOf->GetContext();
m_glContext = new wxGLContext( TRUE, this, wxNullPalette, share );
#ifndef OLD_MESA
// XFree(vi);
#endif
SetCurrent();
return true;
}
wxGLCanvas::~wxGLCanvas(void)
{
XVisualInfo *vi = (XVisualInfo *) m_vi;
if (vi) XFree( vi );
if (m_glContext) delete m_glContext;
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXDestroyContext(display, glx_cx);
}
void wxGLCanvas::SwapBuffers()
{
if( m_glContext ) m_glContext->SwapBuffers();
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXSwapBuffers(display, (Window) GetXWindow());
}
void wxGLCanvas::SetCurrent()
{
if( m_glContext ) m_glContext->SetCurrent();
// Display* display = (Display*) GetXDisplay();
// if(glx_cx) glXMakeCurrent(display, (Window) GetXWindow(), glx_cx);
}
void wxGLCanvas::SetColour(const char *col)
{
if( m_glContext ) m_glContext->SetColour(col);
}
#endif
// wxUSE_GLCANVAS

126
src/x11/gsockx11.c Normal file
View File

@@ -0,0 +1,126 @@
/* -------------------------------------------------------------------------
* Project: GSocket (Generic Socket) for WX
* Name: gsockmot.c
* Purpose: GSocket: Motif part
* CVSID: $Id$
* ------------------------------------------------------------------------- */
#include "wx/setup.h"
#if wxUSE_SOCKETS
#include <stdlib.h>
#include <X11/Intrinsic.h>
#include "wx/gsocket.h"
#include "wx/unix/gsockunx.h"
extern XtAppContext wxGetAppContext();
static void _GSocket_Motif_Input(XtPointer data, int *fid,
XtInputId *id)
{
GSocket *socket = (GSocket *)data;
_GSocket_Detected_Read(socket);
}
static void _GSocket_Motif_Output(XtPointer data, int *fid,
XtInputId *id)
{
GSocket *socket = (GSocket *)data;
_GSocket_Detected_Write(socket);
}
int _GSocket_GUI_Init(GSocket *socket)
{
int *m_id;
socket->m_gui_dependent = (char *)malloc(sizeof(int)*2);
m_id = (int *)(socket->m_gui_dependent);
m_id[0] = -1;
m_id[1] = -1;
return TRUE;
}
void _GSocket_GUI_Destroy(GSocket *socket)
{
free(socket->m_gui_dependent);
}
void _GSocket_Install_Callback(GSocket *socket, GSocketEvent event)
{
int *m_id = (int *)(socket->m_gui_dependent);
int c;
if (socket->m_fd == -1)
return;
switch (event)
{
case GSOCK_LOST: /* fall-through */
case GSOCK_INPUT: c = 0; break;
case GSOCK_OUTPUT: c = 1; break;
case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
default: return;
}
if (m_id[c] != -1)
XtRemoveInput(m_id[c]);
if (c == 0)
{
m_id[0] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
(XtPointer *)XtInputReadMask,
(XtInputCallbackProc) _GSocket_Motif_Input,
(XtPointer) socket);
}
else
{
m_id[1] = XtAppAddInput(wxGetAppContext(), socket->m_fd,
(XtPointer *)XtInputWriteMask,
(XtInputCallbackProc) _GSocket_Motif_Output,
(XtPointer) socket);
}
}
void _GSocket_Uninstall_Callback(GSocket *socket, GSocketEvent event)
{
int *m_id = (int *)(socket->m_gui_dependent);
int c;
switch (event)
{
case GSOCK_LOST: /* fall-through */
case GSOCK_INPUT: c = 0; break;
case GSOCK_OUTPUT: c = 1; break;
case GSOCK_CONNECTION: c = ((socket->m_server) ? 0 : 1); break;
default: return;
}
if (m_id[c] != -1)
XtRemoveInput(m_id[c]);
m_id[c] = -1;
}
void _GSocket_Enable_Events(GSocket *socket)
{
_GSocket_Install_Callback(socket, GSOCK_INPUT);
_GSocket_Install_Callback(socket, GSOCK_OUTPUT);
}
void _GSocket_Disable_Events(GSocket *socket)
{
_GSocket_Uninstall_Callback(socket, GSOCK_INPUT);
_GSocket_Uninstall_Callback(socket, GSOCK_OUTPUT);
}
#else /* !wxUSE_SOCKETS */
/* some compilers don't like having empty source files */
static int wxDummyGsockVar = 0;
#endif /* wxUSE_SOCKETS/!wxUSE_SOCKETS */

82
src/x11/icon.cpp Normal file
View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: icon.cpp
// Purpose: wxIcon class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "icon.h"
#endif
#include "wx/icon.h"
#include "wx/window.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/cursorfont.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxIcon, wxBitmap)
/*
* Icons
*/
wxIcon::wxIcon()
{
}
// Create from XBM data
wxIcon::wxIcon(const char bits[], int width, int height)
{
(void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, 1);
}
// Create from XPM data
wxIcon::wxIcon(char **data)
{
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
wxIcon::wxIcon(const char **data)
{
(void) Create((void*) data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
}
wxIcon::wxIcon(const wxString& icon_file, long flags,
int desiredWidth, int desiredHeight)
{
LoadFile(icon_file, flags, desiredWidth, desiredHeight);
}
wxIcon::~wxIcon()
{
}
bool wxIcon::LoadFile(const wxString& filename, long type,
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;
}

284
src/x11/joystick.cpp Normal file
View File

@@ -0,0 +1,284 @@
/////////////////////////////////////////////////////////////////////////////
// Name: joystick.cpp
// Purpose: wxJoystick class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "joystick.h"
#endif
// Not implemented in wxMotif
#if 0
#include "wx/joystick.h"
IMPLEMENT_DYNAMIC_CLASS(wxJoystick, wxObject)
// Attributes
////////////////////////////////////////////////////////////////////////////
wxPoint wxJoystick::GetPosition() const
{
// TODO
return wxPoint(0, 0);
}
int wxJoystick::GetZPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetButtonState() const
{
// TODO
return 0;
}
int wxJoystick::GetPOVPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetPOVCTSPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetRudderPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetUPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetVPosition() const
{
// TODO
return 0;
}
int wxJoystick::GetMovementThreshold() const
{
// TODO
return 0;
}
void wxJoystick::SetMovementThreshold(int threshold)
{
// TODO
}
// Capabilities
////////////////////////////////////////////////////////////////////////////
bool wxJoystick::IsOk() const
{
// TODO
return FALSE;
}
int wxJoystick::GetNumberJoysticks() const
{
// TODO
return 0;
}
int wxJoystick::GetManufacturerId() const
{
// TODO
return 0;
}
int wxJoystick::GetProductId() const
{
// TODO
return 0;
}
wxString wxJoystick::GetProductName() const
{
// TODO
return wxString("");
}
int wxJoystick::GetXMin() const
{
// TODO
return 0;
}
int wxJoystick::GetYMin() const
{
// TODO
return 0;
}
int wxJoystick::GetZMin() const
{
// TODO
return 0;
}
int wxJoystick::GetXMax() const
{
// TODO
return 0;
}
int wxJoystick::GetYMax() const
{
// TODO
return 0;
}
int wxJoystick::GetZMax() const
{
// TODO
return 0;
}
int wxJoystick::GetNumberButtons() const
{
// TODO
return 0;
}
int wxJoystick::GetNumberAxes() const
{
// TODO
return 0;
}
int wxJoystick::GetMaxButtons() const
{
// TODO
return 0;
}
int wxJoystick::GetMaxAxes() const
{
// TODO
return 0;
}
int wxJoystick::GetPollingMin() const
{
// TODO
return 0;
}
int wxJoystick::GetPollingMax() const
{
// TODO
return 0;
}
int wxJoystick::GetRudderMin() const
{
// TODO
return 0;
}
int wxJoystick::GetRudderMax() const
{
// TODO
return 0;
}
int wxJoystick::GetUMin() const
{
// TODO
return 0;
}
int wxJoystick::GetUMax() const
{
// TODO
return 0;
}
int wxJoystick::GetVMin() const
{
// TODO
return 0;
}
int wxJoystick::GetVMax() const
{
// TODO
return 0;
}
bool wxJoystick::HasRudder() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasZ() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasU() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasV() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasPOV() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasPOV4Dir() const
{
// TODO
return FALSE;
}
bool wxJoystick::HasPOVCTS() const
{
// TODO
return FALSE;
}
// Operations
////////////////////////////////////////////////////////////////////////////
bool wxJoystick::SetCapture(wxWindow* win, int pollingFreq)
{
// TODO
return FALSE;
}
bool wxJoystick::ReleaseCapture()
{
// TODO
return FALSE;
}
#endif
// 0

18
src/x11/main.cpp Normal file
View File

@@ -0,0 +1,18 @@
/////////////////////////////////////////////////////////////////////////////
// Name: main.cpp
// Purpose: Entry point
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#include "wx/app.h"
int main(int argc, char* argv[])
{
return wxEntry(argc, argv);
}

356
src/x11/makefile.unx Normal file
View File

@@ -0,0 +1,356 @@
##############################################################################
# Microwindows template Makefile
# Copyright (c) 2000 Martin Jolicoeur, Greg Haerr
##############################################################################
TOP=$(MICROWINDOWS)
ifeq "$(MICROWINDOWS)" ""
TOP=/home/julians/local/microwindows/microwindows-0.89pre8/src
endif
CONFIG = $(TOP)/config
WXDIR = ../..
OBJSUFF = o
SRCSUFF = cpp
WXLIB=$(WXDIR)/lib/libwx.a
AROPTIONS = ruv
RANLIB = ranlib
RM = rm -f
GENDIR = $(WXDIR)/src/generic
COMMDIR = $(WXDIR)/src/common
HTMLDIR = $(WXDIR)/src/html
ZLIBDIR = $(WXDIR)/src/zlib
PNGDIR = $(WXDIR)/src/png
JPEGDIR = $(WXDIR)/src/jpeg
TIFFDIR = $(WXDIR)/src/tiff
OLEDIR = $(WXDIR)/src/msw/ole
MICROWINDIR = $(WXDIR)/src/msw
UNIXDIR = $(WXDIR)/src/unix
UNIVDIR = $(WXDIR)/src/univ
ZLIBLIB = $(WXDIR)/lib/libzlib.a
PNGLIB = $(WXDIR)/lib/libpng.a
JPEGLIB = $(WXDIR)/lib/libjpeg.a
TIFFLIB = $(WXDIR)/lib/libtiff.a
GENERICOBJS = \
$(GENDIR)/accel.$(OBJSUFF) \
$(GENDIR)/busyinfo.$(OBJSUFF) \
$(GENDIR)/calctrl.$(OBJSUFF) \
$(GENDIR)/choicdgg.$(OBJSUFF) \
$(GENDIR)/colrdlgg.$(OBJSUFF) \
$(GENDIR)/dirctrlg.$(OBJSUFF) \
$(GENDIR)/dragimgg.$(OBJSUFF) \
$(GENDIR)/fontdlgg.$(OBJSUFF) \
$(GENDIR)/grid.$(OBJSUFF) \
$(GENDIR)/gridctrl.$(OBJSUFF) \
$(GENDIR)/gridsel.$(OBJSUFF) \
$(GENDIR)/imaglist.$(OBJSUFF) \
$(GENDIR)/laywin.$(OBJSUFF) \
$(GENDIR)/listctrl.$(OBJSUFF) \
$(GENDIR)/logg.$(OBJSUFF) \
$(GENDIR)/msgdlgg.$(OBJSUFF) \
$(GENDIR)/numdlgg.$(OBJSUFF) \
$(GENDIR)/panelg.$(OBJSUFF) \
$(GENDIR)/progdlgg.$(OBJSUFF) \
$(GENDIR)/sashwin.$(OBJSUFF) \
$(GENDIR)/scrlwing.$(OBJSUFF) \
$(GENDIR)/spinctlg.$(OBJSUFF) \
$(GENDIR)/splash.$(OBJSUFF) \
$(GENDIR)/splitter.$(OBJSUFF) \
$(GENDIR)/tabg.$(OBJSUFF) \
$(GENDIR)/tbarsmpl.$(OBJSUFF) \
$(GENDIR)/textdlgg.$(OBJSUFF) \
$(GENDIR)/tipdlg.$(OBJSUFF) \
$(GENDIR)/tipwin.$(OBJSUFF) \
$(GENDIR)/treectlg.$(OBJSUFF) \
$(GENDIR)/treelay.$(OBJSUFF) \
$(GENDIR)/wizard.$(OBJSUFF)
COMMONOBJS = \
$(COMMDIR)/appcmn.$(OBJSUFF) \
$(COMMDIR)/choiccmn.$(OBJSUFF) \
$(COMMDIR)/clntdata.$(OBJSUFF) \
$(COMMDIR)/clipcmn.$(OBJSUFF) \
$(COMMDIR)/cmdline.$(OBJSUFF) \
$(COMMDIR)/cmdproc.$(OBJSUFF) \
$(COMMDIR)/cmndata.$(OBJSUFF) \
$(COMMDIR)/config.$(OBJSUFF) \
$(COMMDIR)/containr.$(OBJSUFF) \
$(COMMDIR)/cshelp.$(OBJSUFF) \
$(COMMDIR)/ctrlcmn.$(OBJSUFF) \
$(COMMDIR)/ctrlsub.$(OBJSUFF) \
$(COMMDIR)/datetime.$(OBJSUFF) \
$(COMMDIR)/datstrm.$(OBJSUFF) \
$(COMMDIR)/dcbase.$(OBJSUFF) \
$(COMMDIR)/dircmn.$(OBJSUFF) \
$(COMMDIR)/dlgcmn.$(OBJSUFF) \
$(COMMDIR)/dobjcmn.$(OBJSUFF) \
$(COMMDIR)/docview.$(OBJSUFF) \
$(COMMDIR)/dynarray.$(OBJSUFF) \
$(COMMDIR)/dynlib.$(OBJSUFF) \
$(COMMDIR)/effects.$(OBJSUFF) \
$(COMMDIR)/encconv.$(OBJSUFF) \
$(COMMDIR)/event.$(OBJSUFF) \
$(COMMDIR)/extended.$(OBJSUFF) \
$(COMMDIR)/ffile.$(OBJSUFF) \
$(COMMDIR)/file.$(OBJSUFF) \
$(COMMDIR)/fileconf.$(OBJSUFF) \
$(COMMDIR)/filefn.$(OBJSUFF) \
$(COMMDIR)/filename.$(OBJSUFF) \
$(COMMDIR)/filesys.$(OBJSUFF) \
$(COMMDIR)/fontcmn.$(OBJSUFF) \
$(COMMDIR)/fontmap.$(OBJSUFF) \
$(COMMDIR)/framecmn.$(OBJSUFF) \
$(COMMDIR)/gaugecmn.$(OBJSUFF) \
$(COMMDIR)/gdicmn.$(OBJSUFF) \
$(COMMDIR)/geometry.$(OBJSUFF) \
$(COMMDIR)/gifdecod.$(OBJSUFF) \
$(COMMDIR)/hash.$(OBJSUFF) \
$(COMMDIR)/helpbase.$(OBJSUFF) \
$(COMMDIR)/imagall.$(OBJSUFF) \
$(COMMDIR)/imagbmp.$(OBJSUFF) \
$(COMMDIR)/image.$(OBJSUFF) \
$(COMMDIR)/imaggif.$(OBJSUFF) \
$(COMMDIR)/imagjpeg.$(OBJSUFF) \
$(COMMDIR)/imagpcx.$(OBJSUFF) \
$(COMMDIR)/imagpng.$(OBJSUFF) \
$(COMMDIR)/imagpnm.$(OBJSUFF) \
$(COMMDIR)/imagtiff.$(OBJSUFF) \
$(COMMDIR)/imagxpm.$(OBJSUFF) \
$(COMMDIR)/intl.$(OBJSUFF) \
$(COMMDIR)/ipcbase.$(OBJSUFF) \
$(COMMDIR)/layout.$(OBJSUFF) \
$(COMMDIR)/lboxcmn.$(OBJSUFF) \
$(COMMDIR)/list.$(OBJSUFF) \
$(COMMDIR)/log.$(OBJSUFF) \
$(COMMDIR)/longlong.$(OBJSUFF) \
$(COMMDIR)/matrix.$(OBJSUFF) \
$(COMMDIR)/memory.$(OBJSUFF) \
$(COMMDIR)/menucmn.$(OBJSUFF) \
$(COMMDIR)/mimecmn.$(OBJSUFF) \
$(COMMDIR)/module.$(OBJSUFF) \
$(COMMDIR)/mstream.$(OBJSUFF) \
$(COMMDIR)/nbkbase.$(OBJSUFF) \
$(COMMDIR)/object.$(OBJSUFF) \
$(COMMDIR)/paper.$(OBJSUFF) \
$(COMMDIR)/popupcmn.$(OBJSUFF) \
$(COMMDIR)/prntbase.$(OBJSUFF) \
$(COMMDIR)/process.$(OBJSUFF) \
$(COMMDIR)/quantize.$(OBJSUFF) \
$(COMMDIR)/radiocmn.$(OBJSUFF) \
$(COMMDIR)/resource.$(OBJSUFF) \
$(COMMDIR)/sizer.$(OBJSUFF) \
$(COMMDIR)/statbar.$(OBJSUFF) \
$(COMMDIR)/strconv.$(OBJSUFF) \
$(COMMDIR)/stream.$(OBJSUFF) \
$(COMMDIR)/string.$(OBJSUFF) \
$(COMMDIR)/sysopt.$(OBJSUFF) \
$(COMMDIR)/tbarbase.$(OBJSUFF) \
$(COMMDIR)/textbuf.$(OBJSUFF) \
$(COMMDIR)/textcmn.$(OBJSUFF) \
$(COMMDIR)/textfile.$(OBJSUFF) \
$(COMMDIR)/timercmn.$(OBJSUFF) \
$(COMMDIR)/tokenzr.$(OBJSUFF) \
$(COMMDIR)/toplvcmn.$(OBJSUFF) \
$(COMMDIR)/treebase.$(OBJSUFF) \
$(COMMDIR)/txtstrm.$(OBJSUFF) \
$(COMMDIR)/utilscmn.$(OBJSUFF) \
$(UNIXDIR)/utilsunx.$(OBJSUFF) \
$(COMMDIR)/valgen.$(OBJSUFF) \
$(COMMDIR)/validate.$(OBJSUFF) \
$(COMMDIR)/valtext.$(OBJSUFF) \
$(COMMDIR)/variant.$(OBJSUFF) \
$(COMMDIR)/wfstream.$(OBJSUFF) \
$(COMMDIR)/wincmn.$(OBJSUFF) \
$(COMMDIR)/wxchar.$(OBJSUFF) \
$(COMMDIR)/xpmdecod.$(OBJSUFF)
HTMLOBJS = \
$(HTMLDIR)/helpctrl.$(OBJSUFF) \
$(HTMLDIR)/helpdata.$(OBJSUFF) \
$(HTMLDIR)/helpfrm.$(OBJSUFF) \
$(HTMLDIR)/htmlcell.$(OBJSUFF) \
$(HTMLDIR)/htmlfilt.$(OBJSUFF) \
$(HTMLDIR)/htmlpars.$(OBJSUFF) \
$(HTMLDIR)/htmltag.$(OBJSUFF) \
$(HTMLDIR)/htmlwin.$(OBJSUFF) \
$(HTMLDIR)/htmprint.$(OBJSUFF) \
$(HTMLDIR)/m_dflist.$(OBJSUFF) \
$(HTMLDIR)/m_fonts.$(OBJSUFF) \
$(HTMLDIR)/m_hline.$(OBJSUFF) \
$(HTMLDIR)/m_image.$(OBJSUFF) \
$(HTMLDIR)/m_layout.$(OBJSUFF) \
$(HTMLDIR)/m_links.$(OBJSUFF) \
$(HTMLDIR)/m_list.$(OBJSUFF) \
$(HTMLDIR)/m_meta.$(OBJSUFF) \
$(HTMLDIR)/m_pre.$(OBJSUFF) \
$(HTMLDIR)/m_tables.$(OBJSUFF) \
$(HTMLDIR)/winpars.$(OBJSUFF)
MSWOBJS = \
$(MICROWINDIR)/app.$(OBJSUFF) \
$(MICROWINDIR)/bitmap.$(OBJSUFF) \
$(MICROWINDIR)/brush.$(OBJSUFF) \
$(MICROWINDIR)/caret.$(OBJSUFF) \
$(MICROWINDIR)/clipbrd.$(OBJSUFF) \
$(MICROWINDIR)/colour.$(OBJSUFF) \
$(MICROWINDIR)/cursor.$(OBJSUFF) \
$(MICROWINDIR)/data.$(OBJSUFF) \
$(MICROWINDIR)/dc.$(OBJSUFF) \
$(MICROWINDIR)/dcclient.$(OBJSUFF) \
$(MICROWINDIR)/dcmemory.$(OBJSUFF) \
$(MICROWINDIR)/dcprint.$(OBJSUFF) \
$(MICROWINDIR)/dcscreen.$(OBJSUFF) \
$(MICROWINDIR)/dde.$(OBJSUFF) \
$(MICROWINDIR)/dialog.$(OBJSUFF) \
$(MICROWINDIR)/dialup.$(OBJSUFF) \
$(UNIXDIR)/dir.$(OBJSUFF) \
$(MICROWINDIR)/evtloop.$(OBJSUFF) \
$(MICROWINDIR)/font.$(OBJSUFF) \
$(MICROWINDIR)/fontenum.$(OBJSUFF) \
$(MICROWINDIR)/fontutil.$(OBJSUFF) \
$(MICROWINDIR)/gdiimage.$(OBJSUFF) \
$(MICROWINDIR)/gdiobj.$(OBJSUFF) \
$(MICROWINDIR)/icon.$(OBJSUFF) \
$(MICROWINDIR)/main.$(OBJSUFF) \
$(MICROWINDIR)/microwin.$(OBJSUFF) \
$(MICROWINDIR)/palette.$(OBJSUFF) \
$(MICROWINDIR)/pen.$(OBJSUFF) \
$(MICROWINDIR)/region.$(OBJSUFF) \
$(MICROWINDIR)/settings.$(OBJSUFF) \
$(MICROWINDIR)/snglinst.$(OBJSUFF) \
$(MICROWINDIR)/thread.$(OBJSUFF) \
$(MICROWINDIR)/timer.$(OBJSUFF) \
$(MICROWINDIR)/toplevel.$(OBJSUFF) \
$(MICROWINDIR)/utils.$(OBJSUFF) \
$(MICROWINDIR)/window.$(OBJSUFF) \
$(OLEDIR)/dataobj.$(OBJSUFF)
UNIVOBJS_TODO = $(UNIVDIR)/choice.$(OBJSUFF) \
$(UNIVDIR)/colordlg.$(OBJSUFF) \
UNIVOBJS = \
$(UNIVDIR)/bmpbuttn.$(OBJSUFF) \
$(UNIVDIR)/button.$(OBJSUFF) \
$(UNIVDIR)/checkbox.$(OBJSUFF) \
$(UNIVDIR)/checklst.$(OBJSUFF) \
$(UNIVDIR)/colschem.$(OBJSUFF) \
$(UNIVDIR)/combobox.$(OBJSUFF) \
$(UNIVDIR)/control.$(OBJSUFF) \
$(UNIVDIR)/framuniv.$(OBJSUFF) \
$(UNIVDIR)/gauge.$(OBJSUFF) \
$(UNIVDIR)/inphand.$(OBJSUFF) \
$(UNIVDIR)/inpcons.$(OBJSUFF) \
$(UNIVDIR)/listbox.$(OBJSUFF) \
$(UNIVDIR)/menu.$(OBJSUFF) \
$(UNIVDIR)/notebook.$(OBJSUFF) \
$(UNIVDIR)/radiobox.$(OBJSUFF) \
$(UNIVDIR)/radiobut.$(OBJSUFF) \
$(UNIVDIR)/renderer.$(OBJSUFF) \
$(UNIVDIR)/scrarrow.$(OBJSUFF) \
$(UNIVDIR)/scrolbar.$(OBJSUFF) \
$(UNIVDIR)/scrthumb.$(OBJSUFF) \
$(UNIVDIR)/slider.$(OBJSUFF) \
$(UNIVDIR)/spinbutt.$(OBJSUFF) \
$(UNIVDIR)/statbmp.$(OBJSUFF) \
$(UNIVDIR)/statbox.$(OBJSUFF) \
$(UNIVDIR)/statline.$(OBJSUFF) \
$(UNIVDIR)/stattext.$(OBJSUFF) \
$(UNIVDIR)/statusbr.$(OBJSUFF) \
$(UNIVDIR)/textctrl.$(OBJSUFF) \
$(UNIVDIR)/theme.$(OBJSUFF) \
$(UNIVDIR)/topluniv.$(OBJSUFF) \
$(UNIVDIR)/winuniv.$(OBJSUFF) \
$(UNIVDIR)/themes/gtk.$(OBJSUFF) \
$(UNIVDIR)/themes/win32.$(OBJSUFF)
include $(CONFIG)
######################## Additional Flags section ############################
# Directories list for header files
INCLUDEDIRS += -I$(WXDIR)/include
# Defines for preprocessor
DEFINES += -DMWIN -D__WXMSW__ -D__WXMICROWIN__ -D__WXUNIVERSAL__ -D__WIN32__ -D__WIN95__ -DHAVE_BOOL -DMICROWIN_TODO=1 -D__UNIX__ -DHAVE_NANOSLEEP -DMICROWIN_NOCONTROLS -D__WXDEBUG__ -DwxSIZE_T_IS_UINT -DWXWIN_OS_DESCRIPTION="\"MicroWindows\""
# Compilation flags for C files OTHER than include directories
CFLAGS +=
# Preprocessor flags OTHER than defines
CPPFLAGS +=
# Linking flags
LDFLAGS +=
############################# targets section ################################
# If you want to create a library with the objects files, define the name here
LIBNAME =
# If we put it below OBJS=, Makefile.rules includes .depend
# and it continually looks for .c files to satisfy .o.cpp
# dependency. What's going on there?
include $(TOP)/Makefile.rules
# List of objects to compile
OBJS = $(COMMONOBJS) $(MSWOBJS) $(GENERICOBJS) $(UNIVOBJS)
all: $(WXLIB)
######################### Makefile.rules section #############################
######################## Tools targets section ###############################
#ntest: $(OBJS) $(NANOXCLIENTLIBS) $(TOP)/config
# $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $@ $(NANOXCLIENTLIBS)
$(WXLIB): $(OBJS)
ar $(AROPTIONS) $@ $(OBJS)
$(RANLIB) $@
#.SUFFIXES: .cpp .cxx .c
#.c.o:
# $(CC) -c $(CFLAGS) $(CFLAGS) -o $@ $*.c
.cxx.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.cxx
.cpp.o:
$(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $*.cpp
#$(COMMDIR)/appcmn.o: $(COMMDIR)/appcmn.cpp
# $(CC) -c $(CPPFLAGS) -o $@ $*.cpp
#appcmn.o: $(COMMDIR)/appcmn.cpp
# $(CC) $(CPPFLAGS) -c -o $@ $<
cleanwx:
-$(RM) *.o
-$(RM) *.bak
-$(RM) core
-$(RM) ole/*.o
-$(RM) ../common/y_tab.c
-$(RM) ../common/lex_yy.c
-$(RM) ../common/*.o
-$(RM) ../common/*.bak
-$(RM) ../generic/*.o
-$(RM) ../generic/*.bak
-$(RM) ../univ/*.o
-$(RM) ../univ/*.bak
-$(RM) ../univ/themes/*.o
-$(RM) ../univ/themes/*.bak
-$(RM) ../unix/*.o
-$(RM) ../unix/*.bak
-$(RM) ../html/*.o
-$(RM) ../zlib/*.o
-$(RM) ../zlib/*.bak
-$(RM) ../png/*.o
-$(RM) ../png/*.bak
-$(RM) ../jpeg/*.o
-$(RM) ../jpeg/*.bak
-$(RM) ../tiff/*.o
-$(RM) ../tiff/*.bak

767
src/x11/menu.cpp Normal file
View File

@@ -0,0 +1,767 @@
/////////////////////////////////////////////////////////////////////////////
// Name: menu.cpp
// Purpose: wxMenu, wxMenuBar, wxMenuItem
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
#ifdef __GNUG__
#pragma implementation "menu.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#include "wx/menu.h"
#include "wx/menuitem.h"
#include "wx/log.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/frame.h"
#include "wx/settings.h"
#ifdef __VMS__
#pragma message disable nosimpint
#define XtDisplay XTDISPLAY
#define XtWindow XTWINDOW
#endif
#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/CascadeBG.h>
#include <Xm/CascadeB.h>
#include <Xm/SeparatoG.h>
#include <Xm/PushBG.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#include <Xm/RowColumn.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
// other standard headers
#include <string.h>
IMPLEMENT_DYNAMIC_CLASS(wxMenu, wxEvtHandler)
IMPLEMENT_DYNAMIC_CLASS(wxMenuBar, wxEvtHandler)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// Menus
// ----------------------------------------------------------------------------
// Construct a menu with optional title (then use append)
void wxMenu::Init()
{
// Motif-specific members
m_numColumns = 1;
m_menuWidget = (WXWidget) NULL;
m_popupShell = (WXWidget) NULL;
m_buttonWidget = (WXWidget) NULL;
m_menuId = 0;
m_topLevelMenu = (wxMenu*) NULL;
m_ownedByMenuBar = FALSE;
if ( !!m_title )
{
Append(wxID_SEPARATOR, m_title) ;
AppendSeparator() ;
}
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT);
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
}
// The wxWindow destructor will take care of deleting the submenus.
wxMenu::~wxMenu()
{
if (m_menuWidget)
{
if (m_menuParent)
DestroyMenu(TRUE);
else
DestroyMenu(FALSE);
}
// Not sure if this is right
if (m_menuParent && m_menuBar)
{
m_menuParent = NULL;
// m_menuBar = NULL;
}
}
void wxMenu::Break()
{
m_numColumns++;
}
// function appends a new item or submenu to the menu
bool wxMenu::DoAppend(wxMenuItem *pItem)
{
if (m_menuWidget)
{
// this is a dynamic Append
pItem->CreateItem(m_menuWidget, m_menuBar, m_topLevelMenu);
}
if ( pItem->IsSubMenu() )
{
pItem->GetSubMenu()->m_topLevelMenu = m_topLevelMenu;
}
return wxMenuBase::DoAppend(pItem);
}
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
{
item->DestroyItem(TRUE);
return wxMenuBase::DoRemove(item);
}
bool wxMenu::DoInsert(size_t pos, wxMenuItem *item)
{
if ( !wxMenuBase::DoInsert(pos, item) )
return FALSE;
wxFAIL_MSG(wxT("not implemented"));
return FALSE;
}
void wxMenu::SetTitle(const wxString& label)
{
m_title = label;
wxMenuItemList::Node *node = GetMenuItems().GetFirst();
if ( !node )
return;
wxMenuItem *item = node->GetData ();
Widget widget = (Widget) item->GetButtonWidget();
if ( !widget )
return;
wxXmString title_str(label);
XtVaSetValues(widget,
XmNlabelString, title_str(),
NULL);
}
bool wxMenu::ProcessCommand(wxCommandEvent & event)
{
bool processed = FALSE;
#if wxUSE_MENU_CALLBACK
// Try a callback
if (m_callback)
{
(void) (*(m_callback)) (*this, event);
processed = TRUE;
}
#endif // wxUSE_MENU_CALLBACK
// Try the menu's event handler
if ( !processed && GetEventHandler())
{
processed = GetEventHandler()->ProcessEvent(event);
}
// Try the window the menu was popped up from (and up
// through the hierarchy)
if ( !processed && GetInvokingWindow())
processed = GetInvokingWindow()->ProcessEvent(event);
return processed;
}
// ----------------------------------------------------------------------------
// Menu Bar
// ----------------------------------------------------------------------------
void wxMenuBar::Init()
{
m_eventHandler = this;
m_menuBarFrame = NULL;
m_mainWidget = (WXWidget) NULL;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENU);
m_foregroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_MENUTEXT);
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
}
wxMenuBar::wxMenuBar(int n, wxMenu *menus[], const wxString titles[])
{
Init();
for ( int i = 0; i < n; i++ )
{
m_menus.Append(menus[i]);
m_titles.Add(titles[i]);
}
}
wxMenuBar::~wxMenuBar()
{
// nothing to do: wxMenuBarBase will delete the menus
}
void wxMenuBar::EnableTop(size_t WXUNUSED(pos), bool WXUNUSED(flag))
{
// wxFAIL_MSG("TODO");
// wxLogWarning("wxMenuBar::EnableTop not yet implemented.");
}
void wxMenuBar::SetLabelTop(size_t pos, const wxString& label)
{
wxMenu *menu = GetMenu(pos);
if ( !menu )
return;
Widget w = (Widget)menu->GetButtonWidget();
if (w)
{
wxXmString label_str(label);
XtVaSetValues(w,
XmNlabelString, label_str(),
NULL);
}
}
wxString wxMenuBar::GetLabelTop(size_t pos) const
{
wxString str;
wxMenu *menu = GetMenu(pos);
if ( menu )
{
Widget w = (Widget)menu->GetButtonWidget();
if (w)
{
XmString text;
XtVaGetValues(w,
XmNlabelString, &text,
NULL);
char *s;
if ( XmStringGetLtoR(text, XmSTRING_DEFAULT_CHARSET, &s) )
{
str = s;
XtFree(s);
}
}
}
return str;
}
bool wxMenuBar::Append(wxMenu * menu, const wxString& title)
{
wxCHECK_MSG( menu, FALSE, wxT("invalid menu") );
wxCHECK_MSG( !menu->GetParent() && !menu->GetButtonWidget(), FALSE,
wxT("menu already appended") );
if ( m_menuBarFrame )
{
WXWidget w = menu->CreateMenu(this, GetMainWidget(), menu, title, TRUE);
wxCHECK_MSG( w, FALSE, wxT("failed to create menu") );
menu->SetButtonWidget(w);
}
//menu->SetMenuBar(this);
m_titles.Add(title);
return wxMenuBarBase::Append(menu, title);
}
bool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title)
{
if ( !wxMenuBarBase::Insert(pos, menu, title) )
return FALSE;
wxFAIL_MSG(wxT("TODO"));
return FALSE;
}
wxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title)
{
if ( !wxMenuBarBase::Replace(pos, menu, title) )
return FALSE;
wxFAIL_MSG(wxT("TODO"));
return NULL;
}
wxMenu *wxMenuBar::Remove(size_t pos)
{
wxMenu *menu = wxMenuBarBase::Remove(pos);
if ( !menu )
return NULL;
if ( m_menuBarFrame )
menu->DestroyMenu(TRUE);
menu->SetMenuBar(NULL);
m_titles.Remove(pos);
return menu;
}
// Find the menu menuString, item itemString, and return the item id.
// Returns -1 if none found.
int wxMenuBar::FindMenuItem (const wxString& menuString, const wxString& itemString) const
{
char buf1[200];
char buf2[200];
wxStripMenuCodes ((char *)(const char *)menuString, buf1);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
{
wxStripMenuCodes ((char *)(const char *)m_titles[i], buf2);
if (strcmp (buf1, buf2) == 0)
return m_menus[i]->FindItem (itemString);
}
return -1;
}
wxMenuItem *wxMenuBar::FindItem(int id, wxMenu ** itemMenu) const
{
if (itemMenu)
*itemMenu = NULL;
wxMenuItem *item = NULL;
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
if ((item = m_menus[i]->FindItem(id, itemMenu)))
return item;
return NULL;
}
// Create menubar
bool wxMenuBar::CreateMenuBar(wxFrame* parent)
{
if (m_mainWidget)
{
XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
/*
if (!XtIsManaged((Widget) m_mainWidget))
XtManageChild((Widget) m_mainWidget);
*/
XtMapWidget((Widget) m_mainWidget);
return TRUE;
}
Widget menuBarW = XmCreateMenuBar ((Widget) parent->GetMainWidget(), "MenuBar", NULL, 0);
m_mainWidget = (WXWidget) menuBarW;
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
{
wxMenu *menu = GetMenu(i);
wxString title(m_titles[i]);
menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE));
if (strcmp (wxStripMenuCodes(title), "Help") == 0)
XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
// tear off menu support
#if (XmVersion >= 1002)
if ( menu->IsTearOff() )
{
XtVaSetValues(GetWidget(menu),
XmNtearOffModel, XmTEAR_OFF_ENABLED,
NULL);
Widget tearOff = XmGetTearOffControl(GetWidget(menu));
wxDoChangeForegroundColour((Widget) tearOff, m_foregroundColour);
wxDoChangeBackgroundColour((Widget) tearOff, m_backgroundColour, TRUE);
#endif
}
}
SetBackgroundColour(m_backgroundColour);
SetForegroundColour(m_foregroundColour);
SetFont(m_font);
XtVaSetValues((Widget) parent->GetMainWidget(), XmNmenuBar, (Widget) m_mainWidget, NULL);
XtRealizeWidget ((Widget) menuBarW);
XtManageChild ((Widget) menuBarW);
SetMenuBarFrame(parent);
return TRUE;
}
// Destroy menubar, but keep data structures intact so we can recreate it.
bool wxMenuBar::DestroyMenuBar()
{
if (!m_mainWidget)
{
SetMenuBarFrame((wxFrame*) NULL);
return FALSE;
}
XtUnmanageChild ((Widget) m_mainWidget);
XtUnrealizeWidget ((Widget) m_mainWidget);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
{
wxMenu *menu = GetMenu(i);
menu->DestroyMenu(TRUE);
}
XtDestroyWidget((Widget) m_mainWidget);
m_mainWidget = (WXWidget) 0;
SetMenuBarFrame((wxFrame*) NULL);
return TRUE;
}
//// Motif-specific
static XtWorkProcId WorkProcMenuId;
/* Since PopupMenu under Motif stills grab right mouse button events
* after it was closed, we need to delete the associated widgets to
* allow next PopUpMenu to appear...
*/
int PostDeletionOfMenu( XtPointer* clientData )
{
XtRemoveWorkProc(WorkProcMenuId);
wxMenu *menu = (wxMenu *)clientData;
if (menu->GetMainWidget())
{
wxMenu *menuParent = menu->GetParent();
if ( menuParent )
{
wxMenuItemList::Node *node = menuParent->GetMenuItems().GetFirst();
while ( node )
{
if ( node->GetData()->GetSubMenu() == menu )
{
menuParent->GetMenuItems().DeleteNode(node);
break;
}
node = node->GetNext();
}
}
menu->DestroyMenu(TRUE);
}
// Mark as no longer popped up
menu->m_menuId = -1;
return TRUE;
}
void
wxMenuPopdownCallback(Widget WXUNUSED(w), XtPointer clientData,
XtPointer WXUNUSED(ptr))
{
wxMenu *menu = (wxMenu *)clientData;
// Added by JOREL Jean-Charles <jjorel@silr.ireste.fr>
/* Since Callbacks of MenuItems are not yet processed, we put a
* background job which will be done when system will be idle.
* What awful hack!! :(
*/
WorkProcMenuId = XtAppAddWorkProc(
(XtAppContext) wxTheApp->GetAppContext(),
(XtWorkProc) PostDeletionOfMenu,
(XtPointer) menu );
// Apparently not found in Motif headers
// XtVaSetValues( w, XmNpopupEnabled, XmPOPUP_DISABLED, NULL );
}
/*
* Create a popup or pulldown menu.
* Submenus of a popup will be pulldown.
*
*/
WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topMenu, const wxString& title, bool pullDown)
{
Widget menu = (Widget) 0;
Widget buttonWidget = (Widget) 0;
Arg args[5];
XtSetArg (args[0], XmNnumColumns, m_numColumns);
XtSetArg (args[1], XmNpacking, XmPACK_COLUMN);
if (!pullDown)
{
menu = XmCreatePopupMenu ((Widget) parent, "popup", args, 2);
XtAddCallback(menu,
XmNunmapCallback,
(XtCallbackProc)wxMenuPopdownCallback,
(XtPointer)this);
}
else
{
char mnem = wxFindMnemonic (title);
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
wxString title2(wxStripMenuCodes(title));
wxXmString label_str(title2);
buttonWidget = XtVaCreateManagedWidget(title2,
#if wxUSE_GADGETS
xmCascadeButtonGadgetClass, (Widget) parent,
#else
xmCascadeButtonWidgetClass, (Widget) parent,
#endif
XmNlabelString, label_str(),
XmNsubMenuId, menu,
NULL);
if (mnem != 0)
XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
}
m_menuWidget = (WXWidget) menu;
m_menuBar = menuBar;
m_topLevelMenu = topMenu;
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem *item = node->GetData();
item->CreateItem(menu, menuBar, topMenu);
}
SetBackgroundColour(m_backgroundColour);
SetForegroundColour(m_foregroundColour);
SetFont(m_font);
return buttonWidget;
}
// Destroys the Motif implementation of the menu,
// but maintains the wxWindows data structures so we can
// do a CreateMenu again.
void wxMenu::DestroyMenu (bool full)
{
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem *item = node->GetData();
item->SetMenuBar((wxMenuBar*) NULL);
item->DestroyItem(full);
}
if (m_buttonWidget)
{
if (full)
{
XtVaSetValues((Widget) m_buttonWidget, XmNsubMenuId, NULL, NULL);
XtDestroyWidget ((Widget) m_buttonWidget);
m_buttonWidget = (WXWidget) 0;
}
}
if (m_menuWidget && full)
{
XtDestroyWidget((Widget) m_menuWidget);
m_menuWidget = (WXWidget) NULL;
}
}
WXWidget wxMenu::FindMenuItem (int id, wxMenuItem ** it) const
{
if (id == m_menuId)
{
if (it)
*it = (wxMenuItem*) NULL;
return m_buttonWidget;
}
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem *item = node->GetData ();
if (item->GetId() == id)
{
if (it)
*it = item;
return item->GetButtonWidget();
}
if (item->GetSubMenu())
{
WXWidget w = item->GetSubMenu()->FindMenuItem (id, it);
if (w)
{
return w;
}
}
}
if (it)
*it = (wxMenuItem*) NULL;
return (WXWidget) NULL;
}
void wxMenu::SetBackgroundColour(const wxColour& col)
{
m_backgroundColour = col;
if (m_menuWidget)
wxDoChangeBackgroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
wxDoChangeBackgroundColour(m_buttonWidget, (wxColour&) col, TRUE);
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem* item = node->GetData();
if (item->GetButtonWidget())
{
// This crashes because it uses gadgets
// wxDoChangeBackgroundColour(item->GetButtonWidget(), (wxColour&) col, TRUE);
}
if (item->GetSubMenu())
item->GetSubMenu()->SetBackgroundColour((wxColour&) col);
}
}
void wxMenu::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col;
if (m_menuWidget)
wxDoChangeForegroundColour(m_menuWidget, (wxColour&) col);
if (m_buttonWidget)
wxDoChangeForegroundColour(m_buttonWidget, (wxColour&) col);
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem* item = node->GetData();
if (item->GetButtonWidget())
{
// This crashes because it uses gadgets
// wxDoChangeForegroundColour(item->GetButtonWidget(), (wxColour&) col);
}
if (item->GetSubMenu())
item->GetSubMenu()->SetForegroundColour((wxColour&) col);
}
}
void wxMenu::ChangeFont(bool keepOriginalSize)
{
// lesstif 0.87 hangs when setting XmNfontList
#ifndef LESSTIF_VERSION
if (!m_font.Ok() || !m_menuWidget)
return;
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_menuWidget));
XtVaSetValues ((Widget) m_menuWidget,
XmNfontList, fontList,
NULL);
if (m_buttonWidget)
{
XtVaSetValues ((Widget) m_buttonWidget,
XmNfontList, fontList,
NULL);
}
for ( wxMenuItemList::Node *node = GetMenuItems().GetFirst();
node;
node = node->GetNext() )
{
wxMenuItem* item = node->GetData();
if (m_menuWidget && item->GetButtonWidget() && m_font.Ok())
{
XtVaSetValues ((Widget) item->GetButtonWidget(),
XmNfontList, fontList,
NULL);
}
if (item->GetSubMenu())
item->GetSubMenu()->ChangeFont(keepOriginalSize);
}
#endif
}
void wxMenu::SetFont(const wxFont& font)
{
m_font = font;
ChangeFont();
}
bool wxMenuBar::SetBackgroundColour(const wxColour& col)
{
m_backgroundColour = col;
if (m_mainWidget)
wxDoChangeBackgroundColour(m_mainWidget, (wxColour&) col);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
m_menus[i]->SetBackgroundColour((wxColour&) col);
return TRUE;
}
bool wxMenuBar::SetForegroundColour(const wxColour& col)
{
m_foregroundColour = col;
if (m_mainWidget)
wxDoChangeForegroundColour(m_mainWidget, (wxColour&) col);
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
m_menus[i]->SetForegroundColour((wxColour&) col);
return TRUE;
}
void wxMenuBar::ChangeFont(bool WXUNUSED(keepOriginalSize))
{
// Nothing to do for menubar, fonts are kept in wxMenus
}
bool wxMenuBar::SetFont(const wxFont& font)
{
m_font = font;
ChangeFont();
size_t menuCount = GetMenuCount();
for (size_t i = 0; i < menuCount; i++)
m_menus[i]->SetFont(font);
return TRUE;
}

20
src/x11/minifram.cpp Normal file
View File

@@ -0,0 +1,20 @@
/////////////////////////////////////////////////////////////////////////////
// Name: minifram.cpp
// Purpose: wxMiniFrame. Optional; identical to wxFrame if not supported.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "minifram.h"
#endif
#include "wx/minifram.h"
IMPLEMENT_DYNAMIC_CLASS(wxMiniFrame, wxFrame)

356
src/x11/palette.cpp Normal file
View File

@@ -0,0 +1,356 @@
/////////////////////////////////////////////////////////////////////////////
// Name: palette.cpp
// Purpose: wxPalette
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*
* Colour map
*
* When constructed with the default constructor, we start from
* the wxApp::GetMainColormap, allocating additional read-only cells
* in Create(). The cells are freed on the next call to Create()
* or when the destructor is called.
*/
/* Wolfram Gloger <u7y22ab@sunmail.lrz-muenchen.de>
I have implemented basic colormap support for the X11 versions of
wxWindows, notably wxPalette::Create(). The way I did it is to
allocate additional read-only color cells in the default colormap. In
general you will get arbitrary pixel values assigned to these new
cells and therefore I added a method wxColourMap::TransferBitmap()
which maps the pixel values 0..n to the real ones obtained with
Create(). This is only implemented for the popular case of 8-bit
depth.
Allocating read-write color cells would involve installing a private
X11 colormap for a particular window, and AFAIK this is not
recommended; only the window manager should do this... Also, it is
not the functionality that wxPalette::Create() aims to provide.
*/
#ifdef __GNUG__
#pragma implementation "palette.h"
#endif
#include "wx/palette.h"
#include "wx/window.h"
#include "wx/app.h"
#include "wx/utils.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxPalette, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxXPalette, wxObject)
/*
* Palette
*
*/
wxXPalette::wxXPalette()
{
m_cmap = (WXColormap) 0;
m_pix_array_n = 0;
m_pix_array = (unsigned long*) 0;
m_display = (WXDisplay*) 0;
m_destroyable = FALSE;
}
wxPaletteRefData::wxPaletteRefData()
{
}
wxPaletteRefData::~wxPaletteRefData()
{
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;
}
}
wxPalette::wxPalette()
{
}
wxPalette::wxPalette(int n, const unsigned char *red, const unsigned char *green, const unsigned char *blue)
{
Create(n, red, green, blue);
}
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;
}
int wxPalette::GetPixel(const unsigned char red, const unsigned char green, const unsigned char blue) const
{
if ( !m_refData )
return FALSE;
// TODO
return FALSE;
}
bool wxPalette::GetRGB(int index, unsigned char *WXUNUSED(red), unsigned char *WXUNUSED(green), unsigned char *WXUNUSED(blue)) const
{
if ( !m_refData )
return FALSE;
if (index < 0 || index > 255)
return FALSE;
// TODO
return FALSE;
}
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)
{
wxXPalette* p = (wxXPalette*) node->Data();
return p->m_cmap;
}
while (node)
{
wxXPalette* p = (wxXPalette*) node->Data();
if (p->m_display == display)
return p->m_cmap;
node = node->Next();
}
/* Make a new one: */
wxXPalette *c = new wxXPalette;
wxXPalette *first = (wxXPalette *)M_PALETTEDATA->m_palettes.First()->Data();
XColor xcol;
int pix_array_n = first->m_pix_array_n;
c->m_pix_array_n = pix_array_n;
c->m_pix_array = new unsigned long[pix_array_n];
c->m_display = display;
c->m_cmap = wxTheApp->GetMainColormap(display);
c->m_destroyable = FALSE;
xcol.flags = DoRed | DoGreen | DoBlue;
int i;
for (i = 0; i < pix_array_n; i++)
{
xcol.pixel = first->m_pix_array[i];
XQueryColor((Display*) first->m_display, (Colormap) first->m_cmap, &xcol);
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++;
}
return TRUE;
}
default:
return FALSE;
}
}
bool wxPalette::TransferBitmap8(unsigned char *data, unsigned long sz,
void *dest, unsigned int bpp)
{
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;
}
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;
}
default:
return FALSE;
}
return TRUE;
}
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();
if (c->m_display == display)
{
if (n)
*n = c->m_pix_array_n;
return c->m_pix_array;
}
}
/* Not found; call GetXColormap, which will create it, then this again */
if (GetXColormap(display))
return GetXPixArray(display, n);
else
return (unsigned long*) 0;
}
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);
}

182
src/x11/pen.cpp Normal file
View File

@@ -0,0 +1,182 @@
/////////////////////////////////////////////////////////////////////////////
// Name: src/motif/pen.cpp
// Purpose: wxPen
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "pen.h"
#endif
#include "wx/setup.h"
#include "wx/utils.h"
#include "wx/pen.h"
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
wxPenRefData::wxPenRefData()
{
m_style = wxSOLID;
m_width = 1;
m_join = wxJOIN_ROUND ;
m_cap = wxCAP_ROUND ;
m_nbDash = 0 ;
m_dash = (wxMOTIFDash*)NULL;
}
wxPenRefData::wxPenRefData(const wxPenRefData& data)
{
m_style = data.m_style;
m_width = data.m_width;
m_join = data.m_join;
m_cap = data.m_cap;
m_nbDash = data.m_nbDash;
m_dash = data.m_dash;
m_colour = data.m_colour;
}
wxPenRefData::~wxPenRefData()
{
}
// Pens
wxPen::wxPen()
{
}
wxPen::~wxPen()
{
}
// Should implement Create
wxPen::wxPen(const wxColour& col, int Width, int Style)
{
m_refData = new wxPenRefData;
M_PENDATA->m_colour = col;
M_PENDATA->m_width = Width;
M_PENDATA->m_style = Style;
M_PENDATA->m_join = wxJOIN_ROUND ;
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
RealizeResource();
}
wxPen::wxPen(const wxBitmap& stipple, int Width)
{
m_refData = new wxPenRefData;
M_PENDATA->m_stipple = stipple;
M_PENDATA->m_width = Width;
M_PENDATA->m_style = wxSTIPPLE;
M_PENDATA->m_join = wxJOIN_ROUND ;
M_PENDATA->m_cap = wxCAP_ROUND ;
M_PENDATA->m_nbDash = 0 ;
M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
RealizeResource();
}
void wxPen::Unshare()
{
// Don't change shared data
if (!m_refData)
{
m_refData = new wxPenRefData();
}
else
{
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 = (wxMOTIFDash *)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();
}
bool wxPen::RealizeResource()
{
// Nothing more to do
return TRUE;
}

536
src/x11/region.cpp Normal file
View File

@@ -0,0 +1,536 @@
/////////////////////////////////////////////////////////////////////////////
// File: region.cpp
// Purpose: Region class
// Author: Markus Holzem/Julian Smart
// Created: Fri Oct 24 10:46:34 MET 1997
// RCS-ID: $Id$
// Copyright: (c) 1997 Markus Holzem/Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
#pragma implementation "region.h"
#endif
#include "wx/region.h"
#include "wx/gdicmn.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
// #include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxRegion, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxRegionIterator, wxObject)
// ----------------------------------------------------------------------------
// list types
// ----------------------------------------------------------------------------
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxRectList);
//-----------------------------------------------------------------------------
// wxRegionRefData implementation
//-----------------------------------------------------------------------------
class WXDLLEXPORT wxRegionRefData : public wxGDIRefData {
public:
wxRegionRefData()
{
m_region = XCreateRegion();
m_usingRects = FALSE;
m_rects = (wxRect*) NULL;
m_rectCount = 0;
}
wxRegionRefData(const wxRegionRefData& data)
{
m_region = XCreateRegion();
m_rects = (wxRect*) NULL;
m_rectCount = 0;
XUnionRegion(m_region, data.m_region, m_region);
SetRects(data.m_rectCount, data.m_rects);
}
~wxRegionRefData()
{
XDestroyRegion(m_region);
DeleteRects();
}
wxRect* GetRects() { return m_rects; };
void SetRects(const wxRectList& rectList);
void SetRects(int count, const wxRect* rects);
bool UsingRects() const { return m_usingRects; }
int GetRectCount() const { return m_rectCount; }
void DeleteRects();
Region m_region;
wxRect* m_rects;
int m_rectCount;
bool m_usingRects; // TRUE if we're using the above.
};
void wxRegionRefData::SetRects(const wxRectList& rectList)
{
DeleteRects();
m_usingRects = (rectList.Number() > 0);
if (m_usingRects)
{
m_rectCount = rectList.Number();
m_rects = new wxRect[m_rectCount];
}
wxRectList::Node* node = rectList.GetFirst();
int i = 0;
while (node) {
wxRect* rect = node->GetData();
m_rects[i] = * rect;
node = node->GetNext();
i ++;
}
}
void wxRegionRefData::SetRects(int count, const wxRect* rects)
{
DeleteRects();
m_usingRects = (count > 0);
if (m_usingRects)
{
m_rectCount = count;
m_rects = new wxRect[m_rectCount];
int i;
for (i = 0; i < m_rectCount; i++)
m_rects[i] = rects[i];
}
}
void wxRegionRefData::DeleteRects()
{
if (m_rects)
{
delete[] m_rects;
m_rects = (wxRect*) NULL;
}
m_rectCount = 0;
m_usingRects = FALSE;
}
#define M_REGION (((wxRegionRefData*)m_refData)->m_region)
//-----------------------------------------------------------------------------
// wxRegion
//-----------------------------------------------------------------------------
/*!
* Create an empty region.
*/
wxRegion::wxRegion()
{
}
wxRegion::wxRegion(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
{
m_refData = new wxRegionRefData;
XRectangle rect;
rect.x = x;
rect.y = y;
rect.width = w;
rect.height = h;
XUnionRectWithRegion(&rect, M_REGION, M_REGION);
}
wxRegion::wxRegion(const wxPoint& topLeft, const wxPoint& bottomRight)
{
m_refData = new wxRegionRefData;
XRectangle rect;
rect.x = topLeft.x;
rect.y = topLeft.y;
rect.width = bottomRight.x - topLeft.x;
rect.height = bottomRight.y - topLeft.y;
XUnionRectWithRegion(&rect, M_REGION, M_REGION);
}
wxRegion::wxRegion(const wxRect& rect)
{
m_refData = new wxRegionRefData;
XRectangle rect1;
rect1.x = rect.x;
rect1.y = rect.y;
rect1.width = rect.width;
rect1.height = rect.height;
XUnionRectWithRegion(&rect1, M_REGION, M_REGION);
}
/*!
* Destroy the region.
*/
wxRegion::~wxRegion()
{
// m_refData unrefed in ~wxObject
}
// Get the internal region handle
WXRegion wxRegion::GetXRegion() const
{
wxASSERT( m_refData !=NULL );
return (WXRegion) ((wxRegionRefData*)m_refData)->m_region;
}
//-----------------------------------------------------------------------------
//# Modify region
//-----------------------------------------------------------------------------
//! Clear current region
void wxRegion::Clear()
{
UnRef();
}
//! Combine rectangle (x, y, w, h) with this.
bool wxRegion::Combine(wxCoord x, wxCoord y, wxCoord width, wxCoord height, wxRegionOp op)
{
// Don't change shared data
if (!m_refData) {
m_refData = new wxRegionRefData();
} else if (m_refData->GetRefCount() > 1) {
wxRegionRefData* ref = (wxRegionRefData*)m_refData;
UnRef();
m_refData = new wxRegionRefData(*ref);
}
// If ref count is 1, that means it's 'ours' anyway so no action.
Region rectRegion = XCreateRegion();
XRectangle rect;
rect.x = x;
rect.y = y;
rect.width = width;
rect.height = height;
XUnionRectWithRegion(&rect, rectRegion, rectRegion);
switch (op)
{
case wxRGN_AND:
XIntersectRegion(M_REGION, rectRegion, M_REGION);
break ;
case wxRGN_OR:
XUnionRegion(M_REGION, rectRegion, M_REGION);
break ;
case wxRGN_XOR:
// TODO
break ;
case wxRGN_DIFF:
// TODO
break ;
case wxRGN_COPY: // Don't have to do this one
default:
// TODO
break ;
}
return FALSE;
}
//! Union /e region with this.
bool wxRegion::Combine(const wxRegion& region, wxRegionOp op)
{
if (region.Empty())
return FALSE;
// Don't change shared data
if (!m_refData) {
m_refData = new wxRegionRefData();
} else if (m_refData->GetRefCount() > 1) {
wxRegionRefData* ref = (wxRegionRefData*)m_refData;
UnRef();
m_refData = new wxRegionRefData(*ref);
}
switch (op)
{
case wxRGN_AND:
XIntersectRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
M_REGION);
break ;
case wxRGN_OR:
XUnionRegion(M_REGION, ((wxRegionRefData*)region.m_refData)->m_region,
M_REGION);
break ;
case wxRGN_XOR:
// TODO
break ;
case wxRGN_DIFF:
// TODO
break ;
case wxRGN_COPY: // Don't have to do this one
default:
// TODO
break ;
}
return FALSE;
}
bool wxRegion::Combine(const wxRect& rect, wxRegionOp op)
{
return Combine(rect.GetLeft(), rect.GetTop(), rect.GetWidth(), rect.GetHeight(), op);
}
//-----------------------------------------------------------------------------
//# Information on region
//-----------------------------------------------------------------------------
// Outer bounds of region
void wxRegion::GetBox(wxCoord& x, wxCoord& y, wxCoord&w, wxCoord &h) const
{
if (m_refData) {
XRectangle rect;
XClipBox(M_REGION, &rect);
x = rect.x;
y = rect.y;
w = rect.width;
h = rect.height;
} else {
x = y = w = h = 0;
}
}
wxRect wxRegion::GetBox() const
{
wxCoord x, y, w, h;
GetBox(x, y, w, h);
return wxRect(x, y, w, h);
}
// Is region empty?
bool wxRegion::Empty() const
{
return m_refData ? XEmptyRegion(M_REGION) : TRUE;
}
//-----------------------------------------------------------------------------
//# Tests
//-----------------------------------------------------------------------------
// Does the region contain the point (x,y)?
wxRegionContain wxRegion::Contains(wxCoord WXUNUSED(x), wxCoord WXUNUSED(y)) const
{
if (!m_refData)
return wxOutRegion;
// TODO. Return wxInRegion if within region.
if (0)
return wxInRegion;
return wxOutRegion;
}
// Does the region contain the point pt?
wxRegionContain wxRegion::Contains(const wxPoint& pt) const
{
if (!m_refData)
return wxOutRegion;
return XPointInRegion(M_REGION, pt.x, pt.y) ? wxInRegion : wxOutRegion;
}
// Does the region contain the rectangle (x, y, w, h)?
wxRegionContain wxRegion::Contains(wxCoord x, wxCoord y, wxCoord w, wxCoord h) const
{
if (!m_refData)
return wxOutRegion;
switch (XRectInRegion(M_REGION, x, y, w, h)) {
case RectangleIn: return wxInRegion;
case RectanglePart: return wxPartRegion;
}
return wxOutRegion;
}
// Does the region contain the rectangle rect
wxRegionContain wxRegion::Contains(const wxRect& rect) const
{
if (!m_refData)
return wxOutRegion;
wxCoord x, y, w, h;
x = rect.x;
y = rect.y;
w = rect.GetWidth();
h = rect.GetHeight();
return Contains(x, y, w, h);
}
bool wxRegion::UsingRects() const
{
return ((wxRegionRefData*)m_refData)->UsingRects();
}
/*
wxRectList& wxRegion::GetRectList()
{
return ((wxRegionRefData*)m_refData)->GetRectList();
}
*/
wxRect* wxRegion::GetRects()
{
return ((wxRegionRefData*)m_refData)->GetRects();
}
int wxRegion::GetRectCount() const
{
return ((wxRegionRefData*)m_refData)->GetRectCount();
}
void wxRegion::SetRects(const wxRectList& rectList)
{
((wxRegionRefData*)m_refData)->SetRects(rectList);
}
void wxRegion::SetRects(int count, const wxRect* rects)
{
((wxRegionRefData*)m_refData)->SetRects(count, rects);
}
///////////////////////////////////////////////////////////////////////////////
// //
// wxRegionIterator //
// //
///////////////////////////////////////////////////////////////////////////////
/*!
* Initialize empty iterator
*/
wxRegionIterator::wxRegionIterator() : m_current(0), m_numRects(0), m_rects(NULL)
{
}
wxRegionIterator::~wxRegionIterator()
{
if (m_rects)
delete[] m_rects;
}
/*!
* Initialize iterator for region
*/
wxRegionIterator::wxRegionIterator(const wxRegion& region)
{
m_rects = NULL;
Reset(region);
}
/*!
* Reset iterator for a new /e region.
*/
void wxRegionIterator::Reset(const wxRegion& region)
{
m_current = 0;
m_region = region;
if (m_rects)
delete[] m_rects;
m_rects = NULL;
if (m_region.Empty())
m_numRects = 0;
else
{
// Create m_rects and fill with rectangles for this region.
// Since we can't find the rectangles in a region, we cheat
// by retrieving the rectangles explicitly set in wxPaintDC::wxPaintDC
// (dcclient.cpp).
if (m_region.UsingRects())
{
wxRect* rects = m_region.GetRects();
int count = m_region.GetRectCount();
m_numRects = count;
m_rects = new wxRect[m_numRects];
for (size_t i = 0; i < m_numRects; i++)
m_rects[i] = rects[i];
/*
int i = 0;
wxRectList::Node* node = rectList.GetFirst();
while (node) {
wxRect* rect = node->GetData();
m_rects[i] = * rect;
node = node->GetNext();
i ++;
}
*/
}
else
{
// For now, fudge by getting the whole bounding box.
m_rects = new wxRect[1];
m_numRects = 1;
m_rects[0] = m_region.GetBox();
}
}
}
/*!
* Increment iterator. The rectangle returned is the one after the
* incrementation.
*/
void wxRegionIterator::operator ++ ()
{
if (m_current < m_numRects)
++m_current;
}
/*!
* Increment iterator. The rectangle returned is the one before the
* incrementation.
*/
void wxRegionIterator::operator ++ (int)
{
if (m_current < m_numRects)
++m_current;
}
wxCoord wxRegionIterator::GetX() const
{
if (m_current < m_numRects)
return m_rects[m_current].x;
return 0;
}
wxCoord wxRegionIterator::GetY() const
{
if (m_current < m_numRects)
return m_rects[m_current].y;
return 0;
}
wxCoord wxRegionIterator::GetW() const
{
if (m_current < m_numRects)
return m_rects[m_current].width ;
return 0;
}
wxCoord wxRegionIterator::GetH() const
{
if (m_current < m_numRects)
return m_rects[m_current].height;
return 0;
}

246
src/x11/settings.cpp Normal file
View File

@@ -0,0 +1,246 @@
/////////////////////////////////////////////////////////////////////////////
// Name: settings.cpp
// Purpose: wxSettings
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// TODO: these settings should probably be configurable from some central or
// per-user file, which can be edited using a Windows-control-panel clone.
// Also they should be documented better. Some are very MS Windows-ish.
#ifdef __GNUG__
#pragma implementation "settings.h"
#endif
#include "wx/settings.h"
#include "wx/gdicmn.h"
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
{
switch (index)
{
case wxSYS_COLOUR_WINDOW:
{
return *wxWHITE;
}
case wxSYS_COLOUR_SCROLLBAR:
// case wxSYS_COLOUR_DESKTOP: // Same as wxSYS_COLOUR_BACKGROUND
case wxSYS_COLOUR_BACKGROUND:
case wxSYS_COLOUR_ACTIVECAPTION:
case wxSYS_COLOUR_INACTIVECAPTION:
case wxSYS_COLOUR_MENU:
case wxSYS_COLOUR_WINDOWFRAME:
case wxSYS_COLOUR_ACTIVEBORDER:
case wxSYS_COLOUR_INACTIVEBORDER:
case wxSYS_COLOUR_BTNFACE:
// case wxSYS_COLOUR_3DFACE: // Same as wxSYS_COLOUR_BTNFACE
case wxSYS_COLOUR_GRAYTEXT:
{
return wxColour("LIGHT GREY");
}
case wxSYS_COLOUR_BTNSHADOW:
// case wxSYS_COLOUR_3DSHADOW: // Same as wxSYS_COLOUR_BTNSHADOW
{
return wxColour("GREY");
}
case wxSYS_COLOUR_3DDKSHADOW:
{
return *wxBLACK;
}
case wxSYS_COLOUR_HIGHLIGHT:
{
return *wxBLUE;
}
case wxSYS_COLOUR_BTNHIGHLIGHT:
case wxSYS_COLOUR_LISTBOX:
// case wxSYS_COLOUR_3DHIGHLIGHT: // Same as wxSYS_COLOUR_BTNHIGHLIGHT
{
return *wxWHITE;
}
case wxSYS_COLOUR_3DLIGHT:
{
return wxColour("LIGHT GREY");
}
case wxSYS_COLOUR_MENUTEXT:
case wxSYS_COLOUR_WINDOWTEXT:
case wxSYS_COLOUR_CAPTIONTEXT:
case wxSYS_COLOUR_INACTIVECAPTIONTEXT:
case wxSYS_COLOUR_BTNTEXT:
case wxSYS_COLOUR_INFOTEXT:
{
return *wxBLACK;
}
case wxSYS_COLOUR_HIGHLIGHTTEXT:
{
return *wxWHITE;
}
case wxSYS_COLOUR_INFOBK:
case wxSYS_COLOUR_APPWORKSPACE:
{
return wxColour("LIGHT GREY");
// return *wxWHITE;
}
}
return *wxWHITE;
}
wxFont wxSystemSettingsNative::GetFont(wxSystemFont index)
{
switch (index)
{
case wxSYS_SYSTEM_FIXED_FONT:
{
return wxFont(12, wxMODERN, wxNORMAL, wxNORMAL, FALSE);
break;
}
case wxSYS_DEVICE_DEFAULT_FONT:
case wxSYS_SYSTEM_FONT:
case wxSYS_DEFAULT_GUI_FONT:
default:
{
return wxFont(12, wxSWISS, wxNORMAL, wxNORMAL, FALSE);
break;
}
}
return wxFont();
}
// Get a system metric, e.g. scrollbar size
int wxSystemSettingsNative::GetMetric(wxSystemMetric index)
{
switch ( index)
{
case wxSYS_MOUSE_BUTTONS:
// TODO
return 0;
case wxSYS_BORDER_X:
// TODO
return 0;
case wxSYS_BORDER_Y:
// TODO
return 0;
case wxSYS_CURSOR_X:
// TODO
return 0;
case wxSYS_CURSOR_Y:
// TODO
return 0;
case wxSYS_DCLICK_X:
// TODO
return 0;
case wxSYS_DCLICK_Y:
// TODO
return 0;
case wxSYS_DRAG_X:
// TODO
return 0;
case wxSYS_DRAG_Y:
// TODO
return 0;
case wxSYS_EDGE_X:
// TODO
return 0;
case wxSYS_EDGE_Y:
// TODO
return 0;
case wxSYS_HSCROLL_ARROW_X:
// TODO
return 0;
case wxSYS_HSCROLL_ARROW_Y:
// TODO
return 0;
case wxSYS_HTHUMB_X:
// TODO
return 0;
case wxSYS_ICON_X:
// TODO
return 0;
case wxSYS_ICON_Y:
// TODO
return 0;
case wxSYS_ICONSPACING_X:
// TODO
return 0;
case wxSYS_ICONSPACING_Y:
// TODO
return 0;
case wxSYS_WINDOWMIN_X:
// TODO
return 0;
case wxSYS_WINDOWMIN_Y:
// TODO
return 0;
case wxSYS_SCREEN_X:
// TODO
return 0;
case wxSYS_SCREEN_Y:
// TODO
return 0;
case wxSYS_FRAMESIZE_X:
// TODO
return 0;
case wxSYS_FRAMESIZE_Y:
// TODO
return 0;
case wxSYS_SMALLICON_X:
// TODO
return 0;
case wxSYS_SMALLICON_Y:
// TODO
return 0;
case wxSYS_HSCROLL_Y:
// TODO
return 0;
case wxSYS_VSCROLL_X:
// TODO
return 0;
case wxSYS_VSCROLL_ARROW_X:
// TODO
return 0;
case wxSYS_VSCROLL_ARROW_Y:
// TODO
return 0;
case wxSYS_VTHUMB_Y:
// TODO
return 0;
case wxSYS_CAPTION_Y:
// TODO
return 0;
case wxSYS_MENU_Y:
// TODO
return 0;
case wxSYS_NETWORK_PRESENT:
// TODO
return 0;
case wxSYS_PENWINDOWS_PRESENT:
// TODO
return 0;
case wxSYS_SHOW_SOUNDS:
// TODO
return 0;
case wxSYS_SWAP_BUTTONS:
// TODO
return 0;
default:
return 0;
}
}
bool wxSystemSettingsNative::HasFeature(wxSystemFeature index)
{
switch (index)
{
case wxSYS_CAN_ICONIZE_FRAME:
case wxSYS_CAN_DRAW_FRAME_DECORATIONS:
return TRUE;
default:
return FALSE;
}
}

Some files were not shown because too many files have changed in this diff Show More