1. more wxMotif fixes

2. wxGetNumberFromUser added
3. more compilation fixes when compiling without sockets


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3107 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-07-23 21:03:02 +00:00
parent c45a644eda
commit 31528cd3ca
63 changed files with 1153 additions and 1361 deletions

View File

@@ -47,6 +47,7 @@ scrolwin.cpp G
splitter.cpp G
statusbr.cpp G
tabg.cpp G
numdlgg.cpp G
textdlgg.cpp G
tipdlg.cpp G
treectrl.cpp G 16

View File

@@ -1307,11 +1307,10 @@ public:
virtual void OnCommand(wxWindow& WXUNUSED(win),
wxCommandEvent& WXUNUSED(event))
{
wxFAIL_MSG("shouldn't be called any more");
}
// Called if child control has no
// callback function
// Default behaviour
// Called if child control has no callback function
virtual long Default()
{ return GetNextHandler() ? GetNextHandler()->Default() : 0; };
#endif // WXWIN_COMPATIBILITY_2

View File

@@ -53,7 +53,7 @@ private:
};
// ----------------------------------------------------------------------------
// functions to get a string or a number from user
// function to get a string from user
// ----------------------------------------------------------------------------
wxString WXDLLEXPORT
@@ -65,15 +65,5 @@ wxGetTextFromUser(const wxString& message,
int y = -1,
bool centre = TRUE);
long WXDLLEXPORT
wxGetNumberFromUser(const wxString& message,
const wxString& prompt,
const wxString& caption,
long value = 0,
long min = 0,
long max = 100,
wxWindow *parent = (wxWindow *)NULL,
const wxPoint& pos = wxDefaultPosition);
#endif
// __TEXTDLGH_G__

View File

@@ -61,13 +61,13 @@ enum {
GSOCK_INPUT_FLAG = 1 << GSOCK_INPUT,
GSOCK_OUTPUT_FLAG = 1 << GSOCK_OUTPUT,
GSOCK_CONNECTION_FLAG = 1 << GSOCK_CONNECTION,
GSOCK_LOST_FLAG = 1 << GSOCK_LOST,
GSOCK_LOST_FLAG = 1 << GSOCK_LOST
};
typedef int GSocketEventFlags;
typedef void (*GSocketFallback)(GSocket *socket, GSocketEvent event,
char *cdata);
char *cdata);
#ifdef __cplusplus
extern "C" {
@@ -118,13 +118,13 @@ GSocketError GSocket_Connect(GSocket *socket, GSocketStream stream);
/* Generic IO */
/* Like recv(), send(), ... */
/*
/*
NOTE: In case we read from a non-oriented connection, the incoming (outgoing)
connection address is stored in the "Local" ("Peer") field.
connection address is stored in the "Local" ("Peer") field.
*/
int GSocket_Read(GSocket *socket, char *buffer, int size);
int GSocket_Write(GSocket *socket, const char *buffer,
int size);
int size);
bool GSocket_DataAvailable(GSocket *socket);
/* Flags */
@@ -143,15 +143,15 @@ GSocketError GSocket_GetError(GSocket *socket);
/* Callbacks */
/*
/*
Only one fallback is possible for each event (INPUT, OUTPUT, CONNECTION, LOST)
INPUT: The function is called when there is at least a byte in the
INPUT: The function is called when there is at least a byte in the
input buffer
OUTPUT: The function is called when the system is sure the next write call
will not block
CONNECTION: Two cases is possible:
Client socket -> the connection is established
Server socket -> a client request a connection
Server socket -> a client request a connection
LOST: the connection is lost
SetFallback accepts a combination of these flags so a same callback can
@@ -163,7 +163,7 @@ GSocketError GSocket_GetError(GSocket *socket);
CONNECTION -> GSocket_Accept()
*/
void GSocket_SetFallback(GSocket *socket, GSocketEventFlags event,
GSocketFallback fallback, char *cdata);
GSocketFallback fallback, char *cdata);
/*
UnsetFallback will disables all fallbacks specified by "event".
@@ -180,7 +180,7 @@ void GAddress_destroy(GAddress *address);
void GAddress_SetFamily(GAddress *address, GAddressType type);
GAddressType GAddress_GetFamily(GAddress *address);
/*
/*
The use of any of the next functions will set the address family to the adapted
one. For example if you use GAddress_INET_SetHostName, address family will be AF_INET
implicitely

View File

@@ -5,7 +5,7 @@
// Modified by:
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKSPINPUTTH__
@@ -15,89 +15,46 @@
#pragma interface
#endif
#include "wx/defs.h"
#ifdef wxUSE_SPINBTN
#include "wx/object.h"
#include "wx/control.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxSpinButton;
class wxSpinEvent;
//-----------------------------------------------------------------------------
// wxSpinButton
//-----------------------------------------------------------------------------
class wxSpinButton : public wxControl
class wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
wxSpinButton();
inline wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{
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" );
int GetValue() const;
void SetValue( int value );
void SetRange( int minVal, int maxVal );
int GetMin() const;
int GetMax() const;
// implementation
void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
GtkAdjustment *m_adjust;
float m_oldPos;
DECLARE_EVENT_TABLE()
};
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
class wxSpinEvent : public wxScrollEvent
{
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
wxSpinButton() { }
wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{
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" );
virtual int GetValue() const;
virtual void SetValue( int value );
virtual void SetRange( int minVal, int maxVal );
virtual int GetMin() const;
virtual int GetMax() const;
// implementation
void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
GtkAdjustment *m_adjust;
float m_oldPos;
private:
DECLARE_EVENT_TABLE()
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// Spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN(id, func) \
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#endif
#endif
// __GTKSPINBUTTH__

View File

@@ -5,7 +5,7 @@
// Modified by:
// RCS-ID: $Id$
// Copyright: (c) Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKSPINPUTTH__
@@ -15,89 +15,46 @@
#pragma interface
#endif
#include "wx/defs.h"
#ifdef wxUSE_SPINBTN
#include "wx/object.h"
#include "wx/control.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxSpinButton;
class wxSpinEvent;
//-----------------------------------------------------------------------------
// wxSpinButton
//-----------------------------------------------------------------------------
class wxSpinButton : public wxControl
class wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
wxSpinButton();
inline wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{
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" );
int GetValue() const;
void SetValue( int value );
void SetRange( int minVal, int maxVal );
int GetMin() const;
int GetMax() const;
// implementation
void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
GtkAdjustment *m_adjust;
float m_oldPos;
DECLARE_EVENT_TABLE()
};
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
class wxSpinEvent : public wxScrollEvent
{
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
wxSpinButton() { }
wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{
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" );
virtual int GetValue() const;
virtual void SetValue( int value );
virtual void SetRange( int minVal, int maxVal );
virtual int GetMin() const;
virtual int GetMax() const;
// implementation
void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window );
void ApplyWidgetStyle();
GtkAdjustment *m_adjust;
float m_oldPos;
private:
DECLARE_EVENT_TABLE()
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// Spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN(id, func) \
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#endif
#endif
// __GTKSPINBUTTH__

View File

@@ -6,14 +6,14 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_BUTTON_H_
#define _WX_BUTTON_H_
#ifdef __GNUG__
#pragma interface "button.h"
#pragma interface "button.h"
#endif
#include "wx/control.h"
@@ -24,31 +24,34 @@ WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
// Pushbutton
class WXDLLEXPORT wxButton: public wxControl
{
DECLARE_DYNAMIC_CLASS(wxButton)
public:
inline wxButton() {}
inline wxButton(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 = wxButtonNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
DECLARE_DYNAMIC_CLASS(wxButton)
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 = wxButtonNameStr);
public:
wxButton() { }
wxButton(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 = wxButtonNameStr)
{
Create(parent, id, label, pos, size, style, validator, name);
}
virtual void SetDefault();
virtual void Command(wxCommandEvent& event);
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 = wxButtonNameStr);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
virtual void SetDefault();
virtual void Command(wxCommandEvent& event);
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
};
#endif

View File

@@ -29,22 +29,28 @@ public:
wxControl();
~wxControl();
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // Simulates an event
virtual void ProcessCommand(wxCommandEvent& event); // Calls the callback and
// appropriate event handlers
// 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 ;
// Places item in centre of panel - so can't be used BEFORE panel->Fit()
void Centre(int direction = wxHORIZONTAL);
#if WXWIN_COMPATIBILITY
void Callback(const wxFunction function) { m_callback = function; }; // Adds callback
wxFunction GetCallback() { return m_callback; }
#endif // WXWIN_COMPATIBILITY
bool InSetValue() const { return m_inSetValue; }
protected:
#if WXWIN_COMPATIBILITY
wxFunction m_callback; // Callback associated with the window
#endif // WXWIN_COMPATIBILITY
bool m_inSetValue; // Motif: prevent callbacks being called while
// in SetValue

View File

@@ -39,9 +39,15 @@ extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win);
// ----------------------------------------------------------------------------
// key events related functions
// ----------------------------------------------------------------------------
extern char wxFindMnemonic(const char* s);
extern char * wxFindAccelerator (char *s);
extern XmString wxFindAcceleratorText (char *s);
extern char * wxFindAccelerator (const char *s);
extern XmString wxFindAcceleratorText (const char *s);
extern int wxCharCodeXToWX(KeySym keySym);
extern KeySym wxCharCodeWXToX(int id);

View File

@@ -6,97 +6,61 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPINBUTT_H_
#define _WX_SPINBUTT_H_
#ifdef __GNUG__
#pragma interface "spinbutt.h"
#pragma interface "spinbutt.h"
#endif
#include "wx/control.h"
#include "wx/event.h"
/*
The wxSpinButton is like a small scrollbar than is often placed next
to a text control.
wxSP_HORIZONTAL: horizontal spin button
wxSP_VERTICAL: vertical spin button (the default)
wxSP_ARROW_KEYS: arrow keys increment/decrement value
wxSP_WRAP: value wraps at either end
*/
class WXDLLEXPORT wxSpinButton: public wxControl
class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
public:
/*
* Public interface
*/
DECLARE_DYNAMIC_CLASS(wxSpinButton)
wxSpinButton();
public:
wxSpinButton() { }
inline wxSpinButton(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{
Create(parent, id, pos, size, style, name);
}
~wxSpinButton();
wxSpinButton(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton")
{
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");
bool Create(wxWindow *parent,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton");
// Attributes
////////////////////////////////////////////////////////////////////////////
// accessors
int GetValue() const;
int GetMin() const { return m_min; }
int GetMax() const { return m_max; }
int GetValue() const ;
void SetValue(int val) ;
void SetRange(int minVal, int maxVal) ;
inline int GetMin() const { return m_min; }
inline int GetMax() const { return m_max; }
// operations
void SetValue(int val);
void SetRange(int minVal, int maxVal);
// Operations
////////////////////////////////////////////////////////////////////////////
void Command(wxCommandEvent& event) { ProcessCommand(event); };
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
// Implementation
virtual void Command(wxCommandEvent& event) { (void)ProcessCommand(event); };
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
protected:
int m_min;
int m_max;
int m_min;
int m_max;
};
class WXDLLEXPORT wxSpinEvent: public wxScrollEvent
{
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// Spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN(id, func) \
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#endif
// _WX_SPINBUTT_H_

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBMP_H_
@@ -47,8 +47,10 @@ public:
virtual void SetBitmap(const wxBitmap& bitmap);
virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return FALSE;
}
wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; }

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATBOX_H_
@@ -45,8 +45,10 @@ public:
long style = 0,
const wxString& name = wxStaticBoxNameStr);
virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return FALSE;
}
void SetLabel(const wxString& label);
wxString GetLabel() const;

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_STATTEXT_H_
@@ -22,35 +22,40 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr;
class WXDLLEXPORT wxStaticText: public wxControl
{
DECLARE_DYNAMIC_CLASS(wxStaticText)
public:
inline wxStaticText() { }
DECLARE_DYNAMIC_CLASS(wxStaticText)
inline 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);
}
public:
wxStaticText() { }
bool Create(wxWindow *parent, wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const wxString& name = wxStaticTextNameStr);
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);
}
// operations
virtual void Command(wxCommandEvent& WXUNUSED(event)) {};
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
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
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
// implementation
// --------------
// operations
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return FALSE;
}
virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour();
};
#endif

View File

@@ -16,22 +16,11 @@
#pragma interface "textctrl.h"
#endif
#include "wx/control.h"
#include "wx/ioswrap.h"
// TODO Some platforms/compilers don't like inheritance from streambuf.
#if (defined(__BORLANDC__) && !defined(__WIN32__)) || defined(__MWERKS__)
#define NO_TEXT_WINDOW_STREAM
#endif
WXDLLEXPORT_DATA(extern const char*) wxTextCtrlNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
// Single-line text item
class WXDLLEXPORT wxTextCtrl: public wxControl
#ifndef NO_TEXT_WINDOW_STREAM
, public streambuf
#endif
class WXDLLEXPORT wxTextCtrl : public wxControl
{
DECLARE_DYNAMIC_CLASS(wxTextCtrl)
@@ -47,9 +36,6 @@ public:
long style = 0,
const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr)
#ifndef NO_TEXT_WINDOW_STREAM
: streambuf()
#endif
{
Create(parent, id, value, pos, size, style, validator, name);
}
@@ -101,20 +87,6 @@ public:
virtual void GetSelection(long* from, long* to) const;
virtual bool IsEditable() const ;
// streambuf implementation
#ifndef NO_TEXT_WINDOW_STREAM
int overflow(int i);
int sync();
int underflow();
#endif
wxTextCtrl& operator<<(const wxString& s);
wxTextCtrl& operator<<(int i);
wxTextCtrl& operator<<(long i);
wxTextCtrl& operator<<(float f);
wxTextCtrl& operator<<(double d);
wxTextCtrl& operator<<(const char c);
virtual bool LoadFile(const wxString& file);
virtual bool SaveFile(const wxString& file);
virtual void WriteText(const wxString& text);

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPINBUTT_H_
@@ -21,17 +21,8 @@
#if defined(__WIN95__)
/*
The wxSpinButton is like a small scrollbar than is often placed next
to a text control.
wxSP_HORIZONTAL: horizontal spin button
wxSP_VERTICAL: vertical spin button (the default)
wxSP_ARROW_KEYS: arrow keys increment/decrement value
wxSP_WRAP: value wraps at either end
*/
class WXDLLEXPORT wxSpinButton : public wxControl
class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
{
DECLARE_DYNAMIC_CLASS(wxSpinButton)
@@ -64,49 +55,16 @@ public:
// Attributes
////////////////////////////////////////////////////////////////////////////
int GetValue() const ;
void SetValue(int val) ;
void SetRange(int minVal, int maxVal);
int GetMin() const { return m_min; }
int GetMax() const { return m_max; }
// Operations
////////////////////////////////////////////////////////////////////////////
virtual int GetValue() const;
virtual void SetValue(int val);
virtual void SetRange(int minVal, int maxVal);
// IMPLEMENTATION
virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual bool MSWOnScroll(int orientation, WXWORD wParam,
WXWORD pos, WXHWND control);
protected:
int m_min;
int m_max;
};
class WXDLLEXPORT wxSpinEvent: public wxScrollEvent
{
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0);
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// Spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN(id, func) \
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#endif
// _WX_WIN95__
#endif

