Compare commits

..

1 Commits

Author SHA1 Message Date
Bryan Petty
79108072e4 This commit was manufactured by cvs2svn to create tag
'MOTIF_BEFORE_JA_FONT_CHANGES'.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/tags/MOTIF_BEFORE_JA_FONT_CHANGES@35028 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
2005-07-30 17:32:49 +00:00
166 changed files with 41304 additions and 19140 deletions

View File

@@ -1,90 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/scrolwin.h
// Purpose: wxGenericScrolledWindow class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_SCROLLWIN_H_
#define _WX_GENERIC_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// headers and constants
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/panel.h"
extern WXDLLEXPORT_DATA(const wxChar*) wxPanelNameStr;
// default scrolled window style
#ifndef wxScrolledWindowStyle
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
#endif
// ----------------------------------------------------------------------------
// wxGenericScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxGenericScrolledWindow : public wxPanel,
public wxScrollHelper
{
public:
wxGenericScrolledWindow() : wxScrollHelper(this) { }
wxGenericScrolledWindow(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
: wxScrollHelper(this)
{
Create(parent, winid, pos, size, style, name);
}
virtual ~wxGenericScrolledWindow();
bool Create(wxWindow *parent,
wxWindowID winid,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
virtual void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
virtual void DoSetVirtualSize(int x, int y);
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
protected:
// this is needed for wxEVT_PAINT processing hack described in
// wxScrollHelperEvtHandler::ProcessEvent()
void OnPaint(wxPaintEvent& event);
// we need to return a special WM_GETDLGCODE value to process just the
// arrows but let the other navigation characters through
#ifdef __WXMSW__
virtual WXLRESULT MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam);
#endif // __WXMSW__
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxGenericScrolledWindow)
DECLARE_EVENT_TABLE()
};
#endif // _WX_GENERIC_SCROLLWIN_H_

View File

@@ -1,193 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/scrolwin.h
// Purpose: wxScrolledWindow class
// Author: Robert Roebling
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_SCROLLWIN_H_
#define _WX_GTK_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// headers and constants
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/panel.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
// default scrolled window style
#ifndef wxScrolledWindowStyle
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
#endif
// ----------------------------------------------------------------------------
// wxScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxScrolledWindow : public wxPanel
{
public:
wxScrolledWindow()
{ Init(); }
wxScrolledWindow(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
{ Create(parent, id, pos, size, style, name); }
void Init();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
// Normally the wxScrolledWindow will scroll itself, but in
// some rare occasions you might want it to scroll another
// window (e.g. a child of it in order to scroll only a portion
// the area between the scrollbars (spreadsheet: only cell area
// will move).
virtual void SetTargetWindow( wxWindow *target, bool pushEventHandler = FALSE );
virtual wxWindow *GetTargetWindow() const;
// Set the scrolled area of the window.
virtual void DoSetVirtualSize( int x, int y );
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// Number of pixels per user unit (0 or -1 for no scrollbar)
// Length of virtual canvas in user units
// Length of page in user units
// Default action is to set the virtual size and alter scrollbars
// accordingly.
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
bool noRefresh = FALSE );
// Physically scroll the window
virtual void Scroll(int x_pos, int y_pos);
int GetScrollPageSize(int orient) const;
void SetScrollPageSize(int orient, int pageSize);
virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
// Enable/disable Windows scrolling in either direction.
// If TRUE, wxWidgets scrolls the canvas and only a bit of
// the canvas is invalidated; no Clear() is necessary.
// If FALSE, the whole canvas is invalidated and a Clear() is
// necessary. Disable for when the scroll increment is used
// to actually scroll a non-constant distance
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// Get the view start
virtual void GetViewStart(int *x, int *y) const;
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// Override this function to draw the graphic (or just process EVT_PAINT)
virtual void OnDraw(wxDC& WXUNUSED(dc)) {}
// Override this function if you don't want to have wxScrolledWindow
// automatically change the origin according to the scroll position.
void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars
virtual void AdjustScrollbars();
// Set the scale factor, used in PrepareDC
void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
double GetScaleX() const { return m_scaleX; }
double GetScaleY() const { return m_scaleY; }
// implementation from now on
void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();
void GtkHDisconnectEvent();
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Overridden from wxWidgets due callback being static
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual void DoPrepareDC(wxDC& dc);
protected:
wxWindow *m_targetWindow;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
// FIXME: these next four members are duplicated in the GtkAdjustment
// members of wxWindow. Can they be safely removed from here?
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
double m_scaleY,m_scaleX;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxScrolledWindow)
};
#endif
// _WX_GTK_SCROLLWIN_H_
// vi:sts=4:sw=4:et

View File

@@ -1,300 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/window.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__
#define __GTKWINDOWH__
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK;
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
//-----------------------------------------------------------------------------
// wxWindowGTK
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
{
public:
// creating the window
// -------------------
wxWindowGTK();
wxWindowGTK(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
virtual ~wxWindowGTK();
// implement base class (pure) virtual methods
// -------------------------------------------
virtual bool Destroy();
virtual void Raise();
virtual void Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual bool IsRetained() const;
virtual void SetFocus();
virtual bool AcceptsFocus() const;
virtual bool Reparent( wxWindowBase *newParent );
virtual void WarpPointer(int x, int y);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Update();
virtual void ClearBackground();
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 bool SetBackgroundStyle(wxBackgroundStyle style) ;
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;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
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 );
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP
#ifdef __WXGTK20__
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
#endif
// implementation
// --------------
virtual WXWidget GetHandle() const { return m_widget; }
// I don't want users to override what's done in idle so everything that
// has to be done in idle time in order for wxGTK to work is done in
// OnInternalIdle
virtual void OnInternalIdle();
// Internal represention of Update()
void GtkUpdate();
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
// wxGTK-specific: called recursively by Enable,
// to give widgets an oppprtunity to correct their colours after they
// have been changed by Enable
virtual void OnParentEnable( bool WXUNUSED(enable) ) {}
// Used by all window classes in the widget creation process.
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
void PostCreation();
// Internal addition of child windows. differs from class
// to class not by using virtual functions but by using
// the m_insertCallback.
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
// the widget means setting it for all subwidgets as well.
// also, it is nor clear, which native widget is the top
// widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget );
#ifdef __WXGTK20__
// Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext();
// Returns the X11 context which renders on the X11 client
// side (which can be remote) and which usually is not
// anti-aliased and is thus faster
// MR: Now returns the default pango_context for the widget as GtkGetPangoDefaultContext to
// not depend on libpangox - which is completely deprecated.
//BCI: Remove GtkGetPangoX11Context and m_x11Context completely when symbols may be removed
PangoContext *GtkGetPangoX11Context();
PangoContext *m_x11Context; // MR: Now unused
#endif
#if wxUSE_TOOLTIPS
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
// Called from GTK signales handlers. it indicates that
// the layouting functions have to be called later on
// (i.e. in idle time, implemented in OnInternalIdle() ).
void GtkUpdateSize() { m_sizeSet = FALSE; }
// fix up the mouse event coords, used by wxListBox only so far
virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget),
wxCoord& WXUNUSED(x),
wxCoord& WXUNUSED(y)) { }
// is this window transparent for the mouse events (as wxStaticBox is)?
virtual bool IsTransparentForMouse() const { return FALSE; }
// is this a radiobutton (used by radiobutton code itself only)?
virtual bool IsRadioButton() const { return FALSE; }
// position and size of the window
int m_x, m_y;
int m_width, m_height;
int m_oldClientWidth,m_oldClientHeight;
// see the docs in src/gtk/window.cpp
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
// this widget will be queried for GTK's focus events
GtkWidget *m_focusWidget;
#ifdef __WXGTK20__
wxGtkIMData *m_imData;
#else // GTK 1
#ifdef HAVE_XIM
// XIM support for wxWidgets
GdkIC *m_ic;
GdkICAttr *m_icattr;
#endif // HAVE_XIM
#endif // GTK 2/1
#ifndef __WXGTK20__
// The area to be cleared (and not just refreshed)
// We cannot make this distinction under GTK 2.0.
wxRegion m_clearRegion;
#endif
// scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
float m_oldHorizontalPos;
float m_oldVerticalPos;
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
bool m_noExpose:1; // wxGLCanvas has its own redrawing
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
bool m_hasScrolling:1;
bool m_hasVMT:1;
bool m_sizeSet:1;
bool m_resizing:1;
bool m_acceptsFocus:1; // true if not static
bool m_hasFocus:1; // true if == FindFocus()
bool m_isScrolling:1; // dragging scrollbar thumb?
bool m_clipPaintRegion:1; // TRUE after ScrollWindow()
#ifdef __WXGTK20__
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
// chain needs update
#endif
bool m_needsStyleChange:1; // May not be able to change
// background style until OnIdle
// C++ has no virtual methods in the constrcutor of any class but we need
// different methods of inserting a child window into a wxFrame,
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
wxInsertChildFunction m_insertCallback;
// 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 void DoCaptureMouse();
virtual void DoReleaseMouse();
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
protected:
// common part of all ctors (not virtual because called from ctor)
void Init();
#ifdef __WXGTK20__
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#endif
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *CreateWidgetStyle(bool forceStyle = false);
// Overridden in many GTK widgets who have to handle subwidgets
virtual void ApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
private:
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
DECLARE_NO_COPY_CLASS(wxWindowGTK)
};
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__

View File

@@ -1,193 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/scrolwin.h
// Purpose: wxScrolledWindow class
// Author: Robert Roebling
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GTK_SCROLLWIN_H_
#define _WX_GTK_SCROLLWIN_H_
// ----------------------------------------------------------------------------
// headers and constants
// ----------------------------------------------------------------------------
#include "wx/window.h"
#include "wx/panel.h"
WXDLLEXPORT_DATA(extern const wxChar*) wxPanelNameStr;
// default scrolled window style
#ifndef wxScrolledWindowStyle
#define wxScrolledWindowStyle (wxHSCROLL | wxVSCROLL)
#endif
// ----------------------------------------------------------------------------
// wxScrolledWindow
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxScrolledWindow : public wxPanel
{
public:
wxScrolledWindow()
{ Init(); }
wxScrolledWindow(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
{ Create(parent, id, pos, size, style, name); }
void Init();
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr);
// Normally the wxScrolledWindow will scroll itself, but in
// some rare occasions you might want it to scroll another
// window (e.g. a child of it in order to scroll only a portion
// the area between the scrollbars (spreadsheet: only cell area
// will move).
virtual void SetTargetWindow( wxWindow *target, bool pushEventHandler = FALSE );
virtual wxWindow *GetTargetWindow() const;
// Set the scrolled area of the window.
virtual void DoSetVirtualSize( int x, int y );
// wxWindow's GetBestVirtualSize returns the actual window size,
// whereas we want to return the virtual size
virtual wxSize GetBestVirtualSize() const;
// Return the size best suited for the current window
// (this isn't a virtual size, this is a sensible size for the window)
virtual wxSize DoGetBestSize() const;
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// Number of pixels per user unit (0 or -1 for no scrollbar)
// Length of virtual canvas in user units
// Length of page in user units
// Default action is to set the virtual size and alter scrollbars
// accordingly.
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
bool noRefresh = FALSE );
// Physically scroll the window
virtual void Scroll(int x_pos, int y_pos);
int GetScrollPageSize(int orient) const;
void SetScrollPageSize(int orient, int pageSize);
virtual void GetScrollPixelsPerUnit(int *x_unit, int *y_unit) const;
// Enable/disable Windows scrolling in either direction.
// If TRUE, wxWidgets scrolls the canvas and only a bit of
// the canvas is invalidated; no Clear() is necessary.
// If FALSE, the whole canvas is invalidated and a Clear() is
// necessary. Disable for when the scroll increment is used
// to actually scroll a non-constant distance
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// Get the view start
virtual void GetViewStart(int *x, int *y) const;
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// Override this function to draw the graphic (or just process EVT_PAINT)
virtual void OnDraw(wxDC& WXUNUSED(dc)) {}
// Override this function if you don't want to have wxScrolledWindow
// automatically change the origin according to the scroll position.
void PrepareDC(wxDC& dc) { DoPrepareDC(dc); }
// lay out the window and its children
virtual bool Layout();
// Adjust the scrollbars
virtual void AdjustScrollbars();
// Set the scale factor, used in PrepareDC
void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
double GetScaleX() const { return m_scaleX; }
double GetScaleY() const { return m_scaleY; }
// implementation from now on
void OnScroll(wxScrollWinEvent& event);
void OnSize(wxSizeEvent& event);
void OnPaint(wxPaintEvent& event);
void OnChar(wxKeyEvent& event);
void GtkVScroll( float value, unsigned int scroll_type );
void GtkHScroll( float value, unsigned int scroll_type );
void GtkVConnectEvent();
void GtkHConnectEvent();
void GtkVDisconnectEvent();
void GtkHDisconnectEvent();
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Overridden from wxWidgets due callback being static
virtual void SetScrollPos( int orient, int pos, bool refresh = TRUE );
virtual void DoPrepareDC(wxDC& dc);
protected:
wxWindow *m_targetWindow;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
// FIXME: these next four members are duplicated in the GtkAdjustment
// members of wxWindow. Can they be safely removed from here?
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
double m_scaleY,m_scaleX;
private:
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxScrolledWindow)
};
#endif
// _WX_GTK_SCROLLWIN_H_
// vi:sts=4:sw=4:et

View File

@@ -1,300 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/gtk/window.h
// Purpose:
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKWINDOWH__
#define __GTKWINDOWH__
// helper structure that holds class that holds GtkIMContext object and
// some additional data needed for key events processing
struct wxGtkIMData;
//-----------------------------------------------------------------------------
// callback definition for inserting a window (internal)
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK;
typedef void (*wxInsertChildFunction)( wxWindowGTK*, wxWindowGTK* );
//-----------------------------------------------------------------------------
// wxWindowGTK
//-----------------------------------------------------------------------------
class WXDLLIMPEXP_CORE wxWindowGTK : public wxWindowBase
{
public:
// creating the window
// -------------------
wxWindowGTK();
wxWindowGTK(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
bool Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxPanelNameStr);
virtual ~wxWindowGTK();
// implement base class (pure) virtual methods
// -------------------------------------------
virtual bool Destroy();
virtual void Raise();
virtual void Lower();
virtual bool Show( bool show = TRUE );
virtual bool Enable( bool enable = TRUE );
virtual bool IsRetained() const;
virtual void SetFocus();
virtual bool AcceptsFocus() const;
virtual bool Reparent( wxWindowBase *newParent );
virtual void WarpPointer(int x, int y);
virtual void Refresh( bool eraseBackground = TRUE,
const wxRect *rect = (const wxRect *) NULL );
virtual void Update();
virtual void ClearBackground();
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 bool SetBackgroundStyle(wxBackgroundStyle style) ;
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;
#if wxUSE_MENUS_NATIVE
virtual bool DoPopupMenu( wxMenu *menu, int x, int y );
#endif // wxUSE_MENUS_NATIVE
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 );
#if wxUSE_DRAG_AND_DROP
virtual void SetDropTarget( wxDropTarget *dropTarget );
#endif // wxUSE_DRAG_AND_DROP
#ifdef __WXGTK20__
virtual void AddChild( wxWindowBase *child );
virtual void RemoveChild( wxWindowBase *child );
#endif
// implementation
// --------------
virtual WXWidget GetHandle() const { return m_widget; }
// I don't want users to override what's done in idle so everything that
// has to be done in idle time in order for wxGTK to work is done in
// OnInternalIdle
virtual void OnInternalIdle();
// Internal represention of Update()
void GtkUpdate();
// For compatibility across platforms (not in event table)
void OnIdle(wxIdleEvent& WXUNUSED(event)) {}
// wxGTK-specific: called recursively by Enable,
// to give widgets an oppprtunity to correct their colours after they
// have been changed by Enable
virtual void OnParentEnable( bool WXUNUSED(enable) ) {}
// Used by all window classes in the widget creation process.
bool PreCreation( wxWindowGTK *parent, const wxPoint &pos, const wxSize &size );
void PostCreation();
// Internal addition of child windows. differs from class
// to class not by using virtual functions but by using
// the m_insertCallback.
void DoAddChild(wxWindowGTK *child);
// This methods sends wxPaintEvents to the window. It reads the
// update region, breaks it up into rects and sends an event
// for each rect. It is also responsible for background erase
// events and NC paint events. It is called from "draw" and
// "expose" handlers as well as from ::Update()
void GtkSendPaintEvents();
// The methods below are required because many native widgets
// are composed of several subwidgets and setting a style for
// the widget means setting it for all subwidgets as well.
// also, it is nor clear, which native widget is the top
// widget where (most of) the input goes. even tooltips have
// to be applied to all subwidgets.
virtual GtkWidget* GetConnectWidget();
virtual bool IsOwnGtkWindow( GdkWindow *window );
void ConnectWidget( GtkWidget *widget );
#ifdef __WXGTK20__
// Returns the default context which usually is anti-aliased
PangoContext *GtkGetPangoDefaultContext();
// Returns the X11 context which renders on the X11 client
// side (which can be remote) and which usually is not
// anti-aliased and is thus faster
// MR: Now returns the default pango_context for the widget as GtkGetPangoDefaultContext to
// not depend on libpangox - which is completely deprecated.
//BCI: Remove GtkGetPangoX11Context and m_x11Context completely when symbols may be removed
PangoContext *GtkGetPangoX11Context();
PangoContext *m_x11Context; // MR: Now unused
#endif
#if wxUSE_TOOLTIPS
virtual void ApplyToolTip( GtkTooltips *tips, const wxChar *tip );
#endif // wxUSE_TOOLTIPS
// Called from GTK signales handlers. it indicates that
// the layouting functions have to be called later on
// (i.e. in idle time, implemented in OnInternalIdle() ).
void GtkUpdateSize() { m_sizeSet = FALSE; }
// fix up the mouse event coords, used by wxListBox only so far
virtual void FixUpMouseEvent(GtkWidget * WXUNUSED(widget),
wxCoord& WXUNUSED(x),
wxCoord& WXUNUSED(y)) { }
// is this window transparent for the mouse events (as wxStaticBox is)?
virtual bool IsTransparentForMouse() const { return FALSE; }
// is this a radiobutton (used by radiobutton code itself only)?
virtual bool IsRadioButton() const { return FALSE; }
// position and size of the window
int m_x, m_y;
int m_width, m_height;
int m_oldClientWidth,m_oldClientHeight;
// see the docs in src/gtk/window.cpp
GtkWidget *m_widget; // mostly the widget seen by the rest of GTK
GtkWidget *m_wxwindow; // mostly the client area as per wxWidgets
// this widget will be queried for GTK's focus events
GtkWidget *m_focusWidget;
#ifdef __WXGTK20__
wxGtkIMData *m_imData;
#else // GTK 1
#ifdef HAVE_XIM
// XIM support for wxWidgets
GdkIC *m_ic;
GdkICAttr *m_icattr;
#endif // HAVE_XIM
#endif // GTK 2/1
#ifndef __WXGTK20__
// The area to be cleared (and not just refreshed)
// We cannot make this distinction under GTK 2.0.
wxRegion m_clearRegion;
#endif
// scrolling stuff
GtkAdjustment *m_hAdjust,*m_vAdjust;
float m_oldHorizontalPos;
float m_oldVerticalPos;
// extra (wxGTK-specific) flags
bool m_needParent:1; // ! wxFrame, wxDialog, wxNotebookPage ?
bool m_noExpose:1; // wxGLCanvas has its own redrawing
bool m_nativeSizeEvent:1; // wxGLCanvas sends wxSizeEvent upon "alloc_size"
bool m_hasScrolling:1;
bool m_hasVMT:1;
bool m_sizeSet:1;
bool m_resizing:1;
bool m_acceptsFocus:1; // true if not static
bool m_hasFocus:1; // true if == FindFocus()
bool m_isScrolling:1; // dragging scrollbar thumb?
bool m_clipPaintRegion:1; // TRUE after ScrollWindow()
#ifdef __WXGTK20__
bool m_dirtyTabOrder:1; // tab order changed, GTK focus
// chain needs update
#endif
bool m_needsStyleChange:1; // May not be able to change
// background style until OnIdle
// C++ has no virtual methods in the constrcutor of any class but we need
// different methods of inserting a child window into a wxFrame,
// wxMDIFrame, wxNotebook etc. this is the callback that will get used.
wxInsertChildFunction m_insertCallback;
// 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 void DoCaptureMouse();
virtual void DoReleaseMouse();
#if wxUSE_TOOLTIPS
virtual void DoSetToolTip( wxToolTip *tip );
#endif // wxUSE_TOOLTIPS
protected:
// common part of all ctors (not virtual because called from ctor)
void Init();
#ifdef __WXGTK20__
virtual void DoMoveInTabOrder(wxWindow *win, MoveKind move);
// Copies m_children tab order to GTK focus chain:
void RealizeTabOrder();
#endif
// Called by ApplyWidgetStyle (which is called by SetFont() and
// SetXXXColour etc to apply style changed to native widgets) to create
// modified GTK style with non-standard attributes. If forceStyle=true,
// creates empty GtkRcStyle if there are no modifications, otherwise
// returns NULL in such case.
GtkRcStyle *CreateWidgetStyle(bool forceStyle = false);
// Overridden in many GTK widgets who have to handle subwidgets
virtual void ApplyWidgetStyle(bool forceStyle = false);
// helper function to ease native widgets wrapping, called by
// ApplyWidgetStyle -- override this, not ApplyWidgetStyle
virtual void DoApplyWidgetStyle(GtkRcStyle *style);
private:
DECLARE_DYNAMIC_CLASS(wxWindowGTK)
DECLARE_NO_COPY_CLASS(wxWindowGTK)
};
extern WXDLLIMPEXP_CORE wxWindow *wxFindFocusedChild(wxWindowGTK *win);
#endif // __GTKWINDOWH__

View File

@@ -0,0 +1,2 @@
Makefile.in

51
include/wx/motif/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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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, const 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_

104
include/wx/motif/app.h Normal file
View File

@@ -0,0 +1,104 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "app.h"
#endif
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/event.h"
#include "wx/hashmap.h"
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxApp;
class WXDLLEXPORT wxKeyEvent;
class WXDLLEXPORT wxLog;
class WXDLLEXPORT wxEventLoop;
class WXDLLEXPORT wxXVisualInfo;
class WXDLLEXPORT wxPerDisplayData;
// ----------------------------------------------------------------------------
// the wxApp class for Motif - see wxAppBase for more details
// ----------------------------------------------------------------------------
WX_DECLARE_VOIDPTR_HASH_MAP( wxPerDisplayData*, wxPerDisplayDataMap );
class WXDLLEXPORT wxApp : public wxAppBase
{
DECLARE_DYNAMIC_CLASS(wxApp)
public:
wxApp();
virtual ~wxApp();
// override base class (pure) virtuals
// -----------------------------------
virtual int MainLoop();
virtual void Exit();
virtual bool Yield(bool onlyIfNeeded = false);
virtual void WakeUpIdle(); // implemented in motif/evtloop.cpp
virtual bool OnInitGui();
// implementation from now on
// --------------------------
protected:
bool m_showOnInit;
public:
// Implementation
virtual bool Initialize(int& argc, wxChar **argv);
virtual void CleanUp();
// Motif-specific
WXAppContext GetAppContext() const { return m_appContext; }
WXWidget GetTopLevelWidget();
WXWidget GetTopLevelRealizedWidget();
WXColormap GetMainColormap(WXDisplay* display);
WXDisplay* GetInitialDisplay() const { return m_initialDisplay; }
void SetTopLevelWidget(WXDisplay* display, WXWidget widget);
void SetTopLevelRealizedWidget(WXDisplay* display,
WXWidget widget);
// This handler is called when a property change event occurs
virtual void HandlePropertyChange(WXEvent *event);
wxXVisualInfo* GetVisualInfo(WXDisplay* display);
private:
// Motif-specific
WXAppContext m_appContext;
WXColormap m_mainColormap;
WXDisplay* m_initialDisplay;
wxPerDisplayDataMap* m_perDisplayData;
DECLARE_EVENT_TABLE()
};
#endif
// _WX_APP_H_

View File

@@ -0,0 +1,77 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpbuttn.h
// Purpose: wxBitmapButton class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPBUTTN_H_
#define _WX_BMPBUTTN_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "bmpbuttn.h"
#endif
#include "wx/motif/bmpmotif.h"
#define wxDEFAULT_BUTTON_MARGIN 4
class WXDLLEXPORT wxBitmapButton: public wxBitmapButtonBase
{
DECLARE_DYNAMIC_CLASS(wxBitmapButton)
public:
wxBitmapButton();
~wxBitmapButton();
wxBitmapButton(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
Create(parent, id, bitmap, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxBitmap& bitmap,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxBU_AUTODRAW,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
virtual void SetLabel(const wxBitmap& bitmap)
{
SetBitmapLabel(bitmap);
}
virtual void SetLabel(const wxString& label)
{
wxControl::SetLabel(label);
}
virtual void SetBitmapLabel(const wxBitmap& bitmap);
void SetBitmapSelected(const wxBitmap& sel);
void SetBitmapFocus(const wxBitmap& focus);
void SetBitmapDisabled(const wxBitmap& disabled);
// Implementation
void DoSetBitmap();
virtual void ChangeBackgroundColour();
virtual wxSize DoGetBestSize() const;
protected:
wxBitmap m_bmpNormalOriginal; // May be different from m_buttonBitmap
// if m_buttonBitmap has been changed
// to reflect button background colour
wxBitmap m_bmpSelectedOriginal;
wxBitmap m_bmpDisabledOriginal;
wxBitmapCache m_bitmapCache;
WXPixmap m_insensPixmap;
};
#endif
// _WX_BMPBUTTN_H_

View File

@@ -0,0 +1,59 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpmotif.h
// Purpose: Motif-specific bitmap routines
// Author: Julian Smart, originally in bitmap.h
// Modified by:
// Created: 25/03/2003
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BMPMOTIF_H_
#define _WX_BMPMOTIF_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "bmpmotif.h"
#endif
#include "wx/defs.h"
#include "wx/bitmap.h"
class WXDLLEXPORT wxBitmapCache
{
public:
wxBitmapCache()
{
m_labelPixmap = (WXPixmap)NULL;
m_armPixmap = (WXPixmap)NULL;
m_insensPixmap = (WXPixmap)NULL;
m_image = (WXImage)NULL;
m_display = (WXDisplay*)NULL;
SetColoursChanged();
}
~wxBitmapCache();
void SetColoursChanged();
void SetBitmap( const wxBitmap& bitmap );
WXPixmap GetLabelPixmap( WXWidget w );
WXPixmap GetInsensPixmap( WXWidget w = (WXWidget)NULL );
WXPixmap GetArmPixmap( WXWidget w );
private:
void InvalidateCache();
void CreateImageIfNeeded( WXWidget w );
struct
{
bool label : 1;
bool arm : 1;
bool insens : 1;
} m_recalcPixmaps;
wxBitmap m_bitmap;
WXDisplay* m_display;
WXPixmap m_labelPixmap, m_armPixmap, m_insensPixmap;
WXImage m_image;
};
#endif // _WX_BMPMOTIF_H_

57
include/wx/motif/button.h Normal file
View File

@@ -0,0 +1,57 @@
/////////////////////////////////////////////////////////////////////////////
// Name: button.h
// Purpose: wxButton class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_
#define _WX_BUTTON_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "button.h"
#endif
// Pushbutton
class WXDLLEXPORT wxButton: public wxButtonBase
{
DECLARE_DYNAMIC_CLASS(wxButton)
public:
wxButton() { }
wxButton(wxWindow *parent,
wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxButtonNameStr);
virtual void SetDefault();
virtual void Command(wxCommandEvent& event);
static wxSize GetDefaultSize();
// Implementation
private:
virtual wxSize DoGetBestSize() const;
wxSize OldGetBestSize() const;
void SetDefaultShadowThicknessAndResize();
};
#endif
// _WX_BUTTON_H_

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.h
// Purpose: wxCheckBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKBOX_H_
#define _WX_CHECKBOX_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "checkbox.h"
#endif
// Checkbox item (single checkbox)
class WXDLLEXPORT wxCheckBox: public wxCheckBoxBase
{
DECLARE_DYNAMIC_CLASS(wxCheckBox)
public:
inline wxCheckBox() { Init(); }
inline wxCheckBox(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr)
{
Init();
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr);
virtual void SetValue(bool);
virtual bool GetValue() const ;
virtual void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeBackgroundColour();
private:
// common part of all constructors
void Init()
{
m_evtType = wxEVT_COMMAND_CHECKBOX_CLICKED;
}
virtual void DoSet3StateValue(wxCheckBoxState state);
virtual wxCheckBoxState DoGet3StateValue() const;
// public for the callback
public:
// either exEVT_COMMAND_CHECKBOX_CLICKED or ..._TOGGLEBUTTON_CLICKED
wxEventType m_evtType;
};
#endif
// _WX_CHECKBOX_H_

View File

@@ -0,0 +1,81 @@
///////////////////////////////////////////////////////////////////////////////
// Name: checklst.h
// Purpose: wxCheckListBox class - a listbox with checkable items
// Note: this is an optional class.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHECKLST_H_
#define _WX_CHECKLST_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "checklst.h"
#endif
#include "wx/listbox.h"
class wxCheckListBox : public wxCheckListBoxBase
{
DECLARE_DYNAMIC_CLASS(wxCheckListBox)
public:
// ctors
wxCheckListBox();
wxCheckListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int nStrings = 0,
const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
wxCheckListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
// items may be checked
bool IsChecked(size_t uiIndex) const;
void Check(size_t uiIndex, bool bCheck = true);
// override base class functions
virtual int DoAppend(const wxString& item);
virtual int FindString(const wxString& s) const;
virtual void SetString(int n, const wxString& s);
virtual wxString GetString(int n) const;
virtual void DoInsertItems(const wxArrayString& items, int pos);
virtual void DoSetItems(const wxArrayString& items, void **clientData);
private:
void DoToggleItem( int item, int x );
private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_CHECKLST_H_

View File

@@ -0,0 +1,26 @@
/*
* Name: wx/motif/chkconf.h
* Purpose: Motif-specific config settings checks
* Author: Vadim Zeitlin
* Modified by:
* Created: 2005-04-05 (extracted from wx/chkconf.h)
* RCS-ID: $Id$
* Copyright: (c) 2005 Vadim Zeitlin <vadim@wxwidgets.org>
* Licence: wxWindows licence
*/
/* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
#if wxUSE_UNICODE
# ifdef wxABORT_ON_CONFIG_ERROR
# error "wxUSE_UNICODE is not supported with wxMotif"
# else
# define wxUSE_UNICODE 0
# endif
#endif
#if wxUSE_NOTEBOOK && !wxUSE_TAB_DIALOG
# undef wxUSE_TAB_DIALOG
# define wxUSE_TAB_DIALOG 1
#endif

134
include/wx/motif/choice.h Normal file
View File

@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choice.h
// Purpose: wxChoice class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CHOICE_H_
#define _WX_CHOICE_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "choice.h"
#endif
#include "wx/clntdata.h"
#ifndef wxWIDGET_ARRAY_DEFINED
#define wxWIDGET_ARRAY_DEFINED
#include "wx/dynarray.h"
WX_DEFINE_ARRAY_PTR(WXWidget, wxWidgetArray);
#endif
// Choice item
class WXDLLEXPORT wxChoice: public wxChoiceBase
{
DECLARE_DYNAMIC_CLASS(wxChoice)
public:
wxChoice();
~wxChoice();
wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr)
{
Init();
Create(parent, id, pos, size, n, choices, style, validator, name);
}
wxChoice(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr)
{
Init();
Create(parent, id, pos, size, choices, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxChoiceNameStr);
// implementation of wxControlWithItems
virtual int GetCount() const;
virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, int pos);
virtual void DoSetItemClientData(int n, void* clientData);
virtual void* DoGetItemClientData(int n) const;
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
virtual wxClientData* DoGetItemClientObject(int n) const;
virtual int GetSelection() const;
virtual void Delete(int n);
virtual int FindString(const wxString& s) const;
virtual void Clear();
virtual void SetString(int n, const wxString& s);
virtual wxString GetString(int n) const;
// implementation of wxChoiceBase
virtual void SetSelection(int n);
virtual void SetColumns(int n = 1 );
virtual int GetColumns() const ;
// Original API
virtual void Command(wxCommandEvent& event);
void SetFocus();
// Implementation
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_formWidget; }
WXWidget GetMainWidget() const { return m_buttonWidget; }
virtual wxSize DoGetBestSize() const;
// implementation, for wxChoiceCallback
const wxWidgetArray& GetWidgets() const { return m_widgetArray; }
const wxStringList& GetStrings() const { return m_stringList; }
protected:
// minimum size for the text ctrl
wxSize GetItemsSize() const;
// common part of all contructors
void Init();
size_t m_noStrings;
WXWidget m_menuWidget;
WXWidget m_buttonWidget;
wxWidgetArray m_widgetArray;
WXWidget m_formWidget;
wxStringList m_stringList;
wxClientDataDictionary m_clientDataDict;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
};
#endif
// _WX_CHOICE_H_

View File

@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "clipbrd.h"
#endif
#if wxUSE_CLIPBOARD
class wxDataObject;
struct wxDataIdToDataObject;
#include "wx/list.h"
WX_DECLARE_LIST(wxDataObject, wxDataObjectList);
WX_DECLARE_LIST(wxDataIdToDataObject, wxDataIdToDataObjectList);
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;
wxDataObjectList m_data;
bool m_usePrimary;
wxDataIdToDataObjectList m_idToObject;
private:
DECLARE_DYNAMIC_CLASS(wxClipboard)
};
#endif // wxUSE_CLIPBOARD
#endif
// _WX_CLIPBRD_H_

100
include/wx/motif/colour.h Normal file
View File

@@ -0,0 +1,100 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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 )
{ Set(red, green, 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)); }
// Get colour from name or wxNullColour
static wxColour CreateByName(const wxString& name);
// 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);
protected:
// Helper function
void Init();
private:
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
public:
int m_pixel;
};
#endif
// _WX_COLOUR_H_

126
include/wx/motif/combobox.h Normal file
View File

@@ -0,0 +1,126 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox.h
// Purpose: wxComboBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_COMBOBOX_H_
#define _WX_COMBOBOX_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "combobox.h"
#endif
#include "wx/choice.h"
// Combobox item
class WXDLLEXPORT wxComboBox: public wxChoice
{
DECLARE_DYNAMIC_CLASS(wxComboBox)
public:
wxComboBox() { m_inSetSelection = false; }
~wxComboBox();
inline wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
m_inSetSelection = false;
Create(parent, id, value, pos, size, n, choices,
style, validator, name);
}
inline wxComboBox(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr)
{
m_inSetSelection = false;
Create(parent, id, value, pos, size, choices,
style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxComboBoxNameStr);
// implementation of wxControlWithItems
virtual int DoAppend(const wxString& item);
virtual int DoInsert(const wxString& item, int pos);
virtual void Delete(int n);
virtual void Clear();
virtual int GetSelection() const ;
virtual void SetSelection(int n);
virtual int FindString(const wxString& s) const;
virtual wxString GetString(int n) const ;
virtual void SetString(int n, const wxString& s);
// Text field functions
virtual wxString GetValue() const ;
virtual void SetValue(const wxString& value);
// Clipboard operations
virtual void Copy();
virtual void Cut();
virtual void Paste();
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const ;
virtual wxTextPos GetLastPosition() const ;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const { return m_mainWidget; }
WXWidget GetMainWidget() const { return m_mainWidget; }
virtual wxSize DoGetBestSize() const;
protected:
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private:
// only implemented for native combo box
void AdjustDropDownListSize();
// implementation detail, should really be private
public:
bool m_inSetSelection;
};
#endif
// _WX_COMBOBOX_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: control.h
// Purpose: wxControl class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_CONTROL_H_
#define _WX_CONTROL_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "control.h"
#endif
#include "wx/window.h"
#include "wx/list.h"
#include "wx/validate.h"
// General item class
class WXDLLEXPORT wxControl: public wxControlBase
{
DECLARE_ABSTRACT_CLASS(wxControl)
public:
wxControl();
wxControl( wxWindow *parent,
wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString &name = wxControlNameStr )
{
Create(parent, id, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxControlNameStr);
// simulates the event, returns true if the event was processed
virtual void Command(wxCommandEvent& WXUNUSED(event)) { }
// calls the callback and appropriate event handlers, returns true if
// event was processed
virtual bool ProcessCommand(wxCommandEvent& event);
virtual void SetLabel(const wxString& label);
virtual wxString GetLabel() const ;
bool InSetValue() const { return m_inSetValue; }
protected:
// calls wxControlBase::CreateControl, also sets foreground, background and
// font to parent's values
bool CreateControl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name);
// native implementation using XtQueryGeometry
virtual wxSize DoGetBestSize() const;
// Motif: prevent callbacks being called while in SetValue
bool m_inSetValue;
DECLARE_EVENT_TABLE()
};
#endif // _WX_CONTROL_H_

74
include/wx/motif/cursor.h Normal file
View File

@@ -0,0 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "cursor.h"
#endif
#include "wx/object.h"
#include "wx/gdicmn.h"
class WXDLLEXPORT wxImage;
// Cursor
class WXDLLEXPORT wxCursor: public wxObject
{
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);
#if wxUSE_IMAGE
wxCursor(const wxImage& image);
#endif
wxCursor(wxStockCursor id);
~wxCursor();
virtual bool Ok() const;
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) const;
private:
void Create(const char bits[], int width, int height,
int hotSpotX = -1, int hotSpotY = -1,
const char maskBits[] = NULL);
void Create(WXPixmap cursor, WXPixmap mask, int hotSpotX, int hotSpotY);
// Make a cursor from standard id
WXCursor MakeCursor(WXDisplay* display, wxStockCursor id) const;
};
extern WXDLLEXPORT void wxSetCursor(const wxCursor& cursor);
#endif
// _WX_CURSOR_H_

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

View File

@@ -0,0 +1,28 @@
///////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxDataObject is the same as wxDataObjectBase under wxMotif
// ----------------------------------------------------------------------------
class wxDataObject : public wxDataObjectBase
{
public:
virtual ~wxDataObject();
};
#endif //_WX_MOTIF_DATAOBJ_H_

View File

@@ -0,0 +1,39 @@
///////////////////////////////////////////////////////////////////////////////
// Name: include/wx/motif/dataobj2.h
// Purpose: declaration of standard wxDataObjectSimple-derived classes
// Author: Mattia Barbon
// Created: 27.04.03
// RCS-ID: $Id$
// Copyright: (c) 2003 Mattia Barbon
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_DATAOBJ2_H_
#define _WX_MOTIF_DATAOBJ2_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "dataobj.h"
#endif
// ----------------------------------------------------------------------------
// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
// ----------------------------------------------------------------------------
class wxBitmapDataObject : public wxBitmapDataObjectBase
{
public:
// ctors
wxBitmapDataObject()
: wxBitmapDataObjectBase() { }
wxBitmapDataObject(const wxBitmap& bitmap)
: wxBitmapDataObjectBase(bitmap) { }
// implement base class pure virtuals
// ----------------------------------
virtual size_t GetDataSize() const;
virtual bool GetDataHere(void *buf) const;
virtual bool SetData(size_t len, const void *buf);
};
#endif // _WX_MOTIF_DATAOBJ2_H_

166
include/wx/motif/dc.h Normal file
View File

@@ -0,0 +1,166 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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 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:
virtual 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_

195
include/wx/motif/dcclient.h Normal file
View File

@@ -0,0 +1,195 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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(WXRegion region);
// 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:
// note that this function will call colour.SetPixel,
// and will do one of curCol = colour, curCol = wxWHITE, curCol = wxBLACK
// roundToWhite has an effect for monochrome display only
// if roundToWhite == true then the colour will be set to white unless
// it is RGB 0x000000;if roundToWhite == true the colour wull be set to
// black unless it id RGB 0xffffff
int CalculatePixel(wxColour& colour, wxColour& curCol,
bool roundToWhite) const;
// sets the foreground pixel taking into account the
// currently selected logical operation
void SetForegroundPixelWithLogicalFunction(int pixel);
virtual bool 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);
void DoGetSize( int *width, int *height ) const;
// common part of constructors
void Init();
WXGC m_gc;
WXGC m_gcBacking;
WXDisplay* m_display;
wxWindow* m_window;
// Pixmap for drawing on
WXPixmap m_pixmap;
// Last clipping region set on th GC, this is the combination
// of paint clipping region and all user-defined clipping regions
WXRegion m_clipRegion;
// Not sure if we'll need all of these
int m_backgroundPixel;
wxColour m_currentColour;
int m_currentPenWidth ;
int m_currentPenJoin ;
int m_currentPenCap ;
int m_currentPenDashCount ;
wxX11Dash* 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_

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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

106
include/wx/motif/dialog.h Normal file
View File

@@ -0,0 +1,106 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialog.h
// Purpose: wxDialog class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_DIALOG_H_
#define _WX_DIALOG_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "dialog.h"
#endif
class WXDLLEXPORT wxEventLoop;
// Dialog boxes
class WXDLLEXPORT wxDialog : public wxDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDialog)
public:
wxDialog();
// Constructor with no modal flag - the new convention.
wxDialog(wxWindow *parent, wxWindowID id,
const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxDEFAULT_DIALOG_STYLE,
const wxString& name = wxDialogNameStr)
{
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_DIALOG_STYLE,
const wxString& name = wxDialogNameStr);
~wxDialog();
virtual bool Destroy();
virtual bool Show(bool show = true);
void SetTitle(const wxString& title);
void SetModal(bool flag);
virtual bool IsModal() const
{ return ((GetWindowStyleFlag() & wxDIALOG_MODAL) == wxDIALOG_MODAL); }
virtual int ShowModal();
virtual void EndModal(int retCode);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
inline WXWidget GetTopWidget() const { return m_mainWidget; }
inline WXWidget GetClientWidget() const { return m_mainWidget; }
// Standard buttons
void OnOK(wxCommandEvent& event);
void OnApply(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
// Responds to colour changes
void OnSysColourChanged(wxSysColourChangedEvent& event);
void OnCharHook(wxKeyEvent& event);
void OnCloseWindow(wxCloseEvent& event);
private:
virtual bool DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name );
virtual void DoDestroy();
//// Motif-specific
bool m_modalShowing;
wxEventLoop* m_eventLoop;
protected:
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()
};
#endif
// _WX_DIALOG_H_

178
include/wx/motif/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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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(int flags = wxDrag_CopyOnly);
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_

View File

@@ -0,0 +1,44 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filedlg.h
// Purpose: wxFileDialog class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FILEDLG_H_
#define _WX_FILEDLG_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "filedlg.h"
#endif
//-------------------------------------------------------------------------
// wxFileDialog
//-------------------------------------------------------------------------
class WXDLLEXPORT wxFileDialog: public wxFileDialogBase
{
DECLARE_DYNAMIC_CLASS(wxFileDialog)
public:
// For Motif
static wxString m_fileSelectorAnswer;
static bool m_fileSelectorReturned;
public:
wxFileDialog(wxWindow *parent,
const wxString& message = wxFileSelectorPromptStr,
const wxString& defaultDir = wxEmptyString,
const wxString& defaultFile = wxEmptyString,
const wxString& wildCard = wxFileSelectorDefaultWildcardStr,
long style = 0,
const wxPoint& pos = wxDefaultPosition);
virtual int ShowModal();
};
#endif // _WX_FILEDLG_H_

126
include/wx/motif/font.h Normal file
View File

@@ -0,0 +1,126 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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 const 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);
// 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;
#if __WXMOTIF20__
WXRenderTable GetRenderTable(WXDisplay* display) const;
#endif
// returns either a XmFontList or XmRendition, depending
// on Motif version
WXFontType GetFontType(WXDisplay* display) const;
// like the function above but does a copy for XmFontList
WXFontType GetFontTypeC(WXDisplay* display) const;
static WXString GetFontTag();
protected:
virtual void DoSetNativeFontInfo( const wxNativeFontInfo& info );
// 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_

133
include/wx/motif/frame.h Normal file
View File

@@ -0,0 +1,133 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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);
// Set icon
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons);
#if wxUSE_STATUSBAR
virtual void PositionStatusBar();
#endif // wxUSE_STATUSBAR
// Create toolbar
#if wxUSE_TOOLBAR
virtual wxToolBar* CreateToolBar(long style = -1,
wxWindowID id = wxID_ANY,
const wxString& name = wxToolBarNameStr);
virtual void SetToolBar(wxToolBar *toolbar);
virtual void PositionToolBar();
#endif // wxUSE_TOOLBAR
// 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_mainWidget; }
// The widget that can have children on it
WXWidget GetClientWidget() const;
bool GetVisibleStatus() const { return m_visibleStatus; }
void SetVisibleStatus( bool status ) { m_visibleStatus = status; }
bool PreResize();
void SendSizeEvent();
// for generic/mdig.h
virtual void DoGetClientSize(int *width, int *height) const;
private:
// common part of all ctors
void Init();
// set a single icon for the frame
void DoSetIcon( const wxIcon& icon );
//// Motif-specific
WXWidget m_frameShell;
WXWidget m_workArea;
WXWidget m_clientArea;
bool m_visibleStatus;
bool m_iconized;
virtual void DoGetSize(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);
private:
virtual bool DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name );
virtual void DoDestroy();
DECLARE_EVENT_TABLE()
DECLARE_DYNAMIC_CLASS(wxFrame)
};
#endif
// _WX_MOTIF_FRAME_H_

62
include/wx/motif/gauge.h Normal file
View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: gauge.h
// Purpose: wxGauge class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GAUGE_H_
#define _WX_GAUGE_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "gauge.h"
#endif
// Group box
class WXDLLEXPORT wxGauge : public wxGaugeBase
{
DECLARE_DYNAMIC_CLASS(wxGauge)
public:
inline wxGauge() { m_rangeMax = 0; m_gaugePos = 0; }
inline wxGauge(wxWindow *parent, wxWindowID id,
int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr)
{
Create(parent, id, range, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
int range,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxGA_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxGaugeNameStr);
void SetShadowWidth(int w);
void SetRange(int r);
void SetValue(int pos);
int GetShadowWidth() const ;
int GetRange() const ;
int GetValue() const ;
virtual void Command(wxCommandEvent& WXUNUSED(event)) {} ;
private:
virtual wxSize DoGetBestSize() const;
virtual void DoMoveWindow(int x, int y, int width, int height);
};
#endif
// _WX_GAUGE_H_

48
include/wx/motif/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"
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

69
include/wx/motif/icon.h Normal file
View File

@@ -0,0 +1,69 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "icon.h"
#endif
#include "wx/bitmap.h"
// Icon
class WXDLLEXPORT wxIcon : public wxBitmap
{
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, wxBitmapType type = wxBITMAP_TYPE_XPM,
int desiredWidth = -1, int desiredHeight = -1)
{
LoadFile(name, type, desiredWidth, desiredHeight);
}
wxIcon(const wxIconLocation& loc)
{
LoadFile(loc.GetFileName(), wxBITMAP_TYPE_ANY);
}
~wxIcon();
bool LoadFile(const wxString& name, wxBitmapType type = wxBITMAP_TYPE_XPM,
int desiredWidth = -1, int desiredHeight = -1);
// create from bitmap (which should have a mask unless it's monochrome):
// there shouldn't be any implicit bitmap -> icon conversion (i.e. no
// ctors, assignment operators...), but it's ok to have such function
void CopyFromBitmap(const wxBitmap& bmp);
wxIcon& operator = (const wxIcon& icon)
{ if (this != &icon) Ref(icon); return *this; }
bool operator == (const wxIcon& icon) const
{ return m_refData == icon.m_refData; }
bool operator != (const wxIcon& icon) const
{ return !(*this == icon); }
DECLARE_DYNAMIC_CLASS(wxIcon)
};
#endif // _WX_ICON_H_

117
include/wx/motif/listbox.h Normal file
View File

@@ -0,0 +1,117 @@
/////////////////////////////////////////////////////////////////////////////
// Name: listbox.h
// Purpose: wxListBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_LISTBOX_H_
#define _WX_LISTBOX_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "listbox.h"
#endif
#include "wx/ctrlsub.h"
#include "wx/clntdata.h"
// forward decl for GetSelections()
class WXDLLEXPORT wxArrayInt;
// List box item
class WXDLLEXPORT wxListBox: public wxListBoxBase
{
DECLARE_DYNAMIC_CLASS(wxListBox)
public:
wxListBox();
wxListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr)
{
Create(parent, id, pos, size, n, choices, style, validator, name);
}
wxListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr)
{
Create(parent, id, pos, size, choices, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxListBoxNameStr);
~wxListBox();
// implementation of wxControlWithItems
virtual int GetCount() const;
virtual int DoAppend(const wxString& item);
virtual void DoSetItemClientData(int n, void* clientData);
virtual void* DoGetItemClientData(int n) const;
virtual void DoSetItemClientObject(int n, wxClientData* clientData);
virtual wxClientData* DoGetItemClientObject(int n) const;
virtual int GetSelection() const;
virtual void Delete(int n);
virtual int FindString(const wxString& s) const;
virtual void Clear();
virtual void SetString(int n, const wxString& s);
virtual wxString GetString(int n) const;
// implementation of wxListBoxbase
virtual void DoSetSelection(int n, bool select);
virtual void DoInsertItems(const wxArrayString& items, int pos);
virtual void DoSetItems(const wxArrayString& items, void **clientData);
virtual void DoSetFirstItem(int n);
virtual int GetSelections(wxArrayInt& aSelections) const;
virtual bool IsSelected(int n) const;
// For single or multiple choice list item
void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
WXWidget GetTopWidget() const;
#if wxUSE_CHECKLISTBOX
virtual void DoToggleItem(int item, int x) {};
#endif
protected:
virtual wxSize DoGetBestSize() const;
int m_noItems;
// List mapping positions->client data
wxClientDataDictionary m_clientDataDict;
private:
void SetSelectionPolicy();
};
#endif
// _WX_LISTBOX_H_

249
include/wx/motif/mdi.h Normal file
View File

@@ -0,0 +1,249 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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"
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(wxOrientation WXUNUSED(orient) = wxHORIZONTAL);
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);
virtual void SetIcons(const wxIconBundle& icons );
// Override wxFrame operations
void CaptureMouse();
void ReleaseMouse();
void Raise();
void Lower(void);
void DoSetSizeHints(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);
int FindPage(const wxNotebookPage* page);
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_

179
include/wx/motif/menu.h Normal file
View File

@@ -0,0 +1,179 @@
/////////////////////////////////////////////////////////////////////////////
// Name: menu.h
// Purpose: wxMenu, wxMenuBar classes
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_MENU_H_
#define _WX_MOTIF_MENU_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "menu.h"
#endif
#include "wx/colour.h"
#include "wx/font.h"
#include "wx/arrstr.h"
class wxFrame;
// ----------------------------------------------------------------------------
// Menu
// ----------------------------------------------------------------------------
class wxMenu : public wxMenuBase
{
public:
// ctors & dtor
wxMenu(const wxString& title, long style = 0)
: wxMenuBase(title, style) { Init(); }
wxMenu(long style = 0) : wxMenuBase(style) { Init(); }
virtual ~wxMenu();
// implement base class virtuals
virtual wxMenuItem* DoAppend(wxMenuItem *item);
virtual wxMenuItem* DoInsert(size_t pos, wxMenuItem *item);
virtual wxMenuItem* DoRemove(wxMenuItem *item);
virtual void Break();
virtual void SetTitle(const wxString& title);
bool ProcessCommand(wxCommandEvent& event);
//// Motif-specific
WXWidget GetButtonWidget() const { return m_buttonWidget; }
void SetButtonWidget(WXWidget buttonWidget) { m_buttonWidget = buttonWidget; }
WXWidget GetMainWidget() const { return m_menuWidget; }
int GetId() const { return m_menuId; }
void SetId(int id) { m_menuId = id; }
void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
wxMenuBar* GetMenuBar() const { return m_menuBar; }
void CreatePopup(WXWidget logicalParent, int x, int y);
void DestroyPopup();
void ShowPopup(int x, int y);
void HidePopup();
WXWidget CreateMenu(wxMenuBar *menuBar, WXWidget parent, wxMenu *topMenu,
const wxString& title = wxEmptyString,
bool isPulldown = false);
// For popups, need to destroy, then recreate menu for a different (or
// possibly same) window, since the parent may change.
void DestroyMenu(bool full);
WXWidget FindMenuItem(int id, wxMenuItem **it = NULL) const;
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
const wxFont& GetFont() const { return m_font; }
void SetBackgroundColour(const wxColour& colour);
void SetForegroundColour(const wxColour& colour);
void SetFont(const wxFont& colour);
void ChangeFont(bool keepOriginalSize = false);
WXWidget GetHandle() const { return m_menuWidget; }
bool IsTearOff() const { return (m_style & wxMENU_TEAROFF) != 0; }
void DestroyWidgetAndDetach();
public:
// Motif-specific data
int m_numColumns;
WXWidget m_menuWidget;
WXWidget m_popupShell; // For holding the popup shell widget
WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
int m_menuId;
wxMenu* m_topLevelMenu ;
bool m_ownedByMenuBar;
wxColour m_foregroundColour;
wxColour m_backgroundColour;
wxFont m_font;
private:
// common code for both constructors:
void Init();
DECLARE_DYNAMIC_CLASS(wxMenu)
};
// ----------------------------------------------------------------------------
// Menu Bar
// ----------------------------------------------------------------------------
class wxMenuBar : public wxMenuBarBase
{
public:
wxMenuBar() { Init(); }
wxMenuBar(long WXUNUSED(style)) { Init(); }
wxMenuBar(size_t n, wxMenu *menus[], const wxString titles[], long style = 0);
wxMenuBar(size_t n, wxMenu *menus[], const wxArrayString& titles, long style = 0);
virtual ~wxMenuBar();
// implement base class (pure) virtuals
// ------------------------------------
virtual bool Append( wxMenu *menu, const wxString &title );
virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
virtual wxMenu *Remove(size_t pos);
virtual int FindMenuItem(const wxString& menuString,
const wxString& itemString) const;
virtual wxMenuItem* FindItem( int id, wxMenu **menu = NULL ) const;
virtual void EnableTop( size_t pos, bool flag );
virtual void SetLabelTop( size_t pos, const wxString& label );
virtual wxString GetLabelTop( size_t pos ) const;
// implementation only from now on
// -------------------------------
wxFrame* GetMenuBarFrame() const { return m_menuBarFrame; }
void SetMenuBarFrame(wxFrame* frame) { m_menuBarFrame = frame; }
WXWidget GetMainWidget() const { return m_mainWidget; }
void SetMainWidget(WXWidget widget) { m_mainWidget = widget; }
// Create menubar
bool CreateMenuBar(wxFrame* frame);
// Destroy menubar, but keep data structures intact so we can recreate it.
bool DestroyMenuBar();
const wxColour& GetBackgroundColour() const { return m_backgroundColour; }
const wxColour& GetForegroundColour() const { return m_foregroundColour; }
const wxFont& GetFont() const { return m_font; }
virtual bool SetBackgroundColour(const wxColour& colour);
virtual bool SetForegroundColour(const wxColour& colour);
virtual bool SetFont(const wxFont& colour);
void ChangeFont(bool keepOriginalSize = false);
public:
// common part of all ctors
void Init();
wxArrayString m_titles;
wxFrame *m_menuBarFrame;
WXWidget m_mainWidget;
wxColour m_foregroundColour;
wxColour m_backgroundColour;
wxFont m_font;
DECLARE_DYNAMIC_CLASS(wxMenuBar)
};
#endif // _WX_MOTIF_MENU_H_

View File

@@ -0,0 +1,71 @@
///////////////////////////////////////////////////////////////////////////////
// Name: menuitem.h
// Purpose: wxMenuItem class
// Author: Vadim Zeitlin
// Modified by:
// Created: 11.11.97
// RCS-ID: $Id$
// Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_MENUITEM_H
#define _WX_MOTIF_MENUITEM_H
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "menuitem.h"
#endif
#include "wx/bitmap.h"
class WXDLLEXPORT wxMenuBar;
// ----------------------------------------------------------------------------
// wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
// ----------------------------------------------------------------------------
class wxMenuItem : public wxMenuItemBase
{
public:
// ctor & dtor
wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL,
int id = wxID_SEPARATOR,
const wxString& text = wxEmptyString,
const wxString& help = wxEmptyString,
wxItemKind kind = wxITEM_NORMAL,
wxMenu *subMenu = (wxMenu *)NULL);
~wxMenuItem();
// accessors (some more are inherited from wxOwnerDrawn or are below)
virtual void SetText(const wxString& label);
virtual void Enable(bool enable = true);
virtual void Check(bool check = true);
// included SetBitmap and GetBitmap as copied from the GTK include file
// I'm not sure if this works but it silences the linker in the
// menu sample.
// JJ
virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; }
virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
// implementation from now on
void CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu);
void DestroyItem(bool full);
WXWidget GetButtonWidget() const { return m_buttonWidget; }
wxMenuBar* GetMenuBar() const { return m_menuBar; }
void SetMenuBar(wxMenuBar* menuBar) { m_menuBar = menuBar; }
wxMenu* GetTopMenu() const { return m_topMenu; }
void SetTopMenu(wxMenu* menu) { m_topMenu = menu; }
private:
WXWidget m_buttonWidget;
wxMenuBar* m_menuBar;
wxMenu* m_topMenu; // Top-level menu e.g. popup-menu
wxBitmap m_bitmap; // Bitmap for menuitem, if any
DECLARE_DYNAMIC_CLASS(wxMenuItem)
};
#endif // _WX_MOTIF_MENUITEM_H

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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

54
include/wx/motif/msgdlg.h Normal file
View File

@@ -0,0 +1,54 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/msgdlg.h
// Purpose: wxMessageDialog class. Use generic version if no
// platform-specific implementation.
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSGBOXDLG_H_
#define _WX_MSGBOXDLG_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "msgdlg.h"
#endif
#include "wx/setup.h"
#include "wx/dialog.h"
// ----------------------------------------------------------------------------
// Message box dialog
// ----------------------------------------------------------------------------
WXDLLEXPORT_DATA(extern const char*) wxMessageBoxCaptionStr;
class WXDLLEXPORT wxMessageDialog: public wxDialog, public wxMessageDialogBase
{
DECLARE_DYNAMIC_CLASS(wxMessageDialog)
public:
wxMessageDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxMessageBoxCaptionStr,
long style = wxOK | wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
int ShowModal();
// implementation only from now on
// called by the Motif callback
void SetResult(long result) { m_result = result; }
protected:
wxString m_caption;
wxString m_message;
wxWindow * m_parent;
long m_result;
};
#endif
// _WX_MSGBOXDLG_H_

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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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 wxPaletteBase
{
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_

View File

@@ -0,0 +1,40 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/popupwin.h
// Purpose: wxPopupWindow class for wxMotif
// Author: Mattia Barbon
// Modified by:
// Created: 28.08.03
// RCS-ID: $Id$
// Copyright: (c) 2003 Mattia Barbon
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_POPUPWIN_H_
#define _WX_MOTIF_POPUPWIN_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "popup.h"
#endif
// ----------------------------------------------------------------------------
// wxPopupWindow
// ----------------------------------------------------------------------------
class wxPopupWindow : public wxPopupWindowBase
{
public:
wxPopupWindow() { Init(); }
wxPopupWindow( wxWindow *parent, int flags = wxBORDER_NONE )
{ Init(); (void)Create( parent, flags ); }
bool Create( wxWindow *parent, int flags = wxBORDER_NONE );
virtual bool Show( bool show = true );
private:
void Init() { m_isShown = false; }
DECLARE_DYNAMIC_CLASS_NO_COPY(wxPopupWindow)
};
#endif // _WX_MOTIF_POPUPWIN_H_

56
include/wx/motif/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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

189
include/wx/motif/private.h Normal file
View File

@@ -0,0 +1,189 @@
/////////////////////////////////////////////////////////////////////////////
// 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"
#include "X11/Xlib.h"
class WXDLLEXPORT wxFont;
class WXDLLEXPORT wxWindow;
class WXDLLEXPORT wxSize;
class WXDLLEXPORT wxBitmap;
class WXDLLEXPORT wxColour;
#include "wx/x11/privx.h"
// Put any private declarations here: native Motif types may be used because
// this header is included after Xm/Xm.h
// ----------------------------------------------------------------------------
// convenience macros
// ----------------------------------------------------------------------------
#define wxCHECK_MOTIF_VERSION( major, minor ) \
( XmVersion >= (major) * 1000 + (minor) )
#define wxCHECK_LESSTIF_VERSION( major, minor ) \
( LesstifVersion >= (major) * 1000 + (minor) )
#define wxCHECK_LESSTIF() ( defined(LesstifVersion) && LesstifVersion > 0 )
// ----------------------------------------------------------------------------
// Miscellaneous functions
// ----------------------------------------------------------------------------
WXWidget wxCreateBorderWidget( WXWidget parent, long style );
// ----------------------------------------------------------------------------
// 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);
// ----------------------------------------------------------------------------
// wxBitmap related functions
// ----------------------------------------------------------------------------
// Creates a bitmap with transparent areas drawn in the given colour.
wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour);
// ----------------------------------------------------------------------------
// key events related functions
// ----------------------------------------------------------------------------
extern char wxFindMnemonic(const char* s);
extern char * wxFindAccelerator (const char *s);
extern XmString wxFindAcceleratorText (const char *s);
// ----------------------------------------------------------------------------
// TranslateXXXEvent() functions - translate Motif event to wxWindow one
// ----------------------------------------------------------------------------
extern bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win,
Widget widget, const XEvent *xevent);
extern bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win,
Widget widget, const XEvent *xevent);
extern void wxDoChangeForegroundColour(WXWidget widget,
wxColour& foregroundColour);
extern void wxDoChangeBackgroundColour(WXWidget widget,
wxColour& backgroundColour,
bool changeArmColour = false);
extern void wxDoChangeFont(WXWidget widget, wxFont& font);
#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
// ----------------------------------------------------------------------------
// XmString/wxString conversion utilities
// ----------------------------------------------------------------------------
wxString wxXmStringToString( const XmString& xmString );
XmString wxStringToXmString( const wxString& string );
XmString wxStringToXmString( const char* string );
// XmString made easy to use in wxWidgets (and has an added benefit of
// cleaning up automatically)
class wxXmString
{
public:
wxXmString(const char* str)
{
m_string = XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
}
wxXmString(const wxString& str)
{
m_string = XmStringCreateLtoR((char *)str.c_str(),
XmSTRING_DEFAULT_CHARSET);
}
// just to avoid calling XmStringFree()
wxXmString(const XmString& string) { m_string = string; }
~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;
};
// ----------------------------------------------------------------------------
// Routines used in both wxTextCtrl/wxListBox and nativa wxComboBox
// (defined in src/motif/listbox.cpp or src/motif/textctrl.cpp
// ----------------------------------------------------------------------------
int wxDoFindStringInList( Widget listWidget, const wxString& str );
int wxDoGetSelectionInList( Widget listWidget );
wxString wxDoGetStringInList( Widget listWidget, int n );
wxSize wxDoGetListBoxBestSize( Widget listWidget, const wxWindow* window );
wxSize wxDoGetSingleTextCtrlBestSize( Widget textWidget,
const wxWindow* window );
// ----------------------------------------------------------------------------
// event-related functions
// ----------------------------------------------------------------------------
class wxEventLoop;
// executes one main loop iteration (implemented in src/motif/evtloop.cpp)
// returns true if the loop should be exited
bool wxDoEventLoopIteration( wxEventLoop& evtLoop );
// Consume all events until no more left
void wxFlushEvents(WXDisplay* display);
// ----------------------------------------------------------------------------
// 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_

130
include/wx/motif/radiobox.h Normal file
View File

@@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobox.h
// Purpose: wxRadioBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MOTIF_RADIOBOX_H_
#define _WX_MOTIF_RADIOBOX_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "radiobox.h"
#endif
#ifndef wxWIDGET_ARRAY_DEFINED
#define wxWIDGET_ARRAY_DEFINED
#include "wx/dynarray.h"
WX_DEFINE_ARRAY_PTR(WXWidget, wxWidgetArray);
#endif // wxWIDGET_ARRAY_DEFINED
#include "wx/arrstr.h"
class WXDLLEXPORT wxRadioBox : public wxControl, public wxRadioBoxBase
{
public:
wxRadioBox() { Init(); }
wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
Init();
Create(parent, id, title, pos, size, n, choices,
majorDim, style, val, name);
}
wxRadioBox(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr)
{
Init();
Create(parent, id, title, pos, size, choices,
majorDim, style, val, name);
}
~wxRadioBox();
bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int n = 0, const wxString choices[] = NULL,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
bool Create(wxWindow *parent, wxWindowID id, const wxString& title,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
int majorDim = 0, long style = wxRA_HORIZONTAL,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxRadioBoxNameStr);
int FindString(const wxString& s) const;
void SetSelection(int N);
int GetSelection() const;
void SetString(int item, const wxString& label) ;
wxString GetString(int item) const;
virtual bool Enable(bool enable = true);
virtual bool Enable(int item, bool enable = true);
virtual bool Show(int item, bool show = true);
virtual bool Show(bool show = true);
virtual wxString GetStringSelection() const;
virtual bool SetStringSelection(const wxString& s);
virtual int GetCount() const { return m_noItems; } ;
void Command(wxCommandEvent& event);
int GetColumnCount() const;
int GetRowCount() const;
int GetNumberOfRowsOrCols() const { return m_noRowsOrCols; }
void SetNumberOfRowsOrCols(int n) { m_noRowsOrCols = n; }
// Implementation
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
const wxWidgetArray& GetRadioButtons() const { return m_radioButtons; }
void SetSel(int i) { m_selectedButton = i; }
virtual WXWidget GetLabelWidget() const { return m_labelWidget; }
protected:
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
int m_majorDim;
int m_noItems;
int m_noRowsOrCols;
int m_selectedButton;
wxWidgetArray m_radioButtons;
WXWidget m_labelWidget;
wxArrayString m_radioButtonLabels;
private:
void Init();
DECLARE_DYNAMIC_CLASS(wxRadioBox)
};
#endif // _WX_MOTIF_RADIOBOX_H_

View File

@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: radiobut.h
// Purpose: wxRadioButton class
// Author: Julian Smart
// Modified by:
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_RADIOBUT_H_
#define _WX_RADIOBUT_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "radiobut.h"
#endif
class WXDLLEXPORT wxRadioButton: public wxControl
{
DECLARE_DYNAMIC_CLASS(wxRadioButton)
public:
wxRadioButton();
~wxRadioButton() { RemoveFromCycle(); }
inline wxRadioButton(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxRadioButtonNameStr);
virtual void SetValue(bool val);
virtual bool GetValue() const ;
void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeBackgroundColour();
// *this function is an implementation detail*
// clears the selection in the radiobuttons in the cycle
// and returns the old selection (if any)
wxRadioButton* ClearSelections();
private:
wxRadioButton* AddInCycle(wxRadioButton* cycle);
void RemoveFromCycle();
wxRadioButton* NextInCycle() { return m_cycle; }
wxRadioButton *m_cycle;
};
#endif
// _WX_RADIOBUT_H_

View File

@@ -0,0 +1,66 @@
/////////////////////////////////////////////////////////////////////////////
// Name: scrollbar.h
// Purpose: wxScrollBar class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SCROLBAR_H_
#define _WX_SCROLBAR_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "scrolbar.h"
#endif
// Scrollbar item
class WXDLLEXPORT wxScrollBar: public wxScrollBarBase
{
DECLARE_DYNAMIC_CLASS(wxScrollBar)
public:
inline wxScrollBar() { m_pageSize = 0; m_viewSize = 0; m_objectSize = 0; }
~wxScrollBar();
inline wxScrollBar(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSB_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxScrollBarNameStr)
{
Create(parent, id, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSB_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxScrollBarNameStr);
int GetThumbPosition() const ;
inline int GetThumbSize() const { return m_pageSize; }
inline int GetPageSize() const { return m_viewSize; }
inline int GetRange() const { return m_objectSize; }
virtual void SetThumbPosition(int viewStart);
virtual void SetScrollbar(int position, int thumbSize, int range, int pageSize,
bool refresh = true);
void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
protected:
int m_pageSize;
int m_viewSize;
int m_objectSize;
};
#endif
// _WX_SCROLBAR_H_

83
include/wx/motif/slider.h Normal file
View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: slider.h
// Purpose: wxSlider class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SLIDER_H_
#define _WX_SLIDER_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "slider.h"
#endif
#include "wx/control.h"
// Slider
class WXDLLEXPORT wxSlider: public wxSliderBase
{
DECLARE_DYNAMIC_CLASS(wxSlider)
public:
wxSlider();
wxSlider(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSL_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxSliderNameStr)
{
Create(parent, id, value, minValue, maxValue, pos, size, style, validator, name);
}
~wxSlider();
bool Create(wxWindow *parent, wxWindowID id,
int value, int minValue, int maxValue,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSL_HORIZONTAL,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxSliderNameStr);
virtual int GetValue() const ;
virtual void SetValue(int);
void SetRange(int minValue, int maxValue);
inline int GetMin() const { return m_rangeMin; }
inline int GetMax() const { return m_rangeMax; }
// For trackbars only
void SetPageSize(int pageSize);
int GetPageSize() const ;
void SetLineSize(int lineSize);
int GetLineSize() const ;
void SetThumbLength(int len) ;
int GetThumbLength() const ;
void Command(wxCommandEvent& event);
protected:
int m_rangeMin;
int m_rangeMax;
int m_pageSize;
int m_lineSize;
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_SLIDER_H_

View File

@@ -0,0 +1,80 @@
/////////////////////////////////////////////////////////////////////////////
// Name: spinbutt.h
// Purpose: wxSpinButton class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPINBUTT_H_
#define _WX_SPINBUTT_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "spinbutt.h"
#endif
class WXDLLEXPORT wxArrowButton; // internal
class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
wxSpinButton() : m_up( 0 ), m_down( 0 ), m_pos( 0 ) { }
wxSpinButton(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton")
: m_up( 0 ),
m_down( 0 ),
m_pos( 0 )
{
Create(parent, id, pos, size, style, name);
}
~wxSpinButton();
bool Create(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton");
// accessors
int GetValue() const;
int GetMin() const { return m_min; }
int GetMax() const { return m_max; }
// operations
void SetValue(int val);
void SetRange(int minVal, int maxVal);
// Implementation
virtual void Command(wxCommandEvent& event)
{ (void)ProcessCommand(event); };
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
public:
// implementation detail
void Increment( int delta );
private:
virtual void DoSetSize(int x, int y, int width, int height,
int sizeFlags = wxSIZE_AUTO);
virtual void DoMoveWindow(int x, int y, int width, int height);
virtual wxSize DoGetBestSize() const;
wxArrowButton* m_up;
wxArrowButton* m_down;
int m_pos;
};
#endif
// _WX_SPINBUTT_H_

View File

@@ -0,0 +1,83 @@
/////////////////////////////////////////////////////////////////////////////
// Name: statbmp.h
// Purpose: wxStaticBitmap class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBMP_H_
#define _WX_STATBMP_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "statbmp.h"
#endif
#include "wx/motif/bmpmotif.h"
#include "wx/icon.h"
class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
{
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
public:
wxStaticBitmap() { }
~wxStaticBitmap();
wxStaticBitmap(wxWindow *parent, wxWindowID id,
const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticBitmapNameStr)
{
Create(parent, id, label, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxBitmap& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticBitmapNameStr);
virtual void SetBitmap(const wxBitmap& bitmap);
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return false;
}
wxBitmap GetBitmap() const { return m_messageBitmap; }
// for compatibility with wxMSW
wxIcon GetIcon() const
{
// don't use wxDynamicCast, icons and bitmaps are really the same thing
return *(wxIcon*)&m_messageBitmap;
}
// for compatibility with wxMSW
void SetIcon(const wxIcon& icon)
{
SetBitmap( icon );
}
// Implementation
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
protected:
void DoSetBitmap();
protected:
wxBitmap m_messageBitmap;
wxBitmap m_messageBitmapOriginal;
wxBitmapCache m_bitmapCache;
};
#endif
// _WX_STATBMP_H_

View File

@@ -0,0 +1,62 @@
/////////////////////////////////////////////////////////////////////////////
// Name: statbox.h
// Purpose: wxStaticBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBOX_H_
#define _WX_STATBOX_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "statbox.h"
#endif
// Group box
class WXDLLEXPORT wxStaticBox: public wxStaticBoxBase
{
DECLARE_DYNAMIC_CLASS(wxStaticBox)
public:
wxStaticBox();
wxStaticBox(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticBoxNameStr)
{
Create(parent, id, label, pos, size, style, name);
}
~wxStaticBox();
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticBoxNameStr);
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return false;
}
virtual WXWidget GetLabelWidget() const { return m_labelWidget; }
virtual void SetLabel(const wxString& label);
private:
WXWidget m_labelWidget;
private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_STATBOX_H_

View File

@@ -0,0 +1,64 @@
/////////////////////////////////////////////////////////////////////////////
// Name: stattext.h
// Purpose: wxStaticText class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATTEXT_H_
#define _WX_STATTEXT_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "stattext.h"
#endif
class WXDLLEXPORT wxStaticText: public wxStaticTextBase
{
DECLARE_DYNAMIC_CLASS(wxStaticText)
public:
wxStaticText() { }
wxStaticText(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticTextNameStr)
{
Create(parent, id, label, pos, size, style, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticTextNameStr);
// implementation
// --------------
// operations
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return false;
}
virtual void SetLabel(const wxString& label);
// Get the widget that corresponds to the label
// (for font setting, label setting etc.)
virtual WXWidget GetLabelWidget() const
{ return m_labelWidget; }
protected:
WXWidget m_labelWidget;
};
#endif
// _WX_STATTEXT_H_

148
include/wx/motif/textctrl.h Normal file
View File

@@ -0,0 +1,148 @@
/////////////////////////////////////////////////////////////////////////////
// Name: textctrl.h
// Purpose: wxTextCtrl class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TEXTCTRL_H_
#define _WX_TEXTCTRL_H_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "textctrl.h"
#endif
// Single-line text item
class WXDLLEXPORT wxTextCtrl : public wxTextCtrlBase
{
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
public:
// creation
// --------
wxTextCtrl();
wxTextCtrl(wxWindow *parent,
wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr)
{
Create(parent, id, value, pos, size, style, validator, name);
}
bool Create(wxWindow *parent, wxWindowID id,
const wxString& value = wxEmptyString,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr);
// accessors
// ---------
virtual wxString GetValue() const;
virtual void SetValue(const wxString& value);
virtual int GetLineLength(long lineNo) const;
virtual wxString GetLineText(long lineNo) const;
virtual int GetNumberOfLines() const;
// operations
// ----------
// Clipboard operations
virtual void Copy();
virtual void Cut();
virtual void Paste();
virtual bool CanCopy() const;
virtual bool CanCut() const;
virtual bool CanPaste() const;
// Undo/redo
virtual void Undo();
virtual void Redo();
virtual bool CanUndo() const;
virtual bool CanRedo() const;
virtual void SetInsertionPoint(long pos);
virtual void SetInsertionPointEnd();
virtual long GetInsertionPoint() const;
virtual wxTextPos GetLastPosition() const;
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
virtual void SetSelection(long from, long to);
virtual void SetEditable(bool editable);
// If the return values from and to are the same, there is no
// selection.
virtual void GetSelection(long* from, long* to) const;
virtual bool IsEditable() const ;
virtual void WriteText(const wxString& text);
virtual void AppendText(const wxString& text);
virtual void MarkDirty();
virtual void DiscardEdits();
virtual bool IsModified() const;
virtual long XYToPosition(long x, long y) const;
virtual bool PositionToXY(long pos, long *x, long *y) const;
virtual void ShowPosition(long pos);
virtual void Clear();
// callbacks
// ---------
void OnDropFiles(wxDropFilesEvent& event);
void OnChar(wxKeyEvent& event);
// void OnEraseBackground(wxEraseEvent& event);
void OnCut(wxCommandEvent& event);
void OnCopy(wxCommandEvent& event);
void OnPaste(wxCommandEvent& event);
void OnUndo(wxCommandEvent& event);
void OnRedo(wxCommandEvent& event);
void OnUpdateCut(wxUpdateUIEvent& event);
void OnUpdateCopy(wxUpdateUIEvent& event);
void OnUpdatePaste(wxUpdateUIEvent& event);
void OnUpdateUndo(wxUpdateUIEvent& event);
void OnUpdateRedo(wxUpdateUIEvent& event);
virtual void Command(wxCommandEvent& event);
// implementation from here to the end
// -----------------------------------
virtual void ChangeFont(bool keepOriginalSize = true);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
void SetModified(bool mod) { m_modified = mod; }
virtual WXWidget GetTopWidget() const;
// send the CHAR and TEXT_UPDATED events
void DoSendEvents(void /* XmTextVerifyCallbackStruct */ *cbs,
long keycode);
protected:
wxString m_fileName;
virtual wxSize DoGetBestSize() const;
public:
// Motif-specific
void* m_tempCallbackStruct;
bool m_modified;
wxString m_value; // Required for password text controls
// Did we call wxTextCtrl::OnChar? If so, generate a command event.
bool m_processedDefault;
private:
DECLARE_EVENT_TABLE()
};
#endif
// _WX_TEXTCTRL_H_

50
include/wx/motif/tglbtn.h Normal file
View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/tglbtn.h
// Purpose: Declaration of the wxToggleButton class, which implements a
// toggle button under wxMotif.
// Author: Mattia Barbon
// Modified by:
// Created: 10.02.03
// RCS-ID: $Id$
// Copyright: (c) 2003 Mattia Barbon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_TOGGLEBUTTON_H_
#define _WX_TOGGLEBUTTON_H_
#include "wx/checkbox.h"
class WXDLLEXPORT wxToggleButton : public wxCheckBox
{
public:
wxToggleButton() { Init(); }
wxToggleButton( wxWindow* parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString& name = wxCheckBoxNameStr )
{
Init();
Create( parent, id, label, pos, size, style, val, name );
}
bool Create( wxWindow* parent, wxWindowID id, const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxValidator& val = wxDefaultValidator,
const wxString &name = wxCheckBoxNameStr );
private:
DECLARE_DYNAMIC_CLASS(wxToggleButton)
// common part of all constructors
void Init()
{
m_evtType = wxEVT_COMMAND_TOGGLEBUTTON_CLICKED;
}
};
#endif // _WX_TOGGLEBUTTON_H_

44
include/wx/motif/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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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_

View File

@@ -0,0 +1,86 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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;
private:
// 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 wxString& label,
const wxBitmap& bmpNormal,
const wxBitmap& bmpDisabled,
wxItemKind kind,
wxObject *clientData,
const wxString& shortHelp,
const wxString& longHelp);
virtual wxToolBarToolBase *CreateTool(wxControl *control);
virtual void DoSetSize(int x, int y,
int width, int height,
int sizeFlags = wxSIZE_AUTO);
private:
DECLARE_DYNAMIC_CLASS(wxToolBar)
};
#endif
// _WX_TOOLBAR_H_