View File

@@ -1,19 +1,119 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/spinbutt.h
// Purpose: wxSpinButtonBase class
// Author: Julian Smart, Vadim Zeitlin
// Modified by:
// Created: 23.07.99
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_SPINBUTT_H_BASE_
#define _WX_SPINBUTT_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h"
#ifdef wxUSE_SPINBTN
#include "wx/control.h"
#include "wx/event.h"
// ----------------------------------------------------------------------------
// The wxSpinButton is like a small scrollbar than is often placed next
// to a text control.
//
// Styles:
// wxSP_HORIZONTAL: horizontal spin button
// wxSP_VERTICAL: vertical spin button (the default)
// wxSP_ARROW_KEYS: arrow keys increment/decrement value
// wxSP_WRAP: value wraps at either end
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSpinButtonBase : public wxControl
{
public:
wxSpinButtonBase() { InitBase(); }
// accessors
virtual int GetValue() const = 0;
virtual int GetMin() const { return m_min; }
virtual int GetMax() const { return m_max; }
// operations
virtual void SetValue(int val) = 0;
virtual void SetRange(int minVal, int maxVal)
{
m_min = minVal;
m_max = maxVal;
}
protected:
// init the base part of the control
void InitBase()
{
m_min = 0;
m_max = 100;
}
// the range value
int m_min;
int m_max;
};
// ----------------------------------------------------------------------------
// include the declaration of the real class
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/spinbutt.h"
#include "wx/msw/spinbutt.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/spinbutt.h"
#include "wx/motif/spinbutt.h"
#elif defined(__WXGTK__)
#include "wx/gtk/spinbutt.h"
#include "wx/gtk/spinbutt.h"
#elif defined(__WXQT__)
#include "wx/qt/spinbutt.h"
#include "wx/qt/spinbutt.h"
#elif defined(__WXMAC__)
#include "wx/mac/spinbutt.h"
#include "wx/mac/spinbutt.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/spinbutt.h"
#include "wx/stubs/spinbutt.h"
#endif
// ----------------------------------------------------------------------------
// the wxSpinButton event
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxSpinEvent : public wxScrollEvent
{
DECLARE_DYNAMIC_CLASS(wxSpinEvent)
public:
wxSpinEvent(wxEventType commandType = wxEVT_NULL, int id = 0)
: wxScrollEvent(commandType, id)
{
}
};
typedef void (wxEvtHandler::*wxSpinEventFunction)(wxSpinEvent&);
// macros for handling spin events
#define EVT_SPIN_UP(id, func) { wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN_DOWN(id, func) { wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func }
#define EVT_SPIN(id, func) \
{ wxEVT_SCROLL_TOP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_BOTTOM, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_LINEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEUP, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_PAGEDOWN, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },\
{ wxEVT_SCROLL_THUMBTRACK, id, -1, (wxObjectEventFunction) (wxEventFunction) (wxSpinEventFunction) & func },
#endif // wxUSE_SPINBTN
#endif
// _WX_SPINBUTT_H_BASE_

View File

@@ -7,5 +7,19 @@
#include "wx/generic/textdlgg.h"
#endif
// ----------------------------------------------------------------------------
// function to get a number from user
// ----------------------------------------------------------------------------
long WXDLLEXPORT
wxGetNumberFromUser(const wxString& message,
const wxString& prompt,
const wxString& caption,
long value = 0,
long min = 0,
long max = 100,
wxWindow *parent = (wxWindow *)NULL,
const wxPoint& pos = wxDefaultPosition);
#endif
// _WX_TEXTDLG_H_BASE_

View File

@@ -159,6 +159,9 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
// ... and attach this menu bar to the frame
SetMenuBar(menuBar);
(void)new wxTextCtrl(this, -1, "Hi!", wxPoint(20, 20),
wxSize(100, 30));
#if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2);

View File