View File

@@ -0,0 +1,90 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/motif/toplevel.h
// Purpose: wxTopLevelWindow Motif implementation
// Author: Mattia Barbon
// Modified by:
// Created: 12/10/2002
// RCS-ID: $Id$
// Copyright: (c) Mattia Barbon
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __MOTIFTOPLEVELH__
#define __MOTIFTOPLEVELH__
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma interface "toplevel.h"
#endif
class wxTopLevelWindowMotif : public wxTopLevelWindowBase
{
public:
wxTopLevelWindowMotif() { Init(); }
wxTopLevelWindowMotif( 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 ~wxTopLevelWindowMotif();
virtual bool ShowFullScreen( bool show, long style = wxFULLSCREEN_ALL );
virtual bool IsFullScreen() const;
virtual void Maximize(bool maximize = true);
virtual void Restore();
virtual void Iconize(bool iconize = true);
virtual bool IsMaximized() const;
virtual bool IsIconized() const;
virtual void Raise();
virtual void Lower();
virtual wxString GetTitle() const { return m_title; }
virtual void SetTitle( const wxString& title ) { m_title = title; }
virtual void DoSetSizeHints( int minW, int minH,
int maxW = -1, int maxH = -1,
int incW = -1, int incH = -1 );
virtual bool SetShape( const wxRegion& region );
WXWidget GetShellWidget() const;
protected:
// common part of all constructors
void Init();
// common part of wxDialog/wxFrame destructors
void PreDestroy();
virtual void DoGetPosition(int* x, int* y) const;
private:
// both these functions should be pure virtual
virtual bool DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
return false;
}
virtual void DoDestroy() { }
wxString m_title;
};
#endif // __MOTIFTOPLEVELH__

333
include/wx/motif/window.h Normal file
View File

@@ -0,0 +1,333 @@
/////////////////////////////////////////////////////////////////////////////
// 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_
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#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 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 );
#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 GetClientXWindow() const;
WXWindow GetXWindow() const;
WXDisplay *GetXDisplay() const;
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)
// -----------------------------------------
// Adds a recangle to the updates list
void AddUpdateRect(int x, int y, int w, int h);
void ClearUpdateRegion() { m_updateRegion.Clear(); }
void SetUpdateRegion(const wxRegion& region) { m_updateRegion = region; }
// Process idle (send update events)
void OnInternalIdle();
protected:
// Responds to colour changes: passes event on to children.
void OnSysColourChanged(wxSysColourChangedEvent& event);
// Motif-specific
void SetMainWidget(WXWidget w) { m_mainWidget = w; }
// See src/motif/window.cpp, near the top, for an explanation
// why this is necessary
void CanvasSetSizeIntr(int x, int y, int width, int height,
int sizeFlags, bool fromCtor);
void DoSetSizeIntr(int x, int y,
int width, int height,
int sizeFlags, bool fromCtor);
// for DoMoveWindowIntr flags
enum
{
wxMOVE_X = 1,
wxMOVE_Y = 2,
wxMOVE_WIDTH = 4,
wxMOVE_HEIGHT = 8
};
void DoMoveWindowIntr(int x, int y, int width, int height,
int flags);
// helper function, to remove duplicate code, used in wxScrollBar
WXWidget DoCreateScrollBar(WXWidget parent, wxOrientation orientation,
void (*callback)());
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
// Change to the current font (often overridden)
virtual void ChangeFont(bool keepOriginalSize = true);
// 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
// wxWidgets 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 wxWidgets 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?
// For double-click detection
long m_lastTS; // last timestamp
unsigned m_lastButton:2; // last pressed button
protected:
WXWidget m_mainWidget;
WXWidget m_hScrollBar;
WXWidget m_vScrollBar;
WXWidget m_borderWidget;
WXWidget m_scrolledWindow;
WXWidget m_drawingArea;
bool m_winCaptured:1;
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_

View File

@@ -1,238 +0,0 @@
/////////////////////////////////////////////////////////////////////////////
// Name: include/wx/scrolwin.h
// Purpose: wxScrolledWindow, wxScrolledControl and wxScrollHelper
// Author: Vadim Zeitlin
// Modified by:
// Created: 30.08.00
// RCS-ID: $Id$
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SCROLWIN_H_BASE_
#define _WX_SCROLWIN_H_BASE_
#include "wx/window.h"
class WXDLLEXPORT wxScrollHelperEvtHandler;
class WXDLLEXPORT wxTimer;
// ----------------------------------------------------------------------------
// wxScrollHelper: this class implements the scrolling logic which is used by
// wxScrolledWindow and wxScrolledControl. It is a mix-in: just derive from it
// to implement scrolling in your class.
// ----------------------------------------------------------------------------
#if !defined(__WXGTK__) || defined(__WXUNIVERSAL__)
class WXDLLEXPORT wxScrollHelper
{
public:
// ctor and dtor
wxScrollHelper(wxWindow *winToScroll = (wxWindow *)NULL);
void SetWindow(wxWindow *winToScroll);
virtual ~wxScrollHelper();
// configure the scrolling
virtual void SetScrollbars(int pixelsPerUnitX, int pixelsPerUnitY,
int noUnitsX, int noUnitsY,
int xPos = 0, int yPos = 0,
bool noRefresh = false );
// scroll to the given (in logical coords) position
virtual void Scroll(int x, int y);
// get/set the page size for this orientation (wxVERTICAL/wxHORIZONTAL)
int GetScrollPageSize(int orient) const;
void SetScrollPageSize(int orient, int pageSize);
// Set the x, y scrolling increments.
void SetScrollRate( int xstep, int ystep );
// get the size of one logical unit in physical ones
virtual void GetScrollPixelsPerUnit(int *pixelsPerUnitX,
int *pixelsPerUnitY) const;
// Enable/disable Windows scrolling in either direction. If true, wxWidgets
// scrolls the canvas and only a bit of the canvas is invalidated; no
// Clear() is necessary. If false, the whole canvas is invalidated and a
// Clear() is necessary. Disable for when the scroll increment is used to
// actually scroll a non-constant distance
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// Get the view start
virtual void GetViewStart(int *x, int *y) const;
// Set the scale factor, used in PrepareDC
void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
double GetScaleX() const { return m_scaleX; }
double GetScaleY() const { return m_scaleY; }
// translate between scrolled and unscrolled coordinates
void CalcScrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcScrolledPosition(x, y, xx, yy); }
wxPoint CalcScrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const
{ DoCalcUnscrolledPosition(x, y, xx, yy); }
wxPoint CalcUnscrolledPosition(const wxPoint& pt) const
{
wxPoint p2;
DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y);
return p2;
}
virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const;
virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const;
// Adjust the scrollbars
virtual void AdjustScrollbars(void);
// Calculate scroll increment
virtual int CalcScrollInc(wxScrollWinEvent& event);
// Normally the wxScrolledWindow will scroll itself, but in some rare
// occasions you might want it to scroll [part of] another window (e.g. a
// child of it in order to scroll only a portion the area between the
// scrollbars (spreadsheet: only cell area will move).
virtual void SetTargetWindow(wxWindow *target);
virtual wxWindow *GetTargetWindow() const;
void SetTargetRect(const wxRect& rect) { m_rectToScroll = rect; }
wxRect GetTargetRect() const { return m_rectToScroll; }
// Override this function to draw the graphic (or just process EVT_PAINT)
virtual void OnDraw(wxDC& WXUNUSED(dc)) { }
// change the DC origin according to the scroll position.
virtual void DoPrepareDC(wxDC& dc);
// are we generating the autoscroll events?
bool IsAutoScrolling() const { return m_timerAutoScroll != NULL; }
// stop generating the scroll events when mouse is held outside the window
void StopAutoScrolling();
// this method can be overridden in a derived class to forbid sending the
// auto scroll events - note that unlike StopAutoScrolling() it doesn't
// stop the timer, so it will be called repeatedly and will typically
// return different values depending on the current mouse position
//
// the base class version just returns true
virtual bool SendAutoScrollEvents(wxScrollWinEvent& event) const;
// the methods to be called from the window event handlers
void HandleOnScroll(wxScrollWinEvent& event);
void HandleOnSize(wxSizeEvent& event);
void HandleOnPaint(wxPaintEvent& event);
void HandleOnChar(wxKeyEvent& event);
void HandleOnMouseEnter(wxMouseEvent& event);
void HandleOnMouseLeave(wxMouseEvent& event);
#if wxUSE_MOUSEWHEEL
void HandleOnMouseWheel(wxMouseEvent& event);
#endif // wxUSE_MOUSEWHEEL
// FIXME: this is needed for now for wxPlot compilation, should be removed
// once it is fixed!
void OnScroll(wxScrollWinEvent& event) { HandleOnScroll(event); }
protected:
// get pointer to our scroll rect if we use it or NULL
const wxRect *GetScrollRect() const
{
return m_rectToScroll.width != 0 ? &m_rectToScroll : NULL;
}
// get the size of the target window
wxSize GetTargetSize() const
{
return m_rectToScroll.width != 0 ? m_rectToScroll.GetSize()
: m_targetWindow->GetClientSize();
}
void GetTargetSize(int *w, int *h)
{
wxSize size = GetTargetSize();
if ( w )
*w = size.x;
if ( h )
*h = size.y;
}
// change just the target window (unlike SetWindow which changes m_win as
// well)
void DoSetTargetWindow(wxWindow *target);
// delete the event handler we installed
void DeleteEvtHandler();
double m_scaleX;
double m_scaleY;
wxWindow *m_win,
*m_targetWindow;
wxRect m_rectToScroll;
wxTimer *m_timerAutoScroll;
int m_xScrollPixelsPerLine;
int m_yScrollPixelsPerLine;
int m_xScrollPosition;
int m_yScrollPosition;
int m_xScrollLines;
int m_yScrollLines;
int m_xScrollLinesPerPage;
int m_yScrollLinesPerPage;
bool m_xScrollingEnabled;
bool m_yScrollingEnabled;
#if wxUSE_MOUSEWHEEL
int m_wheelRotation;
#endif // wxUSE_MOUSEWHEEL
wxScrollHelperEvtHandler *m_handler;
DECLARE_NO_COPY_CLASS(wxScrollHelper)
};
#endif
// ----------------------------------------------------------------------------
// wxScrolledWindow: a wxWindow which knows how to scroll
// ----------------------------------------------------------------------------
#if defined(__WXGTK__) && !defined(__WXUNIVERSAL__)
#include "wx/gtk/scrolwin.h"
#else // !wxGTK
#include "wx/generic/scrolwin.h"
class WXDLLEXPORT wxScrolledWindow : public wxGenericScrolledWindow
{
public:
wxScrolledWindow() { }
wxScrolledWindow(wxWindow *parent,
wxWindowID winid = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxScrolledWindowStyle,
const wxString& name = wxPanelNameStr)
: wxGenericScrolledWindow(parent, winid, pos, size, style, name)
{
}
private:
DECLARE_DYNAMIC_CLASS_NO_COPY(wxScrolledWindow)
};
#define wxSCROLLED_WINDOW_IS_GENERIC 1
#endif
#endif
// _WX_SCROLWIN_H_BASE_

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

119
src/motif/accel.cpp Normal file
View File

@@ -0,0 +1,119 @@
/////////////////////////////////////////////////////////////////////////////
// Name: accel.cpp
// Purpose: wxAcceleratorTable
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "accel.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#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, const 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.GetKeyCode();
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))) ;
}

396
src/motif/app.cpp Normal file
View File

@@ -0,0 +1,396 @@
/////////////////////////////////////////////////////////////////////////////
// Name: app.cpp
// Purpose: wxApp
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "app.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtParent XTPARENT
#define XtDisplay XTDISPLAY
#endif
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/module.h"
#include "wx/memory.h"
#include "wx/log.h"
#include "wx/intl.h"
#include "wx/evtloop.h"
#include "wx/hash.h"
#if wxUSE_THREADS
#include "wx/thread.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>
struct wxPerDisplayData
{
wxPerDisplayData()
{
m_visualInfo = NULL;
m_topLevelWidget = NULL;
m_topLevelRealizedWidget = NULL;
}
wxXVisualInfo* m_visualInfo;
Widget m_topLevelWidget, m_topLevelRealizedWidget;
};
static void wxTLWidgetDestroyCallback(Widget w, XtPointer clientData,
XtPointer ptr);
static WXWidget wxCreateTopLevelWidget( WXDisplay* display );
extern wxList wxPendingDelete;
extern bool wxAddIdleCallback();
wxHashTable *wxWidgetHashTable = NULL;
IMPLEMENT_DYNAMIC_CLASS(wxApp, wxEvtHandler)
BEGIN_EVENT_TABLE(wxApp, wxEvtHandler)
EVT_IDLE(wxAppBase::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__
bool wxApp::Initialize(int& argc, wxChar **argv)
{
if ( !wxAppBase::Initialize(argc, argv) )
return false;
wxWidgetHashTable = new wxHashTable(wxKEY_INTEGER);
#if wxUSE_INTL
wxFont::SetDefaultEncoding(wxLocale::GetSystemEncoding());
#endif
return true;
}
void wxApp::CleanUp()
{
wxAppBase::CleanUp();
delete wxWidgetHashTable;
wxWidgetHashTable = NULL;
delete m_mainLoop;
for( wxPerDisplayDataMap::iterator it = m_perDisplayData->begin(),
end = m_perDisplayData->end();
it != end; ++it )
{
delete it->second->m_visualInfo;
XtDestroyWidget( it->second->m_topLevelWidget );
delete it->second;
}
delete m_perDisplayData;
}
void wxApp::Exit()
{
wxApp::CleanUp();
wxAppConsole::Exit();
}
// ============================================================================
// wxApp
// ============================================================================
wxApp::wxApp()
{
argc = 0;
argv = NULL;
m_mainLoop = new wxEventLoop;
m_mainColormap = (WXColormap) NULL;
m_appContext = (WXAppContext) NULL;
m_initialDisplay = (WXDisplay*) 0;
m_perDisplayData = new wxPerDisplayDataMap;
}
wxApp::~wxApp()
{
wxApp::SetInstance(NULL);
}
int wxApp::MainLoop()
{
/*
* 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);
m_mainLoop->Run();
return 0;
}
// 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 */
}
static char *fallbackResources[] = {
"*menuBar.marginHeight: 0",
"*menuBar.shadowThickness: 1",
"*background: #c0c0c0",
"*foreground: black",
NULL
};
// Create an application context
bool wxApp::OnInitGui()
{
if( !wxAppBase::OnInitGui() )
return false;
XtSetLanguageProc(NULL, NULL, NULL);
XtToolkitInitialize() ;
wxTheApp->m_appContext = (WXAppContext) XtCreateApplicationContext();
XtAppSetFallbackResources((XtAppContext) wxTheApp->m_appContext, fallbackResources);
Display *dpy = XtOpenDisplay((XtAppContext) wxTheApp->m_appContext,(String)NULL,NULL,
wxTheApp->GetClassName().c_str(), NULL, 0,
# if XtSpecificationRelease < 5
(Cardinal*) &argc,
# else
&argc,
# endif
argv);
if (!dpy) {
// if you don't log to stderr, nothing will be shown...
delete wxLog::SetActiveTarget(new wxLogStderr);
wxString className(wxTheApp->GetClassName());
wxLogError(_("wxWidgets could not open display for '%s': exiting."),
className.c_str());
exit(-1);
}
m_initialDisplay = (WXDisplay*) dpy;
#ifdef __WXDEBUG__
// install the X error handler
gs_pfnXErrorHandler = XSetErrorHandler(wxXErrorHandler);
#endif // __WXDEBUG__
// Add general resize proc
XtActionsRec rec;
rec.string = "resize";
rec.proc = (XtActionProc)wxWidgetResizeProc;
XtAppAddActions((XtAppContext) wxTheApp->m_appContext, &rec, 1);
GetMainColormap(dpy);
wxAddIdleCallback();
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;
}
static inline wxPerDisplayData& GetOrCreatePerDisplayData
( wxPerDisplayDataMap& m, WXDisplay* display )
{
wxPerDisplayDataMap::iterator it = m.find( display );
if( it != m.end() && it->second != NULL )
return *(it->second);
wxPerDisplayData* nData = new wxPerDisplayData();
m[display] = nData;
return *nData;
}
wxXVisualInfo* wxApp::GetVisualInfo( WXDisplay* display )
{
wxPerDisplayData& data = GetOrCreatePerDisplayData( *m_perDisplayData,
display );
if( data.m_visualInfo )
return data.m_visualInfo;
wxXVisualInfo* vi = new wxXVisualInfo;
wxFillXVisualInfo( vi, (Display*)display );
data.m_visualInfo = vi;
return vi;
}
static void wxTLWidgetDestroyCallback(Widget w, XtPointer clientData,
XtPointer ptr)
{
if( wxTheApp )
{
wxTheApp->SetTopLevelWidget( (WXDisplay*)XtDisplay(w),
(WXWidget)NULL );
wxTheApp->SetTopLevelRealizedWidget( (WXDisplay*)XtDisplay(w),
(WXWidget)NULL );
}
}
WXWidget wxCreateTopLevelWidget( WXDisplay* display )
{
Widget tlw = XtAppCreateShell( (String)NULL,
wxTheApp->GetClassName().c_str(),
applicationShellWidgetClass,
(Display*)display,
NULL, 0 );
XtVaSetValues( tlw,
XmNoverrideRedirect, True,
NULL );
XtAddCallback( tlw, XmNdestroyCallback,
(XtCallbackProc)wxTLWidgetDestroyCallback,
(XtPointer)NULL );
return (WXWidget)tlw;
}
WXWidget wxCreateTopLevelRealizedWidget( WXDisplay* display )
{
Widget rTlw = XtVaCreateWidget( "dummy_widget", topLevelShellWidgetClass,
(Widget)wxTheApp->GetTopLevelWidget(),
NULL, 0 );
XtSetMappedWhenManaged( rTlw, False );
XtRealizeWidget( rTlw );
return (WXWidget)rTlw;
}
WXWidget wxApp::GetTopLevelWidget()
{
WXDisplay* display = wxGetDisplay();
wxPerDisplayData& data = GetOrCreatePerDisplayData( *m_perDisplayData,
display );
if( data.m_topLevelWidget )
return (WXWidget)data.m_topLevelWidget;
WXWidget tlw = wxCreateTopLevelWidget( display );
SetTopLevelWidget( display, tlw );
return tlw;
}
WXWidget wxApp::GetTopLevelRealizedWidget()
{
WXDisplay* display = wxGetDisplay();
wxPerDisplayDataMap::iterator it = m_perDisplayData->find( display );
if( it != m_perDisplayData->end() && it->second->m_topLevelRealizedWidget )
return (WXWidget)it->second->m_topLevelRealizedWidget;
WXWidget rTlw = wxCreateTopLevelRealizedWidget( display );
SetTopLevelRealizedWidget( display, rTlw );
return rTlw;
}
void wxApp::SetTopLevelWidget(WXDisplay* display, WXWidget widget)
{
GetOrCreatePerDisplayData( *m_perDisplayData, display )
.m_topLevelWidget = (Widget)widget;
}
void wxApp::SetTopLevelRealizedWidget(WXDisplay* display, WXWidget widget)
{
GetOrCreatePerDisplayData( *m_perDisplayData, display )
.m_topLevelRealizedWidget = (Widget)widget;
}
// Yield to other processes
bool wxApp::Yield(bool onlyIfNeeded)
{
static 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;
}
// ----------------------------------------------------------------------------
// accessors for C modules
// ----------------------------------------------------------------------------
extern "C" XtAppContext wxGetAppContext()
{
return (XtAppContext)wxTheApp->GetAppContext();
}

6
src/motif/bdiag.xbm Normal file
View File

@@ -0,0 +1,6 @@
#define bdiag_width 16
#define bdiag_height 16
static char bdiag_bits[] = {
0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04,
0x02, 0x02, 0x01, 0x01, 0x80, 0x80, 0x40, 0x40, 0x20, 0x20, 0x10, 0x10,
0x08, 0x08, 0x04, 0x04, 0x02, 0x02, 0x01, 0x01};

272
src/motif/bmpbuttn.cpp Normal file
View File

@@ -0,0 +1,272 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bmpbuttn.cpp
// Purpose: wxBitmapButton
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "bmpbuttn.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtScreen XTSCREEN
#endif
#include "wx/defs.h"
#include "wx/bmpbuttn.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/PushBG.h>
#include <Xm/PushB.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
// Implemented in button.cpp
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr);
// Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
wxBitmapButton::wxBitmapButton()
{
m_marginX = m_marginY = wxDEFAULT_BUTTON_MARGIN;
m_insensPixmap = (WXPixmap) 0;
}
bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id,
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
m_bmpNormal = m_bmpNormalOriginal = bitmap;
m_bmpSelected = m_bmpSelectedOriginal = bitmap;
Widget parentWidget = (Widget) parent->GetClientWidget();
/*
* Patch Note (important)
* There is no major reason to put a defaultButtonThickness here.
* Not requesting it give the ability to put wxButton with a spacing
* as small as requested. However, if some button become a DefaultButton,
* other buttons are no more aligned -- This is why we set
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
* in the ::SetDefaultButton method.
*/
Widget buttonWidget = XtVaCreateManagedWidget ("button",
// Gadget causes problems for default button operation.
#if wxUSE_GADGETS
xmPushButtonGadgetClass, parentWidget,
#else
xmPushButtonWidgetClass, parentWidget,
#endif
// See comment for wxButton::SetDefault
// XmNdefaultButtonShadowThickness, 1,
XmNrecomputeSize, False,
NULL);
m_mainWidget = (WXWidget) buttonWidget;
ChangeFont(false);
ChangeBackgroundColour ();
DoSetBitmap();
XtAddCallback (buttonWidget,
XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this);
wxSize best = m_bmpNormal.Ok() ? GetBestSize() : wxSize(30, 30);
if( size.x != -1 ) best.x = size.x;
if( size.y != -1 ) best.y = size.y;
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
pos.x, pos.y, best.x, best.y);
return true;
}
wxBitmapButton::~wxBitmapButton()
{
SetBitmapLabel(wxNullBitmap);
if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) GetXDisplay()),
(Pixmap) m_insensPixmap);
}
void wxBitmapButton::SetBitmapLabel(const wxBitmap& bitmap)
{
m_bmpNormalOriginal = bitmap;
m_bmpNormal = bitmap;
DoSetBitmap();
}
void wxBitmapButton::SetBitmapSelected(const wxBitmap& sel)
{
m_bmpSelected = sel;
m_bmpSelectedOriginal = sel;
DoSetBitmap();
};
void wxBitmapButton::SetBitmapFocus(const wxBitmap& focus)
{
m_bmpFocus = focus;
// Not used in Motif
};
void wxBitmapButton::SetBitmapDisabled(const wxBitmap& disabled)
{
m_bmpDisabled = disabled;
m_bmpDisabledOriginal = disabled;
DoSetBitmap();
};
void wxBitmapButton::DoSetBitmap()
{
if (m_bmpNormalOriginal.Ok())
{
Pixmap pixmap = 0;
Pixmap insensPixmap = 0;
Pixmap armPixmap = 0;
// Must re-make the bitmap to have its transparent areas drawn
// in the current widget background colour.
if (m_bmpNormalOriginal.GetMask())
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget,
XmNbackground, &backgroundPixel,
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap =
wxCreateMaskedBitmap(m_bmpNormalOriginal, col);
m_bmpNormal = newBitmap;
m_bitmapCache.SetBitmap( m_bmpNormal );
pixmap = (Pixmap) m_bmpNormal.GetDrawable();
}
else
{
m_bitmapCache.SetBitmap( m_bmpNormal );
pixmap = (Pixmap) m_bitmapCache.GetLabelPixmap(m_mainWidget);
}
if (m_bmpDisabledOriginal.Ok())
{
if (m_bmpDisabledOriginal.GetMask())
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget,
XmNbackground, &backgroundPixel,
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap =
wxCreateMaskedBitmap(m_bmpDisabledOriginal, col);
m_bmpDisabled = newBitmap;
insensPixmap = (Pixmap) m_bmpDisabled.GetDrawable();
}
else
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
}
else
insensPixmap = (Pixmap) m_bitmapCache.GetInsensPixmap(m_mainWidget);
// Now make the bitmap representing the armed state
if (m_bmpSelectedOriginal.Ok())
{
if (m_bmpSelectedOriginal.GetMask())
{
int backgroundPixel;
XtVaGetValues((Widget) m_mainWidget,
XmNarmColor, &backgroundPixel,
NULL);
wxColour col;
col.SetPixel(backgroundPixel);
wxBitmap newBitmap =
wxCreateMaskedBitmap(m_bmpSelectedOriginal, col);
m_bmpSelected = newBitmap;
armPixmap = (Pixmap) m_bmpSelected.GetDrawable();
}
else
armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
}
else
armPixmap = (Pixmap) m_bitmapCache.GetArmPixmap(m_mainWidget);
XtVaSetValues ((Widget) m_mainWidget,
XmNlabelPixmap, pixmap,
XmNlabelInsensitivePixmap, insensPixmap,
XmNarmPixmap, armPixmap,
XmNlabelType, XmPIXMAP,
NULL);
}
else
{
// Null bitmap: must not use current pixmap
// since it is no longer valid.
XtVaSetValues ((Widget) m_mainWidget,
XmNlabelType, XmSTRING,
XmNlabelPixmap, XmUNSPECIFIED_PIXMAP,
XmNlabelInsensitivePixmap, XmUNSPECIFIED_PIXMAP,
XmNarmPixmap, XmUNSPECIFIED_PIXMAP,
NULL);
}
}
void wxBitmapButton::ChangeBackgroundColour()
{
wxDoChangeBackgroundColour(m_mainWidget, m_backgroundColour, true);
// Must reset the bitmaps since the colours have changed.
DoSetBitmap();
}
wxSize wxBitmapButton::DoGetBestSize() const
{
wxSize ret( 30,30 );
if (m_bmpNormal.Ok())
{
int border = (GetWindowStyle() & wxNO_BORDER) ? 4 : 10;
ret.x = m_bmpNormal.GetWidth()+border;
ret.y = m_bmpNormal.GetHeight()+border;
}
return ret;
}

305
src/motif/bmpmotif.cpp Normal file
View File

@@ -0,0 +1,305 @@
/////////////////////////////////////////////////////////////////////////////
// Name: bitmap.cpp
// Purpose: wxBitmap
// Author: Julian Smart, originally in bitmap.cpp
// Modified by:
// Created: 25/03/2003
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "bmpmotif.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtParent XTPARENT
#define XtDisplay XTDISPLAY
#endif
#include "wx/defs.h"
#include "wx/motif/bmpmotif.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
#if wxHAVE_LIB_XPM
#include <X11/xpm.h>
#endif
#include "wx/math.h"
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap );
wxBitmapCache::~wxBitmapCache()
{
if( m_display )
{
Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
if( m_labelPixmap )
XmDestroyPixmap( screen, (Pixmap)m_labelPixmap );
if( m_armPixmap )
XmDestroyPixmap( screen, (Pixmap)m_armPixmap );
if( m_insensPixmap )
XmDestroyPixmap( screen, (Pixmap)m_insensPixmap );
}
if( m_image )
{
XmUninstallImage( (XImage*)m_image );
XtFree( (char*)(XImage*)m_image );
}
}
void wxBitmapCache::SetBitmap( const wxBitmap& bitmap )
{
if( m_bitmap != bitmap )
{
InvalidateCache();
m_bitmap = bitmap;
if( m_image )
{
XmUninstallImage( (XImage*)m_image );
XtFree( (char*)(XImage*)m_image );
m_image = (WXImage*)NULL;
}
}
}
void wxBitmapCache::InvalidateCache()
{
m_recalcPixmaps.label = true;
m_recalcPixmaps.arm = true;
m_recalcPixmaps.insens = true;
}
void wxBitmapCache::SetColoursChanged()
{
InvalidateCache();
}
void wxBitmapCache::CreateImageIfNeeded( WXWidget w )
{
if( m_image )
return;
m_display = w ?
(WXDisplay*)XtDisplay( (Widget)w ) :
(WXDisplay*)wxGetDisplay();
XImage *ximage = XGetImage( (Display*)m_display,
(Drawable)m_bitmap.GetDrawable(),
0, 0,
m_bitmap.GetWidth(), m_bitmap.GetHeight(),
AllPlanes, ZPixmap );
m_image = (WXImage*)ximage;
if( m_image )
{
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)ximage );
XmInstallImage( ximage, tmp );
}
}
WXPixmap wxBitmapCache::GetLabelPixmap( WXWidget w )
{
if( m_labelPixmap && !m_recalcPixmaps.label )
return m_labelPixmap;
CreateImageIfNeeded( w );
Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
if( m_labelPixmap )
XmDestroyPixmap( screen, (Pixmap)m_labelPixmap );
if( !m_image )
return (WXPixmap)NULL;
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)m_image );
Pixel fg, bg;
Widget widget = (Widget)w;
while( XmIsGadget( widget ) )
widget = XtParent( widget );
XtVaGetValues( widget,
XmNbackground, &bg,
XmNforeground, &fg,
NULL );
m_labelPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
m_recalcPixmaps.label = !m_labelPixmap;
return m_labelPixmap;
}
WXPixmap wxBitmapCache::GetArmPixmap( WXWidget w )
{
if( m_armPixmap && !m_recalcPixmaps.arm )
return m_armPixmap;
CreateImageIfNeeded( w );
Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
if( m_armPixmap )
XmDestroyPixmap( screen, (Pixmap)m_armPixmap );
if( !m_image )
return (WXPixmap)NULL;
char tmp[128];
sprintf( tmp, "Im%x", (unsigned int)m_image );
Pixel fg, bg;
Widget widget = (Widget) w;
XtVaGetValues( widget, XmNarmColor, &bg, NULL );
while( XmIsGadget( widget ) )
widget = XtParent( widget );
XtVaGetValues( widget, XmNforeground, &fg, NULL );
m_armPixmap = (WXPixmap)XmGetPixmap( screen, tmp, fg, bg );
m_recalcPixmaps.arm = !m_armPixmap;
return m_armPixmap;
}
WXPixmap wxBitmapCache::GetInsensPixmap( WXWidget w )
{
if( m_insensPixmap && !m_recalcPixmaps.insens )
return m_insensPixmap;
CreateImageIfNeeded( w );
Screen* screen = DefaultScreenOfDisplay( (Display*)m_display );
if( m_insensPixmap )
XmDestroyPixmap( screen, (Pixmap)m_insensPixmap );
if( !m_image )
return (WXPixmap)NULL;
m_insensPixmap =
(WXPixmap)XCreateInsensitivePixmap( (Display*)m_display,
(Pixmap)m_bitmap.GetDrawable() );
m_recalcPixmaps.insens = !m_insensPixmap;
return m_insensPixmap;
}
//////////////////////////////////////////////////////////////////////////////
// Utility function
//////////////////////////////////////////////////////////////////////////////
/****************************************************************************
NAME
XCreateInsensitivePixmap - create a grayed-out copy of a pixmap
SYNOPSIS
Pixmap XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
DESCRIPTION
This function creates a grayed-out copy of the argument pixmap, suitable
for use as a XmLabel's XmNlabelInsensitivePixmap resource.
RETURN VALUES
The return value is the new Pixmap id or zero on error. Errors include
a NULL display argument or an invalid Pixmap argument.
ERRORS
If one of the XLib functions fail, it will produce a X error. The
default X error handler prints a diagnostic and calls exit().
SEE ALSO
XCopyArea(3), XCreateBitmapFromData(3), XCreateGC(3), XCreatePixmap(3),
XFillRectangle(3), exit(2)
AUTHOR
John R Veregge - john@puente.jpl.nasa.gov
Advanced Engineering and Prototyping Group (AEG)
Information Systems Technology Section (395)
Jet Propulsion Lab - Calif Institute of Technology
*****************************************************************************/
Pixmap
XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
{
static char stipple_data[] =
{
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA
};
GC gc;
Pixmap ipixmap, stipple;
unsigned width, height, depth;
Window window; /* These return values */
unsigned border; /* from XGetGeometry() */
int x, y; /* are not needed. */
ipixmap = 0;
if ( NULL == display || 0 == pixmap )
return ipixmap;
if ( 0 == XGetGeometry( display, pixmap, &window, &x, &y,
&width, &height, &border, &depth )
)
return ipixmap; /* BadDrawable: probably an invalid pixmap */
/* Get the stipple pixmap to be used to 'gray-out' the argument pixmap.
*/
stipple = XCreateBitmapFromData( display, pixmap, stipple_data, 16, 16 );
if ( 0 != stipple )
{
gc = XCreateGC( display, pixmap, (XtGCMask)0, (XGCValues*)NULL );
if ( NULL != gc )
{
/* Create an identical copy of the argument pixmap.
*/
ipixmap = XCreatePixmap( display, pixmap, width, height, depth );
if ( 0 != ipixmap )
{
/* Copy the argument pixmap into the new pixmap.
*/
XCopyArea( display, pixmap, ipixmap,
gc, 0, 0, width, height, 0, 0 );
/* Refill the new pixmap using the stipple algorithm/pixmap.
*/
XSetStipple( display, gc, stipple );
XSetFillStyle( display, gc, FillStippled );
XFillRectangle( display, ipixmap, gc, 0, 0, width, height );
}
XFreeGC( display, gc );
}
XFreePixmap( display, stipple );
}
return ipixmap;
}

240
src/motif/button.cpp Normal file
View File

@@ -0,0 +1,240 @@
/////////////////////////////////////////////////////////////////////////////
// Name: button.cpp
// Purpose: wxButton
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "button.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#endif
#include "wx/defs.h"
#include "wx/button.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/PushBG.h>
#include <Xm/PushB.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/stockitem.h"
#include "wx/motif/private.h"
#include "wx/sysopt.h"
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer ptr);
IMPLEMENT_DYNAMIC_CLASS(wxButton, wxControl)
#define MIN_WIDTH 78
#define MIN_LARGE_HEIGHT 30
// Button
bool wxButton::Create(wxWindow *parent, wxWindowID id, const wxString& lbl,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
wxString label(lbl);
if (label.empty() && wxIsStockID(id))
label = wxGetStockLabel(id);
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
wxString label1(wxStripMenuCodes(label));
wxXmString text( label1 );
Widget parentWidget = (Widget) parent->GetClientWidget();
/*
* Patch Note (important)
* There is no major reason to put a defaultButtonThickness here.
* Not requesting it give the ability to put wxButton with a spacing
* as small as requested. However, if some button become a DefaultButton,
* other buttons are no more aligned -- This is why we set
* defaultButtonThickness of ALL buttons belonging to the same wxPanel,
* in the ::SetDefaultButton method.
*/
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("button",
xmPushButtonWidgetClass,
parentWidget,
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
XmNlabelString, text(),
XmNrecomputeSize, False,
// See comment for wxButton::SetDefault
// XmNdefaultButtonShadowThickness, 1,
NULL);
XtAddCallback ((Widget) m_mainWidget,
XmNactivateCallback, (XtCallbackProc) wxButtonCallback,
(XtPointer) this);
wxSize best = GetBestSize();
if( size.x != -1 ) best.x = size.x;
if( size.y != -1 ) best.y = size.y;
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
pos.x, pos.y, best.x, best.y);
ChangeBackgroundColour();
return true;
}
void wxButton::SetDefaultShadowThicknessAndResize()
{
Widget buttonWidget = (Widget)GetMainWidget();
bool managed = XtIsManaged( buttonWidget );
if( managed )
XtUnmanageChild( buttonWidget );
XtVaSetValues( buttonWidget,
XmNdefaultButtonShadowThickness, 1,
NULL );
if( managed )
XtManageChild( buttonWidget );
// this can't currently be done, because user code that calls SetDefault
// will break otherwise
#if 0
wxSize best = GetBestSize(), actual = GetSize();
if( best.x < actual.x ) best.x = actual.x;
if( best.y < actual.y ) best.y = actual.y;
if( best != actual )
SetSize( best );
#endif
}
void wxButton::SetDefault()
{
wxWindow *parent = GetParent();
if ( parent )
parent->SetDefaultItem(this);
// We initially do not set XmNdefaultShadowThickness, to have
// small buttons. Unfortunately, buttons are now mis-aligned. We
// try to correct this now -- setting this ressource to 1 for each
// button in the same row. Because it's very hard to find
// wxButton in the same row, correction is straighforward: we set
// resource for all wxButton in this parent (but not sub panels)
for (wxWindowList::compatibility_iterator node = parent->GetChildren().GetFirst ();
node; node = node->GetNext ())
{
wxWindow *win = node->GetData ();
wxButton *item = wxDynamicCast(win, wxButton);
if (item)
item->SetDefaultShadowThicknessAndResize();
}
XtVaSetValues ((Widget) parent->GetMainWidget(),
XmNdefaultButton, (Widget) GetMainWidget(),
NULL);
}
static inline bool wxMotifLargeButtons()
{
return wxSystemOptions::HasOption("motif.largebuttons")
&& wxSystemOptions::GetOptionInt("motif.largebuttons") != 0;
}
/* static */
wxSize wxButton::GetDefaultSize()
{
// TODO: check font size as in wxMSW ? MB
// Note: this is the button size (text + margin + shadow + defaultBorder)
return wxSize( MIN_WIDTH, MIN_LARGE_HEIGHT );
}
wxSize wxButton::DoGetBestSize() const
{
if( wxMotifLargeButtons() )
return OldGetBestSize();
wxSize best = wxControl::DoGetBestSize();
if( HasFlag( wxBU_EXACTFIT ) )
return best;
else if( best.x < MIN_WIDTH )
best.x = MIN_WIDTH;
return best;
}
wxSize wxButton::OldGetBestSize() const
{
Dimension xmargin, ymargin, highlight, shadow, defThickness;
XtVaGetValues( (Widget)m_mainWidget,
XmNmarginWidth, &xmargin,
XmNmarginHeight, &ymargin,
XmNhighlightThickness, &highlight,
XmNshadowThickness, &shadow,
XmNdefaultButtonShadowThickness, &defThickness,
NULL );
int x = 0; int y = 0;
GetTextExtent( GetLabel(), &x, &y );
int margin = highlight * 2 +
( defThickness ? ( ( shadow + defThickness ) * 4 ) : ( shadow * 2 ) );
wxSize best( x + xmargin * 2 + margin,
y + ymargin * 2 + margin );
// all buttons have at least the standard size unless the user explicitly
// wants them to be of smaller size and used wxBU_EXACTFIT style when
// creating the button
if( !HasFlag( wxBU_EXACTFIT ) )
{
wxSize def = GetDefaultSize();
int margin = highlight * 2 +
( defThickness ? ( shadow * 4 + defThickness * 4 ) : 0 );
def.x += margin;
def.y += margin;
if( def.x > best.x )
best.x = def.x;
if( def.y > best.y )
best.y = def.y;
}
return best;
}
void wxButton::Command (wxCommandEvent & event)
{
ProcessCommand (event);
}
void wxButtonCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
{
if (!wxGetWindowFromTable(w))
// Widget has been deleted!
return;
wxButton *item = (wxButton *) clientData;
wxCommandEvent event (wxEVT_COMMAND_BUTTON_CLICKED, item->GetId());
event.SetEventObject(item);
item->ProcessCommand (event);
}

6
src/motif/cdiag.xbm Normal file
View File

@@ -0,0 +1,6 @@
#define cdiag_width 16
#define cdiag_height 16
static char cdiag_bits[] = {
0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18, 0x18, 0x18, 0x24, 0x24,
0x42, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x42, 0x24, 0x24, 0x18, 0x18,
0x18, 0x18, 0x24, 0x24, 0x42, 0x42, 0x81, 0x81};

249
src/motif/checkbox.cpp Normal file
View File

@@ -0,0 +1,249 @@
/////////////////////////////////////////////////////////////////////////////
// Name: checkbox.cpp
// Purpose: wxCheckBox
// Author: Julian Smart
// Modified by:
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "checkbox.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#endif
#include "wx/defs.h"
#include "wx/checkbox.h"
#include "wx/tglbtn.h"
#include "wx/utils.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Label.h>
#include <Xm/LabelG.h>
#include <Xm/ToggleB.h>
#include <Xm/ToggleBG.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
// define symbols that are missing in old versions of Motif.
#if (XmVersion < 2000)
#define XmNtoggleMode 0
#define XmTOGGLE_INDETERMINATE 1
#define XmTOGGLE_BOOLEAN 2
#define XmUNSET 3
#define XmSET 4
#define XmINDETERMINATE 5
#endif
#include "wx/motif/private.h"
void wxCheckBoxCallback (Widget w, XtPointer clientData,
XtPointer ptr);
IMPLEMENT_DYNAMIC_CLASS(wxCheckBox, wxControl)
// Single check box item
bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
const wxPoint& pos,
const wxSize& size, long style,
const wxValidator& validator,
const wxString& name)
{
if( !wxControl::CreateControl( parent, id, pos, size, style, validator,
name ) )
return false;
wxString label1(wxStripMenuCodes(label));
wxXmString text( label1 );
Widget parentWidget = (Widget) parent->GetClientWidget();
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
xmToggleButtonWidgetClass, parentWidget,
wxFont::GetFontTag(), m_font.GetFontTypeC(XtDisplay(parentWidget)),
XmNlabelString, text(),
XmNrecomputeSize, False,
// XmNindicatorOn, XmINDICATOR_CHECK_BOX,
// XmNfillOnSelect, False,
XmNtoggleMode, Is3State() ? XmTOGGLE_INDETERMINATE : XmTOGGLE_BOOLEAN,
NULL);
XtAddCallback( (Widget)m_mainWidget,
XmNvalueChangedCallback, (XtCallbackProc)wxCheckBoxCallback,
(XtPointer)this );
XmToggleButtonSetState ((Widget) m_mainWidget, False, True);
AttachWidget( parent, m_mainWidget, (WXWidget)NULL,
pos.x, pos.y, size.x, size.y );
ChangeBackgroundColour();
return true;
}
void wxCheckBox::SetValue(bool val)
{
if (val)
{
Set3StateValue(wxCHK_CHECKED);
}
else
{
Set3StateValue(wxCHK_UNCHECKED);
}
}
bool wxCheckBox::GetValue() const
{
return (Get3StateValue() != 0);
}
void wxCheckBox::Command (wxCommandEvent & event)
{
int state = event.GetInt();
wxCHECK_RET( (state == wxCHK_UNCHECKED) || (state == wxCHK_CHECKED)
|| (state == wxCHK_UNDETERMINED),
wxT("event.GetInt() returned an invalid checkbox state") );
Set3StateValue((wxCheckBoxState) state);
ProcessCommand(event);
}
void wxCheckBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
XtPointer WXUNUSED(ptr))
{
wxCheckBox *item = (wxCheckBox *) clientData;
if (item->InSetValue())
return;
wxCheckBoxState state = item->Get3StateValue();
if( !item->Is3rdStateAllowedForUser() && state == wxCHK_UNDETERMINED )
{
state = wxCHK_UNCHECKED;
item->Set3StateValue( state );
}
wxCommandEvent event( item->m_evtType, item->GetId() );
event.SetInt( (int)state );
event.SetEventObject( item );
item->ProcessCommand( event );
}
void wxCheckBox::ChangeBackgroundColour()
{
wxComputeColours (XtDisplay((Widget) m_mainWidget), & m_backgroundColour,
(wxColour*) NULL);
XtVaSetValues ((Widget) m_mainWidget,
XmNbackground, g_itemColors[wxBACK_INDEX].pixel,
XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel,
XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel,
XmNforeground, g_itemColors[wxFORE_INDEX].pixel,
NULL);
int selectPixel = wxBLACK->AllocColour(XtDisplay((Widget)m_mainWidget));
// Better to have the checkbox selection in black, or it's
// hard to determine what state it is in.
XtVaSetValues ((Widget) m_mainWidget,
XmNselectColor, selectPixel,
NULL);
}
void wxCheckBox::DoSet3StateValue(wxCheckBoxState state)
{
m_inSetValue = true;
unsigned char value;
switch (state)
{
case wxCHK_UNCHECKED: value = XmUNSET; break;
case wxCHK_CHECKED: value = XmSET; break;
case wxCHK_UNDETERMINED: value = XmINDETERMINATE; break;
default: wxASSERT(0); return;
}
XtVaSetValues( (Widget) m_mainWidget,
XmNset, value,
NULL );
m_inSetValue = false;
}
wxCheckBoxState wxCheckBox::DoGet3StateValue() const
{
unsigned char value = 0;
XtVaGetValues( (Widget) m_mainWidget,
XmNset, &value,
NULL );
switch (value)
{
case XmUNSET: return wxCHK_UNCHECKED;
case XmSET: return wxCHK_CHECKED;
case XmINDETERMINATE: return wxCHK_UNDETERMINED;
}
// impossible...
return wxCHK_UNDETERMINED;
}
///////////////////////////////////////////////////////////////////////////////
// wxToggleButton
///////////////////////////////////////////////////////////////////////////////
#if wxUSE_TOGGLEBTN
DEFINE_EVENT_TYPE(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED)
IMPLEMENT_DYNAMIC_CLASS(wxToggleButton, wxControl)
bool wxToggleButton::Create( wxWindow* parent, wxWindowID id,
const wxString& label,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& val,
const wxString &name )
{
if( !wxCheckBox::Create( parent, id, label, pos, size, style, val, name ) )
return false;
XtVaSetValues( (Widget)m_mainWidget,
XmNindicatorSize, 0,
#if XmVersion >= 2000
XmNindicatorOn, XmINDICATOR_NONE,
#else
XmNindicatorOn, False,
#endif
XmNfillOnSelect, False,
XmNshadowThickness, 2,
XmNalignment, XmALIGNMENT_CENTER,
XmNmarginLeft, 0,
XmNmarginRight, 0,
NULL );
// set it again, because the XtVaSetValue above resets it
if( size.x != -1 || size.y != -1 )
SetSize( size );
return true;
}
#endif // wxUSE_TOGGLEBUTTON

199
src/motif/checklst.cpp Normal file
View File

@@ -0,0 +1,199 @@
///////////////////////////////////////////////////////////////////////////////
// Name: checklst.cpp
// Purpose: implementation of wxCheckListBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// headers & declarations
// ============================================================================
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "checklst.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/defs.h"
#include "wx/checklst.h"
#include "wx/arrstr.h"
// ============================================================================
// implementation
// ============================================================================
IMPLEMENT_DYNAMIC_CLASS(wxCheckListBox, wxListBox)
// ----------------------------------------------------------------------------
// implementation of wxCheckListBox class
// ----------------------------------------------------------------------------
// define event table
// ------------------
BEGIN_EVENT_TABLE(wxCheckListBox, wxListBox)
END_EVENT_TABLE()
// control creation
// ----------------
static const wxString prefixChecked = "[x] ";
static const wxString prefixUnchecked = "[ ] ";
static const char checkChar = 'x', uncheckChar = ' ';
static inline const wxString& Prefix(bool checked)
{ return checked ? prefixChecked : prefixUnchecked; }
static inline bool IsChecked(const wxString& s)
{ wxASSERT(s.length() >=4); return s[1] == checkChar; }
static void CopyStringsAddingPrefix(const wxArrayString& orig,
wxArrayString& copy)
{
copy.Clear();
for(size_t i = 0; i < orig.GetCount(); ++i )
copy.Add( Prefix(false) + orig[i] );
}
// def ctor: use Create() to really create the control
wxCheckListBox::wxCheckListBox() : wxCheckListBoxBase()
{
}
// ctor which creates the associated control
wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
int nStrings, const wxString choices[],
long style, const wxValidator& val,
const wxString& name)
: wxCheckListBoxBase()
{
Create(parent, id, pos, size, nStrings, choices,
style, val, name);
}
wxCheckListBox::wxCheckListBox(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size,
const wxArrayString& choices,
long style, const wxValidator& val,
const wxString& name)
: wxCheckListBoxBase()
{
Create(parent, id, pos, size, choices,
style, val, name);
}
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
// wxListBox::Create calls set, which adds the prefixes
bool retVal = wxListBox::Create(parent, id, pos, size, n, choices,
style, validator, name);
return retVal;
}
bool wxCheckListBox::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator,
const wxString& name)
{
// wxListBox::Create calls set, which adds the prefixes
bool retVal = wxListBox::Create(parent, id, pos, size, choices,
style, validator, name);
return retVal;
}
// check items
// -----------
bool wxCheckListBox::IsChecked(size_t uiIndex) const
{
return ::IsChecked(wxListBox::GetString(uiIndex));
}
void wxCheckListBox::Check(size_t uiIndex, bool bCheck)
{
wxString label = wxListBox::GetString(uiIndex);
if(::IsChecked(label) == bCheck) return;
label[1u] = bCheck ? checkChar : uncheckChar;
wxListBox::SetString(uiIndex, label);
}
void wxCheckListBox::DoToggleItem( int n, int x )
{
if( x < 23 )
{
wxString label = wxListBox::GetString(n);
label[1u] = (!::IsChecked(label)) ? checkChar : uncheckChar;
wxListBox::SetString(n, label);
wxCommandEvent event(wxEVT_COMMAND_CHECKLISTBOX_TOGGLED, GetId());
if( HasClientObjectData() )
event.SetClientObject( GetClientObject(n) );
else if( HasClientUntypedData() )
event.SetClientData( GetClientData(n) );
event.SetInt(n);
event.SetExtraLong(true);
event.SetEventObject(this);
event.SetString( GetString( n ) );
GetEventHandler()->ProcessEvent(event);
}
}
int wxCheckListBox::DoAppend(const wxString& item)
{
return wxListBox::DoAppend( Prefix(false) + item );
}
int wxCheckListBox::FindString(const wxString& s) const
{
int n1 = wxListBox::FindString(Prefix(false) + s);
int n2 = wxListBox::FindString(Prefix(true) + s);
int min = wxMin(n1, n2), max = wxMax(n1, n2);
// why this works:
// n1 == -1, n2 == -1 => return -1 OK
// n1 != -1 || n2 != -1 => min == -1 => return the other one
// both != -1 => return the first one.
if( min == -1 ) return max;
return min;
}
void wxCheckListBox::SetString(int n, const wxString& s)
{
wxListBox::SetString( n, Prefix(IsChecked(n)) + s );
}
wxString wxCheckListBox::GetString(int n) const
{
return wxListBox::GetString(n).substr(4);
}
void wxCheckListBox::DoInsertItems(const wxArrayString& items, int pos)
{
wxArrayString copy;
CopyStringsAddingPrefix(items, copy);
wxListBox::DoInsertItems(copy, pos);
}
void wxCheckListBox::DoSetItems(const wxArrayString& items, void **clientData)
{
wxArrayString copy;
CopyStringsAddingPrefix(items, copy);
wxListBox::DoSetItems(copy, clientData);
}

566
src/motif/choice.cpp Normal file
View File