@@ -281,10 +281,10 @@ bool wxDocument::OnSaveDocument(const wxString& file)
msgTitle = wxString(_("File error"));
#if wxUSE_STD_IOSTREAM
ofstream store(file.fn_str());
ofstream store(wxString(file.fn_str()));
if (store.fail() || store.bad())
#else
wxFileOutputStream store(file.fn_str());
wxFileOutputStream store(wxString(file.fn_str()));
if (store.LastError() != 0)
#endif
{
@@ -317,10 +317,10 @@ bool wxDocument::OnOpenDocument(const wxString& file)
msgTitle = wxString(_("File error"));
#if wxUSE_STD_IOSTREAM
ifstream store(file.fn_str());
ifstream store(wxString(file.fn_str()));
if (store.fail() || store.bad())
#else
wxFileInputStream store(file.fn_str());
wxFileInputStream store(wxString(file.fn_str()));
if (store.LastError() != 0)
#endif
{

View File

@@ -16,6 +16,13 @@
#pragma hdrstop
#endif
#if !wxUSE_SOCKETS
#undef wxUSE_FS_ZIP
#undef wxUSE_FS_INET
#define wxUSE_FS_ZIP 0
#define wxUSE_FS_INET 0
#endif
#if (wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
#include "wx/wfstream.h"

View File

@@ -29,6 +29,11 @@ limitation)
#pragma hdrstop
#endif
#if !wxUSE_SOCKETS
#undef wxUSE_FS_INET
#define wxUSE_FS_INET 0
#endif
#if wxUSE_FS_INET
#ifndef WXPRECOMP

View File

@@ -17,6 +17,11 @@
#pragma hdrstop
#endif
#if !wxUSE_SOCKETS
#undef wxUSE_FS_ZIP
#define wxUSE_FS_ZIP 0
#endif
#if wxUSE_FS_ZIP
#ifndef WXPRECOMP

View File

@@ -69,13 +69,13 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
int rshift = 0, gshift = 0, bshift = 0;
wxUint8 aByte;
wxUint16 aWord;
wxInt32 dbuf[4], aDword,
wxInt32 dbuf[4], aDword,
rmask = 0, gmask = 0, bmask = 0;
wxInt8 bbuf[4];
struct _cmap {
unsigned char r, g, b;
} *cmap = NULL;
off_t start_offset = stream.TellI();
image->Destroy();
@@ -87,7 +87,9 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
stream.Read( &bbuf, 2 );
stream.Read( dbuf, 4 * 4 );
#if 0 // unused
wxInt32 size = wxINT32_SWAP_ON_BE( dbuf[0] );
#endif
wxInt32 offset = wxINT32_SWAP_ON_BE( dbuf[2] );
stream.Read(dbuf, 4 * 2);
@@ -103,7 +105,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
wxLogError( _T("Image height > 32767 pixels for file.") );
return FALSE;
}
stream.Read( &aWord, 2 );
/*
TODO
@@ -116,7 +118,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
wxLogError( _T("unknown bitdepth in file.") );
return FALSE;
}
stream.Read( dbuf, 4 * 4 );
int comp = (int)wxINT32_SWAP_ON_BE( dbuf[0] );
if (comp != BI_RGB && comp != BI_RLE4 && comp != BI_RLE8 && comp != BI_BITFIELDS)
@@ -124,15 +126,15 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
wxLogError( _T("unknown encoding in Windows BMP file.") );
return FALSE;
}
stream.Read( dbuf, 4 * 2 );
int ncolors = (int)wxINT32_SWAP_ON_BE( dbuf[0] );
if (ncolors == 0)
ncolors = 1 << bpp;
/* some more sanity checks */
if (((comp == BI_RLE4) && (bpp != 4)) ||
((comp == BI_RLE8) && (bpp != 8)) ||
((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32)))
if (((comp == BI_RLE4) && (bpp != 4)) ||
((comp == BI_RLE8) && (bpp != 8)) ||
((comp == BI_BITFIELDS) && (bpp != 16 && bpp != 32)))
{
wxLogError( _T("encoding of BMP doesn't match bitdepth.") );
return FALSE;
@@ -229,13 +231,13 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
}
ptr = data;
}
int line = 0;
int column = 0;
int linesize = ((width * bpp + 31) / 32) * 4;
/* BMPs are stored upside down */
for (line = (height - 1); line >= 0; line--)
for (line = (height - 1); line >= 0; line--)
{
int linepos = 0;
for (column = 0; column < width;)
@@ -358,7 +360,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
{
unsigned char temp;
stream.Read( &aWord, 2 );
aWord = wxUINT16_SWAP_ON_BE( aWord );
aWord = wxUINT16_SWAP_ON_BE( aWord );
linepos += 2;
temp = (aWord & rmask) >> rshift;
ptr[poffset] = temp;
@@ -372,7 +374,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
{
unsigned char temp;
stream.Read( &aDword, 4 );
aDword = wxINT32_SWAP_ON_BE( aDword );
aDword = wxINT32_SWAP_ON_BE( aDword );
linepos += 4;
temp = (aDword & rmask) >> rshift;
ptr[poffset] = temp;
@@ -391,7 +393,7 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
break;
}
}
if (cmap)
if (cmap)
free(cmap);
image->SetMask( FALSE );

View File

@@ -54,7 +54,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
class wxSocketState : public wxObject {
public:
bool notify_state;
bool notify_state;
GSocketEventFlags evt_notify_state;
wxSocketBase::wxSockFlags socket_flags;
wxSocketBase::wxSockCbk c_callback;
@@ -112,7 +112,7 @@ wxSocketBase::~wxSocketBase()
bool wxSocketBase::Close()
{
if (m_socket)
if (m_socket)
{
if (m_notify_state == TRUE)
Notify(FALSE);
@@ -140,7 +140,7 @@ int wxSocketBase::DeferRead(char *buffer, size_t nbytes)
old_event_flags = NeededReq();
old_notify_state = m_notify_state;
SetNotify(GSOCK_INPUT_FLAG | GSOCK_LOST_FLAG);
Notify(TRUE);
@@ -415,7 +415,7 @@ void wxSocketBase::Discard()
SaveState();
SetFlags(NOWAIT | SPEED);
while (recv_size == MAX_BUFSIZE)
while (recv_size == MAX_BUFSIZE)
{
recv_size = Read(my_data, MAX_BUFSIZE).LastCount();
}
@@ -593,7 +593,7 @@ bool wxSocketBase::WaitForLost(long seconds, long milliseconds)
GSocketEventFlags wxSocketBase::EventToNotify(GSocketEvent evt)
{
switch (evt)
switch (evt)
{
case GSOCK_INPUT:
return GSOCK_INPUT_FLAG;
@@ -724,7 +724,7 @@ void wxSocketBase::CreatePushbackBefore(const char *buffer, size_t size)
m_unread = tmp;
}
m_unrd_size += size;
memcpy(m_unread, buffer, size);
@@ -870,9 +870,9 @@ bool wxSocketClient::WaitOnConnect(long seconds, long microseconds)
void wxSocketClient::OnRequest(GSocketEvent evt)
{
if (evt == GSOCK_CONNECTION)
if (evt == GSOCK_CONNECTION)
{
if (m_connected)
if (m_connected)
{
m_neededreq &= ~GSOCK_CONNECTION_FLAG;
return;

View File

@@ -19,6 +19,8 @@
#pragma hdrstop
#endif
#if wxUSE_HELP
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/string.h"
@@ -39,7 +41,7 @@
#endif
IMPLEMENT_CLASS(wxExtHelpController, wxHTMLHelpControllerBase)
/**
This class implements help via an external browser.
It requires the name of a directory containing the documentation
@@ -109,7 +111,7 @@ wxExtHelpController::DisplayHelp(wxString const &relativeURL)
long success;
command << m_BrowserName << _T(" -remote openURL(")
<< _T("file://") << m_MapFile
<< WXEXTHELP_SEPARATOR << relativeURL << _T(")");
<< WXEXTHELP_SEPARATOR << relativeURL << _T(")");
success = wxExecute(command);
if(success != 0 ) // returns PID on success
return TRUE;
@@ -117,9 +119,10 @@ wxExtHelpController::DisplayHelp(wxString const &relativeURL)
}
command = m_BrowserName;
command << _T(" file://")
<< m_MapFile << WXEXTHELP_SEPARATOR << relativeURL;
return wxExecute(command) != 0;
<< m_MapFile << WXEXTHELP_SEPARATOR << relativeURL;
return wxExecute(command) != 0;
#endif
}
#endif // wxUSE_HELP

View File

@@ -19,6 +19,8 @@
#pragma hdrstop
#endif
#if wxUSE_HELP
#ifndef WX_PRECOMP
#include "wx/setup.h"
#include "wx/string.h"
@@ -320,3 +322,4 @@ wxHTMLHelpControllerBase::OnQuit()
{
}
#endif // wxUSE_HELP

208
src/generic/numdlgg.cpp Normal file
View File

@@ -0,0 +1,208 @@
/////////////////////////////////////////////////////////////////////////////
// Name: numdlgg.cpp
// Purpose: wxGetNumberFromUser implementation
// Author: Vadim Zeitlin
// Modified by:
// Created: 23.07.99
// RCS-ID: $Id$
// Copyright: (c) Vadim Zeitlin
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#ifdef __GNUG__
#pragma interface "numdlgg.h"
#pragma implementation "numdlgg.h"
#endif
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include <stdio.h>
#include "wx/utils.h"
#include "wx/dialog.h"
#include "wx/button.h"
#include "wx/stattext.h"
#include "wx/textctrl.h"
#include "wx/intl.h"
#endif
// this is where wxGetNumberFromUser() is declared
#include "wx/generic/textdlgg.h"
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNumberEntryDialog : public wxDialog
{
public:
wxNumberEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value, long min, long max,
const wxPoint& pos);
long GetValue() const { return m_value; }
// implementation only
void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
protected:
wxTextCtrl *m_spinctrl; // TODO replace it with wxSpinCtrl once it's done
long m_value, m_min, m_max;
private:
DECLARE_EVENT_TABLE()
};
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// wxNumberEntryDialog
// ----------------------------------------------------------------------------
BEGIN_EVENT_TABLE(wxNumberEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxNumberEntryDialog::OnOK)
EVT_BUTTON(wxID_CANCEL, wxNumberEntryDialog::OnCancel)
END_EVENT_TABLE()
wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value,
long min,
long max,
const wxPoint& pos)
: wxDialog(parent, -1, caption,
pos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
{
// init members
// ------------
m_value = value;
m_max = max;
m_min = min;
// calculate the sizes
// -------------------
wxArrayString lines;
wxSize sizeText = SplitTextMessage(message, &lines);
wxSize sizeBtn = GetStandardButtonSize();
int wPrompt, hPrompt;
GetTextExtent(prompt, &wPrompt, &hPrompt);
long wText = wxMax(2*sizeBtn.GetWidth(),
wxMax(wPrompt, sizeText.GetWidth()));
long hText = GetStandardTextHeight();
long wDialog = 5*LAYOUT_X_MARGIN + wText + wPrompt;
long hDialog = 2*LAYOUT_Y_MARGIN +
sizeText.GetHeight() * lines.GetCount() +
2*LAYOUT_Y_MARGIN +
hText +
2*LAYOUT_Y_MARGIN +
sizeBtn.GetHeight() +
2*LAYOUT_Y_MARGIN;
// create the controls
// -------------------
// message
long x = 2*LAYOUT_X_MARGIN;
long y = CreateTextMessage(lines,
wxPoint(x, 2*LAYOUT_Y_MARGIN),
sizeText);
y += 2*LAYOUT_X_MARGIN;
// prompt
(void)new wxStaticText(this, -1, prompt,
wxPoint(x, y),
wxSize(wPrompt, hPrompt));
// spin ctrl
wxString valStr;
valStr.Printf("%lu", m_value);
m_spinctrl = new wxTextCtrl(this, -1, valStr,
wxPoint(x + wPrompt + LAYOUT_X_MARGIN, y),
wxSize(wText, hText));
y += hText + 2*LAYOUT_X_MARGIN;
// and buttons
CreateStandardButtons(wDialog, y, sizeBtn.GetWidth(), sizeBtn.GetHeight());
// set the dialog size and position
SetClientSize(wDialog, hDialog);
if ( pos == wxDefaultPosition )
{
// centre the dialog if no explicit position given
Centre(wxBOTH | wxCENTER_FRAME);
}
m_spinctrl->SetFocus();
}
void wxNumberEntryDialog::OnOK(wxCommandEvent& event)
{
if ( (sscanf(m_spinctrl->GetValue(), "%lu", &m_value) != 1) ||
(m_value < m_min) || (m_value > m_max) )
{
// not a number or out of range
m_value = -1;
}
EndModal(wxID_OK);
}
void wxNumberEntryDialog::OnCancel(wxCommandEvent& event)
{
m_value = -1;
EndModal(wxID_CANCEL);
}
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// wxGetTextFromUser is in utilscmn.cpp
long wxGetNumberFromUser(const wxString& msg,
const wxString& prompt,
const wxString& title,
long value,
long min,
long max,
wxWindow *parent,
const wxPoint& pos)
{
wxNumberEntryDialog dialog(parent, msg, prompt, title,
value, min, max, pos);
(void)dialog.ShowModal();
return dialog.GetValue();
}

View File

@@ -45,35 +45,6 @@
#include "wx/generic/textdlgg.h"
// ----------------------------------------------------------------------------
// private classes
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxNumberEntryDialog : public wxDialog
{
public:
wxNumberEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value, long min, long max,
const wxPoint& pos);
long GetValue() const { return m_value; }
// implementation only
void OnOK(wxCommandEvent& event);
void OnCancel(wxCommandEvent& event);
protected:
wxTextCtrl *m_spinctrl; // TODO replace it with wxSpinCtrl once it's done
long m_value, m_min, m_max;
private:
DECLARE_EVENT_TABLE()
};
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@@ -89,11 +60,6 @@ static const int wxID_TEXT = 3000;
// ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxNumberEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxNumberEntryDialog::OnOK)
EVT_BUTTON(wxID_CANCEL, wxNumberEntryDialog::OnCancel)
END_EVENT_TABLE()
BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
END_EVENT_TABLE()
@@ -168,129 +134,3 @@ void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
EndModal(wxID_OK);
}
// ----------------------------------------------------------------------------
// wxNumberEntryDialog
// ----------------------------------------------------------------------------
wxNumberEntryDialog::wxNumberEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& prompt,
const wxString& caption,
long value,
long min,
long max,
const wxPoint& pos)
: wxDialog(parent, -1, caption,
pos, wxDefaultSize,
wxDEFAULT_DIALOG_STYLE | wxDIALOG_MODAL)
{
// init members
// ------------
m_value = value;
m_max = max;
m_min = min;
// calculate the sizes
// -------------------
wxArrayString lines;
wxSize sizeText = SplitTextMessage(message, &lines);
wxSize sizeBtn = GetStandardButtonSize();
int wPrompt, hPrompt;
GetTextExtent(prompt, &wPrompt, &hPrompt);
long wText = wxMax(2*sizeBtn.GetWidth(),
wxMax(wPrompt, sizeText.GetWidth()));
long hText = GetStandardTextHeight();
long wDialog = 5*LAYOUT_X_MARGIN + wText + wPrompt;
long hDialog = 2*LAYOUT_Y_MARGIN +
sizeText.GetHeight() * lines.GetCount() +
2*LAYOUT_Y_MARGIN +
hText +
2*LAYOUT_Y_MARGIN +
sizeBtn.GetHeight() +
2*LAYOUT_Y_MARGIN;
// create the controls
// -------------------
// message
long x = 2*LAYOUT_X_MARGIN;
long y = CreateTextMessage(lines,
wxPoint(x, 2*LAYOUT_Y_MARGIN),
sizeText);
y += 2*LAYOUT_X_MARGIN;
// prompt
(void)new wxStaticText(this, -1, prompt,
wxPoint(x, y),
wxSize(wPrompt, hPrompt));
// spin ctrl
wxString valStr;
valStr.Printf("%lu", m_value);
m_spinctrl = new wxTextCtrl(this, -1, valStr,
wxPoint(x + wPrompt + LAYOUT_X_MARGIN, y),
wxSize(wText, hText));
y += hText + 2*LAYOUT_X_MARGIN;
// and buttons
CreateStandardButtons(wDialog, y, sizeBtn.GetWidth(), sizeBtn.GetHeight());
// set the dialog size and position
SetClientSize(wDialog, hDialog);
if ( pos == wxDefaultPosition )
{
// centre the dialog if no explicit position given
Centre(wxBOTH | wxCENTER_FRAME);
}
m_spinctrl->SetFocus();
}
void wxNumberEntryDialog::OnOK(wxCommandEvent& event)
{
if ( (sscanf(m_spinctrl->GetValue(), "%lu", &m_value) != 1) ||
(m_value < m_min) || (m_value > m_max) )
{
// not a number or out of range
m_value = -1;
}
EndModal(wxID_OK);
}
void wxNumberEntryDialog::OnCancel(wxCommandEvent& event)
{
m_value = -1;
EndModal(wxID_CANCEL);
}
// ----------------------------------------------------------------------------
// global functions
// ----------------------------------------------------------------------------
// wxGetTextFromUser is in utilscmn.cpp
long wxGetNumberFromUser(const wxString& msg,
const wxString& prompt,
const wxString& title,
long value,
long min,
long max,
wxWindow *parent,
const wxPoint& pos)
{
wxNumberEntryDialog dialog(parent, msg, prompt, title,
value, min, max, pos);
(void)dialog.ShowModal();
return dialog.GetValue();
}

View File

@@ -127,6 +127,7 @@ libwx_gtk_la_SOURCES = \
imaglist.cpp \
laywin.cpp \
listctrl.cpp \
numdlgg.cpp \
panelg.cpp \
printps.cpp \
prntdlgg.cpp \

View File

@@ -59,7 +59,7 @@ gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
event.SetInt( combo->GetSelection() );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event );
}
@@ -71,7 +71,7 @@ static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
if (g_isIdle) wxapp_install_idle_handler();
if (!combo->m_hasVMT) return;
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
@@ -126,7 +126,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
/* don't send first event, which GTK sends aways when
inserting the first item */
m_alreadySent = TRUE;
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
m_clientDataList.Append( (wxObject*)NULL );
@@ -360,8 +360,6 @@ int wxComboBox::GetSelection() const
}
}
wxFAIL_MSG( _T("wxComboBox: no selection") );
return -1;
}
@@ -596,7 +594,7 @@ void wxComboBox::DisableEvents()
GList *child = list->children;
while (child)
{
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
child = child->next;
@@ -619,7 +617,7 @@ void wxComboBox::EnableEvents()
void wxComboBox::OnSize( wxSizeEvent &event )
{
event.Skip();
return;
int w = 21;

View File

@@ -21,15 +21,18 @@
IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow)
wxControl::wxControl(void)
wxControl::wxControl()
{
m_needParent = TRUE;
}
wxControl::wxControl( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) :
wxWindow( parent, id, pos, size, style, name )
wxControl::wxControl( wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
const wxSize &size,
long style,
const wxString &name )
: wxWindow( parent, id, pos, size, style, name )
{
}
@@ -40,10 +43,10 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label )
{
m_label = _T("");
for ( const wxChar *pc = label; *pc != _T('\0'); pc++ )
for ( const wxChar *pc = label; *pc != _T('\0'); pc++ )
{
if ( *pc == _T('&') )
{
if ( *pc == _T('&') )
{
pc++; // skip it
#if 0 // it would be unused anyhow for now - kbd interface not done yet
if ( *pc != _T('&') ) m_chAccel = *pc;

View File

@@ -78,17 +78,18 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton,wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
BEGIN_EVENT_TABLE(wxSpinButton, wxControl)
EVT_SIZE(wxSpinButton::OnSize)
END_EVENT_TABLE()
wxSpinButton::wxSpinButton()
{
}
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
bool wxSpinButton::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_needParent = TRUE;
@@ -201,15 +202,4 @@ void wxSpinButton::ApplyWidgetStyle()
gtk_widget_set_style( m_widget, m_widgetStyle );
}
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
wxScrollEvent(commandType, id)
{
}
#endif
#endif

View File

@@ -46,7 +46,7 @@ void wxStaticBitmap::CreatePixmapWidget()
/* insert GTK representation */
(*m_parent->m_insertCallback)(m_parent, this);
gtk_widget_show( m_widget );
PostCreation();
@@ -81,7 +81,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
PostCreation();
}
m_parent->DoAddChild( this );
Show( TRUE );
@@ -100,17 +100,17 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
{
gtk_widget_destroy( m_widget );
/* recreate m_widget because we've created a label
and not a bitmap above */
/* recreate m_widget because we've created a label
and not a bitmap above */
CreatePixmapWidget();
}
else
{
else
{
GdkBitmap *mask = (GdkBitmap *) NULL;
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
}
}
SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
}
}

View File

@@ -127,6 +127,7 @@ libwx_gtk_la_SOURCES = \
imaglist.cpp \
laywin.cpp \
listctrl.cpp \
numdlgg.cpp \
panelg.cpp \
printps.cpp \
prntdlgg.cpp \

View File

@@ -59,7 +59,7 @@ gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
event.SetInt( combo->GetSelection() );
event.SetString( combo->GetStringSelection() );
event.SetEventObject( combo );
combo->GetEventHandler()->ProcessEvent( event );
}
@@ -71,7 +71,7 @@ static void
gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
{
if (g_isIdle) wxapp_install_idle_handler();
if (!combo->m_hasVMT) return;
wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
@@ -126,7 +126,7 @@ bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
/* don't send first event, which GTK sends aways when
inserting the first item */
m_alreadySent = TRUE;
GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
m_clientDataList.Append( (wxObject*)NULL );
@@ -360,8 +360,6 @@ int wxComboBox::GetSelection() const
}
}
wxFAIL_MSG( _T("wxComboBox: no selection") );
return -1;
}
@@ -596,7 +594,7 @@ void wxComboBox::DisableEvents()
GList *child = list->children;
while (child)
{
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
gtk_signal_disconnect_by_func( GTK_OBJECT(child->data),
GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
child = child->next;
@@ -619,7 +617,7 @@ void wxComboBox::EnableEvents()
void wxComboBox::OnSize( wxSizeEvent &event )
{
event.Skip();
return;
int w = 21;

View File

@@ -21,15 +21,18 @@
IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow)
wxControl::wxControl(void)
wxControl::wxControl()
{
m_needParent = TRUE;
}
wxControl::wxControl( wxWindow *parent, wxWindowID id,
const wxPoint &pos, const wxSize &size,
long style, const wxString &name ) :
wxWindow( parent, id, pos, size, style, name )
wxControl::wxControl( wxWindow *parent,
wxWindowID id,
const wxPoint &pos,
const wxSize &size,
long style,
const wxString &name )
: wxWindow( parent, id, pos, size, style, name )
{
}
@@ -40,10 +43,10 @@ void wxControl::Command( wxCommandEvent &WXUNUSED(event) )
void wxControl::SetLabel( const wxString &label )
{
m_label = _T("");
for ( const wxChar *pc = label; *pc != _T('\0'); pc++ )
for ( const wxChar *pc = label; *pc != _T('\0'); pc++ )
{
if ( *pc == _T('&') )
{
if ( *pc == _T('&') )
{
pc++; // skip it
#if 0 // it would be unused anyhow for now - kbd interface not done yet
if ( *pc != _T('&') ) m_chAccel = *pc;

View File

@@ -78,17 +78,18 @@ static void gtk_spinbutt_callback( GtkWidget *WXUNUSED(widget), wxSpinButton *wi
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton,wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
BEGIN_EVENT_TABLE(wxSpinButton, wxControl)
EVT_SIZE(wxSpinButton::OnSize)
END_EVENT_TABLE()
wxSpinButton::wxSpinButton()
{
}
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
bool wxSpinButton::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
m_needParent = TRUE;
@@ -201,15 +202,4 @@ void wxSpinButton::ApplyWidgetStyle()
gtk_widget_set_style( m_widget, m_widgetStyle );
}
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
wxScrollEvent(commandType, id)
{
}
#endif
#endif

View File

@@ -46,7 +46,7 @@ void wxStaticBitmap::CreatePixmapWidget()
/* insert GTK representation */
(*m_parent->m_insertCallback)(m_parent, this);
gtk_widget_show( m_widget );
PostCreation();
@@ -81,7 +81,7 @@ bool wxStaticBitmap::Create( wxWindow *parent, wxWindowID id, const wxBitmap &bi
PostCreation();
}
m_parent->DoAddChild( this );
Show( TRUE );
@@ -100,17 +100,17 @@ void wxStaticBitmap::SetBitmap( const wxBitmap &bitmap )
{
gtk_widget_destroy( m_widget );
/* recreate m_widget because we've created a label
and not a bitmap above */
/* recreate m_widget because we've created a label
and not a bitmap above */
CreatePixmapWidget();
}
else
{
else
{
GdkBitmap *mask = (GdkBitmap *) NULL;
if (m_bitmap.GetMask()) mask = m_bitmap.GetMask()->GetBitmap();
gtk_pixmap_set( GTK_PIXMAP(m_widget), m_bitmap.GetPixmap(), mask );
}
}
SetSize( m_bitmap.GetWidth(), m_bitmap.GetHeight() );
}
}

View File

@@ -61,6 +61,7 @@ libwx_motif_la_SOURCES = \
docview.cpp \
dynlib.cpp \
event.cpp \
ffile.cpp \
file.cpp \
fileconf.cpp \
filesys.cpp \
@@ -99,6 +100,7 @@ libwx_motif_la_SOURCES = \
stream.cpp \
tbarbase.cpp \
tbarsmpl.cpp \
textcmn.cpp \
textfile.cpp \
txtstrm.cpp \
time.cpp \
@@ -126,6 +128,7 @@ libwx_motif_la_SOURCES = \
imaglist.cpp \
laywin.cpp \
listctrl.cpp \
numdlgg.cpp \
panelg.cpp \
printps.cpp \
prntdlgg.cpp \

View File

@@ -340,6 +340,12 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if (event->type == KeyPress)
{
#ifdef __WXDEBUG__
Widget widget = XtWindowToWidget(event->xany.display, event->xany.window);
wxLogDebug("Got key press event for 0x%08x (parent = 0x%08x)",
widget, XtParent(widget));
#endif // DEBUG
if (CheckForAccelerator(_event))
{
// Do nothing! We intercepted and processed the event as an
@@ -632,10 +638,6 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
bool wxApp::CheckForKeyDown(WXEvent* event)
{
XEvent* xEvent = (XEvent*) event;
// VZ: this code doesn't work for me because it never finds the correct
// window. Also, if we go this way, we should generate KEY_UP and
// CHAR events as well, not only KEY_DOWN.
#if 0
if (xEvent->xany.type == KeyPress)
{
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
@@ -655,7 +657,6 @@ bool wxApp::CheckForKeyDown(WXEvent* event)
win->ProcessEvent( keyEvent );
return (keyEvent.GetSkipped() != TRUE);
}
#endif // 0
return FALSE;
}

View File

@@ -26,13 +26,13 @@
#include "wx/motif/private.h"
#if wxUSE_XPM
#include <X11/xpm.h>
#if wxHAVE_LIB_XPM
#include <X11/xpm.h>
#endif
#if !USE_SHARED_LIBRARIES
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
IMPLEMENT_DYNAMIC_CLASS(wxBitmap, wxGDIObject)
IMPLEMENT_DYNAMIC_CLASS(wxMask, wxObject)
#endif
wxBitmapRefData::wxBitmapRefData()
@@ -44,14 +44,14 @@ wxBitmapRefData::wxBitmapRefData()
m_quality = 0;
m_numColors = 0;
m_bitmapMask = NULL;
m_pixmap = (WXPixmap) 0;
m_display = (WXDisplay*) 0;
m_freePixmap = TRUE; //TODO: necessary?
m_freeColors = (unsigned long*) 0;
m_freeColorsCount = 0;
// These 5 variables are for wxControl
m_insensPixmap = (WXPixmap) 0;
m_labelPixmap = (WXPixmap) 0;
@@ -64,19 +64,19 @@ wxBitmapRefData::~wxBitmapRefData()
{
if (m_labelPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_labelPixmap);
if (m_armPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_armPixmap);
if (m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay ((Display*) m_display), (Pixmap) m_insensPixmap);
if (m_image)
{
XmUninstallImage ((XImage*) m_image);
XtFree ((char *) (XImage*) m_image);
}
if (m_insensImage)
{
XmUninstallImage ((XImage*) m_insensImage);
@@ -85,7 +85,7 @@ wxBitmapRefData::~wxBitmapRefData()
}
if (m_pixmap && m_freePixmap)
XFreePixmap ((Display*) m_display, (Pixmap) m_pixmap);
if (m_freeColors)
{
int screen = DefaultScreen((Display*) m_display);
@@ -95,7 +95,7 @@ wxBitmapRefData::~wxBitmapRefData()
XFreeColors((Display*) m_display, cmp, &m_freeColors[llp], 1, 0L);
delete m_freeColors;
};
if (m_bitmapMask)
delete m_bitmapMask;
m_bitmapMask = NULL;
@@ -106,7 +106,7 @@ wxList wxBitmap::sm_handlers;
wxBitmap::wxBitmap()
{
m_refData = NULL;
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
@@ -120,9 +120,9 @@ wxBitmap::~wxBitmap()
wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
{
m_refData = new wxBitmapRefData;
(void) Create((void*) bits, wxBITMAP_TYPE_XBM_DATA, width, height, depth);
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
@@ -130,7 +130,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
wxBitmap::wxBitmap(int w, int h, int d)
{
(void)Create(w, h, d);
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
@@ -138,7 +138,7 @@ wxBitmap::wxBitmap(int w, int h, int d)
wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
{
(void) Create(data, type, width, height, depth);
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
@@ -146,7 +146,7 @@ wxBitmap::wxBitmap(void *data, long type, int width, int height, int depth)
wxBitmap::wxBitmap(const wxString& filename, long type)
{
LoadFile(filename, (int)type);
if ( wxTheBitmapList )
wxTheBitmapList->AddBitmap(this);
}
@@ -157,33 +157,33 @@ wxBitmap::wxBitmap(char **data, wxControl* control)
{
// Pass the control to the Create function using a global
sg_Control = control;
(void) Create((void *)data, wxBITMAP_TYPE_XPM_DATA, 0, 0, 0);
sg_Control = (wxControl*) NULL;
}
bool wxBitmap::Create(int w, int h, int d)
{
UnRef();
m_refData = new wxBitmapRefData;
if (d < 1)
d = wxDisplayDepth();
M_BITMAPDATA->m_width = w;
M_BITMAPDATA->m_height = h;
M_BITMAPDATA->m_depth = d;
M_BITMAPDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPDATA->m_display = dpy; /* MATTHEW: [4] Remember the display */
M_BITMAPDATA->m_pixmap = (WXPixmap) XCreatePixmap (dpy, RootWindow (dpy, DefaultScreen (dpy)),
w, h, d);
M_BITMAPDATA->m_ok = (M_BITMAPDATA->m_pixmap != (WXPixmap) 0) ;
return M_BITMAPDATA->m_ok;
}
@@ -191,47 +191,47 @@ bool wxBitmap::Create(int w, int h, int d)
bool wxBitmap::LoadFile(const wxString& filename, long type)
{
UnRef();
m_refData = new wxBitmapRefData;
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
wxLogWarning("%s: no bitmap handler for type %d defined.", (const char*) filename, type);
return FALSE;
}
return handler->LoadFile(this, filename, type, -1, -1);
}
bool wxBitmap::Create(void *data, long type, int width, int height, int depth)
{
UnRef();
m_refData = new wxBitmapRefData;
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
wxLogWarning("no data bitmap handler for type %d defined.", type);
return FALSE;
}
return handler->Create(this, data, type, width, height, depth);
}
bool wxBitmap::SaveFile(const wxString& filename, int type, const wxPalette *palette)
{
wxBitmapHandler *handler = FindHandler(type);
if ( handler == NULL ) {
wxLogWarning("no bitmap handler for type %d defined.", type);
return FALSE;
}
return handler->SaveFile(this, filename, type, palette);
}
@@ -239,7 +239,7 @@ void wxBitmap::SetWidth(int w)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_width = w;
}
@@ -247,7 +247,7 @@ void wxBitmap::SetHeight(int h)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_height = h;
}
@@ -255,7 +255,7 @@ void wxBitmap::SetDepth(int d)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_depth = d;
}
@@ -263,7 +263,7 @@ void wxBitmap::SetQuality(int q)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_quality = q;
}
@@ -271,7 +271,7 @@ void wxBitmap::SetOk(bool isOk)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_ok = isOk;
}
@@ -279,7 +279,7 @@ void wxBitmap::SetPalette(const wxPalette& palette)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_bitmapPalette = palette ;
}
@@ -287,7 +287,7 @@ void wxBitmap::SetMask(wxMask *mask)
{
if (!M_BITMAPDATA)
m_refData = new wxBitmapRefData;
M_BITMAPDATA->m_bitmapMask = mask ;
}
@@ -367,7 +367,7 @@ wxMask::wxMask()
wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
{
m_pixmap = (WXPixmap) 0;
Create(bitmap, colour);
}
@@ -376,7 +376,7 @@ wxMask::wxMask(const wxBitmap& bitmap, const wxColour& colour)
wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
{
m_pixmap = (WXPixmap) 0;
Create(bitmap, paletteIndex);
}
@@ -384,7 +384,7 @@ wxMask::wxMask(const wxBitmap& bitmap, int paletteIndex)
wxMask::wxMask(const wxBitmap& bitmap)
{
m_pixmap = (WXPixmap) 0;
Create(bitmap);
}
@@ -424,7 +424,7 @@ bool wxMask::Create(const wxBitmap& WXUNUSED(bitmap), const wxColour& WXUNUSED(c
IMPLEMENT_DYNAMIC_CLASS(wxBitmapHandler, wxObject)
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type),
bool wxBitmapHandler::Create(wxBitmap *WXUNUSED(bitmap), void *WXUNUSED(data), long WXUNUSED(type),
int WXUNUSED(width), int WXUNUSED(height), int WXUNUSED(depth))
{
return FALSE;
@@ -436,7 +436,7 @@ bool wxBitmapHandler::LoadFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNU
return FALSE;
}
bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type),
bool wxBitmapHandler::SaveFile(wxBitmap *WXUNUSED(bitmap), const wxString& WXUNUSED(name), int WXUNUSED(type),
const wxPalette *WXUNUSED(palette))
{
return FALSE;
@@ -456,7 +456,7 @@ public:
m_extension = "xbm";
m_type = wxBITMAP_TYPE_XBM;
};
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight);
};
@@ -466,21 +466,21 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXU
int WXUNUSED(desiredWidth), int WXUNUSED(desiredHeight))
{
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
int hotX, hotY;
unsigned int w, h;
Pixmap pixmap;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPDATA->m_display = (WXDisplay*) dpy;
int value = XReadBitmapFile (dpy, RootWindow (dpy, DefaultScreen (dpy)),
(char*) (const char*) name, &w, &h, &pixmap, &hotX, &hotY);
M_BITMAPHANDLERDATA->m_width = w;
M_BITMAPHANDLERDATA->m_height = h;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
if ((value == BitmapFileInvalid) ||
(value == BitmapOpenFailed) ||
(value == BitmapNoMemory))
@@ -490,7 +490,7 @@ bool wxXBMFileHandler::LoadFile(wxBitmap *bitmap, const wxString& name, long WXU
}
else
M_BITMAPHANDLERDATA->m_ok = TRUE;
return M_BITMAPHANDLERDATA->m_ok ;
}
@@ -504,25 +504,25 @@ public:
m_extension = "xbm";
m_type = wxBITMAP_TYPE_XBM_DATA;
};
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
};
IMPLEMENT_DYNAMIC_CLASS(wxXBMDataHandler, wxBitmapHandler)
bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
int width, int height, int WXUNUSED(depth))
{
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) XCreateBitmapFromData (dpy, RootWindow (dpy, DefaultScreen (dpy)), (char*) data, width, height);
M_BITMAPHANDLERDATA->m_ok = (M_BITMAPHANDLERDATA->m_pixmap != (WXPixmap) 0) ;
// code for wxControl. TODO: can we avoid doing this until we need it?
// E.g. have CreateButtonPixmaps which is called on demand.
XImage* image = (XImage *) XtMalloc (sizeof (XImage));
@@ -537,13 +537,13 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
image->bitmap_bit_order = LSBFirst;
image->bitmap_pad = 8;
image->bytes_per_line = (width + 7) >> 3;
char tmp[128];
sprintf (tmp, "Im%x", (unsigned int) image);
XmInstallImage (image, tmp);
// Build our manually stipped pixmap.
int bpl = (width + 7) / 8;
char *data1 = new char[height * bpl];
char* bits = (char*) data;
@@ -567,17 +567,17 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
insensImage->bitmap_bit_order = LSBFirst;
insensImage->bitmap_pad = 8;
insensImage->bytes_per_line = bpl;
sprintf (tmp, "Not%x", (unsigned int)insensImage);
XmInstallImage (insensImage, tmp);
M_BITMAPHANDLERDATA->m_image = (WXImage*) image;
M_BITMAPHANDLERDATA->m_insensImage = (WXImage*) insensImage;
return TRUE;
}
#if wxUSE_XPM
#if wxHAVE_LIB_XPM
class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler
{
DECLARE_DYNAMIC_CLASS(wxXPMFileHandler)
@@ -588,7 +588,7 @@ public:
m_extension = "xpm";
m_type = wxBITMAP_TYPE_XPM;
};
virtual bool LoadFile(wxBitmap *bitmap, const wxString& name, long flags,
int desiredWidth, int desiredHeight);
virtual bool SaveFile(wxBitmap *bitmap, const wxString& name, int type, const wxPalette *palette = NULL);
@@ -601,18 +601,18 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WX
{
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
XpmAttributes xpmAttr;
Pixmap pixmap;
Pixmap mask = 0;
M_BITMAPHANDLERDATA->m_ok = FALSE;
xpmAttr.valuemask = XpmReturnInfos | XpmCloseness;
xpmAttr.closeness = 40000;
int errorStatus = XpmReadFileToPixmap(dpy,
RootWindow(dpy, DefaultScreen(dpy)), (char*) (const char*) name,
&pixmap, &mask, &xpmAttr);
if (errorStatus == XpmSuccess)
{
M_BITMAPHANDLERDATA->m_pixmap = (WXPixmap) pixmap;
@@ -621,17 +621,17 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WX
M_BITMAPHANDLERDATA->m_bitmapMask = new wxMask;
M_BITMAPHANDLERDATA->m_bitmapMask->SetPixmap((WXPixmap) mask);
}
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
/*
if ( xpmAttr.npixels > 2 )
{
@@ -641,13 +641,13 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WX
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
*/
M_BITMAPHANDLERDATA->m_depth = depthRet;
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
return TRUE;
} else
@@ -658,7 +658,7 @@ bool wxXPMFileHandler::LoadFile( wxBitmap *bitmap, const wxString& name, long WX
}
}
bool wxXPMFileHandler::SaveFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(type),
bool wxXPMFileHandler::SaveFile( wxBitmap *bitmap, const wxString& name, int WXUNUSED(type),
const wxPalette *WXUNUSED(palette))
{
if (M_BITMAPHANDLERDATA->m_ok && M_BITMAPHANDLERDATA->m_pixmap)
@@ -687,26 +687,26 @@ public:
m_extension = "xpm";
m_type = wxBITMAP_TYPE_XPM_DATA;
};
virtual bool Create(wxBitmap *bitmap, void *data, long flags, int width, int height, int depth = 1);
};
IMPLEMENT_DYNAMIC_CLASS(wxXPMDataHandler, wxBitmapHandler)
bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags),
int width, int height, int WXUNUSED(depth))
{
M_BITMAPHANDLERDATA->m_width = width;
M_BITMAPHANDLERDATA->m_height = height;
M_BITMAPHANDLERDATA->m_depth = 1;
M_BITMAPHANDLERDATA->m_freePixmap = TRUE;
Display *dpy = (Display*) wxGetDisplay();
M_BITMAPHANDLERDATA->m_display = (WXDisplay*) dpy;
XpmAttributes xpmAttr;
xpmAttr.valuemask = XpmReturnInfos; /* nothing yet, but get infos back */
XpmColorSymbol symbolicColors[4];
if (sg_Control && sg_Control->GetMainWidget())
{
@@ -721,7 +721,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
xpmAttr.colorsymbols = symbolicColors;
xpmAttr.valuemask |= XpmColorSymbols; // add flag
}
Pixmap pixmap;
Pixmap mask = 0;
int ErrorStatus = XpmCreatePixmapFromData(dpy, RootWindow(dpy, DefaultScreen(dpy)),
@@ -731,14 +731,14 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
// Set attributes
M_BITMAPHANDLERDATA->m_width = xpmAttr.width;
M_BITMAPHANDLERDATA->m_height = xpmAttr.height;
unsigned int depthRet;
int xRet, yRet;
unsigned int widthRet, heightRet, borderWidthRet;
Window rootWindowRet;
XGetGeometry(dpy, pixmap, &rootWindowRet, &xRet, &yRet,
&widthRet, &heightRet, &borderWidthRet, &depthRet);
/*
if ( xpmAttr.npixels > 2 )
{
@@ -748,9 +748,9 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
M_BITMAPHANDLERDATA->m_depth = 1; // mono
}
*/
M_BITMAPHANDLERDATA->m_depth = depthRet;
M_BITMAPHANDLERDATA->m_numColors = xpmAttr.npixels;
XpmFreeAttributes(&xpmAttr);
M_BITMAPHANDLERDATA->m_ok = TRUE;
@@ -769,7 +769,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
return M_BITMAPHANDLERDATA->m_ok ;
}
#endif
#endif // wxHAVE_LIB_XPM
void wxBitmap::CleanUpHandlers()
{
@@ -789,35 +789,35 @@ void wxBitmap::InitStandardHandlers()
// Initialize all standard bitmap or derived class handlers here.
AddHandler(new wxXBMFileHandler);
AddHandler(new wxXBMDataHandler);
// XPM is considered standard for Motif, although it can be omitted if absolutely
// necessary.
#if wxUSE_XPM
// XPM is considered standard for Motif, although it can be omitted if
// libXpm is not installed
#if wxHAVE_LIB_XPM
AddHandler(new wxXPMFileHandler);
AddHandler(new wxXPMDataHandler);
#endif
#endif // wxHAVE_LIB_XPM
}
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
{
if (M_BITMAPDATA->m_image == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
Display *dpy = (Display*) M_BITMAPDATA->m_display;
#ifdef FOO
/*
If we do:
if (labelPixmap) return labelPixmap;
things can be wrong, because colors can have been changed.
If we do:
if (labelPixmap)
XmDestroyPixmap(DefaultScreenOfDisplay(dpy),labelPixmap) ;
we got BadDrawable if the pixmap is referenced by multiples widgets
this is a catch22!!
So, before doing thing really clean, I just do nothing; if the pixmap is
referenced by many widgets, Motif performs caching functions.
And if pixmap is referenced with multiples colors, we just have some
@@ -827,19 +827,19 @@ WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)
if (M_BITMAPDATA->m_labelPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_labelPixmap);
#endif
char tmp[128];
sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
Pixel fg, bg;
Widget widget = (Widget) w;
while (XmIsGadget ( widget ))
widget = XtParent (widget);
XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
M_BITMAPDATA->m_labelPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_labelPixmap;
}
@@ -847,7 +847,7 @@ WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
{
if (M_BITMAPDATA->m_image == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
Display *dpy = (Display*) M_BITMAPDATA->m_display;
#ifdef FOO
See GetLabelPixmap () comment
@@ -855,30 +855,30 @@ WXPixmap wxBitmap::GetArmPixmap (WXWidget w)
if (M_BITMAPDATA->m_armPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay (dpy), M_BITMAPDATA->m_armPixmap);
#endif
char tmp[128];
sprintf (tmp, "Im%x", (unsigned int) M_BITMAPDATA->m_image);
Pixel fg, bg;
Widget widget = (Widget) w;
XtVaGetValues (widget, XmNarmColor, &bg, NULL);
while (XmIsGadget (widget))
widget = XtParent (widget);
XtVaGetValues (widget, XmNforeground, &fg, NULL);
M_BITMAPDATA->m_armPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_armPixmap;
}
WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
{
Display *dpy = (Display*) M_BITMAPDATA->m_display;
if (M_BITMAPDATA->m_insensPixmap)
return M_BITMAPDATA->m_insensPixmap;
if (!w)
{
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XCreateInsensitivePixmap(dpy, (Pixmap) M_BITMAPDATA->m_pixmap);
@@ -887,29 +887,29 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
else
return M_BITMAPDATA->m_pixmap;
}
if (M_BITMAPDATA->m_insensImage == (WXPixmap) 0)
return M_BITMAPDATA->m_pixmap;
#ifdef FOO
See GetLabelPixmap () comment
// Must be destroyed, because colours can have been changed!
if (M_BITMAPDATA->m_insensPixmap)
XmDestroyPixmap (DefaultScreenOfDisplay (dpy), (Pixmap) M_BITMAPDATA->m_insensPixmap);
#endif
char tmp[128];
sprintf (tmp, "Not%x", (unsigned int) M_BITMAPDATA->m_insensImage);
Pixel fg, bg;
Widget widget = (Widget) w;
while (XmIsGadget (widget))
widget = XtParent (widget);
XtVaGetValues (widget, XmNbackground, &bg, XmNforeground, &fg, NULL);
M_BITMAPDATA->m_insensPixmap = (WXPixmap) XmGetPixmap (DefaultScreenOfDisplay (dpy), tmp, fg, bg);
return M_BITMAPDATA->m_insensPixmap;
}
@@ -919,32 +919,32 @@ WXPixmap wxBitmap::GetInsensPixmap (WXWidget w)
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
@@ -952,7 +952,7 @@ XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
{
static
char stipple_data[] =
char stipple_data[] =
{
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
0x55, 0x55, 0xAA, 0xAA, 0x55, 0x55, 0xAA, 0xAA,
@@ -962,21 +962,21 @@ XCreateInsensitivePixmap( Display *display, Pixmap pixmap )
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 );
@@ -994,7 +994,7 @@ XCreateInsensitivePixmap( Display *display, Pixmap 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 );
@@ -1019,12 +1019,12 @@ wxBitmap wxCreateMaskedBitmap(wxBitmap& bitmap, wxColour& colour)
wxMemoryDC srcDC;
srcDC.SelectObject(bitmap);
destDC.SelectObject(newBitmap);
wxBrush brush(colour, wxSOLID);
destDC.SetOptimization(FALSE);
destDC.SetBackground(brush);
destDC.Clear();
destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(), & srcDC, 0, 0, wxCOPY, TRUE);
return newBitmap;
}

View File

@@ -44,35 +44,35 @@ bool wxCheckBox::Create(wxWindow *parent, wxWindowID id, const wxString& label,
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_font = parent->GetFont();
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
char* label1 = (label.IsNull() ? "" : (char*) (const char*) label);
XmString text = XmStringCreateSimple (label1);
Widget parentWidget = (Widget) parent->GetClientWidget();
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
m_mainWidget = (WXWidget) XtVaCreateManagedWidget ("toggle",
xmToggleButtonWidgetClass, parentWidget,
XmNfontList, fontList,
XmNlabelString, text,
NULL);
XmStringFree (text);
XtAddCallback ((Widget) m_mainWidget, XmNvalueChangedCallback, (XtCallbackProc) wxCheckBoxCallback,
(XtPointer) this);
XmToggleButtonSetState ((Widget) m_mainWidget, FALSE, TRUE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -105,16 +105,16 @@ bool wxBitmapCheckBox::Create(wxWindow *parent, wxWindowID id, const wxBitmap *l
SetName(name);
SetValidator(validator);
m_windowStyle = style;
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = NewControlId();
else
m_windowId = id;
// TODO: Create the bitmap checkbox
return FALSE;
}
@@ -143,10 +143,10 @@ void wxCheckBoxCallback (Widget w, XtPointer clientData,
XtPointer ptr)
{
wxCheckBox *item = (wxCheckBox *) clientData;
if (item->InSetValue())
return;
wxCommandEvent event (wxEVT_COMMAND_CHECKBOX_CLICKED, item->GetId());
event.SetInt((int) item->GetValue ());
event.SetEventObject(item);
@@ -162,14 +162,14 @@ 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(wxGetDisplay());
// Better to have the checkbox selection in black, or it's

View File

@@ -56,35 +56,35 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
m_menuWidget = (WXWidget) 0;
m_widgetList = (WXWidget*) 0;
m_formWidget = (WXWidget) 0;
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_font = parent->GetFont();
Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name,
m_formWidget = (WXWidget) XtVaCreateManagedWidget(name.c_str(),
xmRowColumnWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
XmNpacking, XmPACK_TIGHT,
XmNorientation, XmHORIZONTAL,
NULL);
XtVaSetValues ((Widget) m_formWidget, XmNspacing, 0, NULL);
/*
* Create the popup menu
*/
m_menuWidget = (WXWidget) XmCreatePulldownMenu ((Widget) m_formWidget, "choiceMenu", NULL, 0);
// int i;
if (n > 0)
{
@@ -92,13 +92,13 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
for (i = 0; i < n; i++)
Append (choices[i]);
}
/*
* Create button
*/
Arg args[10];
Cardinal argcnt = 0;
XtSetArg (args[argcnt], XmNsubMenuId, (Widget) m_menuWidget);
argcnt++;
XtSetArg (args[argcnt], XmNmarginWidth, 0);
@@ -108,9 +108,9 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
XtSetArg (args[argcnt], XmNpacking, XmPACK_TIGHT);
argcnt++;
m_buttonWidget = (WXWidget) XmCreateOptionMenu ((Widget) m_formWidget, "choiceButton", args, argcnt);
m_mainWidget = m_buttonWidget;
XtManageChild ((Widget) m_buttonWidget);
// New code from Roland Haenel (roland_haenel@ac.cybercity.de)
@@ -128,13 +128,13 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
#endif
XtVaSetValues((Widget) m_formWidget, XmNresizePolicy, XmRESIZE_NONE, NULL);
ChangeFont(FALSE);
AttachWidget (parent, m_buttonWidget, m_formWidget, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -147,15 +147,15 @@ wxChoice::~wxChoice()
// XtDestroyWidget (menuWidget);
if (m_widgetList)
delete[] m_widgetList;
if (GetMainWidget())
{
DetachWidget(GetMainWidget()); // Removes event handlers
DetachWidget(m_formWidget);
XtDestroyWidget((Widget) m_formWidget);
m_formWidget = (WXWidget) 0;
// Presumably the other widgets have been deleted now, via the form
m_mainWidget = (WXWidget) 0;
m_buttonWidget = (WXWidget) 0;
@@ -164,40 +164,39 @@ wxChoice::~wxChoice()
void wxChoice::Append(const wxString& item)
{
wxStripMenuCodes ((char *)(const char *)item, wxBuffer);
Widget w = XtVaCreateManagedWidget (wxBuffer,
Widget w = XtVaCreateManagedWidget (wxStripMenuCodes(item),
#if USE_GADGETS
xmPushButtonGadgetClass, (Widget) m_menuWidget,
#else
xmPushButtonWidgetClass, (Widget) m_menuWidget,
#endif
NULL);
DoChangeBackgroundColour((WXWidget) w, m_backgroundColour);
if (m_font.Ok())
XtVaSetValues (w,
XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_formWidget)),
NULL);
WXWidget *new_widgetList = new WXWidget[m_noStrings + 1];
int i;
if (m_widgetList)
for (i = 0; i < m_noStrings; i++)
new_widgetList[i] = m_widgetList[i];
new_widgetList[m_noStrings] = (WXWidget) w;
if (m_widgetList)
delete[] m_widgetList;
m_widgetList = new_widgetList;
char mnem = wxFindMnemonic ((char*) (const char*) item);
if (mnem != 0)
XtVaSetValues (w, XmNmnemonic, mnem, NULL);
XtAddCallback (w, XmNactivateCallback, (XtCallbackProc) wxChoiceCallback, (XtPointer) this);
if (m_noStrings == 0 && m_buttonWidget)
{
XtVaSetValues ((Widget) m_buttonWidget, XmNmenuHistory, w, NULL);
@@ -210,18 +209,18 @@ void wxChoice::Append(const wxString& item)
}
wxNode *node = m_stringList.Add (item);
XtVaSetValues (w, XmNuserData, node->Data (), NULL);
m_noStrings ++;
}
void wxChoice::Delete(int WXUNUSED(n))
{
wxFAIL_MSG( "Sorry, wxChoice::Delete isn't implemented yet. Maybe you'd like to volunteer? :-)" );
// What should we do -- remove the callback for this button widget,
// delete the m_stringList entry, delete the button widget, construct a new widget list
// (see Append)
// TODO
m_noStrings --;
}
@@ -251,7 +250,7 @@ int wxChoice::GetSelection() const
XtVaGetValues (label,
XmNlabelString, &text,
NULL);
if (XmStringGetLtoR (text, XmSTRING_DEFAULT_CHARSET, &s))
{
int i = 0;
@@ -267,7 +266,7 @@ int wxChoice::GetSelection() const
else
i++;
} // for()
XmStringFree(text) ;
XtFree (s);
return -1;
@@ -279,12 +278,12 @@ int wxChoice::GetSelection() const
void wxChoice::SetSelection(int n)
{
m_inSetValue = TRUE;
wxNode *node = m_stringList.Nth (n);
if (node)
{
Dimension selectionWidth, selectionHeight;
char *s = (char *) node->Data ();
XmString text = XmStringCreateSimple (s);
XtVaGetValues ((Widget) m_widgetList[n], XmNwidth, &selectionWidth, XmNheight, &selectionHeight, NULL);
@@ -328,10 +327,10 @@ wxString wxChoice::GetString(int n) const
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) ;
@@ -340,7 +339,7 @@ void wxChoice::SetColumns(int n)
int wxChoice::GetColumns(void) const
{
short numColumns ;
XtVaGetValues((Widget) m_menuWidget,XmNnumColumns,&numColumns,NULL) ;
return numColumns ;
}
@@ -354,12 +353,12 @@ 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, actualHeight = height;
if (width > -1)
{
int i;
@@ -376,11 +375,11 @@ void wxChoice::DoSetSize(int x, int y, int width, int height, int sizeFlags)
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);
}
@@ -418,7 +417,7 @@ void wxChoiceCallback (Widget w, XtPointer clientData, XtPointer WXUNUSED(ptr))
{
if (item->InSetValue())
return;
char *s = NULL;
XtVaGetValues (w, XmNuserData, &s, NULL);
if (s)
@@ -441,11 +440,11 @@ void wxChoice::ChangeFont(bool keepOriginalSize)
{
int width, height, width1, height1;
GetSize(& width, & height);
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay((Widget) m_mainWidget));
XtVaSetValues ((Widget) m_mainWidget, XmNfontList, fontList, NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNfontList, fontList, NULL);
/* TODO: why does this cause a crash in XtWidgetToApplicationContext?
int i;
for (i = 0; i < m_noStrings; i++)

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -43,17 +43,17 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
// m_backgroundColour = parent->GetBackgroundColour();
m_backgroundColour = * wxWHITE;
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name,
Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(),
xmComboBoxWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
@@ -62,12 +62,12 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
XmNsorted, ((style & wxCB_SORT) == wxCB_SORT),
XmNstaticList, ((style & wxCB_SIMPLE) == wxCB_SIMPLE),
NULL);
XtAddCallback (buttonWidget, XmNselectionCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
XtAddCallback (buttonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxComboBoxCallback,
(XtPointer) this);
int i;
for (i = 0; i < n; i++)
{
@@ -77,21 +77,21 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
m_stringList.Add(choices[i]);
}
m_noStrings = n;
m_mainWidget = (Widget) buttonWidget;
XtManageChild (buttonWidget);
SetValue(value);
m_font = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -207,16 +207,16 @@ int wxComboBox::FindString(const wxString& s) const
XmString text = XmStringCreateSimple ((char*) (const char*) s);
bool found = (XmComboBoxGetMatchPos((Widget) m_mainWidget,
text, &pos_list, &count) != 0);
XmStringFree(text);
if (found && count > 0)
{
int pos = pos_list[0] - 1;
free(pos_list);
return pos;
}
return -1;
}
@@ -271,21 +271,21 @@ void wxComboBox::Replace(long from, long to, const wxString& value)
void wxComboBox::Remove(long from, long to)
{
XmComboBoxSetSelection ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(Time) 0);
(Time) 0);
XmComboBoxRemove ((Widget) m_mainWidget);
}
void wxComboBox::SetSelection(long from, long to)
{
XmComboBoxSetSelection ((Widget) m_mainWidget, (XmTextPosition) from, (XmTextPosition) to,
(Time) 0);
(Time) 0);
}
void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
XmComboBoxSelectionCallbackStruct * cbs)
{
wxComboBox *item = (wxComboBox *) clientData;
switch (cbs->reason)
{
case XmCR_SINGLE_SELECT:
@@ -293,7 +293,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
{
wxCommandEvent event (wxEVT_COMMAND_COMBOBOX_SELECTED, item->GetId());
event.m_commandInt = cbs->index - 1;
// event.m_commandString = item->GetString (event.m_commandInt);
// event.m_commandString = item->GetString (event.m_commandInt);
event.m_extraLong = TRUE;
event.SetEventObject(item);
item->ProcessCommand (event);
@@ -303,7 +303,7 @@ void wxComboBoxCallback (Widget WXUNUSED(w), XtPointer clientData,
{
wxCommandEvent event (wxEVT_COMMAND_TEXT_UPDATED, item->GetId());
event.m_commandInt = -1;
// event.m_commandString = item->GetValue();
// event.m_commandString = item->GetValue();
event.m_extraLong = TRUE;
event.SetEventObject(item);
item->ProcessCommand (event);

View File

@@ -31,7 +31,11 @@ wxControl::wxControl()
{
m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY
m_callback = 0;
#endif // WXWIN_COMPATIBILITY
m_inSetValue = FALSE;
}
@@ -89,43 +93,17 @@ wxString wxControl::GetLabel() const
}
}
void wxControl::ProcessCommand (wxCommandEvent & event)
bool wxControl::ProcessCommand(wxCommandEvent & event)
{
// Tries:
// 1) A callback function (to become obsolete)
// 2) OnCommand, starting at this window and working up parent hierarchy
// 3) OnCommand then calls ProcessEvent to search the event tables.
if (m_callback)
#if WXWIN_COMPATIBILITY
if ( m_callback )
{
(void) (*(m_callback)) (*this, event);
(void)(*m_callback)(this, event);
return TRUE;
}
else
{
GetEventHandler()->OnCommand(*this, event);
}
#endif // WXWIN_COMPATIBILITY
return GetEventHandler()->ProcessEvent(event);
}
void wxControl::Centre (int direction)
{
int x, y, width, height, panel_width, panel_height, new_x, new_y;
wxWindow *parent = (wxWindow *) GetParent ();
if (!parent)
return;
parent->GetClientSize (&panel_width, &panel_height);
GetSize (&width, &height);
GetPosition (&x, &y);
new_x = x;
new_y = y;
if (direction & wxHORIZONTAL)
new_x = (int) ((panel_width - width) / 2);
if (direction & wxVERTICAL)
new_y = (int) ((panel_height - height) / 2);
SetSize (new_x, new_y, width, height);
}

View File

@@ -60,8 +60,6 @@ wxList wxModalDialogs;
wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete;
extern wxHashTable *wxWidgetHashTable;
#define wxUSE_INVISIBLE_RESIZE 1
#if !USE_SHARED_LIBRARY

View File

@@ -50,8 +50,6 @@
#include "wx/motif/private.h"
extern wxHashTable *wxWidgetHashTable;
void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs);
@@ -150,8 +148,18 @@ bool wxFrame::Create(wxWindow *parent,
int width = size.x; int height = size.y;
if (wxTopLevelUsed)
{
// Change suggested by Matthew Flatt
m_frameShell = (WXWidget) XtAppCreateShell(name, wxTheApp->GetClassName(), topLevelShellWidgetClass, (Display*) wxGetDisplay(), NULL, 0);
m_frameShell = (WXWidget)XtAppCreateShell
(
name,
wxTheApp->GetClassName(),
topLevelShellWidgetClass,
(Display*) wxGetDisplay(),
NULL,
0
);
}
else
{
m_frameShell = wxTheApp->GetTopLevelWidget();
@@ -192,6 +200,9 @@ bool wxFrame::Create(wxWindow *parent,
// XmNresizePolicy, XmRESIZE_ANY,
NULL);
wxLogDebug("Created frame (0x%08x) with work area 0x%08x and client "
"area 0x%08x", m_frameWidget, m_workArea, m_clientArea);
XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
wxUniversalRepaintProc, (XtPointer) this);
@@ -202,9 +213,6 @@ bool wxFrame::Create(wxWindow *parent,
XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea);
wxASSERT_MSG( !wxGetWindowFromTable((Widget)m_workArea),
"Widget table clash in frame.cpp") ;
wxAddWindowToTable((Widget) m_workArea, this);
XtTranslations ptr ;

View File

@@ -43,7 +43,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxGauge, wxControl)
* 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
* action, arising out of or in connection with the use
* or performance of this software.
*
*/
@@ -87,16 +87,16 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
m_windowStyle = style;
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
Widget parentWidget = (Widget) parent->GetClientWidget();
Arg args[4];
int count = 4;
if (style & wxHORIZONTAL)
@@ -113,24 +113,24 @@ bool wxGauge::Create(wxWindow *parent, wxWindowID id,
XtSetArg(args[3], XmNmaximum, range);
Widget gaugeWidget = XtCreateManagedWidget("gauge", xmGaugeWidgetClass, parentWidget, args, count);
m_mainWidget = (WXWidget) gaugeWidget ;
XtManageChild (gaugeWidget);
int x = pos.x; int y = pos.y;
int width = size.x; int height = size.y;
if (width == -1)
width = 150;
if (height == -1)
height = 80;
m_font = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, x, y, width, height);
ChangeBackgroundColour();
return TRUE;
}
@@ -209,7 +209,7 @@ typedef struct {
int empty;
} XmGaugeClassPart;
typedef struct _XmGaugeClassRec {
typedef struct _XmGaugeClassRec {
CoreClassPart core_class;
XmPrimitiveClassPart primitive_class;
XmGaugeClassPart gauge_class;
@@ -222,10 +222,10 @@ typedef struct _XmGaugePart{
int maximum;
unsigned char orientation;
unsigned char processingDirection;
XtCallbackList dragCallback;
XtCallbackList valueChangedCallback;
/* private fields */
Boolean dragging; /* drag in progress ? */
int oldx, oldy;
@@ -247,9 +247,9 @@ extern XmGaugeClassRec xmGaugeClassRec;
void
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args);
void
void
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args);
void
void
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args);
@@ -280,9 +280,9 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
unsigned long backgr,foregr;
XRectangle rects[1];
***/
sht = gw->primitive.shadow_thickness;
ratio = (float)THIS.value/
(float)(THIS.maximum - THIS.minimum);
/***chubraev
@@ -290,7 +290,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
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);
@@ -299,7 +299,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
case XmHORIZONTAL:
size = (int) ((gw->core.width - 2 * sht)*ratio);
/***chubraev
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht+gw->core.width/2,
gw->core.height - 2 * sht, string, len);
***/
switch(THIS.processingDirection) {
@@ -307,7 +307,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
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;
@@ -318,7 +318,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
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;
@@ -328,15 +328,15 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
/***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,
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,
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
sht+gw->core.height/2, string,len);
***/
switch(THIS.processingDirection) {
@@ -344,7 +344,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
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;
@@ -355,7 +355,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
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;
@@ -364,7 +364,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
/***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,
XDrawString(XtDisplay(gw), XtWindow(gw), THIS.gc, sht,
sht+gw->core.height/2, string,len);
***/
break;
@@ -373,7 +373,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
XSetClipMask(XtDisplay(gw), THIS.gc, None);
XSetForeground(XtDisplay(gw), THIS.gc, foregr);
***/
#undef THIS
#undef THIS
}
/* Old code
@@ -385,7 +385,7 @@ 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 -
@@ -431,7 +431,7 @@ DrawSlider(XmGaugeWidget gw, Boolean clear)
}
break;
}
#undef THIS
#undef THIS
}
#endif
@@ -441,12 +441,12 @@ Initialize(Widget req, Widget new_w, ArgList args, Cardinal *num_args )
XmGaugeWidget gw = (XmGaugeWidget)new_w;
#define THIS gw->gauge
XGCValues values;
values.foreground = gw->primitive.foreground;
THIS.gc = XtGetGC(new_w, GCForeground, &values);
#undef THIS
#undef THIS
}
@@ -457,7 +457,7 @@ Destroy(Widget w)
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
XtReleaseGC(w, THIS.gc);
#undef THIS
#undef THIS
}
@@ -473,11 +473,11 @@ SetValues(
{
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;
@@ -498,7 +498,7 @@ ExposeProc(Widget w, XEvent *event, Region r)
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
int sht;
sht = gw->primitive.shadow_thickness;
_XmDrawShadows(XtDisplay(w), XtWindow(w),
gw->primitive.top_shadow_GC,
@@ -506,39 +506,39 @@ ExposeProc(Widget w, XEvent *event, Region r)
0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN);
DrawSlider(gw, False);
#undef THIS
#undef THIS
}
static XtResource
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
};
@@ -598,7 +598,7 @@ WidgetClass xmGaugeWidgetClass = (WidgetClass)&xmGaugeClassRec;
void
void
GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
/* Commented out for a read-only gauge in wxWindows */
@@ -610,7 +610,7 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
Boolean dragging = False;
XButtonEvent *event = (XButtonEvent *)e;
int x, y;
x = event->x;
y = event->y;
sht = gw->primitive.shadow_thickness;
@@ -619,10 +619,10 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
gw->primitive.bottom_shadow_GC,
0, 0, w->core.width, w->core.height,
sht, XmSHADOW_IN);
ratio = (float)((float)THIS.maximum -
(float)THIS.minimum) / (float)THIS.value;
(float)THIS.minimum) / (float)THIS.value;
switch(THIS.orientation) {
case XmHORIZONTAL:
size = (w->core.width - 2 * sht) / ratio;
@@ -658,13 +658,13 @@ GaugePick(Widget w, XEvent *e, String *args, Cardinal *num_args)
THIS.dragging = dragging;
THIS.oldx = x;
THIS.oldy = y;
#undef THIS
#undef THIS
#endif
}
#define round(x) ( (x) > 0 ? ((x) + 0.5) : -(-(x) + 0.5) )
void
void
GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
/* Commented out for a read-only gauge in wxWindows */
@@ -674,13 +674,13 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
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) {
@@ -706,21 +706,21 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
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;
@@ -728,12 +728,12 @@ GaugeDrag(Widget w, XEvent *e, String *args, Cardinal *num_args)
XtCallCallbacks(w, XmNdragCallback, &call);
}
}
#undef THIS
#undef THIS
#endif
}
void
void
GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
{
/* Commented out for a read-only gauge in wxWindows */
@@ -741,7 +741,7 @@ GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
XmGaugeWidget gw = (XmGaugeWidget)w;
#define THIS gw->gauge
if( ! THIS.dragging) return;
if(NULL != THIS.valueChangedCallback) {
XmGaugeCallbackStruct call;
call.reason = XmCR_VALUE_CHANGED;
@@ -750,7 +750,7 @@ GaugeDrop(Widget w, XEvent *e, String *args, Cardinal *num_args)
XtCallCallbacks(w, XmNvalueChangedCallback, &call);
}
THIS.dragging = False;
#undef THIS
#undef THIS
#endif
}
@@ -758,7 +758,7 @@ void
XmGaugeSetValue(Widget w, int value)
{
XmGaugeWidget gw = (XmGaugeWidget)w;
gw->gauge.value = value;
DrawSlider(gw, True);
XFlush(XtDisplay(w));
@@ -766,8 +766,8 @@ XmGaugeSetValue(Widget w, int value)
int
XmGaugeGetValue(Widget w)
{
{
XmGaugeWidget gw = (XmGaugeWidget)w;
return gw->gauge.value;
}

View File

@@ -778,9 +778,7 @@ bool wxMenuBar::CreateMenuBar(wxFrame* parent)
wxString title(m_titles[i]);
menu->SetButtonWidget(menu->CreateMenu (this, menuBarW, menu, title, TRUE));
wxStripMenuCodes ((char*) (const char*) title, wxBuffer);
if (strcmp (wxBuffer, "Help") == 0)
if (strcmp (wxStripMenuCodes(title), "Help") == 0)
XtVaSetValues ((Widget) menuBarW, XmNmenuHelpWidget, (Widget) menu->GetButtonWidget(), NULL);
// tear off menu support
@@ -910,8 +908,9 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
menu = XmCreatePulldownMenu ((Widget) parent, "pulldown", args, 2);
XmString label_str = XmStringCreateSimple (wxBuffer);
buttonWidget = XtVaCreateManagedWidget (wxBuffer,
wxString title2(wxStripMenuCodes(title));
wxXmString label_str(title2);
buttonWidget = XtVaCreateManagedWidget(title2,
#if wxUSE_GADGETS
xmCascadeButtonGadgetClass, (Widget) parent,
#else
@@ -923,8 +922,6 @@ WXWidget wxMenu::CreateMenu (wxMenuBar * menuBar, WXWidget parent, wxMenu * topM
if (mnem != 0)
XtVaSetValues (buttonWidget, XmNmnemonic, mnem, NULL);
XmStringFree (label_str);
}
m_menuWidget = (WXWidget) menu;

View File

@@ -65,20 +65,20 @@ m_bCheckable(bCheckable),
m_strName(strName)
{
wxASSERT( pParentMenu != NULL );
m_pParentMenu = pParentMenu;
m_pSubMenu = pSubMenu;
m_idItem = id;
m_bEnabled = TRUE;
m_bChecked = FALSE;
//// Motif-specific
m_menuBar = NULL;
m_buttonWidget = (WXWidget) NULL;
m_topMenu = NULL;
}
wxMenuItem::~wxMenuItem()
wxMenuItem::~wxMenuItem()
{
}
@@ -89,7 +89,7 @@ wxMenuItem::~wxMenuItem()
void wxMenuItem::DeleteSubMenu()
{
wxASSERT( m_pSubMenu != NULL );
delete m_pSubMenu;
m_pSubMenu = NULL;
}
@@ -113,7 +113,7 @@ void wxMenuItem::Enable(bool bDoEnable)
if (m_buttonWidget)
XtSetSensitive( (Widget) m_buttonWidget, (Boolean) bDoEnable);
}
m_bEnabled = bDoEnable;
}
}
@@ -121,7 +121,7 @@ void wxMenuItem::Enable(bool bDoEnable)
void wxMenuItem::Check(bool bDoCheck)
{
wxCHECK_RET( IsCheckable(), "only checkable items may be checked" );
if ( m_bChecked != bDoCheck )
{
if (m_buttonWidget && XtIsSubclass ((Widget) m_buttonWidget, xmToggleButtonGadgetClass))
@@ -138,48 +138,47 @@ void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMen
{
m_menuBar = menuBar;
m_topMenu = topMenu;
if (GetId() == -2)
{
// Id=-2 identifies a Title item.
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget
(wxStripMenuCodes(m_strName),
xmLabelGadgetClass, (Widget) menu, NULL);
}
else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
{
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer);
wxString strName = wxStripMenuCodes(m_strName);
if (IsCheckable())
{
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
xmToggleButtonGadgetClass, (Widget) menu,
NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
}
else
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer,
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
xmPushButtonGadgetClass, (Widget) menu,
NULL);
char mnem = wxFindMnemonic (m_strName);
if (mnem != 0)
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
//// TODO: proper accelerator treatment. What does wxFindAccelerator
//// look for?
strcpy(wxBuffer, (char*) (const char*) m_strName);
char *accel = wxFindAccelerator (wxBuffer);
strName = m_strName;
char *accel = wxFindAccelerator (strName);
if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
// TODO: What does this do?
strcpy(wxBuffer, (char*) (const char*) m_strName);
XmString accel_str = wxFindAcceleratorText (wxBuffer);
XmString accel_str = wxFindAcceleratorText (strName);
if (accel_str)
{
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
XmStringFree (accel_str);
}
if (IsCheckable())
XtAddCallback ((Widget) m_buttonWidget,
XmNvalueChangedCallback,
@@ -222,7 +221,7 @@ void wxMenuItem::DestroyItem(bool full)
if (GetId() == -2)
{
; // Nothing
}
else if ((!m_strName.IsNull() && (m_strName != "")) && !m_pSubMenu)
{
@@ -243,7 +242,7 @@ void wxMenuItem::DestroyItem(bool full)
else if (GetId() == -1)
{
; // Nothing
}
else if (GetSubMenu())
{
@@ -256,7 +255,7 @@ void wxMenuItem::DestroyItem(bool full)
if (full)
m_buttonWidget = NULL;
}
if (m_buttonWidget && full)
{
XtDestroyWidget ((Widget) m_buttonWidget);
@@ -267,26 +266,23 @@ void wxMenuItem::DestroyItem(bool full)
void wxMenuItem::SetLabel(const wxString& label)
{
char mnem = wxFindMnemonic (label);
wxStripMenuCodes ((char*) (const char*) label, wxBuffer);
wxString label2 = wxStripMenuCodes(label);
m_strName = label;
if (m_buttonWidget)
{
XmString label_str = XmStringCreateSimple (wxBuffer);
wxXmString label_str(label2);
XtVaSetValues ((Widget) m_buttonWidget,
XmNlabelString, label_str,
NULL);
XmStringFree (label_str);
if (mnem != 0)
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
strcpy(wxBuffer, (char*) (const char*) label);
char *accel = wxFindAccelerator (wxBuffer);
char *accel = wxFindAccelerator (label2);
if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
strcpy(wxBuffer, (char*) (const char*) label);
XmString accel_str = wxFindAcceleratorText (wxBuffer);
XmString accel_str = wxFindAcceleratorText (label2);
if (accel_str)
{
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
@@ -312,7 +308,7 @@ void wxMenuItemCallback (Widget w, XtPointer clientData,
wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, item->GetId());
commandEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
commandEvent.SetInt( item->GetId() );
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(commandEvent);
}
else if (item->GetTopMenu())
@@ -320,7 +316,7 @@ void wxMenuItemCallback (Widget w, XtPointer clientData,
wxCommandEvent event (wxEVT_COMMAND_MENU_SELECTED, item->GetId());
event.SetEventObject(item->GetTopMenu());
event.SetInt( item->GetId() );
item->GetTopMenu()->ProcessCommand (event);
}
}
@@ -336,13 +332,13 @@ void wxMenuItemArmCallback (Widget w, XtPointer clientData,
{
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, item->GetId());
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
}
}
}
void
void
wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
XtPointer ptr)
{
@@ -355,7 +351,7 @@ wxMenuItemDisarmCallback (Widget w, XtPointer clientData,
// special to event system
wxMenuEvent menuEvent(wxEVT_MENU_HIGHLIGHT, -1);
menuEvent.SetEventObject(item->GetMenuBar()->GetMenuBarFrame());
item->GetMenuBar()->GetMenuBarFrame()->GetEventHandler()->ProcessEvent(menuEvent);
}
}

View File

@@ -88,9 +88,9 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
wxString label1(wxStripMenuCodes(title));
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
wxXmString text(label1.c_str());
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
Widget formWidget = XtVaCreateManagedWidget (name.c_str(),
xmFormWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
@@ -101,11 +101,11 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
if (label1 != "")
{
text = XmStringCreateSimple ((char*) (const char*) label1);
Widget labelWidget = XtVaCreateManagedWidget ((char*) (const char*) label1,
wxXmString text(label1);
(void)XtVaCreateManagedWidget(label1.c_str(),
#if wxUSE_GADGETS
style & wxCOLOURED ?
xmLabelWidgetClass : xmLabelGadgetClass,
style & wxCOLOURED ? xmLabelWidgetClass
: xmLabelGadgetClass,
formWidget,
#else
xmLabelWidgetClass, formWidget,
@@ -113,8 +113,6 @@ bool wxRadioBox::Create(wxWindow *parent, wxWindowID id, const wxString& title,
XmNfontList, fontList,
XmNlabelString, text,
NULL);
XmStringFree (text);
}
Widget frameWidget = XtVaCreateManagedWidget ("frame",

View File

@@ -48,24 +48,24 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
m_font = parent->GetFont();
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowStyle = style ;
Widget parentWidget = (Widget) parent->GetClientWidget();
wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
XmFontList fontList = (XmFontList) m_font.GetFontList(1.0, XtDisplay(parentWidget));
Widget radioButtonWidget = XtVaCreateManagedWidget ("toggle",
#if wxUSE_GADGETS
xmToggleButtonGadgetClass, parentWidget,
@@ -78,19 +78,19 @@ bool wxRadioButton::Create(wxWindow *parent, wxWindowID id,
XmNindicatorType, XmONE_OF_MANY, // diamond-shape
NULL);
XmStringFree (text);
XtAddCallback (radioButtonWidget, XmNvalueChangedCallback, (XtCallbackProc) wxRadioButtonCallback,
(XtCallbackProc) this);
m_mainWidget = (WXWidget) radioButtonWidget;
XtManageChild (radioButtonWidget);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -140,14 +140,14 @@ void wxRadioButtonCallback (Widget w, XtPointer clientData,
{
if (!cbs->set)
return;
wxRadioButton *item = (wxRadioButton *) clientData;
if (item->InSetValue())
return;
wxCommandEvent event (wxEVT_COMMAND_RADIOBUTTON_SELECTED, item->GetId());
event.SetEventObject(item);
item->ProcessCommand (event);
}

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -43,13 +43,13 @@ bool wxScrollBar::Create(wxWindow *parent, wxWindowID id,
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
SetValidator(validator);
m_windowStyle = style;
if ( id == -1 )
m_windowId = (int)NewControlId();
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowId = id;
int x = pos.x;
int y = pos.y;

View File

@@ -56,26 +56,26 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
SetValidator(validator);
m_backgroundColour = parent->GetBackgroundColour();
m_foregroundColour = parent->GetForegroundColour();
if (parent) parent->AddChild(this);
m_lineSize = 1;
m_windowStyle = style;
m_tickFreq = 0;
if ( id == -1 )
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_rangeMax = maxValue;
m_rangeMin = minValue;
// Not used in Motif, I think
m_pageSize = (int)((maxValue-minValue)/10);
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget sliderWidget = XtVaCreateManagedWidget ("sliderWidget",
xmScaleWidgetClass, parentWidget,
XmNorientation,
@@ -87,26 +87,26 @@ bool wxSlider::Create(wxWindow *parent, wxWindowID id,
XmNvalue, value,
XmNshowValue, True,
NULL);
m_mainWidget = (WXWidget) sliderWidget;
if(style & wxSL_NOTIFY_DRAG)
XtAddCallback (sliderWidget, XmNdragCallback,
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
else
XtAddCallback (sliderWidget, XmNvalueChangedCallback,
(XtCallbackProc) wxSliderCallback, (XtPointer) this);
XtAddCallback (sliderWidget, XmNdragCallback, (XtCallbackProc) wxSliderCallback, (XtPointer) this);
m_font = parent->GetFont();
ChangeFont(FALSE);
SetCanAddEventHandler(TRUE);
AttachWidget (parent, m_mainWidget, (WXWidget) NULL, pos.x, pos.y, size.x, size.y);
ChangeBackgroundColour();
return TRUE;
}
@@ -134,30 +134,30 @@ void wxSlider::GetSize(int *width, int *height) const
void wxSlider::DoSetSize(int x, int y, int width, int height, int sizeFlags)
{
Widget widget = (Widget) m_mainWidget;
bool managed = XtIsManaged(widget);
if (managed)
XtUnmanageChild (widget);
if (((m_windowStyle & wxHORIZONTAL) == wxHORIZONTAL) && (width > -1))
{
XtVaSetValues (widget, XmNscaleWidth, wxMax (width, 10), NULL);
}
if (((m_windowStyle & wxVERTICAL) == wxVERTICAL) && (height > -1))
{
XtVaSetValues (widget, XmNscaleHeight, wxMax (height, 10), NULL);
}
int xx = x; int yy = y;
AdjustForParentClientOrigin(xx, yy, sizeFlags);
if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues (widget, XmNx, xx, NULL);
if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE))
XtVaSetValues (widget, XmNy, yy, NULL);
if (managed)
XtManageChild (widget);
}
@@ -166,7 +166,7 @@ void wxSlider::SetRange(int minValue, int maxValue)
{
m_rangeMin = minValue;
m_rangeMax = maxValue;
XtVaSetValues ((Widget) m_mainWidget, XmNminimum, minValue, XmNmaximum, maxValue, NULL);
}
@@ -276,12 +276,12 @@ void wxSliderCallback (Widget widget, XtPointer clientData, XmScaleCallbackStruc
// TODO: the XmCR_VALUE_CHANGED case should be handled
// differently (it's not sent continually as the slider moves).
// In which case we need a similar behaviour for other platforms.
wxScrollEvent event(wxEVT_SCROLL_THUMBTRACK, slider->GetId());
XtVaGetValues (widget, XmNvalue, &event.m_commandInt, NULL);
event.SetEventObject(slider);
slider->ProcessCommand(event);
// Also send a wxCommandEvent for compatibility.
wxCommandEvent event2(wxEVT_COMMAND_SLIDER_UPDATED, slider->GetId());
event2.SetEventObject(slider);

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -17,14 +17,9 @@
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
#endif
wxSpinButton::wxSpinButton()
{
m_min = 0;
m_max = 100;
}
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
{
@@ -33,9 +28,8 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
m_windowStyle = style;
if (parent) parent->AddChild(this);
m_min = 0;
m_max = 100;
InitBase();
m_windowId = (id == -1) ? NewControlId() : id;
@@ -52,20 +46,19 @@ wxSpinButton::~wxSpinButton()
int wxSpinButton::GetValue() const
{
// TODO
// TODO
return 0;
}
void wxSpinButton::SetValue(int val)
{
// TODO
// TODO
}
void wxSpinButton::SetRange(int minVal, int maxVal)
{
m_min = minVal;
m_max = maxVal;
// TODO
// TODO
wxSpinButtonBase::SetRange(minVal, maxVal);
}
void wxSpinButton::ChangeFont(bool keepOriginalSize)
@@ -82,12 +75,3 @@ void wxSpinButton::ChangeForegroundColour()
{
// TODO
}
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
wxScrollEvent(commandType, id)
{
}

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -44,9 +44,9 @@ bool wxStaticBitmap::Create(wxWindow *parent, wxWindowID id,
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowId = id;
m_windowStyle = style;
@@ -98,7 +98,7 @@ void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
XtVaSetValues (widget,
XmNlabelPixmap, ((wxBitmap&)bitmap).GetLabelPixmap (widget),
XmNlabelType, XmPIXMAP,
NULL);
NULL);
GetSize(&w1, &h1);
if (! (w1 == w2) && (h1 == h2))

View File

@@ -6,7 +6,7 @@
// Created: 17/09/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -27,7 +27,7 @@
IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
BEGIN_EVENT_TABLE(wxStaticBox, wxControl)
// EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
//EVT_ERASE_BACKGROUND(wxStaticBox::OnEraseBackground)
END_EVENT_TABLE()
#endif
@@ -35,7 +35,7 @@ END_EVENT_TABLE()
/*
* Static box
*/
wxStaticBox::wxStaticBox()
{
m_formWidget = (WXWidget) 0;
@@ -60,9 +60,9 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
if (parent) parent->AddChild(this);
if ( id == -1 )
m_windowId = (int)NewControlId();
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowId = id;
m_windowStyle = style;
@@ -71,10 +71,10 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
Widget parentWidget = (Widget) parent->GetClientWidget();
Widget formWidget = XtVaCreateManagedWidget ((char*) (const char*) name,
xmFormWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
NULL);
xmFormWidgetClass, parentWidget,
XmNmarginHeight, 0,
XmNmarginWidth, 0,
NULL);
if (hasLabel)
@@ -84,35 +84,35 @@ bool wxStaticBox::Create(wxWindow *parent, wxWindowID id,
wxString label1(wxStripMenuCodes(label));
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
m_labelWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) label1,
xmLabelWidgetClass, formWidget,
XmNfontList, fontList,
XmNlabelString, text,
NULL);
xmLabelWidgetClass, formWidget,
XmNfontList, fontList,
XmNlabelString, text,
NULL);
XmStringFree (text);
}
Widget frameWidget = XtVaCreateManagedWidget ("frame",
xmFrameWidgetClass, formWidget,
XmNshadowType, XmSHADOW_IN,
// XmNmarginHeight, 0,
// XmNmarginWidth, 0,
NULL);
xmFrameWidgetClass, formWidget,
XmNshadowType, XmSHADOW_IN,
//XmNmarginHeight, 0,
//XmNmarginWidth, 0,
NULL);
if (hasLabel)
XtVaSetValues ((Widget) m_labelWidget,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNalignment, XmALIGNMENT_BEGINNING,
NULL);
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
XmNalignment, XmALIGNMENT_BEGINNING,
NULL);
XtVaSetValues (frameWidget,
XmNtopAttachment, hasLabel ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, hasLabel ? (Widget) m_labelWidget : formWidget,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XmNtopAttachment, hasLabel ? XmATTACH_WIDGET : XmATTACH_FORM,
XmNtopWidget, hasLabel ? (Widget) m_labelWidget : formWidget,
XmNbottomAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
m_mainWidget = (WXWidget) frameWidget;
m_formWidget = (WXWidget) formWidget;
@@ -149,9 +149,9 @@ void wxStaticBox::SetLabel(const wxString& label)
XmString text = XmStringCreateSimple ((char*) (const char*) label1);
XtVaSetValues ((Widget) m_labelWidget,
XmNlabelString, text,
XmNlabelType, XmSTRING,
NULL);
XmNlabelString, text,
XmNlabelType, XmSTRING,
NULL);
XmStringFree (text);
}
}
@@ -164,8 +164,8 @@ wxString wxStaticBox::GetLabel() const
XmString text = 0;
char *s;
XtVaGetValues ((Widget) m_labelWidget,
XmNlabelString, &text,
NULL);
XmNlabelString, &text,
NULL);
if (!text)
return wxEmptyString;
@@ -193,10 +193,10 @@ void wxStaticBox::DoSetSize(int x, int y, int width, int height, int sizeFlags)
if (width > -1)
XtVaSetValues ((Widget) m_mainWidget, XmNwidth, width,
NULL);
NULL);
if (height > -1)
XtVaSetValues ((Widget) m_mainWidget, XmNheight, height - yy,
NULL);
NULL);
}
}

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -40,9 +40,9 @@ bool wxStaticText::Create(wxWindow *parent, wxWindowID id,
m_foregroundColour = parent->GetForegroundColour();
if ( id == -1 )
m_windowId = (int)NewControlId();
m_windowId = (int)NewControlId();
else
m_windowId = id;
m_windowId = id;
m_windowStyle = style;
m_font = parent->GetFont();

View File

@@ -83,9 +83,6 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallba
// Text item
wxTextCtrl::wxTextCtrl()
#ifndef NO_TEXT_WINDOW_STREAM
: streambuf()
#endif
{
m_tempCallbackStruct = (void*) NULL;
m_modified = FALSE;
@@ -587,161 +584,6 @@ void wxTextCtrl::OnDropFiles(wxDropFilesEvent& event)
}
}
// The streambuf code was partly taken from chapter 3 by Jerry Schwarz of
// AT&T's "C++ Lanuage System Release 3.0 Library Manual" - Stein Somers
//=========================================================================
// Called then the buffer is full (gcc 2.6.3)
// or when "endl" is output (Borland 4.5)
//=========================================================================
// Class declaration using multiple inheritance doesn't work properly for
// Borland. See note in wb_text.h.
#ifndef NO_TEXT_WINDOW_STREAM
int wxTextCtrl::overflow(int c)
{
// Make sure there is a holding area
if ( allocate()==EOF )
{
wxError("Streambuf allocation failed","Internal error");
return EOF;
}
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("wxTextCtrl::overflow: Who's trespassing my get area?","Internal error");
return EOF;
}
// Reset get area
setg(0,0,0);
// Make sure there is a put area
if ( ! pptr() )
{
/* This doesn't seem to be fatal so comment out error message */
// wxError("Put area not opened","Internal error");
setp( base(), base() );
}
// Determine how many characters have been inserted but no consumed
int plen = pptr() - pbase();
// Now Jerry relies on the fact that the buffer is at least 2 chars
// long, but the holding area "may be as small as 1" ???
// And we need an additional \0, so let's keep this inefficient but
// safe copy.
// If c!=EOF, it is a character that must also be comsumed
int xtra = c==EOF? 0 : 1;
// Write temporary C-string to wxTextWindow
{
char *txt = new char[plen+xtra+1];
memcpy(txt, pbase(), plen);
txt[plen] = (char)c; // append c
txt[plen+xtra] = '\0'; // append '\0' or overwrite c
// If the put area already contained \0, output will be truncated there
WriteText(txt);
delete[] txt;
}
// Reset put area
setp(pbase(), epptr());
#if defined(__WATCOMC__)
return __NOT_EOF;
#elif defined(zapeof) // HP-UX (all cfront based?)
return zapeof(c);
#else
return c!=EOF ? c : 0; // this should make everybody happy
#endif
}
//=========================================================================
// called then "endl" is output (gcc) or then explicit sync is done (Borland)
//=========================================================================
int wxTextCtrl::sync()
{
// Verify that there are no characters in get area
if ( gptr() && gptr() < egptr() )
{
wxError("Who's trespassing my get area?","Internal error");
return EOF;
}
if ( pptr() && pptr() > pbase() ) return overflow(EOF);
return 0;
/* OLD CODE
int len = pptr() - pbase();
char *txt = new char[len+1];
strncpy(txt, pbase(), len);
txt[len] = '\0';
(*this) << txt;
setp(pbase(), epptr());
delete[] txt;
return 0;
*/
}
//=========================================================================
// Should not be called by a "ostream". Used by a "istream"
//=========================================================================
int wxTextCtrl::underflow()
{
return EOF;
}
#endif
wxTextCtrl& wxTextCtrl::operator<<(const wxString& s)
{
AppendText(s);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(float f)
{
wxString str;
str.Printf("%.2f", f);
AppendText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(double d)
{
wxString str;
str.Printf("%.2f", d);
AppendText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(int i)
{
wxString str;
str.Printf("%d", i);
AppendText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(long i)
{
wxString str;
str.Printf("%ld", i);
AppendText(str);
return *this;
}
wxTextCtrl& wxTextCtrl::operator<<(const char c)
{
char buf[2];
buf[0] = c;
buf[1] = 0;
AppendText(buf);
return *this;
}
void wxTextCtrl::OnChar(wxKeyEvent& event)
{
// Indicates that we should generate a normal command, because

View File

@@ -725,7 +725,7 @@ char wxFindMnemonic (const char *s)
return mnem;
}
char * wxFindAccelerator (char *s)
char * wxFindAccelerator (const char *s)
{
// The accelerator text is after the \t char.
while (*s && *s != '\t')
@@ -748,7 +748,7 @@ char * wxFindAccelerator (char *s)
wxBuffer[0] = '\0';
char *tmp = copystring (s);
s = tmp;
char *p = s;
char *p = tmp;
while (1)
{
@@ -763,8 +763,7 @@ char * wxFindAccelerator (char *s)
strcat (wxBuffer, s);
else
strcat (wxBuffer, "Meta");
s = p + 1;
p = s;
s = p++;
}
else
{
@@ -777,7 +776,7 @@ char * wxFindAccelerator (char *s)
return wxBuffer;
}
XmString wxFindAcceleratorText (char *s)
XmString wxFindAcceleratorText (const char *s)
{
// The accelerator text is after the \t char.
while (*s && *s != '\t')
@@ -785,7 +784,7 @@ XmString wxFindAcceleratorText (char *s)
if (*s == '\0')
return (NULL);
s++;
XmString text = XmStringCreateSimple (s);
XmString text = XmStringCreateSimple ((char *)s);
return text;
}

View File

@@ -1671,6 +1671,9 @@ bool wxAddWindowToTable(Widget w, wxWindow *win)
wxWidgetHashTable->Put((long) w, win);
wxLogDebug("Widget 0x%08x <-> window %p (%s)",
w, win, win->GetClassInfo()->GetClassName());
return TRUE;
}

View File

@@ -113,6 +113,7 @@ libwx_msw_la_SOURCES = \
dcpsg.cpp \
gridg.cpp \
laywin.cpp \
numdlgg.cpp \
panelg.cpp \
progdlgg.cpp \
prop.cpp \

View File

@@ -38,16 +38,15 @@
#if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
#endif
wxSpinButton::wxSpinButton()
{
m_min = 0;
m_max = 100;
}
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
bool wxSpinButton::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
wxSystemSettings settings;
m_backgroundColour = parent->GetBackgroundColour() ;
@@ -73,13 +72,12 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
if (y < 0)
y = 0;
m_min = 0;
m_max = 100;
InitBase();
m_windowId = (id == -1) ? NewControlId() : id;
DWORD wstyle = WS_VISIBLE | WS_CHILD | WS_TABSTOP;
if ( m_windowStyle & wxSP_HORIZONTAL )
wstyle |= UDS_HORZ;
if ( m_windowStyle & wxSP_ARROW_KEYS )
@@ -102,7 +100,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
// TODO: have this for all controls.
if ( !m_hWnd )
return FALSE;
SubclassWin((WXHWND) m_hWnd);
return TRUE;
@@ -127,8 +125,7 @@ void wxSpinButton::SetValue(int val)
void wxSpinButton::SetRange(int minVal, int maxVal)
{
m_min = minVal;
m_max = maxVal;
wxSpinButtonBase::SetRange(minVal, maxVal);
::SendMessage(GetHwnd(), UDM_SETRANGE, 0,
(LPARAM) MAKELONG((short)maxVal, (short)minVal));
}
@@ -188,12 +185,4 @@ bool wxSpinButton::MSWCommand(WXUINT cmd, WXWORD id)
return FALSE;
}
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id)
: wxScrollEvent(commandType, id)
{
}
#endif // __WIN95__