@@ -0,0 +1,566 @@
/////////////////////////////////////////////////////////////////////////////
// Name: choice.cpp
// Purpose: wxChoice
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "choice.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#define XtParent XTPARENT
#endif
#include "wx/defs.h"
#if wxUSE_CHOICE
#include "wx/choice.h"
#include "wx/utils.h"
#include "wx/arrstr.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <Xm/PushBG.h>
#include <Xm/PushB.h>
#include <Xm/RowColumn.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
#define WIDTH_OVERHEAD 48
#define WIDTH_OVERHEAD_SUBTRACT 40
#define HEIGHT_OVERHEAD 15
IMPLEMENT_DYNAMIC_CLASS(wxChoice, wxControl)
void wxChoiceCallback (Widget w, XtPointer clientData,
XtPointer ptr);
wxChoice::wxChoice()
{
Init();
}
void wxChoice::Init()
{
m_noStrings = 0;
m_buttonWidget = (WXWidget) 0;
m_menuWidget = (WXWidget) 0;
m_formWidget = (WXWidget) 0;
}
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
if ( !CreateControl(parent, id, pos, size, style, validator, name) )
return false;
Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget(name.c_str(),
xmRowColumnWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
XmNresizeWidth, False,
XmNresizeHeight, False,
NULL);
XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL);
/*
* Create the popup menu
*/
m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget,
"choiceMenu", NULL, 0);
if (n > 0)
{
int i;
for (i = 0; i < n; i++)
Append (choices[i]);
}
/*
* Create button
*/
Arg args[10];
Cardinal argcnt = 0;
XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget); ++argcnt;
XtSetArg (args[argcnt], XmNmarginWidth, 0); ++argcnt;
XtSetArg (args[argcnt], XmNmarginHeight, 0); ++argcnt;
XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT); ++argcnt;
m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget,
"choiceButton",
args, argcnt);
m_mainWidget = m_buttonWidget;
XtManageChild ((Widget) m_buttonWidget);
// New code from Roland Haenel (roland_haenel@ac.cybercity.de)
// Some time ago, I reported a problem with wxChoice-items under
// Linux and Motif 2.0 (they caused sporadic GPFs). Now it seems
// that I have found the code responsible for this behaviour.
#if XmVersion >= 1002
#if XmVersion < 2000
// JACS, 24/1/99: this seems to cause a malloc crash later on, e.g.
// in controls sample.
//
// Widget optionLabel = XmOptionLabelGadget ((Widget) m_buttonWidget);
// XtUnmanageChild (optionLabel);
#endif
#endif
wxSize bestSize = GetBestSize();
if( size.x > 0 ) bestSize.x = size.x;
if( size.y > 0 ) bestSize.y = size.y;
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
ChangeFont(false);
ChangeBackgroundColour();
AttachWidget (parent, m_buttonWidget, m_formWidget,
pos.x, pos.y, bestSize.x, bestSize.y);
return true;
}
bool wxChoice::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator,
const wxString& name)
{
wxCArrayString chs(choices);
return Create(parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
style, validator, name);
}
wxChoice::~wxChoice()
{
// For some reason destroying the menuWidget
// can cause crashes on some machines. It will
// be deleted implicitly by deleting the parent form
// anyway.
// XtDestroyWidget (menuWidget);
if (GetMainWidget())
{
DetachWidget(GetMainWidget()); // Removes event handlers
DetachWidget(m_formWidget);
XtDestroyWidget((Widget) m_formWidget);
m_formWidget = (WXWidget) 0;
// Presumably the other widgets have been deleted now, via the form
m_mainWidget = (WXWidget) 0;
m_buttonWidget = (WXWidget) 0;
}
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
}
int wxChoice::DoAppend(const wxString& item)
{
Widget w = XtVaCreateManagedWidget (wxStripMenuCodes(item),
#if USE_GADGETS
xmPushButtonGadgetClass, (Widget) m_menuWidget,
#else
xmPushButtonWidgetClass, (Widget) m_menuWidget,
#endif
NULL);
wxDoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
if( m_font.Ok() )
wxDoChangeFont( w, m_font );
m_widgetArray.Add(w);
char mnem = wxFindMnemonic (item);
if (mnem != 0)
XtVaSetValues (w, XmNmnemonic, mnem, NULL);
XtAddCallback (w, XmNactivateCallback,
(XtCallbackProc) wxChoiceCallback,
(XtPointer) this);
if (m_noStrings == 0 && m_buttonWidget)
{
XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
wxXmString text( item );
XtVaSetValues (label,
XmNlabelString, text(),
NULL);
}
m_stringList.Add(item);
m_noStrings ++;
return GetCount() - 1;
}
int wxChoice::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(false, -1, wxT("insert not implemented"));
// wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
// if (pos == GetCount()) return DoAppend(item);
}
void wxChoice::Delete(int n)
{
Widget w = (Widget)m_widgetArray[n];
XtRemoveCallback(w, XmNactivateCallback, (XtCallbackProc)wxChoiceCallback,
(XtPointer)this);
m_stringList.Erase(m_stringList.Item(n));
m_widgetArray.RemoveAt(size_t(n));
m_clientDataDict.Delete(n, HasClientObjectData());
XtDestroyWidget(w);
m_noStrings --;
}
void wxChoice::Clear()
{
m_stringList.Clear ();
size_t i;
for (i = 0; i < m_noStrings; i++)
{
XtRemoveCallback((Widget) m_widgetArray[i],
XmNactivateCallback, (XtCallbackProc)wxChoiceCallback,
(XtPointer)this);
XtUnmanageChild ((Widget) m_widgetArray[i]);
XtDestroyWidget ((Widget) m_widgetArray[i]);
}
m_widgetArray.Clear();
if (m_buttonWidget)
XtVaSetValues ((Widget) m_buttonWidget,
XmNmenuHistory, (Widget) NULL,
NULL);
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
m_noStrings = 0;
}
int wxChoice::GetSelection() const
{
XmString text;
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
XtVaGetValues (label,
XmNlabelString, &text,
NULL);
wxXmString freeMe(text);
wxString s = wxXmStringToString( text );
if (!s.IsEmpty())
{
int i = 0;
for (wxStringList::compatibility_iterator node = m_stringList.GetFirst ();
node; node = node->GetNext ())
{
if (wxStrcmp(node->GetData(), s.c_str()) == 0)
{
return i;
}
else
i++;
} // for()
return -1;
}
return -1;
}
void wxChoice::SetSelection(int n)
{
m_inSetValue = true;
wxStringList::compatibility_iterator node = m_stringList.Item(n);
if (node)
{
#if 0
Dimension selectionWidth, selectionHeight;
#endif
wxXmString text( node->GetData() );
// MBN: this seems silly, at best, and causes wxChoices to be clipped:
// will remove "soon"
#if 0
XtVaGetValues ((Widget) m_widgetArray[n],
XmNwidth, &selectionWidth,
XmNheight, &selectionHeight,
NULL);
#endif
Widget label = XmOptionButtonGadget ((Widget) m_buttonWidget);
XtVaSetValues (label,
XmNlabelString, text(),
NULL);
#if 0
XtVaSetValues ((Widget) m_buttonWidget,
XmNwidth, selectionWidth, XmNheight, selectionHeight,
XmNmenuHistory, (Widget) m_widgetArray[n], NULL);
#endif
}
m_inSetValue = false;
}
int wxChoice::FindString(const wxString& s) const
{
int i = 0;
for (wxStringList::compatibility_iterator node = m_stringList.GetFirst();
node; node = node->GetNext ())
{
if (s == node->GetData())
return i;
i++;
}
return wxNOT_FOUND;
}
wxString wxChoice::GetString(int n) const
{
wxStringList::compatibility_iterator node = m_stringList.Item(n);
if (node)
return node->GetData();
else
return wxEmptyString;
}
void wxChoice::SetColumns(int n)
{
if (n<1) n = 1 ;
short numColumns = n ;
Arg args[3];
XtSetArg(args[0], XmNnumColumns, numColumns);
XtSetArg(args[1], XmNpacking, XmPACK_COLUMN);
XtSetValues((Widget) m_menuWidget,args,2) ;
}
int wxChoice::GetColumns(void) const
{
short numColumns ;
XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
return numColumns ;
}
void wxChoice::SetFocus()
{
XmProcessTraversal(XtParent((Widget)m_mainWidget), XmTRAVERSE_CURRENT);
}
void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
bool managed = XtIsManaged((Widget) m_formWidget);
if (managed)
XtUnmanageChild ((Widget) m_formWidget);
int actualWidth = width - WIDTH_OVERHEAD_SUBTRACT,
actualHeight = height - HEIGHT_OVERHEAD;
if (width > -1)
{
size_t i;
for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetArray[i],
XmNwidth, actualWidth,
NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNwidth, actualWidth,
NULL);
}
if (height > -1)
{
#if 0
size_t i;
for (i = 0; i < m_noStrings; i++)
XtVaSetValues ((Widget) m_widgetArray[i],
XmNheight, actualHeight,
NULL);
#endif
XtVaSetValues ((Widget) m_buttonWidget, XmNheight, actualHeight,
NULL);
}
if (managed)
XtManageChild ((Widget) m_formWidget);
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
wxControl::DoSetSize (x, y, width, height, sizeFlags);
}
void wxChoice::Command(wxCommandEvent & event)
{
SetSelection (event.GetInt());
ProcessCommand (event);
}
void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
{
wxChoice *item = (wxChoice *) clientData;
if (item)
{
if (item->InSetValue())
return;
int n = item->GetWidgets().Index(w);
if (n != wxNOT_FOUND)
{
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, item->GetId());
event.SetEventObject(item);
event.SetInt(n);
event.SetString( item->GetStrings().Item(n)->GetData() );
if ( item->HasClientObjectData() )
event.SetClientObject( item->GetClientObject(n) );
else if ( item->HasClientUntypedData() )
event.SetClientData( item->GetClientData(n) );
item->ProcessCommand (event);
}
}
}
void wxChoice::ChangeFont(bool keepOriginalSize)
{
// Note that this causes the widget to be resized back
// to its original size! We therefore have to set the size
// back again. TODO: a better way in Motif?
if (m_font.Ok())
{
Display* dpy = XtDisplay((Widget) m_mainWidget);
int width, height, width1, height1;
GetSize(& width, & height);
WXString fontTag = wxFont::GetFontTag();
XtVaSetValues ((Widget) m_formWidget,
fontTag, m_font.GetFontTypeC(dpy),
NULL);
XtVaSetValues ((Widget) m_buttonWidget,
fontTag, m_font.GetFontTypeC(dpy),
NULL);
for( size_t i = 0; i < m_noStrings; ++i )
XtVaSetValues( (Widget)m_widgetArray[i],
fontTag, m_font.GetFontTypeC(dpy),
NULL );
GetSize(& width1, & height1);
if (keepOriginalSize && (width != width1 || height != height1))
{
SetSize(wxDefaultCoord, wxDefaultCoord, width, height);
}
}
}
void wxChoice::ChangeBackgroundColour()
{
wxDoChangeBackgroundColour(m_formWidget, m_backgroundColour);
wxDoChangeBackgroundColour(m_buttonWidget, m_backgroundColour);
wxDoChangeBackgroundColour(m_menuWidget, m_backgroundColour);
size_t i;
for (i = 0; i < m_noStrings; i++)
wxDoChangeBackgroundColour(m_widgetArray[i], m_backgroundColour);
}
void wxChoice::ChangeForegroundColour()
{
wxDoChangeForegroundColour(m_formWidget, m_foregroundColour);
wxDoChangeForegroundColour(m_buttonWidget, m_foregroundColour);
wxDoChangeForegroundColour(m_menuWidget, m_foregroundColour);
size_t i;
for (i = 0; i < m_noStrings; i++)
wxDoChangeForegroundColour(m_widgetArray[i], m_foregroundColour);
}
int wxChoice::GetCount() const
{
return m_noStrings;
}
void wxChoice::DoSetItemClientData(int n, void* clientData)
{
m_clientDataDict.Set(n, (wxClientData*)clientData, false);
}
void* wxChoice::DoGetItemClientData(int n) const
{
return (void*)m_clientDataDict.Get(n);
}
void wxChoice::DoSetItemClientObject(int n, wxClientData* clientData)
{
// don't delete, wxItemContainer does that for us
m_clientDataDict.Set(n, clientData, false);
}
wxClientData* wxChoice::DoGetItemClientObject(int n) const
{
return m_clientDataDict.Get(n);
}
void wxChoice::SetString(int WXUNUSED(n), const wxString& WXUNUSED(s))
{
wxFAIL_MSG( wxT("wxChoice::SetString not implemented") );
}
wxSize wxChoice::GetItemsSize() const
{
int x, y, mx = 0, my = 0;
// get my
GetTextExtent( "|", &x, &my );
wxStringList::compatibility_iterator curr = m_stringList.GetFirst();
while( curr )
{
GetTextExtent( curr->GetData(), &x, &y );
mx = wxMax( mx, x );
my = wxMax( my, y );
curr = curr->GetNext();
}
return wxSize( mx, my );
}
wxSize wxChoice::DoGetBestSize() const
{
wxSize items = GetItemsSize();
// FIXME arbitrary constants
return wxSize( ( items.x ? items.x + WIDTH_OVERHEAD : 120 ),
items.y + HEIGHT_OVERHEAD );
}
#endif // wxUSE_CHOICE

486
src/motif/clipbrd.cpp Normal file
View File

@@ -0,0 +1,486 @@
/////////////////////////////////////////////////////////////////////////////
// Name: clipbrd.cpp
// Purpose: Clipboard functionality
// Author: Julian Smart
// Modified by: Mattia Barbon (added support for generic wxDataObjects)
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation
#pragma implementation "clipbrd.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#include "wx/vms_x_fix.h"
#define XtWindow XTWINDOW
#define XtScreen XTSCREEN
#define XtParent XTPARENT
#define XtIsRealized XTISREALIZED
#define XtDisplay XTDISPLAY
#endif
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/app.h"
#include "wx/bitmap.h"
#include "wx/utils.h"
#include "wx/clipbrd.h"
#include "wx/dataobj.h"
#include "wx/ptr_scpd.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <Xm/CutPaste.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
bool wxOpenClipboard()
{
return wxTheClipboard->Open();
}
bool wxCloseClipboard()
{
wxTheClipboard->Close();
return true;
}
bool wxEmptyClipboard()
{
wxTheClipboard->Clear();
return true;
}
bool wxClipboardOpen()
{
return wxTheClipboard->IsOpened();
}
bool wxIsClipboardFormatAvailable(wxDataFormat dataFormat)
{
return wxTheClipboard->IsSupported( dataFormat );
}
bool wxSetClipboardData(wxDataFormat dataFormat, wxObject *obj,
int WXUNUSED(width), int WXUNUSED(height))
{
wxDataObject* dobj = NULL;
if( dataFormat == wxDF_TEXT )
{
wxChar* data = (wxChar*)obj;
dobj = new wxTextDataObject( data );
}
else if( dataFormat = wxDF_BITMAP )
{
wxBitmap* data = (wxBitmap*)obj;
dobj = new wxBitmapDataObject( *data );
}
if( !dobj )
return false;
return wxTheClipboard->SetData( dobj );
}
wxObject *wxGetClipboardData(wxDataFormat dataFormat, long *len)
{
wxDataObject* dobj = NULL;
wxTextDataObject* tobj = NULL;
wxBitmapDataObject* bobj = NULL;
if( dataFormat == wxDF_TEXT )
{
dobj = tobj = new wxTextDataObject;
}
else if( dataFormat = wxDF_BITMAP )
{
dobj = bobj = new wxBitmapDataObject;
}
if( !dobj || !wxTheClipboard->GetData( *dobj ) )
return NULL;
if( tobj )
{
wxString text = tobj->GetText();
wxChar* buf = new wxChar[text.length() + 1];
if( len ) *len = text.length();
return (wxObject*)wxStrcpy( buf, text.c_str() );
}
else if( bobj )
{
if( len ) *len = 0;
return new wxBitmap( bobj->GetBitmap() );
}
return NULL; // just in case...
}
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 wxDF_INVALID;
}
bool wxGetClipboardFormatName(wxDataFormat dataFormat, char *formatName,
int maxCount)
{
wxStrncpy( formatName, dataFormat.GetId().c_str(), maxCount );
return true;
}
//-----------------------------------------------------------------------------
// wxClipboard
//-----------------------------------------------------------------------------
struct wxDataIdToDataObject
{
wxDataIdToDataObject( wxDataObject* o, long d, size_t s )
: object( o ), size( s ), dataId( d ) { }
wxDataObject* object;
size_t size;
long dataId;
};
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxDataObjectList);
WX_DEFINE_LIST(wxDataIdToDataObjectList);
#if wxCHECK_LESSTIF()
static void wxClipboardCallback( Widget widget, int* data_id,
int* priv, int* reason );
#else
static void wxClipboardCallback( Widget widget, long* data_id,
long* priv, int* reason );
#endif
IMPLEMENT_DYNAMIC_CLASS(wxClipboard,wxObject)
wxClipboard::wxClipboard()
{
m_open = false;
}
wxClipboard::~wxClipboard()
{
Clear();
}
void wxClipboard::Clear()
{
wxDataObjectList::compatibility_iterator node = m_data.GetFirst();
while (node)
{
delete node->GetData();
node = node->GetNext();
}
m_data.Clear();
for( wxDataIdToDataObjectList::compatibility_iterator node2 = m_idToObject.GetFirst();
node2; node2 = node2->GetNext() )
{
delete node2->GetData();
}
m_idToObject.Clear();
}
bool wxClipboard::Open()
{
wxCHECK_MSG( !m_open, false, "clipboard already open" );
m_open = true;
return true;
}
bool wxClipboard::SetData( wxDataObject *data )
{
wxCHECK_MSG( data, false, "data is invalid" );
wxCHECK_MSG( m_open, false, "clipboard not open" );
Clear();
return AddData( data );
}
wxDECLARE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
wxDEFINE_SCOPED_ARRAY( wxDataFormat, wxDataFormatScopedArray );
#if wxCHECK_LESSTIF()
void wxClipboardCallback( Widget xwidget, int* data_id,
int* priv, int* reason )
#else
void wxClipboardCallback( Widget xwidget, long* data_id,
long* priv, int* reason )
#endif
{
Display* xdisplay = XtDisplay( xwidget );
Window xwindow = XtWindow( xwidget );
wxDataObject* dobj = NULL;
size_t size = 0;
for( wxDataIdToDataObjectList::compatibility_iterator node2 =
wxTheClipboard->m_idToObject.GetFirst();
node2; node2 = node2->GetNext() )
{
wxDataIdToDataObject* dido = node2->GetData();
if( dido->dataId == *data_id )
{
dobj = dido->object;
size = dido->size;
break;
}
}
if( !dobj ) return;
wxCharBuffer buffer(size);
size_t count = dobj->GetFormatCount( wxDataObject::Get );
wxDataFormatScopedArray dfarr( new wxDataFormat[count] );
dobj->GetAllFormats( dfarr.get(), wxDataObject::Get );
if( !dobj->GetDataHere( dfarr[*priv], buffer.data() ) )
return;
while( XmClipboardCopyByName( xdisplay, xwindow, *data_id,
buffer.data(), size, 0 )
== XmClipboardLocked );
}
bool wxClipboard::AddData( wxDataObject *data )
{
wxCHECK_MSG( data, false, "data is invalid" );
wxCHECK_MSG( m_open, false, "clipboard not open" );
m_data.Append( data );
Display* xdisplay = wxGlobalDisplay();
Widget xwidget = (Widget)wxTheApp->GetTopLevelRealizedWidget();
Window xwindow = XtWindow( xwidget );
wxXmString label( wxTheApp->GetAppName() );
Time timestamp = XtLastTimestampProcessed( xdisplay );
long itemId;
int retval;
while( ( retval = XmClipboardStartCopy( xdisplay, xwindow, label(),
timestamp, xwidget,
wxClipboardCallback,
&itemId ) )
== XmClipboardLocked );
if( retval != XmClipboardSuccess )
return false;
size_t count = data->GetFormatCount( wxDataObject::Get );
wxDataFormatScopedArray dfarr( new wxDataFormat[count] );
data->GetAllFormats( dfarr.get(), wxDataObject::Get );
for( size_t i = 0; i < count; ++i )
{
size_t size = data->GetDataSize( dfarr[i] );
long data_id;
wxString id = dfarr[i].GetId();
while( ( retval = XmClipboardCopy( xdisplay, xwindow, itemId,
wxConstCast(id.c_str(), char),
NULL, size, i, &data_id ) )
== XmClipboardLocked );
m_idToObject.Append( new wxDataIdToDataObject( data, data_id, size ) );
}
while( XmClipboardEndCopy( xdisplay, xwindow, itemId )
== XmClipboardLocked );
return true;
}
void wxClipboard::Close()
{
wxCHECK_RET( m_open, "clipboard not open" );
m_open = false;
}
bool wxClipboard::IsSupported(const wxDataFormat& format)
{
Display* xdisplay = wxGlobalDisplay();
Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelRealizedWidget() );
bool isSupported = false;
int retval, count;
unsigned long max_name_length;
wxString id = format.GetId();
while( ( retval = XmClipboardLock( xdisplay, xwindow ) )
== XmClipboardLocked );
if( retval != XmClipboardSuccess )
return false;
if( XmClipboardInquireCount( xdisplay, xwindow, &count, &max_name_length )
== XmClipboardSuccess )
{
wxCharBuffer buf( max_name_length + 1 );
unsigned long copied;
for( int i = 0; i < count; ++i )
{
if( XmClipboardInquireFormat( xdisplay, xwindow, i + 1,
(XtPointer)buf.data(),
max_name_length, &copied )
!= XmClipboardSuccess )
continue;
buf.data()[copied] = '\0';
if( buf == id )
{
isSupported = true;
break;
}
}
}
XmClipboardUnlock( xdisplay, xwindow, False );
return isSupported;
}
class wxClipboardEndRetrieve
{
public:
wxClipboardEndRetrieve( Display* display, Window window )
: m_display( display ), m_window( window ) { }
~wxClipboardEndRetrieve()
{
while( XmClipboardEndRetrieve( m_display, m_window )
== XmClipboardLocked );
}
private:
Display* m_display;
Window m_window;
};
bool wxClipboard::GetData( wxDataObject& data )
{
wxCHECK_MSG( m_open, false, "clipboard not open" );
Display* xdisplay = wxGlobalDisplay();
Window xwindow = XtWindow( (Widget)wxTheApp->GetTopLevelRealizedWidget() );
Time timestamp = XtLastTimestampProcessed( xdisplay );
wxDataFormat chosenFormat;
int retval;
///////////////////////////////////////////////////////////////////////////
// determine if the cliboard holds any format we like
///////////////////////////////////////////////////////////////////////////
while( ( retval = XmClipboardStartRetrieve( xdisplay, xwindow,
timestamp ) )
== XmClipboardLocked );
if( retval != XmClipboardSuccess )
return false;
wxClipboardEndRetrieve endRetrieve( xdisplay, xwindow );
int count;
unsigned long max_name_length;
size_t dfcount = data.GetFormatCount( wxDataObject::Set );
wxDataFormatScopedArray dfarr( new wxDataFormat[dfcount] );
data.GetAllFormats( dfarr.get(), wxDataObject::Set );
if( XmClipboardInquireCount( xdisplay, xwindow, &count, &max_name_length )
== XmClipboardSuccess )
{
wxCharBuffer buf( max_name_length + 1 );
unsigned long copied;
for( int i = 0; i < count; ++i )
{
if( XmClipboardInquireFormat( xdisplay, xwindow, i + 1,
(XtPointer)buf.data(),
max_name_length, &copied )
!= XmClipboardSuccess )
continue;
buf.data()[copied] = '\0';
// try preferred format
if( buf == data.GetPreferredFormat( wxDataObject::Set ).GetId() )
{
chosenFormat = data.GetPreferredFormat( wxDataObject::Set );
break;
}
// try all other formats
for( size_t i = 0; i < dfcount; ++i )
{
if( buf == dfarr[i].GetId() )
chosenFormat = dfarr[i];
}
}
}
if( chosenFormat == wxDF_INVALID )
return false;
///////////////////////////////////////////////////////////////////////////
// now retrieve the data
///////////////////////////////////////////////////////////////////////////
unsigned long length, dummy1;
long dummy2;
wxString id = chosenFormat.GetId();
while( ( retval = XmClipboardInquireLength( xdisplay, xwindow,
wxConstCast(id.c_str(), char),
&length ) )
== XmClipboardLocked );
if( retval != XmClipboardSuccess )
return false;
wxCharBuffer buf(length);
while( ( retval = XmClipboardRetrieve( xdisplay, xwindow,
wxConstCast(id.c_str(), char),
(XtPointer)buf.data(),
length, &dummy1, &dummy2 ) )
== XmClipboardLocked );
if( retval != XmClipboardSuccess )
return false;
if( !data.SetData( chosenFormat, length, buf.data() ) )
return false;
return true;
}
#endif // wxUSE_CLIPBOARD

227
src/motif/colour.cpp Normal file
View File

@@ -0,0 +1,227 @@
/////////////////////////////////////////////////////////////////////////////
// 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.
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "colour.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#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
void wxColour::Init()
{
m_isInit = false;
m_red =
m_blue =
m_green = 0;
m_pixel = -1;
}
wxColour::wxColour()
{
Init();
}
wxColour::wxColour(const wxColour& col)
{
*this = col;
}
wxColour& wxColour::operator =(const wxColour& col)
{
m_red = col.m_red;
m_green = col.m_green;
m_blue = col.m_blue;
m_isInit = col.m_isInit;
m_pixel = col.m_pixel;
return *this;
}
void wxColour::InitFromName(const wxString& name)
{
if ( wxTheColourDatabase )
{
wxColour col = wxTheColourDatabase->Find(name);
if ( col.Ok() )
{
*this = col;
return;
}
}
// leave invalid
Init();
}
/* static */
wxColour wxColour::CreateByName(const wxString& name)
{
wxColour col;
Display *dpy = wxGlobalDisplay();
WXColormap colormap = wxTheApp->GetMainColormap( dpy );
XColor xcol;
if ( XParseColor( dpy, (Colormap)colormap, name.mb_str(), &xcol ) )
{
col.m_red = xcol.red & 0xff;
col.m_green = xcol.green & 0xff;
col.m_blue = xcol.blue & 0xff;
col.m_isInit = true;
col.m_pixel = -1;
}
return col;
}
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;
}

379
src/motif/combobox.cpp Normal file
View File

@@ -0,0 +1,379 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox.cpp
// Purpose: wxComboBox class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "combobox.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/setup.h"
#if wxUSE_COMBOBOX
#include "wx/combobox.h"
#include "wx/arrstr.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
// use the old, GPL'd combobox
#if (XmVersion < 2000)
#include "xmcombo/xmcombo.h"
#include "wx/motif/private.h"
void wxComboBoxCallback (Widget w, XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs);
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
m_noStrings = n;
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(),
xmComboBoxWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNshowLabel, False,
XmNeditable, ((style & wxCB_READONLY) != wxCB_READONLY),
XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
NULL);
int i;
for (i = 0; i < n; i++)
{
wxXmString str( choices[i] );
XmComboBoxAddItem(buttonWidget, str(), 0);
m_stringList.Add(choices[i]);
}
m_mainWidget = (Widget) buttonWidget;
XtManageChild (buttonWidget);
SetValue(value);
ChangeFont(false);
XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return true;
}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator,
const wxString& name)
{
wxCArrayString chs(choices);
return Create(parent, id, value, pos, size, chs.GetCount(),
chs.GetStrings(), style, validator, name);
}
wxComboBox::~wxComboBox()
{
DetachWidget((Widget) m_mainWidget); // Removes event handlers
XtDestroyWidget((Widget) m_mainWidget);
m_mainWidget = (WXWidget) 0;
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
}
void wxComboBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
// Necessary so it doesn't call wxChoice::SetSize
wxWindow::DoSetSize(x, y, width, DoGetBestSize().y, sizeFlags);
}
wxString wxComboBox::GetValue() const
{
char *s = XmComboBoxGetString ((Widget) m_mainWidget);
if (s)
{
wxString str(s);
XtFree (s);
return str;
}
else
return wxEmptyString;
}
void wxComboBox::SetValue(const wxString& value)
{
m_inSetValue = true;
if( !value.empty() )
XmComboBoxSetString( (Widget)m_mainWidget,
wxConstCast(value.c_str(), char) );
m_inSetValue = false;
}
void wxComboBox::SetString(int n, const wxString& s)
{
wxFAIL_MSG( wxT("wxComboBox::SetString only implemented for Motif 2.0") );
}
int wxComboBox::DoAppend(const wxString& item)
{
wxXmString str( item.c_str() );
XmComboBoxAddItem((Widget) m_mainWidget, str(), 0);
m_stringList.Add(item);
m_noStrings ++;
return GetCount() - 1;
}
int wxComboBox::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
if (pos == GetCount())
return DoAppend(item);
wxXmString str( item.c_str() );
XmComboBoxAddItem((Widget) m_mainWidget, str(), pos+1);
wxChar* copy = wxStrcpy(new wxChar[item.length() + 1], item.c_str());
m_stringList.Insert(pos, copy);
m_noStrings ++;
return pos;
}
void wxComboBox::Delete(int n)
{
XmComboBoxDeletePos((Widget) m_mainWidget, n+1);
wxStringList::Node *node = m_stringList.Item(n);
if (node)
{
delete[] node->GetData();
delete node;
}
m_clientDataDict.Delete(n, HasClientObjectData());
m_noStrings--;
}
void wxComboBox::Clear()
{
XmComboBoxDeleteAllItems((Widget) m_mainWidget);
m_stringList.Clear();
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
m_noStrings = 0;
}
void wxComboBox::SetSelection (int n)
{
XmComboBoxSelectPos((Widget) m_mainWidget, n+1, False);
}
int wxComboBox::GetSelection (void) const
{
int sel = XmComboBoxGetSelectedPos((Widget) m_mainWidget);
if (sel == 0)
return -1;
else
return sel - 1;
}
wxString wxComboBox::GetString(int n) const
{
wxStringList::Node *node = m_stringList.Item(n);
if (node)
return wxString(node->GetData ());
else
return wxEmptyString;
}
int wxComboBox::FindString(const wxString& s) const
{
int *pos_list = NULL;
int count = 0;
wxXmString text( s );
bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
text(), &pos_list, &count) != 0);
if (found && count > 0)
{
int pos = pos_list[0] - 1;
free(pos_list);
return pos;
}
return -1;
}
// Clipboard operations
void wxComboBox::Copy()
{
XmComboBoxCopy((Widget) m_mainWidget, CurrentTime);
}
void wxComboBox::Cut()
{
XmComboBoxCut((Widget) m_mainWidget, CurrentTime);
}
void wxComboBox::Paste()
{
XmComboBoxPaste((Widget) m_mainWidget);
}
void wxComboBox::SetEditable(bool WXUNUSED(editable))
{
// TODO
}
void wxComboBox::SetInsertionPoint(long pos)
{
XmComboBoxSetInsertionPosition ((Widget) m_mainWidget, (XmTextPosition) pos);
}
void wxComboBox::SetInsertionPointEnd()
{
XmTextPosition pos = XmComboBoxGetLastPosition ((Widget) m_mainWidget);
XmComboBoxSetInsertionPosition ((Widget) m_mainWidget, (XmTextPosition) (pos + 1));
}
long wxComboBox::GetInsertionPoint() const
{
return (long) XmComboBoxGetInsertionPosition ((Widget) m_mainWidget);
}
wxTextPos wxComboBox::GetLastPosition() const
{
return (wxTextPos) XmComboBoxGetLastPosition ((Widget) m_mainWidget);
}
void wxComboBox::Replace(long from, long to, const wxString& value)
{
XmComboBoxReplace ((Widget) m_mainWidget, (XmTextPosition) from,
(XmTextPosition) to,
wxConstCast(value.c_str(), char));
}
void wxComboBox::Remove(long from, long to)
{
XmComboBoxSetSelection ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(Time) 0);
XmComboBoxRemove ((Widget) m_mainWidget);
}
void wxComboBox::SetSelection(long from, long to)
{
XmComboBoxSetSelection ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(Time) 0);
}
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs)
{
wxComboBox *item = (wxComboBox *) clientData;
switch (cbs->reason)
{
case XmCR_SINGLE_SELECT:
case XmCR_BROWSE_SELECT:
{
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED,
item->GetId());
event.SetInt(cbs->index - 1);
event.SetString( item->GetString ( event.GetInt() ) );
if ( item->HasClientObjectData() )
event.SetClientObject( item->GetClientObject(cbs->index - 1) );
else if ( item->HasClientUntypedData() )
event.SetClientData( item->GetClientData(cbs->index - 1) );
event.SetExtraLong(true);
event.SetEventObject(item);
item->ProcessCommand (event);
break;
}
case XmCR_VALUE_CHANGED:
{
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
event.SetInt(-1);
event.SetString( item->GetValue() );
event.SetExtraLong(true);
event.SetEventObject(item);
item->ProcessCommand (event);
break;
}
default:
break;
}
}
void wxComboBox::ChangeFont(bool keepOriginalSize)
{
// Don't use the base class wxChoice's ChangeFont
wxWindow::ChangeFont(keepOriginalSize);
}
void wxComboBox::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
}
void wxComboBox::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
}
wxSize wxComboBox::DoGetBestSize() const
{
if( (GetWindowStyle() & wxCB_DROPDOWN) == wxCB_DROPDOWN ||
(GetWindowStyle() & wxCB_READONLY) == wxCB_READONLY )
{
wxSize items = GetItemsSize();
// FIXME arbitrary constants
return wxSize( ( items.x ? items.x + 50 : 120 ),
items.y + 10 );
}
else
return wxWindow::DoGetBestSize();
}
#endif // XmVersion < 2000
#endif // wxUSE_COMBOBOX

View File

@@ -0,0 +1,460 @@
/////////////////////////////////////////////////////////////////////////////
// Name: combobox_native.cpp
// Purpose: wxComboBox class
// Author: Julian Smart, Ian Brown
// Modified by:
// Created: 01/02/03
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/setup.h"
#if wxUSE_COMBOBOX
#include "wx/combobox.h"
#include "wx/arrstr.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
// use the new, shiny combobox for Motif 2.x
#if (XmVersion >= 2000)
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/ComboBox.h>
#include <Xm/Text.h>
#include <Xm/List.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
// utility
static Widget GetXmList( const wxComboBox* cb )
{
Widget ret;
XtVaGetValues( (Widget)cb->GetMainWidget(),
XmNlist, &ret,
NULL );
return ret;
}
static Widget GetXmText( const wxComboBox* cb )
{
Widget ret;
XtVaGetValues( (Widget)cb->GetMainWidget(),
XmNtextField, &ret,
NULL );
return ret;
}
void wxComboBoxCallback (Widget w, XtPointer clientData,
XmComboBoxCallbackStruct * cbs);
IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
int n, const wxString choices[],
long style,
const wxValidator& validator,
const wxString& name)
{
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
Widget parentWidget = (Widget) parent->GetClientWidget();
int cb_type = ( style & wxCB_SIMPLE ) ? XmCOMBO_BOX :
( style & wxCB_READONLY ) ? XmDROP_DOWN_LIST :
( style & wxCB_DROPDOWN ) ? XmDROP_DOWN_COMBO_BOX :
// default to wxCB_DROPDOWN
XmDROP_DOWN_COMBO_BOX;
if( cb_type == XmDROP_DOWN_COMBO_BOX )
SetWindowStyle( style | wxCB_DROPDOWN );
Widget buttonWidget= XtVaCreateManagedWidget(name.c_str(),
xmComboBoxWidgetClass, parentWidget,
XmNcomboBoxType, cb_type,
NULL);
m_mainWidget = (Widget) buttonWidget;
int i;
for ( i = 0; i < n; ++i)
Append( choices[i] );
XtManageChild (buttonWidget);
SetValue(value);
ChangeFont(false);
XtAddCallback (buttonWidget, XmNselectionCallback,
(XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
XtAddCallback (GetXmText(this), XmNvalueChangedCallback,
(XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
wxSize best = GetBestSize();
if( size.x != -1 ) best.x = size.x;
if( size.y != -1 ) best.y = size.y;
AttachWidget (parent, m_mainWidget, (WXWidget) NULL,
pos.x, pos.y, best.x, best.y);
ChangeBackgroundColour();
return true;
}
bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
const wxArrayString& choices,
long style,
const wxValidator& validator,
const wxString& name)
{
wxCArrayString chs(choices);
return Create(parent, id, value, pos, size, chs.GetCount(),
chs.GetStrings(), style, validator, name);
}
void wxComboBox::AdjustDropDownListSize()
{
int newListCount = -1, itemCount = GetCount();
const int MAX = 12;
if( !itemCount )
newListCount = 1;
else if( itemCount < MAX )
newListCount = itemCount;
else
newListCount = MAX;
XtVaSetValues( GetXmList(this),
XmNvisibleItemCount, newListCount,
NULL );
}
wxComboBox::~wxComboBox()
{
DetachWidget((Widget) m_mainWidget); // Removes event handlers
XtDestroyWidget((Widget) m_mainWidget);
m_mainWidget = (WXWidget) 0;
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
}
void wxComboBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
// Necessary so it doesn't call wxChoice::SetSize
wxWindow::DoSetSize(x, y, width, DoGetBestSize().y, sizeFlags);
}
wxString wxComboBox::GetValue() const
{
char* s = XmTextGetString (GetXmText (this));
wxString str(s);
if (s)
XtFree (s);
return str;
}
void wxComboBox::SetString(int n, const wxString& s)
{
wxXmString text(s);
Widget listBox = GetXmList(this);
// delete the item and add it again.
// FIXME isn't there a way to change it in place?
XmListDeletePos (listBox, n+1);
XmListAddItem (listBox, text(), n+1);
}
void wxComboBox::SetValue(const wxString& value)
{
m_inSetValue = true;
// Fix crash; probably an OpenMotif bug
const char* val = value.c_str() ? value.c_str() : "";
XtVaSetValues( GetXmText(this),
XmNvalue, wxConstCast(val, char),
NULL);
m_inSetValue = false;
}
int wxComboBox::DoAppend(const wxString& item)
{
wxXmString str( item.c_str() );
XmComboBoxAddItem((Widget) m_mainWidget, str(), 0, False);
m_noStrings ++;
AdjustDropDownListSize();
return GetCount() - 1;
}
int wxComboBox::DoInsert(const wxString& item, int pos)
{
wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
if (pos == GetCount())
return DoAppend(item);
wxXmString str( item.c_str() );
XmComboBoxAddItem((Widget) m_mainWidget, str(), pos+1, False);
m_noStrings ++;
AdjustDropDownListSize();
return GetCount() - 1;
}
void wxComboBox::Delete(int n)
{
#ifdef LESSTIF_VERSION
XmListDeletePos (GetXmList(this), n + 1);
#else
XmComboBoxDeletePos((Widget) m_mainWidget, n+1);
#endif
m_clientDataDict.Delete(n, HasClientObjectData());
m_noStrings--;
AdjustDropDownListSize();
}
void wxComboBox::Clear()
{
#ifdef LESSTIF_VERSION
XmListDeleteAllItems (GetXmList(this));
#else
while(m_noStrings > 0)
{
XmComboBoxDeletePos((Widget) m_mainWidget, m_noStrings--);
}
#endif
if ( HasClientObjectData() )
m_clientDataDict.DestroyData();
m_noStrings = 0;
AdjustDropDownListSize();
}
void wxComboBox::SetSelection (int n)
{
m_inSetSelection = true;
#if wxCHECK_LESSTIF()
XmListSelectPos (GetXmList(this), n + 1, false);
SetValue(GetString(n));
#else
#if 0
wxXmString str( GetString(n).c_str() );
XmComboBoxSelectItem((Widget) m_mainWidget, str());
#endif
XtVaSetValues( (Widget)m_mainWidget,
XmNselectedPosition, n,
NULL );
#endif
m_inSetSelection = false;
}
int wxComboBox::GetSelection (void) const
{
return wxDoGetSelectionInList( GetXmList( this ) );
}
wxString wxComboBox::GetString(int n) const
{
return wxDoGetStringInList( GetXmList(this), n );
}
int wxComboBox::FindString(const wxString& s) const
{
return wxDoFindStringInList( GetXmList( this ), s );
}
// Clipboard operations
void wxComboBox::Copy()
{
XmTextCopy( GetXmText(this), CurrentTime );
}
void wxComboBox::Cut()
{
XmTextCut( GetXmText(this), CurrentTime );
}
void wxComboBox::Paste()
{
XmTextPaste( GetXmText(this) );
}
void wxComboBox::SetEditable(bool WXUNUSED(editable))
{
// TODO
}
void wxComboBox::SetInsertionPoint(long pos)
{
XmTextSetInsertionPosition( GetXmText(this), (XmTextPosition)pos );
}
void wxComboBox::SetInsertionPointEnd()
{
SetInsertionPoint( GetLastPosition() );
}
long wxComboBox::GetInsertionPoint() const
{
return (long)XmTextGetInsertionPosition( GetXmText(this) );
}
wxTextPos wxComboBox::GetLastPosition() const
{
XmTextPosition pos = XmTextGetLastPosition( GetXmText(this) );
return (long)pos;
}
void wxComboBox::Replace(long from, long to, const wxString& value)
{
XmTextReplace( GetXmText(this), (XmTextPosition)from, (XmTextPosition)to,
wxConstCast(value.c_str(), char) );
}
void wxComboBox::Remove(long from, long to)
{
SetSelection( from, to );
XmTextRemove( GetXmText(this) );
}
void wxComboBox::SetSelection(long from, long to)
{
if( to == -1 )
to = GetLastPosition();
XmTextSetSelection( GetXmText(this), (XmTextPosition)from,
(XmTextPosition)to, (Time)0 );
}
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
XmComboBoxCallbackStruct * cbs)
{
wxComboBox *item = (wxComboBox *) clientData;
if( item->m_inSetSelection ) return;
switch (cbs->reason)
{
case XmCR_SELECT:
#if 0
case XmCR_SINGLE_SELECT:
case XmCR_BROWSE_SELECT:
#endif
{
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED,
item->GetId());
int idx = cbs->item_position;
event.SetInt(idx);
event.SetString( item->GetString (idx) );
if ( item->HasClientObjectData() )
event.SetClientObject( item->GetClientObject(idx) );
else if ( item->HasClientUntypedData() )
event.SetClientData( item->GetClientData(idx) );
event.SetExtraLong(true);
event.SetEventObject(item);
item->GetEventHandler()->ProcessEvent(event);
break;
}
case XmCR_VALUE_CHANGED:
{
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
event.SetInt(-1);
event.SetString( item->GetValue() );
event.SetExtraLong(true);
event.SetEventObject(item);
item->GetEventHandler()->ProcessEvent(event);
break;
}
default:
break;
}
}
void wxComboBox::ChangeFont(bool keepOriginalSize)
{
if( m_font.Ok() )
{
wxDoChangeFont( GetXmText(this), m_font );
wxDoChangeFont( GetXmList(this), m_font );
}
// Don't use the base class wxChoice's ChangeFont
wxWindow::ChangeFont(keepOriginalSize);
}
void wxComboBox::ChangeBackgroundColour()
{
wxWindow::ChangeBackgroundColour();
}
void wxComboBox::ChangeForegroundColour()
{
wxWindow::ChangeForegroundColour();
}
wxSize wxComboBox::DoGetBestSize() const
{
if( (GetWindowStyle() & wxCB_DROPDOWN) == wxCB_DROPDOWN ||
(GetWindowStyle() & wxCB_READONLY) == wxCB_READONLY )
{
Dimension arrowW, arrowS, highlight, xmargin, ymargin, shadow;
XtVaGetValues( (Widget)m_mainWidget,
XmNarrowSize, &arrowW,
XmNarrowSpacing, &arrowS,
XmNhighlightThickness, &highlight,
XmNmarginWidth, &xmargin,
XmNmarginHeight, &ymargin,
XmNshadowThickness, &shadow,
NULL );
wxSize listSize = wxDoGetListBoxBestSize( GetXmList(this), this );
wxSize textSize = wxDoGetSingleTextCtrlBestSize( GetXmText(this),
this );
// FIXME arbitrary constants
return wxSize( listSize.x + arrowW + arrowS + 2 * highlight
+ 2 * shadow + 2 * xmargin ,
textSize.y + 2 * highlight + 2 * ymargin + 2 * shadow );
}
else
return wxWindow::DoGetBestSize();
}
#endif // XmVersion >= 2000
#endif // wxUSE_COMBOBOX

129
src/motif/control.cpp Normal file
View File

@@ -0,0 +1,129 @@
/////////////////////////////////////////////////////////////////////////////
// Name: control.cpp
// Purpose: wxControl class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "control.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/defs.h"
#include "wx/control.h"
#include "wx/panel.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_ABSTRACT_CLASS(wxControl, wxWindow)
BEGIN_EVENT_TABLE(wxControl, wxWindow)
END_EVENT_TABLE()
// Item members
wxControl::wxControl()
{
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
m_inSetValue = false;
}
bool wxControl::Create( wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
const wxSize &size,
long style,
const wxValidator& validator,
const wxString &name)
{
bool ret = wxWindow::Create(parent, id, pos, size, style, name);
#if wxUSE_VALIDATORS
SetValidator(validator);
#endif
return ret;
}
bool wxControl::CreateControl(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
if( !wxControlBase::CreateControl( parent, id, pos, size, style,
validator, name ) )
return false;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_font = parent->GetFont();
return true;
}
void wxControl::SetLabel(const wxString& label)
{
Widget widget = (Widget) GetLabelWidget() ;
if (!widget)
return;
wxXmString label_str(wxStripMenuCodes(label));
XtVaSetValues (widget,
XmNlabelString, label_str(),
XmNlabelType, XmSTRING,
NULL);
}
wxString wxControl::GetLabel() const
{
Widget widget = (Widget) GetLabelWidget() ;
if (!widget)
return wxEmptyString;
XmString text = NULL;
XtVaGetValues (widget,
XmNlabelString, &text,
NULL);
return wxXmStringToString( text );
}
bool wxControl::ProcessCommand(wxCommandEvent & event)
{
return GetEventHandler()->ProcessEvent(event);
}
wxSize wxControl::DoGetBestSize() const
{
Widget w = (Widget)GetTopWidget();
// Do not return any arbitrary default value...
wxASSERT_MSG (w, wxT("DoGetBestSize called before creation"));
XtWidgetGeometry preferred;
XtQueryGeometry (w, NULL, &preferred);
return wxSize(preferred.width, preferred.height);
}

6
src/motif/cross.xbm Normal file
View File

@@ -0,0 +1,6 @@
#define cross_width 15
#define cross_height 15
static char cross_bits[] = {
0x84, 0x10, 0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10,
0x84, 0x10, 0xff, 0x7f, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10, 0x84, 0x10,
0xff, 0x7f, 0x84, 0x10, 0x84, 0x10};

503
src/motif/cursor.cpp Normal file
View File

@@ -0,0 +1,503 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "cursor.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/cursor.h"
#include "wx/app.h"
#include "wx/utils.h"
#include "wx/list.h"
#include "wx/window.h"
#if wxUSE_IMAGE
#include "wx/image.h"
#endif
#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"
// Cursor for one display, so we can choose the correct one for
// the current display.
class wxXCursor
{
public:
WXDisplay* m_display;
WXCursor m_cursor;
};
WX_DECLARE_LIST(wxXCursor, wxXCursorList);
#include "wx/listimpl.cpp"
WX_DEFINE_LIST(wxXCursorList);
class WXDLLEXPORT wxCursorRefData: public wxObjectRefData
{
friend class WXDLLEXPORT wxCursor;
public:
wxCursorRefData();
~wxCursorRefData();
wxXCursorList m_cursors; // wxXCursor objects, one per display
wxStockCursor m_cursorId; // wxWidgets standard cursor id
};
#define M_CURSORDATA ((wxCursorRefData *)m_refData)
#define M_CURSORHANDLERDATA ((wxCursorRefData *)bitmap->m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxCursor, wxObject)
wxCursorRefData::wxCursorRefData()
{
m_cursorId = wxCURSOR_NONE;
}
wxCursorRefData::~wxCursorRefData()
{
wxXCursorList::compatibility_iterator node = m_cursors.GetFirst();
while (node)
{
wxXCursor* c = node->GetData();
XFreeCursor((Display*) c->m_display, (Cursor) c->m_cursor);
delete c;
node = node->GetNext();
}
}
wxCursor::wxCursor()
{
}
#if wxUSE_IMAGE
wxCursor::wxCursor(const wxImage & image)
{
unsigned char * rgbBits = image.GetData();
int w = image.GetWidth() ;
int h = image.GetHeight();
bool bHasMask = image.HasMask();
int imagebitcount = (w*h)/8;
unsigned char * bits = new unsigned char [imagebitcount];
unsigned char * maskBits = new unsigned char [imagebitcount];
int i, j, i8; unsigned char c, cMask;
for (i=0; i<imagebitcount; i++)
{
bits[i] = 0xff;
i8 = i * 8;
cMask = 0xfe; // 11111110
for (j=0; j<8; j++)
{
// possible overflow if we do the summation first ?
c = rgbBits[(i8+j)*3]/3 + rgbBits[(i8+j)*3+1]/3 + rgbBits[(i8+j)*3+2]/3;
//if average value is > mid grey
if (c>127)
bits[i] = bits[i] & cMask;
cMask = (cMask << 1) | 1;
}
}
if (bHasMask)
{
unsigned char
r = image.GetMaskRed(),
g = image.GetMaskGreen(),
b = image.GetMaskBlue();
for (i=0; i<imagebitcount; i++)
{
maskBits[i] = 0x0;
i8 = i * 8;
cMask = 0x1;
for (j=0; j<8; j++)
{
if (rgbBits[(i8+j)*3] != r || rgbBits[(i8+j)*3+1] != g || rgbBits[(i8+j)*3+2] != b)
maskBits[i] = maskBits[i] | cMask;
cMask = (cMask << 1);
}
}
}
else // no mask
{
for (i=0; i<imagebitcount; i++)
maskBits[i] = 0xFF;
}
int hotSpotX;
int hotSpotY;
if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_X))
hotSpotX = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_X);
else
hotSpotX = 0;
if (image.HasOption(wxIMAGE_OPTION_CUR_HOTSPOT_Y))
hotSpotY = image.GetOptionInt(wxIMAGE_OPTION_CUR_HOTSPOT_Y);
else
hotSpotY = 0;
if (hotSpotX < 0 || hotSpotX >= w)
hotSpotX = 0;
if (hotSpotY < 0 || hotSpotY >= h)
hotSpotY = 0;
Create( (const char*)bits, w, h, hotSpotX, hotSpotY,
(const char*)maskBits );
delete[] bits;
delete[] maskBits;
}
#endif
void wxCursor::Create(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, const char maskBits[])
{
if( !m_refData )
m_refData = new wxCursorRefData;
Display *dpy = (Display*) wxGetDisplay();
int screen_num = DefaultScreen (dpy);
Pixmap pixmap = XCreatePixmapFromBitmapData (dpy,
RootWindow (dpy, screen_num),
(char*) bits, width, height,
1 , 0 , 1);
Pixmap mask_pixmap = None;
if (maskBits != NULL)
{
mask_pixmap = XCreatePixmapFromBitmapData (dpy,
RootWindow (dpy, screen_num),
(char*) maskBits, width, height,
1 , 0 , 1);
}
Create( (WXPixmap)pixmap, (WXPixmap)mask_pixmap, hotSpotX, hotSpotY );
XFreePixmap( dpy, pixmap );
if (mask_pixmap != None)
{
XFreePixmap( dpy, mask_pixmap );
}
}
void wxCursor::Create(WXPixmap pixmap, WXPixmap mask_pixmap,
int hotSpotX, int hotSpotY)
{
if( !m_refData )
m_refData = new wxCursorRefData;
Display *dpy = (Display*) wxGetDisplay();
int screen_num = DefaultScreen (dpy);
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)pixmap,
(Pixmap)mask_pixmap,
&foreground_color,
&background_color,
hotSpotX ,
hotSpotY);
if (cursor)
{
wxXCursor *c = new wxXCursor;
c->m_cursor = (WXCursor) cursor;
c->m_display = (WXDisplay*) dpy;
M_CURSORDATA->m_cursors.Append(c);
}
}
wxCursor::wxCursor(const char bits[], int width, int height,
int hotSpotX, int hotSpotY, const char maskBits[])
{
Create(bits, width, height, hotSpotX, hotSpotY, maskBits);
}
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 = None, mask_pixmap = None;
Display *dpy = (Display*) wxGetDisplay();
int screen_num = DefaultScreen (dpy);
int value = XReadBitmapFile (dpy, RootWindow (dpy, screen_num),
wxConstCast(name.c_str(), char),
&w, &h, &pixmap, &hotX, &hotY);
if (value == BitmapSuccess)
{
// 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;
}
Create( (WXPixmap)pixmap, (WXPixmap)mask_pixmap, hotX, hotY );
XFreePixmap( dpy, pixmap );
}
}
// Cursors by stock number
wxCursor::wxCursor(wxStockCursor id)
{
m_refData = new wxCursorRefData;
M_CURSORDATA->m_cursorId = id;
}
wxCursor::~wxCursor()
{
}
bool wxCursor::Ok() const
{
return m_refData != NULL;
}
// Motif-specific: create/get a cursor for the current display
WXCursor wxCursor::GetXCursor(WXDisplay* display) const
{
if (!M_CURSORDATA)
return (WXCursor) 0;
wxXCursorList::compatibility_iterator node = M_CURSORDATA->m_cursors.GetFirst();
while (node)
{
wxXCursor* c = node->GetData();
if (c->m_display == display)
return c->m_cursor;
node = node->GetNext();
}
// 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) const
{
Display* dpy = (Display*) display;
Cursor cursor = (Cursor) 0;
int x_cur = -1;
switch (id)
{
case wxCURSOR_WAIT: x_cur = XC_watch; break;
case wxCURSOR_CROSS: x_cur = XC_crosshair; break;
case wxCURSOR_CHAR: return (WXCursor)cursor; break;
case wxCURSOR_HAND: x_cur = XC_hand1; break;
case wxCURSOR_BULLSEYE: x_cur = XC_target; break;
case wxCURSOR_PENCIL: x_cur = XC_pencil; break;
case wxCURSOR_MAGNIFIER: x_cur = XC_sizing; break;
case wxCURSOR_IBEAM: x_cur = XC_xterm; break;
case wxCURSOR_NO_ENTRY: x_cur = XC_pirate; break;
case wxCURSOR_LEFT_BUTTON: x_cur = XC_leftbutton; break;
case wxCURSOR_RIGHT_BUTTON: x_cur = XC_rightbutton; break;
case wxCURSOR_MIDDLE_BUTTON: x_cur = XC_middlebutton; break;
case wxCURSOR_QUESTION_ARROW: x_cur = XC_question_arrow; break;
case wxCURSOR_SIZING: x_cur = XC_sizing; break;
case wxCURSOR_WATCH: x_cur = XC_watch; break;
case wxCURSOR_SPRAYCAN: x_cur = XC_spraycan; break;
case wxCURSOR_PAINT_BRUSH: x_cur = XC_spraycan; break;
case wxCURSOR_SIZENWSE:
case wxCURSOR_SIZENESW: x_cur = XC_crosshair; break;
case wxCURSOR_SIZEWE: x_cur = XC_sb_h_double_arrow; break;
case wxCURSOR_SIZENS: x_cur = XC_sb_v_double_arrow; break;
case wxCURSOR_POINT_LEFT: x_cur = XC_sb_left_arrow; break;
case wxCURSOR_POINT_RIGHT: x_cur = XC_sb_right_arrow; break;
// (JD Huggins) added more stock cursors for X
// X-only cursors BEGIN
case wxCURSOR_CROSS_REVERSE: x_cur = XC_cross_reverse; break;
case wxCURSOR_DOUBLE_ARROW: x_cur = XC_double_arrow; break;
case wxCURSOR_BASED_ARROW_UP: x_cur = XC_based_arrow_up; break;
case wxCURSOR_BASED_ARROW_DOWN: x_cur = XC_based_arrow_down; 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;
}
case wxCURSOR_ARROW:
default: x_cur = XC_top_left_arrow; break;
}
if( x_cur == -1 )
return (WXCursor)cursor;
cursor = XCreateFontCursor (dpy, x_cur);
return (WXCursor) cursor;
}
// Global cursor setting
void wxSetCursor(const wxCursor& WXUNUSED(cursor))
{
// Nothing to do for Motif (no global cursor)
}
// ----------------------------------------------------------------------------
// busy cursor stuff
// ----------------------------------------------------------------------------
static int wxBusyCursorCount = 0;
// Helper function
static void
wxXSetBusyCursor (wxWindow * win, wxCursor * cursor)
{
Display *display = (Display*) win->GetXDisplay();
Window xwin = (Window) win->GetXWindow();
if (!xwin)
return;
XSetWindowAttributes attrs;
if (cursor)
{
attrs.cursor = (Cursor) cursor->GetXCursor(display);
}
else
{
// Restore old cursor
if (win->GetCursor().Ok())
attrs.cursor = (Cursor) win->GetCursor().GetXCursor(display);
else
attrs.cursor = None;
}
if (xwin)
XChangeWindowAttributes (display, xwin, CWCursor, &attrs);
XFlush (display);
for(wxWindowList::compatibility_iterator node = win->GetChildren().GetFirst (); node;
node = node->GetNext())
{
wxWindow *child = node->GetData ();
wxXSetBusyCursor (child, cursor);
}
}
// Set the cursor to the busy cursor for all windows
void wxBeginBusyCursor(wxCursor *cursor)
{
wxBusyCursorCount++;
if (wxBusyCursorCount == 1)
{
for(wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst (); node;
node = node->GetNext())
{
wxWindow *win = node->GetData ();
wxXSetBusyCursor (win, cursor);
}
}
}
// Restore cursor to normal
void wxEndBusyCursor()
{
if (wxBusyCursorCount == 0)
return;
wxBusyCursorCount--;
if (wxBusyCursorCount == 0)
{
for(wxWindowList::compatibility_iterator node = wxTopLevelWindows.GetFirst (); node;
node = node->GetNext())
{
wxWindow *win = node->GetData ();
wxXSetBusyCursor (win, NULL);
}
}
}
// true if we're between the above two calls
bool wxIsBusy()
{
return (wxBusyCursorCount > 0);
}

15
src/motif/data.cpp Normal file
View File

@@ -0,0 +1,15 @@
/////////////////////////////////////////////////////////////////////////////
// Name: motif/data.cpp
// Purpose: Various Motif-specific global data
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// this file is empty for now but a translation unit is not supposed to be
// completely empty
extern int wxMotifDummyData;

193
src/motif/dataobj.cpp Normal file
View File

@@ -0,0 +1,193 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dataobj.cpp
// Purpose: wxDataObject class
// Author: Julian Smart
// Id: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dataobj.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/defs.h"
#if wxUSE_CLIPBOARD
#include "wx/dataobj.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"
//-------------------------------------------------------------------------
// global data
//-------------------------------------------------------------------------
Atom g_textAtom = 0;
Atom g_bitmapAtom = 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_bitmapAtom;
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_bitmapAtom)
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( wxGlobalDisplay(),
tmp.mbc_str(), False );
}
void wxDataFormat::PrepareFormats()
{
if (!g_textAtom)
g_textAtom = XInternAtom( wxGlobalDisplay(), "STRING", False );
if (!g_bitmapAtom)
g_bitmapAtom = XInternAtom( wxGlobalDisplay(), "PIXMAP", False );
if (!g_fileAtom)
g_fileAtom = XInternAtom( wxGlobalDisplay(), "file:ALL", False );
}
// ----------------------------------------------------------------------------
// wxDataObject
// ----------------------------------------------------------------------------
wxDataObject::~wxDataObject()
{
}
// ----------------------------------------------------------------------------
// wxBitmapDataObject
// ----------------------------------------------------------------------------
size_t wxBitmapDataObject::GetDataSize() const
{
return sizeof(Pixmap);
}
bool wxBitmapDataObject::GetDataHere(void* buf) const
{
if( !GetBitmap().Ok() )
return false;
(*(Pixmap*)buf) = (Pixmap)GetBitmap().GetDrawable();
return true;
}
bool wxBitmapDataObject::SetData(size_t len, const void* buf)
{
if( len != sizeof(Pixmap) )
return false;
WXPixmap pixmap = (WXPixmap)*(Pixmap*)buf;
m_bitmap.Create( pixmap );
return true;
}
#endif // wxUSE_CLIPBOARD

219
src/motif/dc.cpp Normal file
View File

@@ -0,0 +1,219 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dc.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/dc.h"
#include "wx/dcmemory.h"
#include "wx/defs.h"
IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
//-----------------------------------------------------------------------------
// 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::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;
}

2323
src/motif/dcclient.cpp Normal file

File diff suppressed because it is too large Load Diff

156
src/motif/dcmemory.cpp Normal file
View File

@@ -0,0 +1,156 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dcmemory.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#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.GetDrawable();
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, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
&gcvalues);
m_backgroundPixel = (int) gcvalues.background;
m_ok = true;
// 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);
}
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;
};
};

137
src/motif/dcscreen.cpp Normal file
View File

@@ -0,0 +1,137 @@
/////////////////////////////////////////////////////////////////////////////
// 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
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dcscreen.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#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;
}

193
src/motif/descrip.mms Normal file
View File

@@ -0,0 +1,193 @@
#*****************************************************************************
# *
# Make file for VMS *
# Author : J.Jansen (joukj@hrem.stm.tudelft.nl) *
# Date : 10 November 1999 *
# *
#*****************************************************************************
.first
define wx [--.include.wx]
.ifdef __WXMOTIF__
CXX_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)\
/assume=(nostdnew,noglobal_array_new)
CC_DEFINE = /define=(__WXMOTIF__=1)/name=(as_is,short)
.else
CXX_DEFINE =
.endif
.suffixes : .cpp
.cpp.obj :
cxx $(CXXFLAGS)$(CXX_DEFINE) $(MMS$TARGET_NAME).cpp
.c.obj :
cc $(CFLAGS)$(CC_DEFINE) $(MMS$TARGET_NAME).c
OBJECTS = \
xmcombo.obj,\
accel.obj,\
app.obj,\
bmpbuttn.obj,\
bmpmotif.obj,\
button.obj,\
checkbox.obj,\
checklst.obj,\
choice.obj,\
clipbrd.obj,\
colour.obj,\
combobox.obj,\
control.obj,\
cursor.obj,\
data.obj,\
dataobj.obj,\
dc.obj,\
dcclient.obj,\
dcmemory.obj,\
dcscreen.obj,\
dialog.obj,\
evtloop.obj,\
filedlg.obj,\
font.obj,\
frame.obj,\
gauge.obj,\
gdiobj.obj,\
gsockmot.obj,\
icon.obj,\
listbox.obj,\
main.obj,\
mdi.obj,\
menu.obj,\
menuitem.obj,\
minifram.obj,\
msgdlg.obj,\
palette.obj,\
radiobox.obj,\
radiobut.obj,\
scrolbar.obj,\
settings.obj,\
slider.obj,\
spinbutt.obj,\
statbmp.obj,\
statbox.obj,\
stattext.obj,\
textctrl.obj,\
toplevel.obj,\
timer.obj,\
toolbar.obj,\
utils.obj,\
window.obj
SOURCES = \
accel.cpp,\
app.cpp,\
bmpbuttn.cpp,\
bmpmotif.cpp,\
button.cpp,\
checkbox.cpp,\
checklst.cpp,\
choice.cpp,\
clipbrd.cpp,\
colour.cpp,\
combobox.cpp,\
control.cpp,\
cursor.cpp,\
data.cpp,\
dataobj.cpp,\
dc.cpp,\
dcclient.cpp,\
dcmemory.cpp,\
dcscreen.cpp,\
dialog.cpp,\
evtloop.cpp,\
filedlg.cpp,\
font.cpp,\
frame.cpp,\
gauge.cpp,\
gdiobj.cpp,\
gsockmot.cpp,\
icon.cpp,\
listbox.cpp,\
main.cpp,\
mdi.cpp,\
menu.cpp,\
menuitem.cpp,\
minifram.cpp,\
msgdlg.cpp,\
palette.cpp,\
radiobox.cpp,\
radiobut.cpp,\
scrolbar.cpp,\
settings.cpp,\
slider.cpp,\
spinbutt.cpp,\
statbmp.cpp,\
statbox.cpp,\
stattext.cpp,\
textctrl.cpp,\
toplevel.cpp,\
timer.cpp,\
toolbar.cpp,\
utils.cpp,\
window.cpp,\
[.xmcombo]xmcombo.c\
all : $(SOURCES)
$(MMS)$(MMSQUALIFIERS) $(OBJECTS)
.ifdef __WXMOTIF__
library [--.lib]libwx_motif.olb $(OBJECTS)
.endif
xmcombo.obj : [.xmcombo]xmcombo.c
cc $(CFLAGS)$(CC_DEFINE) [.xmcombo]xmcombo.c
accel.obj : accel.cpp
app.obj : app.cpp
bmpbuttn.obj : bmpbuttn.cpp
bmpmotif.obj : bmpmotif.cpp
button.obj : button.cpp
checkbox.obj : checkbox.cpp
checklst.obj : checklst.cpp
choice.obj : choice.cpp
clipbrd.obj : clipbrd.cpp
colour.obj : colour.cpp
combobox.obj : combobox.cpp
control.obj : control.cpp
cursor.obj : cursor.cpp
data.obj : data.cpp
dataobj.obj : dataobj.cpp
dc.obj : dc.cpp
dcclient.obj : dcclient.cpp
dcmemory.obj : dcmemory.cpp
dcscreen.obj : dcscreen.cpp
dialog.obj : dialog.cpp
evtloop.obj : evtloop.cpp
filedlg.obj : filedlg.cpp
font.obj : font.cpp
frame.obj : frame.cpp
gauge.obj : gauge.cpp
gdiobj.obj : gdiobj.cpp
gsockmot.obj : gsockmot.cpp
icon.obj : icon.cpp
listbox.obj : listbox.cpp
main.obj : main.cpp
mdi.obj : mdi.cpp
menu.obj : menu.cpp
menuitem.obj : menuitem.cpp
minifram.obj : minifram.cpp
msgdlg.obj : msgdlg.cpp
palette.obj : palette.cpp
radiobox.obj : radiobox.cpp
radiobut.obj : radiobut.cpp
scrolbar.obj : scrolbar.cpp
settings.obj : settings.cpp
slider.obj : slider.cpp
spinbutt.obj : spinbutt.cpp
statbmp.obj : statbmp.cpp
statbox.obj : statbox.cpp
stattext.obj : stattext.cpp
textctrl.obj : textctrl.cpp
toplevel.obj : toplevel.cpp
timer.obj : timer.cpp
toolbar.obj : toolbar.cpp
utils.obj : utils.cpp
window.obj : window.cpp

462
src/motif/dialog.cpp Normal file
View File

@@ -0,0 +1,462 @@
/////////////////////////////////////////////////////////////////////////////
// Name: dialog.cpp
// Purpose: wxDialog class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dialog.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#define XtWindow XTWINDOW
#define XtParent XTPARENT
#define XtScreen XTSCREEN
#endif
#include "wx/dialog.h"
#include "wx/utils.h"
#include "wx/app.h"
#include "wx/settings.h"
#include "wx/evtloop.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/Shell.h>
#if XmVersion >= 1002
#include <Xm/XmAll.h>
#endif
#include <Xm/MwmUtil.h>
#include <Xm/Label.h>
#include <Xm/BulletinB.h>
#include <Xm/Frame.h>
#include <Xm/Text.h>
#include <Xm/DialogS.h>
#include <Xm/FileSB.h>
#include <Xm/RowColumn.h>
#include <Xm/LabelG.h>
#include <Xm/AtomMgr.h>
#if XmVersion > 1000
#include <Xm/Protocols.h>
#endif
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
// A stack of modal_showing flags, since we can't rely
// on accessing wxDialog::m_modalShowing within
// wxDialog::Show in case a callback has deleted the wxDialog.
// static wxList wxModalShowingStack;
// Lists to keep track of windows, so we can disable/enable them
// for modal dialogs
wxList wxModalDialogs;
extern wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete;
#define wxUSE_INVISIBLE_RESIZE 1
IMPLEMENT_DYNAMIC_CLASS(wxDialog, wxTopLevelWindow)
BEGIN_EVENT_TABLE(wxDialog, wxTopLevelWindow)
EVT_BUTTON(wxID_OK, wxDialog::OnOK)
EVT_BUTTON(wxID_APPLY, wxDialog::OnApply)
EVT_BUTTON(wxID_CANCEL, wxDialog::OnCancel)
EVT_CHAR_HOOK(wxDialog::OnCharHook)
EVT_SYS_COLOUR_CHANGED(wxDialog::OnSysColourChanged)
EVT_CLOSE(wxDialog::OnCloseWindow)
END_EVENT_TABLE()
wxDialog::wxDialog()
{
m_modalShowing = false;
m_eventLoop = NULL;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
}
bool wxDialog::Create(wxWindow *parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
SetExtraStyle(GetExtraStyle() | wxTOPLEVEL_EX_DIALOG);
if( !wxTopLevelWindow::Create( parent, id, title, pos, size, style,
name ) )
return false;
m_modalShowing = false;
m_eventLoop = NULL;
m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
m_foregroundColour = *wxBLACK;
Widget dialogShell = (Widget) m_mainWidget;
Widget shell = XtParent(dialogShell) ;
SetTitle( title );
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
ChangeFont(false);
// Can't remember what this was about... but I think it's necessary.
if (wxUSE_INVISIBLE_RESIZE)
{
if (pos.x > -1)
XtVaSetValues(dialogShell, XmNx, pos.x,
NULL);
if (pos.y > -1)
XtVaSetValues(dialogShell, XmNy, pos.y,
NULL);
if (size.x > -1)
XtVaSetValues(dialogShell, XmNwidth, size.x, NULL);
if (size.y > -1)
XtVaSetValues(dialogShell, XmNheight, size.y, NULL);
}
// Positioning of the dialog doesn't work properly unless the dialog
// is managed, so we manage without mapping to the screen.
// To show, we map the shell (actually it's parent).
if (!wxUSE_INVISIBLE_RESIZE)
XtVaSetValues(shell, XmNmappedWhenManaged, False, NULL);
if (!wxUSE_INVISIBLE_RESIZE)
{
XtManageChild(dialogShell);
SetSize(pos.x, pos.y, size.x, size.y);
}
XtAddEventHandler(dialogShell,ExposureMask,False,
wxUniversalRepaintProc, (XtPointer) this);
ChangeBackgroundColour();
return true;
}
bool wxDialog::DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
Widget parentWidget = (Widget) 0;
if( parent )
parentWidget = (Widget) parent->GetTopWidget();
if( !parent )
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
wxASSERT_MSG( (parentWidget != (Widget) 0),
"Could not find a suitable parent shell for dialog." );
Arg args[2];
XtSetArg (args[0], XmNdefaultPosition, False);
XtSetArg (args[1], XmNautoUnmanage, False);
Widget dialogShell =
XmCreateBulletinBoardDialog( parentWidget,
wxConstCast(name.c_str(), char),
args, 2);
m_mainWidget = (WXWidget) dialogShell;
// We don't want margins, since there is enough elsewhere.
XtVaSetValues( dialogShell,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNresizePolicy, XmRESIZE_NONE,
NULL ) ;
XtTranslations ptr ;
XtOverrideTranslations(dialogShell,
ptr = XtParseTranslationTable("<Configure>: resize()"));
XtFree((char *)ptr);
XtRealizeWidget(dialogShell);
wxAddWindowToTable( (Widget)m_mainWidget, this );
return true;
}
void wxDialog::SetModal(bool flag)
{
#ifdef __VMS
#pragma message disable codcauunr
#endif
if ( flag )
m_windowStyle |= wxDIALOG_MODAL ;
else
if ( m_windowStyle & wxDIALOG_MODAL )
m_windowStyle -= wxDIALOG_MODAL ;
wxModelessWindows.DeleteObject(this);
if (!flag)
wxModelessWindows.Append(this);
#ifdef __VMS
#pragma message enable codcauunr
#endif
}
wxDialog::~wxDialog()
{
m_isBeingDeleted = true;
delete m_eventLoop;
if (m_mainWidget)
{
XtRemoveEventHandler((Widget) m_mainWidget, ExposureMask, False,
wxUniversalRepaintProc, (XtPointer) this);
}
m_modalShowing = false;
if (!wxUSE_INVISIBLE_RESIZE && m_mainWidget)
{
XtUnmapWidget((Widget) m_mainWidget);
}
PreDestroy();
DoDestroy();
}
void wxDialog::DoDestroy()
{
if( m_mainWidget )
{
wxDeleteWindowFromTable( (Widget)m_mainWidget );
XtDestroyWidget( (Widget)m_mainWidget );
}
}
// By default, pressing escape cancels the dialog
void wxDialog::OnCharHook(wxKeyEvent& event)
{
if (event.m_keyCode == WXK_ESCAPE)
{
// Behaviour changed in 2.0: we'll send a Cancel message
// to the dialog instead of Close.
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent);
return;
}
// We didn't process this event.
event.Skip();
}
void wxDialog::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_ANY, NULL);
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
XtVaSetValues((Widget) m_mainWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
}
void wxDialog::DoSetClientSize(int width, int height)
{
wxWindow::SetSize(-1, -1, width, height);
}
void wxDialog::SetTitle(const wxString& title)
{
wxTopLevelWindow::SetTitle( title );
if( !title.empty() )
{
wxXmString str( title );
XtVaSetValues( (Widget)m_mainWidget,
XmNtitle, title.c_str(),
XmNdialogTitle, str(), // Roberto Cocchi
XmNiconName, title.c_str(),
NULL );
}
}
bool wxDialog::Show( bool show )
{
if( !wxWindowBase::Show( show ) )
return false;
m_isShown = show;
if (show)
{
if (!wxUSE_INVISIBLE_RESIZE)
XtMapWidget(XtParent((Widget) m_mainWidget));
else
XtManageChild((Widget)m_mainWidget) ;
XRaiseWindow( XtDisplay( (Widget)m_mainWidget ),
XtWindow( (Widget)m_mainWidget) );
}
else
{
if (!wxUSE_INVISIBLE_RESIZE)
XtUnmapWidget(XtParent((Widget) m_mainWidget));
else
XtUnmanageChild((Widget)m_mainWidget) ;
XFlush(XtDisplay((Widget)m_mainWidget));
XSync(XtDisplay((Widget)m_mainWidget), False);
}
return true;
}
// Shows a dialog modally, returning a return code
int wxDialog::ShowModal()
{
m_windowStyle |= wxDIALOG_MODAL;
Show(true);
// after the event loop ran, the widget might already have been destroyed
WXDisplay* display = (WXDisplay*)XtDisplay( (Widget)m_mainWidget );
if (m_modalShowing)
return 0;
m_eventLoop = new wxEventLoop;
m_modalShowing = true;
XtAddGrab((Widget) m_mainWidget, True, False);
m_eventLoop->Run();
// Now process all events in case they get sent to a destroyed dialog
wxFlushEvents( display );
delete m_eventLoop;
m_eventLoop = NULL;
// TODO: is it safe to call this, if the dialog may have been deleted
// by now? Probably only if we're using delayed deletion of dialogs.
return GetReturnCode();
}
void wxDialog::EndModal(int retCode)
{
if (!m_modalShowing)
return;
SetReturnCode(retCode);
// Strangely, we don't seem to need this now.
// XtRemoveGrab((Widget) m_mainWidget);
Show(false);
m_modalShowing = false;
m_eventLoop->Exit();
}
// Standard buttons
void wxDialog::OnOK(wxCommandEvent& WXUNUSED(event))
{
if ( Validate() && TransferDataFromWindow() )
{
if ( IsModal() )
EndModal(wxID_OK);
else
{
SetReturnCode(wxID_OK);
this->Show(false);
}
}
}
void wxDialog::OnApply(wxCommandEvent& WXUNUSED(event))
{
if (Validate())
TransferDataFromWindow();
// TODO probably need to disable the Apply button until things change again
}
void wxDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
{
if ( IsModal() )
EndModal(wxID_CANCEL);
else
{
SetReturnCode(wxID_CANCEL);
this->Show(false);
}
}
void wxDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
{
// We'll send a Cancel message by default,
// which may close the dialog.
// Check for looping if the Cancel event handler calls Close().
// Note that if a cancel button and handler aren't present in the dialog,
// nothing will happen when you close the dialog via the window manager, or
// via Close().
// We wouldn't want to destroy the dialog by default, since the dialog may have been
// created on the stack.
// However, this does mean that calling dialog->Close() won't delete the dialog
// unless the handler for wxID_CANCEL does so. So use Destroy() if you want to be
// sure to destroy the dialog.
// The default OnCancel (above) simply ends a modal dialog, and hides a modeless dialog.
static wxList closing;
if ( closing.Member(this) )
return;
closing.Append(this);
wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL);
cancelEvent.SetEventObject( this );
GetEventHandler()->ProcessEvent(cancelEvent); // This may close the dialog
closing.DeleteObject(this);
}
// Destroy the window (delayed, if a managed window)
bool wxDialog::Destroy()
{
if (!wxPendingDelete.Member(this))
wxPendingDelete.Append(this);
return true;
}
void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event))
{
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
Refresh();
}
void wxDialog::ChangeFont(bool keepOriginalSize)
{
wxWindow::ChangeFont(keepOriginalSize);
}
void wxDialog::ChangeBackgroundColour()
{
if (GetMainWidget())
wxDoChangeBackgroundColour(GetMainWidget(), m_backgroundColour);
}
void wxDialog::ChangeForegroundColour()
{
if (GetMainWidget())
wxDoChangeForegroundColour(GetMainWidget(), m_foregroundColour);
}

241
src/motif/dnd.cpp Normal file
View File

@@ -0,0 +1,241 @@
///////////////////////////////////////////////////////////////////////////////
// Name: dnd.cpp
// Purpose: wxDropTarget, wxDropSource classes
// Author: Julian Smart
// Id: $Id$
// Copyright: (c) 1998 Julian Smart
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "dnd.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#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( int WXUNUSED(flags) )
{
// 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

487
src/motif/evtloop.cpp Normal file
View File

@@ -0,0 +1,487 @@
///////////////////////////////////////////////////////////////////////////////
// Name: motif/evtloop.cpp
// Purpose: implements wxEventLoop for Motif
// Author: Mattia Barbon
// Modified by:
// Created: 01.11.02
// RCS-ID: $Id$
// Copyright: (c) 2002 Mattia Barbon
// License: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "evtloop.h"
#endif
#ifdef __VMS
#define XtParent XTPARENT
#define XtDisplay XTDISPLAY
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#endif //WX_PRECOMP
#include "wx/evtloop.h"
#include "wx/event.h"
#include "wx/app.h"
#include "wx/window.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <X11/Xlib.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
static bool CheckForKeyUp(XEvent* event);
static bool CheckForKeyDown(XEvent* event);
static bool CheckForAccelerator(XEvent* event);
static void ProcessXEvent(XEvent* event);
static void wxBreakDispatch();
// ----------------------------------------------------------------------------
// wxEventLoopImpl
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxEventLoopImpl
{
public:
// ctor
wxEventLoopImpl() { SetExitCode(0); }
// set/get the exit code
void SetExitCode(int exitcode) { m_exitcode = exitcode; }
int GetExitCode() const { return m_exitcode; }
bool SendIdleMessage();
bool GetKeepGoing() const { return m_keepGoing; }
void SetKeepGoing(bool keepGoing) { m_keepGoing = keepGoing; }
private:
// the exit code of the event loop
int m_exitcode;
bool m_keepGoing;
};
// ----------------------------------------------------------------------------
// wxEventLoopImpl idle event processing
// ----------------------------------------------------------------------------
static bool SendIdleMessage()
{
return wxTheApp->ProcessIdle();
}
bool wxEventLoopImpl::SendIdleMessage()
{
return ::SendIdleMessage();
}
// ============================================================================
// wxEventLoop implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxEventLoop running and exiting
// ----------------------------------------------------------------------------
wxEventLoop *wxEventLoopBase::ms_activeLoop = NULL;
wxEventLoop::~wxEventLoop()
{
wxASSERT_MSG( !m_impl, _T("should have been deleted in Run()") );
}
int wxEventLoop::Run()
{
// event loops are not recursive, you need to create another loop!
wxCHECK_MSG( !IsRunning(), -1, _T("can't reenter a message loop") );
wxEventLoop *oldLoop = ms_activeLoop;
ms_activeLoop = this;
m_impl = new wxEventLoopImpl;
m_impl->SetKeepGoing( true );
for( ;; )
{
if( !wxDoEventLoopIteration( *this ) )
break;
}
int exitcode = m_impl->GetExitCode();
delete m_impl;
m_impl = NULL;
ms_activeLoop = oldLoop;
return exitcode;
}
void wxEventLoop::Exit(int rc)
{
wxCHECK_RET( IsRunning(), _T("can't call Exit() if not running") );
m_impl->SetExitCode(rc);
m_impl->SetKeepGoing( false );
::wxBreakDispatch();
}
// ----------------------------------------------------------------------------
// wxEventLoop message processing dispatching
// ----------------------------------------------------------------------------
bool wxEventLoop::Pending() const
{
return XtAppPending( (XtAppContext)wxTheApp->GetAppContext() ) != 0;
}
bool wxEventLoop::Dispatch()
{
XEvent event;
XtAppContext context = (XtAppContext)wxTheApp->GetAppContext();
if( XtAppPeekEvent( context, &event ) != 0 )
{
XtAppNextEvent( context, &event );
ProcessXEvent( &event );
}
else
#ifdef __VMS
XtAppProcessEvent( context, XtIMTimer|XtIMAlternateInput );
#else
XtAppProcessEvent( context, XtIMTimer|XtIMAlternateInput|XtIMSignal );
#endif
return m_impl ? m_impl->GetKeepGoing() : true;
}
// ----------------------------------------------------------------------------
// Static functions (originally in app.cpp)
// ----------------------------------------------------------------------------
void ProcessXEvent(XEvent* event)
{
if (event->type == KeyPress)
{
if (CheckForAccelerator(event))
{
// Do nothing! We intercepted and processed the event as an
// accelerator.
return;
}
// 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;
}
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)
{
wxTheApp->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 = event->xany.display;
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 an accelerator has been processed
bool CheckForAccelerator(XEvent* event)
{
if (event->xany.type == KeyPress)
{
// Find a wxWindow for this window
// TODO: should get display for the window, not the current display
Widget widget = XtWindowToWidget(event->xany.display,
event->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, event);
// 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) { wxFAIL; return false; }
bool CheckForKeyDown(XEvent* event)
{
if (event->xany.type == KeyPress)
{
Widget widget = XtWindowToWidget(event->xany.display,
event->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, event);
return win->GetEventHandler()->ProcessEvent( keyEvent );
}
return false;
}
// bool wxApp::CheckForKeyUp(WXEvent* event) { wxFAIL; return false; }
bool CheckForKeyUp(XEvent* event)
{
if (event->xany.type == KeyRelease)
{
Widget widget = XtWindowToWidget(event->xany.display,
event->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, event);
return win->GetEventHandler()->ProcessEvent( keyEvent );
}
return false;
}
// ----------------------------------------------------------------------------
// executes one main loop iteration (declared in include/wx/motif/private.h)
// ----------------------------------------------------------------------------
bool wxDoEventLoopIteration( wxEventLoop& evtLoop )
{
bool moreRequested, pendingEvents;
for(;;)
{
pendingEvents = evtLoop.Pending();
if( pendingEvents ) break;
moreRequested = ::SendIdleMessage();
if( !moreRequested ) break;
}
#if wxUSE_THREADS
if( !pendingEvents && !moreRequested )
{
// leave the main loop to give other threads a chance to
// perform their GUI work
wxMutexGuiLeave();
wxMilliSleep(20);
wxMutexGuiEnter();
}
#endif
if( !evtLoop.Dispatch() )
return false;
return true;
}
// ----------------------------------------------------------------------------
// ::wxWakeUpIdle implementation
// ----------------------------------------------------------------------------
// As per Vadim's suggestion, we open a pipe, and XtAppAddInputSource it;
// writing a single byte to the pipe will cause wxEventLoop::Pending
// to return true, and wxEventLoop::Dispatch to dispatch an input handler
// that simply removes the byte(s), and to return, which will cause
// an idle event to be sent
// also wxEventLoop::Exit is implemented that way, so that exiting an
// event loop won't require an event being in the queue
#include "wx/module.h"
#include <sys/types.h>
#include <sys/time.h>
#include <unistd.h>
static XtInputId inputId;
static int idleFds[2] = { -1, -1 };
class wxIdlePipeModule : public wxModule
{
public:
wxIdlePipeModule() {};
virtual bool OnInit()
{
// Must be done before modules are initialized
#if 0
if( pipe(idleFds) != 0 )
return false;
#endif
return true;
}
virtual void OnExit()
{
close( idleFds[0] );
close( idleFds[1] );
}
private:
DECLARE_DYNAMIC_CLASS(wxIdlePipeModule)
};
IMPLEMENT_DYNAMIC_CLASS(wxIdlePipeModule, wxModule);
static void wxInputCallback( XtPointer, int* fd, XtInputId* )
{
char buffer[128];
// wxWakeUpIdle may have been called more than once
for(;;)
{
fd_set in;
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
FD_ZERO( &in );
FD_SET( *fd, &in );
if( select( *fd + 1, &in, NULL, NULL, &timeout ) <= 0 )
break;
if( read( *fd, buffer, sizeof(buffer) - 1 ) != sizeof(buffer) - 1 )
break;
}
}
static void wxBreakDispatch()
{
char dummy = 0; // for valgrind
// check if wxWakeUpIdle has already been called
fd_set in;
struct timeval timeout;
timeout.tv_sec = 0;
timeout.tv_usec = 0;
FD_ZERO( &in );
FD_SET( idleFds[0], &in );
if( select( idleFds[0] + 1, &in, NULL, NULL, &timeout ) > 0 )
return;
// write a single byte
write( idleFds[1], &dummy, 1 );
}
void wxApp::WakeUpIdle()
{
::wxBreakDispatch();
}
bool wxInitIdleFds()
{
if( pipe(idleFds) != 0 )
return false;
return true;
}
bool wxAddIdleCallback()
{
if (!wxInitIdleFds())
return false;
// install input handler for wxWakeUpIdle
inputId = XtAppAddInput( (XtAppContext) wxTheApp->GetAppContext(),
idleFds[0],
(XtPointer)XtInputReadMask,
wxInputCallback,
NULL );
return true;
}

6
src/motif/fdiag.xbm Normal file
View File

@@ -0,0 +1,6 @@
#define fdiag_width 16
#define fdiag_height 16
static char fdiag_bits[] = {
0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20,
0x40, 0x40, 0x80, 0x80, 0x01, 0x01, 0x02, 0x02, 0x04, 0x04, 0x08, 0x08,
0x10, 0x10, 0x20, 0x20, 0x40, 0x40, 0x80, 0x80};

316
src/motif/filedlg.cpp Normal file
View File

@@ -0,0 +1,316 @@
/////////////////////////////////////////////////////////////////////////////
// Name: filedlg.cpp
// Purpose: wxFileDialog
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "filedlg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#define XtParent XTPARENT
#define XtWindow XTWINDOW
#endif
#include "wx/defs.h"
#include "wx/utils.h"
#include "wx/filedlg.h"
#include "wx/intl.h"
#include "wx/app.h"
#include "wx/settings.h"
#include "wx/tokenzr.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#include <Xm/MwmUtil.h>
#include <Xm/Label.h>
#include <Xm/BulletinB.h>
#include <Xm/Frame.h>
#include <Xm/Text.h>
#include <Xm/DialogS.h>
#include <Xm/FileSB.h>
#include <Xm/RowColumn.h>
#include <Xm/LabelG.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase)
#define DEFAULT_FILE_SELECTOR_SIZE 0
// Let Motif defines the size of File
// Selector Box (if 1), or fix it to
// wxFSB_WIDTH x wxFSB_HEIGHT (if 0)
#define wxFSB_WIDTH 600
#define wxFSB_HEIGHT 500
wxString wxFileDialog::m_fileSelectorAnswer = "";
bool wxFileDialog::m_fileSelectorReturned = false;
static void wxFileSelClose(Widget WXUNUSED(w),
void* WXUNUSED(client_data),
XmAnyCallbackStruct *WXUNUSED(call_data))
{
wxFileDialog::m_fileSelectorAnswer = "";
wxFileDialog::m_fileSelectorReturned = true;
}
void wxFileSelCancel( Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data),
XmFileSelectionBoxCallbackStruct *WXUNUSED(cbs) )
{
wxFileDialog::m_fileSelectorAnswer = "";
wxFileDialog::m_fileSelectorReturned = true;
}
void wxFileSelOk(Widget WXUNUSED(fs), XtPointer WXUNUSED(client_data), XmFileSelectionBoxCallbackStruct *cbs)
{
char *filename = NULL;
if (!XmStringGetLtoR(cbs->value, XmSTRING_DEFAULT_CHARSET, &filename)) {
wxFileDialog::m_fileSelectorAnswer = "";
wxFileDialog::m_fileSelectorReturned = true;
} else {
if (filename) {
wxFileDialog::m_fileSelectorAnswer = filename;
XtFree(filename);
}
wxFileDialog::m_fileSelectorReturned = true;
}
}
static wxString ParseWildCard( const wxString& wild )
{
#ifdef __WXDEBUG__
static const wxChar* msg =
_T("Motif file dialog does not understand this ")
_T("wildcard syntax");
#endif
wxArrayString wildDescriptions, wildFilters;
const size_t count = wxParseCommonDialogsFilter(wild,
wildDescriptions,
wildFilters);
wxCHECK_MSG( count, _T("*.*"), wxT("wxFileDialog: bad wildcard string") );
wxCHECK_MSG( count == 1, _T("*.*"), msg );
// check for *.txt;*.rtf
wxStringTokenizer tok2( wildFilters[0], _T(";") );
wxString wildcard = tok2.GetNextToken();
wxCHECK_MSG( tok2.CountTokens() <= 1, wildcard, msg );
return wildcard;
}
wxFileDialog::wxFileDialog(wxWindow *parent, const wxString& message,
const wxString& defaultDir, const wxString& defaultFileName, const wxString& wildCard,
long style, const wxPoint& pos)
:wxFileDialogBase(parent, message, defaultDir, defaultFileName, wildCard, style, pos)
{
m_filterIndex = 1;
}
static void wxChangeListBoxColours(wxWindow* WXUNUSED(win), Widget widget)
{
wxDoChangeBackgroundColour((WXWidget) widget, *wxWHITE);
// Change colour of the scrolled areas of the listboxes
Widget listParent = XtParent (widget);
#if 0
wxDoChangeBackgroundColour((WXWidget) listParent, *wxWHITE, true);
#endif
Widget hsb = (Widget) 0;
Widget vsb = (Widget) 0;
XtVaGetValues (listParent,
XmNhorizontalScrollBar, &hsb,
XmNverticalScrollBar, &vsb,
NULL);
/* TODO: should scrollbars be affected? Should probably have separate
* function to change them (by default, taken from wxSystemSettings)
*/
wxColour backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);
wxDoChangeBackgroundColour((WXWidget) hsb, backgroundColour, true);
wxDoChangeBackgroundColour((WXWidget) vsb, backgroundColour, true);
if (hsb)
XtVaSetValues (hsb,
XmNtroughColor, backgroundColour.AllocColour(XtDisplay(hsb)),
NULL);
if (vsb)
XtVaSetValues (vsb,
XmNtroughColor, backgroundColour.AllocColour(XtDisplay(vsb)),
NULL);
}
int wxFileDialog::ShowModal()
{
wxBeginBusyCursor();
// static char fileBuf[512];
Widget parentWidget = (Widget) 0;
if (m_parent)
parentWidget = (Widget) m_parent->GetTopWidget();
else
parentWidget = (Widget) wxTheApp->GetTopLevelWidget();
// prepare the arg list
Arg args[10];
int ac = 0;
wxComputeColours (XtDisplay(parentWidget), & m_backgroundColour,
(wxColour*) NULL);
XtSetArg(args[ac], XmNbackground, g_itemColors[wxBACK_INDEX].pixel); ac++;
XtSetArg(args[ac], XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel); ac++;
XtSetArg(args[ac], XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel); ac++;
XtSetArg(args[ac], XmNforeground, g_itemColors[wxFORE_INDEX].pixel); ac++;
Widget fileSel = XmCreateFileSelectionDialog(parentWidget, "file_selector", args, ac);
XtUnmanageChild(XmFileSelectionBoxGetChild(fileSel, XmDIALOG_HELP_BUTTON));
Widget filterWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_FILTER_TEXT);
Widget selectionWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_TEXT);
Widget dirListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_DIR_LIST);
Widget fileListWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_LIST);
// code using these vars disabled
#if 0
Widget okWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_OK_BUTTON);
Widget applyWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_APPLY_BUTTON);
Widget cancelWidget = XmFileSelectionBoxGetChild(fileSel, XmDIALOG_CANCEL_BUTTON);
#endif
Widget shell = XtParent(fileSel);
if (!m_message.IsNull())
XtVaSetValues(shell,
XmNtitle, wxConstCast(m_message.c_str(), char),
NULL);
wxString entirePath("");
if ((m_dir != "") && (m_fileName != ""))
{
entirePath = m_dir + wxString("/") + m_fileName;
}
else if ((m_dir != "") && (m_fileName == ""))
{
entirePath = m_dir + wxString("/");
}
else if ((m_dir == "") && (m_fileName != ""))
{
entirePath = m_fileName;
}
if (m_wildCard != "")
{
// return something understandable by Motif
wxString wildCard = ParseWildCard( m_wildCard );
wxString filter;
if (m_dir != "")
filter = m_dir + wxString("/") + wildCard;
else
filter = wildCard;
XmTextSetString(filterWidget, wxConstCast(filter.c_str(), char));
XmFileSelectionDoSearch(fileSel, NULL);
}
// Suggested by Terry Gitnick, 16/9/97, because of change in Motif
// file selector on Solaris 1.5.1.
if ( m_dir != "" )
{
wxXmString thePath( m_dir );
XtVaSetValues (fileSel,
XmNdirectory, thePath(),
NULL);
}
if (entirePath != "")
{
XmTextSetString(selectionWidget,
wxConstCast(entirePath.c_str(), char));
}
XtAddCallback(fileSel, XmNcancelCallback, (XtCallbackProc)wxFileSelCancel, (XtPointer)NULL);
XtAddCallback(fileSel, XmNokCallback, (XtCallbackProc)wxFileSelOk, (XtPointer)NULL);
XtAddCallback(fileSel, XmNunmapCallback,
(XtCallbackProc)wxFileSelClose, (XtPointer)this);
//#if XmVersion > 1000
// I'm not sure about what you mean with XmVersion.
// If this is for Motif1.1/Motif1.2, then check XmVersion>=1200
// (Motif1.1.4 ==> XmVersion 1100 )
// Nevertheless, I put here a #define, so anyone can choose in (I)makefile...
//
#if !DEFAULT_FILE_SELECTOR_SIZE
int width = wxFSB_WIDTH;
int height = wxFSB_HEIGHT;
XtVaSetValues(fileSel,
XmNwidth, width,
XmNheight, height,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
#endif
// wxDoChangeBackgroundColour((WXWidget) fileSel, m_backgroundColour);
wxDoChangeBackgroundColour((WXWidget) filterWidget, *wxWHITE);
wxDoChangeBackgroundColour((WXWidget) selectionWidget, *wxWHITE);
wxChangeListBoxColours(this, dirListWidget);
wxChangeListBoxColours(this, fileListWidget);
XtManageChild(fileSel);
m_fileSelectorAnswer = "";
m_fileSelectorReturned = false;
wxEndBusyCursor();
XtAddGrab(XtParent(fileSel), True, False);
XtAppContext context = (XtAppContext) wxTheApp->GetAppContext();
XEvent event;
while (!m_fileSelectorReturned)
{
XtAppNextEvent(context, &event);
XtDispatchEvent(&event);
}
XtRemoveGrab(XtParent(fileSel));
// XmUpdateDisplay((Widget) wxTheApp->GetTopLevelWidget()); // Experimental
Display* display = XtDisplay(fileSel);
XtUnmapWidget(XtParent(fileSel));
XtDestroyWidget(XtParent(fileSel));
// Now process all events, because otherwise
// this might remain on the screen
wxFlushEvents(display);
m_path = m_fileSelectorAnswer;
m_fileName = wxFileNameFromPath(m_fileSelectorAnswer);
m_dir = wxPathOnly(m_path);
if (m_fileName == "")
return wxID_CANCEL;
else
return wxID_OK;
}

644
src/motif/font.cpp Normal file
View File

@@ -0,0 +1,644 @@
/////////////////////////////////////////////////////////////////////////////
// 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
// ----------------------------------------------------------------------------
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "font.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#include "wx/defs.h"
#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/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"
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxFont, wxGDIObject)
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
#define wxUSE_RENDER_TABLE 1
#else
#define wxUSE_RENDER_TABLE 0
#endif
// ----------------------------------------------------------------------------
// 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
#if !wxUSE_RENDER_TABLE
WXFontList m_fontList; // Motif XmFontList
#else // if wxUSE_RENDER_TABLE
WXRenderTable m_renderTable; // Motif XmRenderTable
#endif
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;
#if !wxUSE_RENDER_TABLE
m_fontList = (WXFontList) 0;
#else // if wxUSE_RENDER_TABLE
m_renderTable = (WXRenderTable) 0;
#endif
m_display = (WXDisplay*) 0;
m_scale = 100;
}
wxXFont::~wxXFont()
{
#if !wxUSE_RENDER_TABLE
if (m_fontList)
XmFontListFree ((XmFontList) m_fontList);
m_fontList = NULL;
#else // if wxUSE_RENDER_TABLE
if (m_renderTable)
XmRenderTableFree ((XmRenderTable) m_renderTable);
m_renderTable = NULL;
#endif
// TODO: why does freeing the font produce a segv???
// Note that XFreeFont wasn't called in wxWin 1.68 either.
// MBN: probably some interaction with fonts being still
// in use in some widgets...
// 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()
{
wxList::compatibility_iterator node = m_fonts.GetFirst();
while (node)
{
wxXFont* f = (wxXFont*) node->GetData();
delete f;
node = node->GetNext();
}
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::DoSetNativeFontInfo(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;
}
const wxNativeFontInfo *wxFont::GetNativeFontInfo() const
{
wxCHECK_MSG( Ok(), (wxNativeFontInfo *)NULL, wxT("invalid font") );
if(M_FONTDATA->m_nativeFontInfo.GetXFontName().IsEmpty())
GetInternalFont();
return &(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
wxList::compatibility_iterator node = M_FONTDATA->m_fonts.GetFirst();
while (node)
{
wxXFont* f = (wxXFont*) node->GetData();
if ((!display || (f->m_display == display)) && (f->m_scale == intScale))
return f;
node = node->GetNext();
}
// 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;
M_FONTDATA->m_fonts.Append(f);
#if !wxUSE_RENDER_TABLE
f->m_fontList = XmFontListCreate ((XFontStruct*) font, XmSTRING_DEFAULT_CHARSET);
#else // if wxUSE_RENDER_TABLE
XmRendition rendition;
XmRenderTable renderTable;
Arg args[5];
int count = 0;
XtSetArg( args[count], XmNfont, font ); ++count;
XtSetArg( args[count], XmNunderlineType,
GetUnderlined() ? XmSINGLE_LINE : XmNO_LINE ); ++count;
rendition = XmRenditionCreate( XmGetXmDisplay( (Display*)f->m_display ),
(XmStringTag)"",
args, count );
renderTable = XmRenderTableAddRenditions( NULL, &rendition, 1,
XmMERGE_REPLACE );
f->m_renderTable = (WXRenderTable)renderTable;
#endif
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
{
#if !wxUSE_RENDER_TABLE
wxXFont* f = GetInternalFont(scale, display);
return (f ? f->m_fontList : (WXFontList) 0);
#else
return NULL;
#endif
}
// declared in the header, can't use wxUSE_RENDER_TABLE
#if wxCHECK_MOTIF_VERSION( 2, 0 )
WXRenderTable wxFont::GetRenderTable(WXDisplay* display) const
{
#if wxUSE_RENDER_TABLE
wxXFont* f = GetInternalFont(1.0, display);
return (f ? f->m_renderTable : (WXFontList) 0);
#else
return NULL;
#endif
}
#endif
WXFontType wxFont::GetFontType(WXDisplay* display) const
{
#if wxUSE_RENDER_TABLE
return Ok() ? GetRenderTable(display) : NULL;
#else
return Ok() ? GetFontList(1.0, display) : NULL;
#endif
}
WXFontType wxFont::GetFontTypeC(WXDisplay* display) const
{
#if wxUSE_RENDER_TABLE
return Ok() ? GetRenderTable(display) : NULL;
#else
return Ok() ? XmFontListCopy( (XmFontList)GetFontList(1.0, display) ) : NULL;
#endif
}
/*static*/ WXString wxFont::GetFontTag()
{
#if wxUSE_RENDER_TABLE
return (WXString)XmNrenderTable;
#else
return (WXString)XmNfontList;
#endif
}

694
src/motif/frame.cpp Normal file
View File

@@ -0,0 +1,694 @@
/////////////////////////////////////////////////////////////////////////////
// Name: motif/frame.cpp
// Purpose: wxFrame
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "frame.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#define XtDisplay XTDISPLAY
#define XtWindow XTWINDOW
#define XtScreen XTSCREEN
#endif
#include "wx/frame.h"
#include "wx/statusbr.h"
#include "wx/toolbar.h"
#include "wx/menu.h"
#include "wx/settings.h"
#include "wx/utils.h"
#include "wx/log.h"
#include "wx/app.h"
#include "wx/icon.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#if defined(__ultrix) || defined(__sgi)
#include <Xm/Frame.h>
#endif
#include <Xm/Xm.h>
#include <X11/Shell.h>
#include <X11/Core.h>
#if XmVersion >= 1002
#include <Xm/XmAll.h>
#else
#include <Xm/Frame.h>
#endif
#include <Xm/MwmUtil.h>
#include <Xm/BulletinB.h>
#include <Xm/Form.h>
#include <Xm/MainW.h>
#include <Xm/RowColumn.h>
#include <Xm/Label.h>
#include <Xm/AtomMgr.h>
#include <Xm/LabelG.h>
#include <Xm/Frame.h>
#if XmVersion > 1000
#include <Xm/Protocols.h>
#endif
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
#include "wx/unix/utilsx11.h"
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
static void wxFrameMapProc(Widget frameShell, XtPointer clientData,
XCrossingEvent* event);
// ----------------------------------------------------------------------------
// globals
// ----------------------------------------------------------------------------
extern wxList wxModelessWindows;
extern wxList wxPendingDelete;
// ----------------------------------------------------------------------------
// wxWin macros
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxFrame, wxFrameBase)
EVT_ACTIVATE(wxFrame::OnActivate)
EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow)
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// frame construction
// ----------------------------------------------------------------------------
void wxFrame::Init()
{
m_iconized = false;
//// Motif-specific
m_frameShell = (WXWidget) NULL;
m_mainWidget = (WXWidget) NULL;
m_workArea = (WXWidget) NULL;
m_clientArea = (WXWidget) NULL;
}
bool wxFrame::Create(wxWindow *parent,
wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
if( !wxTopLevelWindow::Create( parent, id, title, pos, size, style,
name ) )
return false;
m_backgroundColour =
wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE);
m_foregroundColour = *wxBLACK;
m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
int x = pos.x, y = pos.y;
int width = size.x, height = size.y;
// Set reasonable values for position and size if defaults have been
// requested
//
// MB TODO: something better than these arbitrary values ?
// VZ should use X resources for this...
if ( width == -1 )
width = 400;
if ( height == -1 )
height = 400;
int displayW, displayH;
wxDisplaySize( &displayW, &displayH );
if ( x == -1 )
{
x = (displayW - width) / 2;
if (x < 10) x = 10;
}
if ( y == -1 )
{
y = (displayH - height) / 2;
if (y < 10) y = 10;
}
SetTitle( title );
wxLogTrace(wxTRACE_Messages,
"Created frame (0x%p) with work area 0x%p and client "
"area 0x%p", m_mainWidget, m_workArea, m_clientArea);
XtAddEventHandler((Widget) m_clientArea, ExposureMask,False,
wxUniversalRepaintProc, (XtPointer) this);
if (x > -1)
XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
if (y > -1)
XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
if (width > -1)
XtVaSetValues((Widget) m_frameShell, XmNwidth, width, NULL);
if (height > -1)
XtVaSetValues((Widget) m_frameShell, XmNheight, height, NULL);
ChangeFont(false);
ChangeBackgroundColour();
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
return true;
}
bool wxFrame::DoCreate( wxWindow* parent, wxWindowID id,
const wxString& title,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name )
{
Widget frameShell;
frameShell = XtCreatePopupShell( name, topLevelShellWidgetClass,
(Widget)wxTheApp->GetTopLevelWidget(),
NULL, 0 );
XtVaSetValues(frameShell,
// Allows menu to resize
XmNallowShellResize, True,
XmNdeleteResponse, XmDO_NOTHING,
XmNmappedWhenManaged, False,
XmNiconic, (style & wxICONIZE) ? True : False,
NULL);
m_frameShell = (WXWidget)frameShell;
m_mainWidget = (WXWidget) XtVaCreateManagedWidget("main_window",
xmMainWindowWidgetClass, frameShell,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_workArea = (WXWidget) XtVaCreateWidget("form",
xmFormWidgetClass, (Widget) m_mainWidget,
XmNresizePolicy, XmRESIZE_NONE,
NULL);
m_clientArea = (WXWidget) XtVaCreateWidget("client",
xmBulletinBoardWidgetClass, (Widget) m_workArea,
XmNmarginWidth, 0,
XmNmarginHeight, 0,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_FORM,
XmNbottomAttachment, XmATTACH_FORM,
NULL);
XtVaSetValues((Widget) m_mainWidget,
XmNworkWindow, (Widget) m_workArea,
NULL);
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
XtTranslations ptr = XtParseTranslationTable( "<Configure>: resize()" );
XtOverrideTranslations( (Widget) m_workArea, ptr );
XtFree( (char *)ptr );
/* Part of show-&-hide fix */
XtAddEventHandler( frameShell, StructureNotifyMask,
False, (XtEventHandler)wxFrameMapProc,
(XtPointer)this );
XtRealizeWidget(frameShell);
wxAddWindowToTable( (Widget)m_workArea, this);
wxAddWindowToTable( (Widget)m_clientArea, this);
wxModelessWindows.Append( this );
return true;
}
wxFrame::~wxFrame()
{
m_isBeingDeleted = true;
if (m_clientArea)
{
XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, False,
wxUniversalRepaintProc, (XtPointer) this);
}
if (GetMainWidget())
Show(false);
if (m_frameMenuBar)
{
m_frameMenuBar->DestroyMenuBar();
// Hack to stop core dump on Ultrix, OSF, for some strange reason.
#if MOTIF_MENUBAR_DELETE_FIX
GetMenuBar()->SetMainWidget((WXWidget) NULL);
#endif
delete m_frameMenuBar;
m_frameMenuBar = NULL;
}
if (m_frameStatusBar)
{
delete m_frameStatusBar;
m_frameStatusBar = NULL;
}
PreDestroy();
DoDestroy();
}
void wxFrame::DoDestroy()
{
Widget frameShell = (Widget)GetShellWidget();
if( frameShell )
XtRemoveEventHandler( frameShell, StructureNotifyMask,
False, (XtEventHandler)wxFrameMapProc,
(XtPointer)this );
if( m_clientArea )
{
wxDeleteWindowFromTable( (Widget)m_clientArea );
XtDestroyWidget( (Widget)m_clientArea );
}
if( m_workArea )
{
XtVaSetValues( (Widget)m_mainWidget,
XmNworkWindow, (Widget)NULL,
NULL );
wxDeleteWindowFromTable( (Widget)m_workArea );
XtDestroyWidget( (Widget)m_workArea );
}
if( m_mainWidget )
XtDestroyWidget( (Widget)m_mainWidget );
if( frameShell )
XtDestroyWidget( frameShell );
}
// Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
void wxFrame::DoGetClientSize(int *x, int *y) const
{
Dimension xx, yy;
XtVaGetValues((Widget) m_workArea, XmNwidth, &xx, XmNheight, &yy, NULL);
if (m_frameStatusBar)
{
int sbw, sbh;
m_frameStatusBar->GetSize(& sbw, & sbh);
yy -= sbh;
}
#if wxUSE_TOOLBAR
if (m_frameToolBar)
{
int tbw, tbh;
m_frameToolBar->GetSize(& tbw, & tbh);
if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
xx -= tbw;
else
yy -= tbh;
}
#endif // wxUSE_TOOLBAR
//CE found a call here with NULL y pointer
if (x)
*x = xx;
if (y)
*y = yy;
}
// Set the client size (i.e. leave the calculation of borders etc.
// to wxWidgets)
void wxFrame::DoSetClientSize(int width, int height)
{
// Calculate how large the new main window should be
// by finding the difference between the client area and the
// main window area, and adding on to the new client area
if (width > -1)
XtVaSetValues((Widget) m_workArea, XmNwidth, width, NULL);
if (height > -1)
{
if (m_frameStatusBar)
{
int sbw, sbh;
m_frameStatusBar->GetSize(& sbw, & sbh);
height += sbh;
}
#if wxUSE_TOOLBAR
if (m_frameToolBar)
{
int tbw, tbh;
m_frameToolBar->GetSize(& tbw, & tbh);
if (m_frameToolBar->GetWindowStyleFlag() & wxTB_VERTICAL)
width += tbw;
else
height += tbh;
}
#endif // wxUSE_TOOLBAR
XtVaSetValues((Widget) m_workArea, XmNheight, height, NULL);
}
PreResize();
wxSizeEvent sizeEvent(wxSize(width, height), GetId());
sizeEvent.SetEventObject(this);
GetEventHandler()->ProcessEvent(sizeEvent);
}
void wxFrame::DoGetSize(int *width, int *height) const
{
Dimension xx, yy;
XtVaGetValues((Widget) m_frameShell, XmNwidth, &xx, XmNheight, &yy, NULL);
*width = xx; *height = yy;
}
void wxFrame::DoSetSize(int x, int y, int width, int height, int WXUNUSED(sizeFlags))
{
if (x > -1)
XtVaSetValues((Widget) m_frameShell, XmNx, x, NULL);
if (y > -1)
XtVaSetValues((Widget) m_frameShell, XmNy, y, NULL);
if (width > -1)
XtVaSetValues((Widget) m_mainWidget, XmNwidth, width, NULL);
if (height > -1)
XtVaSetValues((Widget) m_mainWidget, XmNheight, height, NULL);
if (!(height == -1 && width == -1))
{
PreResize();
}
}
bool wxFrame::Show( bool show )
{
if( !wxWindowBase::Show( show ) )
return false;
m_isShown = show;
Widget shell = (Widget)GetShellWidget();
if (!shell)
return wxWindow::Show(show);
SetVisibleStatus(show);
if (show)
{
XtPopup(shell, XtGrabNone);
}
else
{
XtPopdown(shell);
}
return true;
}
void wxFrame::SetTitle(const wxString& title)
{
wxString oldTitle = GetTitle();
if( title == oldTitle )
return;
wxTopLevelWindow::SetTitle( title );
if( !title.empty() )
XtVaSetValues( (Widget)m_frameShell,
XmNtitle, title.c_str(),
XmNiconName, title.c_str(),
NULL );
}
void wxFrame::DoSetIcon(const wxIcon& icon)
{
if (!m_frameShell)
return;
if (!icon.Ok() || !icon.GetDrawable())
return;
XtVaSetValues((Widget) m_frameShell,
XtNiconPixmap, icon.GetDrawable(),
NULL);
}
void wxFrame::SetIcon(const wxIcon& icon)
{
SetIcons( wxIconBundle( icon ) );
}
void wxFrame::SetIcons(const wxIconBundle& icons)
{
wxFrameBase::SetIcons( icons );
if (!m_frameShell)
return;
DoSetIcon( m_icons.GetIcon( -1 ) );
wxSetIconsX11(GetXDisplay(),
(WXWindow) XtWindow( (Widget) m_frameShell ), icons);
}
void wxFrame::PositionStatusBar()
{
if (!m_frameStatusBar)
return;
int w, h;
GetClientSize(&w, &h);
int sw, sh;
m_frameStatusBar->GetSize(&sw, &sh);
// Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
m_frameStatusBar->SetSize(0, h, w, sh);
}
WXWidget wxFrame::GetMenuBarWidget() const
{
if (GetMenuBar())
return GetMenuBar()->GetMainWidget();
else
return (WXWidget) NULL;
}
void wxFrame::SetMenuBar(wxMenuBar *menuBar)
{
if (!menuBar)
{
m_frameMenuBar = NULL;
return;
}
// Currently can't set it twice
// wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
if (m_frameMenuBar)
{
m_frameMenuBar->DestroyMenuBar();
delete m_frameMenuBar;
}
m_frameMenuBar = menuBar;
m_frameMenuBar->CreateMenuBar(this);
}
// Responds to colour changes, and passes event on to children.
void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event)
{
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE));
Refresh();
if ( m_frameStatusBar )
{
wxSysColourChangedEvent event2;
event2.SetEventObject( m_frameStatusBar );
m_frameStatusBar->ProcessEvent(event2);
}
// Propagate the event to the non-top-level children
wxWindow::OnSysColourChanged(event);
}
// Default activation behaviour - set the focus for the first child
// subwindow found.
void wxFrame::OnActivate(wxActivateEvent& event)
{
if (!event.GetActive())
return;
for(wxWindowList::compatibility_iterator node = GetChildren().GetFirst(); node;
node = node->GetNext())
{
// Find a child that's a subwindow, but not a dialog box.
wxWindow *child = node->GetData();
if (!child->IsTopLevel())
{
child->SetFocus();
return;
}
}
}
void wxFrame::SendSizeEvent()
{
wxSizeEvent event(GetSize(), GetId());
event.SetEventObject(this);
GetEventHandler()->AddPendingEvent(event);
}
#if wxUSE_TOOLBAR
wxToolBar* wxFrame::CreateToolBar(long style,
wxWindowID id,
const wxString& name)
{
if ( wxFrameBase::CreateToolBar(style, id, name) )
{
PositionToolBar();
}
return m_frameToolBar;
}
void wxFrame::SetToolBar(wxToolBar *toolbar)
{
wxFrameBase::SetToolBar(toolbar);
SendSizeEvent();
}
void wxFrame::PositionToolBar()
{
wxToolBar* tb = GetToolBar();
if (tb)
{
int cw, ch;
GetClientSize(& cw, &ch);
int tw, th;
tb->GetSize(& tw, & th);
if (tb->GetWindowStyleFlag() & wxTB_VERTICAL)
{
// Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
// means, pretend we don't have toolbar/status bar, so we
// have the original client size.
th = ch + th;
}
else
{
// Use the 'real' position
tw = cw;
}
tb->SetSize(0, 0, -1, -1, wxSIZE_NO_ADJUSTMENTS);
}
}
#endif // wxUSE_TOOLBAR
//// Motif-specific
bool wxFrame::PreResize()
{
#if wxUSE_TOOLBAR
PositionToolBar();
#endif // wxUSE_TOOLBAR
#if wxUSE_STATUSBAR
PositionStatusBar();
#endif // wxUSE_STATUSBAR
return true;
}
WXWidget wxFrame::GetClientWidget() const
{
return m_clientArea;
}
void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize))
{
// TODO
}
void wxFrame::ChangeBackgroundColour()
{
if (GetClientWidget())
wxDoChangeBackgroundColour(GetClientWidget(), m_backgroundColour);
}
void wxFrame::ChangeForegroundColour()
{
if (GetClientWidget())
wxDoChangeForegroundColour(GetClientWidget(), m_foregroundColour);
}
/* MATTEW: Used to insure that hide-&-show within an event cycle works */
static void wxFrameMapProc( Widget frameShell, XtPointer clientData,
XCrossingEvent* event )
{
wxFrame *tli = (wxFrame*)clientData;
XEvent *e = (XEvent *)event;
if( e->xany.type == MapNotify )
{
// Iconize fix
XtVaSetValues( frameShell, XmNiconic, (Boolean)False, NULL );
if( !tli->GetVisibleStatus() )
{
/* We really wanted this to be hidden! */
XtUnmapWidget( frameShell );
}
}
else if( e->xany.type == UnmapNotify )
// Iconize fix
XtVaSetValues( frameShell, XmNiconic, (Boolean)True, NULL );
}

785
src/motif/gauge.cpp Normal file
View File

@@ -0,0 +1,785 @@
/////////////////////////////////////////////////////////////////////////////
// Name: gauge.cpp
// Purpose: wxGauge class
// Author: Julian Smart
// Modified by:
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "gauge.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __VMS
#include <wx/vms_x_fix.h>
#undef XtDisplay
#undef XtScreen
#undef XtWindow
#undef XtIsRealized
#undef XtParent
#endif
# include "wx/gauge.h"
#ifdef __VMS__
#pragma message disable nosimpint
#endif
#include <Xm/Xm.h>
#ifdef __WXMOTIF20__
#include <Xm/Scale.h>
#endif // __WXMOTIF20__
#ifdef __VMS__
#pragma message enable nosimpint
#endif
#include "wx/motif/private.h"
IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
// XmGauge copyright notice:
/*
* Copyright 1994 GROUPE BULL
*
* Permission to use, copy, modify, and distribute this software and its
* documentation for any purpose and without fee is hereby granted, provided
* that the above copyright notice appear in all copies and that both that
* copyright notice and this permission notice appear in supporting
* documentation, and that the name of GROUPE BULL not be used in advertising
* or publicity pertaining to distribution of the software without specific,
* written prior permission. GROUPE BULL makes no representations about the
* suitability of this software for any purpose. It is provided "as is"
* without express or implied warranty.
*
* GROUPE BULL disclaims all warranties with regard to this software,
* including all implied warranties of merchantability and fitness,
* in no event shall GROUPE BULL be liable for any special,
* indirect or consequential damages or any damages
* whatsoever resulting from loss of use, data or profits,
* whether in an action of contract, negligence or other tortious
* action, arising out of or in connection with the use
* or performance of this software.
*
*/
//// PUBLIC XMGAUGE DECLARATIONS
typedef struct _XmGaugeClassRec* XmGaugeWidgetClass;
typedef struct _XmGaugeRec* XmGaugeWidget;
#ifdef __cplusplus
extern "C" WidgetClass xmGaugeWidgetClass;
#else
extern WidgetClass xmGaugeWidgetClass;
#endif
typedef struct _XmGaugeCallbackStruct{
int reason;
XEvent *event;
int value;
} XmGaugeCallbackStruct;
void
XmGaugeSetValue(Widget w, int value);
int
XmGaugeGetValue(Widget w);
#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
bool wxGauge::Create(wxWindow *parent, wxWindowID id,
int range,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
if( !CreateControl( parent, id, pos, size, style, validator, name ) )
return false;
Widget parentWidget = (Widget) parent->GetClientWidget();
Arg args[7];
int count = 4;
if (style & wxGA_HORIZONTAL)
{
XtSetArg (args[0], XmNorientation, XmHORIZONTAL);
XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_RIGHT);
}
else
{
XtSetArg (args[0], XmNorientation, XmVERTICAL);
XtSetArg (args[1], XmNprocessingDirection, XmMAX_ON_TOP);
}
XtSetArg(args[2], XmNminimum, 0);
XtSetArg(args[3], XmNmaximum, range);
#if wxCHECK_MOTIF_VERSION( 2, 0 ) && !wxCHECK_LESSTIF()
XtSetArg(args[4], XmNeditable, False); ++count;
XtSetArg(args[5], XmNslidingMode, XmTHERMOMETER); ++count;
// XtSetArg(args[6], XmNsliderVisual, XmFOREGROUND_COLOR ); ++count;
Widget gaugeWidget =
XtCreateManagedWidget("gauge", xmScaleWidgetClass,
parentWidget, args, count);
#else
Widget gaugeWidget =
XtCreateManagedWidget("gauge", xmGaugeWidgetClass,
parentWidget, args, count);
#endif
m_mainWidget = (WXWidget) gaugeWidget ;
XtManageChild (gaugeWidget);
int x = pos.x; int y = pos.y;
wxSize best = GetBestSize();
if( size.x != -1 ) best.x = size.x;
if( size.y != -1 ) best.y = size.y;
ChangeFont(false);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y,
best.x, best.y);
ChangeBackgroundColour();
return true;
}
wxSize wxGauge::DoGetBestSize() const
{
if( HasFlag(wxGA_HORIZONTAL) )
return wxSize( 100, 18 );
else
return wxSize( 18, 100 );
}
void wxGauge::SetShadowWidth(int w)
{
if (w == 0)
w = 1;
XtVaSetValues((Widget) m_mainWidget, XmNshadowThickness, w, NULL);
}
void wxGauge::SetRange(int r)
{
XtVaSetValues((Widget) m_mainWidget, XmNmaximum, r, NULL);
}
void wxGauge::SetValue(int pos)
{
XtVaSetValues((Widget) m_mainWidget, XmNvalue, pos, NULL);
}
int wxGauge::GetShadowWidth() const
{
Dimension w;
XtVaGetValues((Widget) m_mainWidget, XmNshadowThickness, &w, NULL);
return (int)w;
}
int wxGauge::GetRange() const
{
int r;
XtVaGetValues((Widget) m_mainWidget, XmNmaximum, &r, NULL);
return (int)r;
}
int wxGauge::GetValue() const
{
int pos;
XtVaGetValues((Widget) m_mainWidget, XmNvalue, &pos, NULL);
return pos;
}
void wxGauge::DoMoveWindow(int x, int y, int width, int height)
{
wxGaugeBase::DoMoveWindow( x, y, width, height );
#ifdef __WXMOTIF20__
XtVaSetValues( (Widget)m_mainWidget,
XmNscaleHeight, height,
NULL );
#endif
}
#if !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()
//// PRIVATE DECLARATIONS FOR XMGAUGE
#include <Xm/PrimitiveP.h>
#include <Xm/DrawP.h>
typedef struct {
int empty;
} XmGaugeClassPart;
typedef struct _XmGaugeClassRec {
CoreClassPart core_class;
XmPrimitiveClassPart primitive_class;
XmGaugeClassPart gauge_class;
} XmGaugeClassRec;
typedef struct _XmGaugePart{
int value;
int minimum;
int maximum;
unsigned char orientation;
unsigned char processingDirection;
XtCallbackList dragCallback;
XtCallbackList valueChangedCallback;
/* private fields */
Boolean dragging; /* drag in progress ? */
int oldx, oldy;
GC gc;
} XmGaugePart;
typedef struct _XmGaugeRec {
CorePart core;
XmPrimitivePart primitive;
XmGaugePart gauge;
} XmGaugeRec;
extern XmGaugeClassRec xmGaugeClassRec;
/* Copyright 1994 GROUPE BULL -- See license conditions in file COPYRIGHT */
//// XMGAUGE IMPLEMENTATION
void
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args);
void
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args);
void
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
static char translations[] =
"<Btn1Down>: GaugePick()\n\
<Btn1Motion>: GaugeDrag()\n\
<Btn1Up>: GaugeDrop()\n\
";
static XtActionsRec actions[] = {
{"GaugePick", GaugePick},
{"GaugeDrag", GaugeDrag},
{"GaugeDrop", GaugeDrop},
};
static void
DrawSlider(XmGaugeWidget gw, Boolean clear)
{
#define THIS gw->gauge
int size, sht;
float ratio;
/***chubraev
char string[20];
int len;
unsigned long backgr,foregr;
XRectangle rects[1];
***/
sht = gw->primitive.shadow_thickness;
ratio = (float)THIS.value/
(float)(THIS.maximum - THIS.minimum);
/***chubraev
sprintf(string,"%-d%%",(int)(ratio*100));
len=strlen(string);
XtVaGetValues(gw,XmNbackground,&backgr,XmNforeground,&foregr,NULL);
***/
if(clear) {
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
}
switch(THIS.orientation) {
case XmHORIZONTAL:
size = (int) ((gw->core.width - 2 * sht)*ratio);
/***chubraev
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
gw->core.height - 2 * sht, string, len);
***/
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, size, gw->core.height - 2 * sht);
/***chubraev
rects[0].x = sht; rects[0].y = sht;
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
***/
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
gw->core.width - size - sht, sht,
size, gw->core.height - 2 * sht);
/***chubraev
rects[0].x = gw->core.width - size - sht; rects[0].y = sht;
rects[0].width = size; rects[0].height = gw->core.height - 2 * sht;
***/
break;
}
/***chubraev
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
gw->core.height - 2 * sht, string, len);
***/
break;
case XmVERTICAL:
size = (int) ((gw->core.height - 2 * sht)*ratio);
/***chubraev
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
sht+gw->core.height/2, string,len);
***/
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, gw->core.width - 2 * sht, size);
/***chubraev
rects[0].x = sht; rects[0].y = sht;
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
***/
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, gw->core.height - size - sht,
gw->core.width - 2 * sht, size);
/***chubraev
rects[0].x = sht; rects[0].y = gw->core.height - size - sht;
rects[0].width = gw->core.width - 2 * sht; rects[0].height = size;
***/
}
/***chubraev
XSetClipRectangles(XtDisplay(gw), THIS.gc, 0, 0, rects, 1, Unsorted);
XSetForeground(XtDisplay(gw), THIS.gc, backgr);
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
sht+gw->core.height/2, string,len);
***/
break;
}
/***chubraev
XSetClipMask(XtDisplay(gw), THIS.gc, None);
XSetForeground(XtDisplay(gw), THIS.gc, foregr);
***/
#undef THIS
}
/* Old code
*/
#if 0
static void
DrawSlider(XmGaugeWidget gw, Boolean clear)
{
#define THIS gw->gauge
int size, sht;
/* float ratio; */
sht = gw->primitive.shadow_thickness;
/* See fix comment below: can cause divide by zero error.
ratio = (float)((float)THIS.maximum -
(float)THIS.minimum) / (float)THIS.value;
*/
if(clear) {
XClearArea(XtDisplay(gw), XtWindow(gw), sht, sht,
gw->core.width - 2 * sht, gw->core.height - 2 * sht, False);
}
switch(THIS.orientation) {
case XmHORIZONTAL:
/* size = (gw->core.width - 2 * sht) / ratio; */
/* A fix suggested by Dmitri Chubraev */
size = (gw->core.width - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, size, gw->core.height - 2 * sht);
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
gw->core.width - size - sht, sht,
size, gw->core.height - 2 * sht);
break;
}
break;
case XmVERTICAL:
size = (gw->core.height - 2 * sht) /((float)THIS.maximum-(float)THIS.minimum)*(float)THIS.value;
/* size = (gw->core.height - 2 * sht)/ ratio; */
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, sht, gw->core.width - 2 * sht, size);
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
XFillRectangle(XtDisplay(gw), XtWindow(gw), THIS.gc,
sht, gw->core.height - size - sht,
gw->core.width - 2 * sht, size);
}
break;
}
#undef THIS
}
#endif
static void
Initialize(Widget WXUNUSED(req), Widget new_w, ArgList WXUNUSED(args), Cardinal *WXUNUSED(num_args ))
{
XmGaugeWidget gw = (XmGaugeWidget)new_w;
#define THIS gw->gauge
XGCValues values;
values.foreground = gw->primitive.foreground;
THIS.gc = XtGetGC(new_w, GCForeground, &values);
#undef THIS
}
static void
Destroy(Widget w)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
XtReleaseGC(w, THIS.gc);
#undef THIS
}
static Boolean
SetValues(
Widget cw,
Widget WXUNUSED(rw),
Widget nw,
ArgList WXUNUSED(args),
Cardinal *WXUNUSED(num_args) )
{
XmGaugeWidget cgw = (XmGaugeWidget)cw;
XmGaugeWidget ngw = (XmGaugeWidget)nw;
Boolean redraw = False;
if(cgw->primitive.foreground != ngw->primitive.foreground) {
XGCValues values;
redraw = True;
XtReleaseGC(nw, ngw->gauge.gc);
values.foreground = ngw->primitive.foreground;
ngw->gauge.gc = XtGetGC(nw, GCForeground, &values);
}
if(cgw->gauge.value != ngw->gauge.value) {
redraw = True;
}
return redraw;
}
static void
ExposeProc(Widget w, XEvent *WXUNUSED(event), Region WXUNUSED(r))
{
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
int sht;
sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w),
gw->primitive.top_shadow_GC,
gw->primitive.bottom_shadow_GC,
0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN);
DrawSlider(gw, False);
#undef THIS
}
static XtResource
resources[] = {
#define offset(field) XtOffset(XmGaugeWidget, gauge.field)
{XmNvalue, XmCValue, XtRInt, sizeof(int),
offset(value), XtRImmediate, (caddr_t)10},
{XmNminimum, XmCValue, XtRInt, sizeof(int),
offset(minimum), XtRImmediate, (caddr_t)0},
{XmNmaximum, XmCValue, XtRInt, sizeof(int),
offset(maximum), XtRImmediate, (caddr_t)100},
{XmNorientation, XmCOrientation, XmROrientation, sizeof(unsigned char),
offset(orientation), XtRImmediate, (caddr_t)XmVERTICAL},
{XmNprocessingDirection, XmCProcessingDirection,
XmRProcessingDirection, sizeof(unsigned char),
offset(processingDirection), XtRImmediate, (caddr_t)XmMAX_ON_RIGHT},
{XmNdragCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
offset(dragCallback), XtRImmediate, (caddr_t)NULL},
{XmNvalueChangedCallback, XmCCallback, XmRCallback, sizeof(XtCallbackList),
offset(valueChangedCallback), XtRImmediate, (caddr_t)NULL},
#undef offset
};
XmGaugeClassRec xmGaugeClassRec = {
{ /* core fields */
(WidgetClass) &xmPrimitiveClassRec, /* superclass */
"XmGauge", /* class_name */
sizeof(XmGaugeRec), /* widget_size */
NULL, /* class_initialize */
NULL, /* class_part_initialize */
False, /* class_inited */
Initialize, /* initialize */
NULL, /* initialize_hook */
XtInheritRealize, /* realize */
actions, /* actions */
XtNumber(actions), /* num_actions */
resources, /* resources */
XtNumber(resources), /* num_resources */
NULLQUARK, /* xrm_class */
True, /* compress_motion */
True, /* compress_exposure */
True, /* compress_enterleave */
False, /* visible_interest */
Destroy, /* destroy */
NULL, /* resize */
ExposeProc, /* expose */
SetValues, /* set_values */
NULL, /* set_values_hook */
XtInheritSetValuesAlmost, /* set_values_almost */
NULL, /* get_values_hook */
NULL, /* accept_focus */
XtVersion, /* version */
NULL, /* callback_private */
translations, /* tm_table */
NULL, /* query_geometry */
NULL, /* display_accelerator */
NULL /* extension */
},
/* primitive_class fields */
{
NULL, /* border_highlight */
NULL, /* border_unhighlight */
NULL, /* translations */
NULL, /* arm_and_activate */
NULL, /* syn_resources */
0, /* num_syn_resources */
NULL /* extension */
},
{ /* gauge fields */
0 /* empty */
}
};
WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
void
GaugePick(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args))
{
/* Commented out for a read-only gauge in wxWidgets */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
int size, sht;
float ratio;
Boolean dragging = False;
XButtonEvent *event = (XButtonEvent *)e;
int x, y;
x = event->x;
y = event->y;
sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w),
gw->primitive.top_shadow_GC,
gw->primitive.bottom_shadow_GC,
0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN);
ratio = (float)((float)THIS.maximum -
(float)THIS.minimum) / (float)THIS.value;
switch(THIS.orientation) {
case XmHORIZONTAL:
size = (w->core.width - 2 * sht) / ratio;
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
dragging = (x > sht) && (y > sht) &&
(x < sht + size) && (y < w->core.height - sht);
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
dragging = (x > w->core.width - size - sht) && (y > sht) &&
(x < w->core.width - sht) && (y < w->core.height + sht);
break;
}
break;
case XmVERTICAL:
size = (w->core.height - 2 * sht) / ratio;
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
dragging = (x > sht) && (y > sht) &&
(x < w->core.width - sht) &&
(y < w->core.width - 2 * sht + size);
break;
case XmMAX_ON_LEFT:
case XmMAX_ON_TOP:
dragging = (x > sht) && (y > w->core.height - size - sht) &&
(x < w->core.width - sht) && (y < w->core.height - sht);
}
break;
}
THIS.dragging = dragging;
THIS.oldx = x;
THIS.oldy = y;
#undef THIS
#endif
}
#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
void
GaugeDrag(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args))
{
/* Commented out for a read-only gauge in wxWidgets */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
int sht, x, y, max, value;
float ratio, nratio, size, nsize, fvalue, delta;
XMotionEvent *event = (XMotionEvent *)e;
if( ! THIS.dragging) return;
x = event->x;
y = event->y;
sht = gw->primitive.shadow_thickness;
ratio = (float)THIS.value / (float)((float)THIS.maximum -
(float)THIS.minimum);
switch(THIS.orientation) {
case XmHORIZONTAL:
max = (w->core.width - 2 * sht);
size = (float)max * ratio;
delta = (float)x - (float)THIS.oldx;
break;
case XmVERTICAL:
max = (w->core.height - 2 * sht);
size = (float) max * ratio;
delta = (float)y - (float)THIS.oldy;
break;
}
switch(THIS.processingDirection) {
case XmMAX_ON_RIGHT:
case XmMAX_ON_BOTTOM:
nsize = size + delta;
break;
default:
nsize = size - delta;
}
if(nsize > (float)max) nsize = (float)max;
if(nsize < (float)0 ) nsize = (float)0;
nratio = nsize / (float)max;
fvalue = (int)((float)THIS.maximum -
(float)THIS.minimum) * (float)nsize / (float)max;
value = round(fvalue);
THIS.value = value;
THIS.oldx = x;
THIS.oldy = y;
/* clear old slider only if it was larger */
DrawSlider(gw, (nsize < size));
{
XmGaugeCallbackStruct call;
if(NULL != THIS.dragCallback) {
call.reason = XmCR_DRAG;
call.event = e;
call.value = THIS.value;
XtCallCallbacks(w, XmNdragCallback, &call);
}
}
#undef THIS
#endif
}
void
GaugeDrop(Widget WXUNUSED(w), XEvent *WXUNUSED(e), String *WXUNUSED(args), Cardinal *WXUNUSED(num_args))
{
/* Commented out for a read-only gauge in wxWidgets */
#if 0
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
if( ! THIS.dragging) return;
if(NULL != THIS.valueChangedCallback) {
XmGaugeCallbackStruct call;
call.reason = XmCR_VALUE_CHANGED;
call.event = e;
call.value = THIS.value;
XtCallCallbacks(w, XmNvalueChangedCallback, &call);
}
THIS.dragging = False;
#undef THIS
#endif
}
void
XmGaugeSetValue(Widget w, int value)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
gw->gauge.value = value;
DrawSlider(gw, True);
XFlush(XtDisplay(w));
}
int
XmGaugeGetValue(Widget w)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
return gw->gauge.value;
}
#endif // !wxCHECK_MOTIF_VERSION( 2, 0 ) || wxCHECK_LESSTIF()

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