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 splitter.cpp G
statusbr.cpp G statusbr.cpp G
tabg.cpp G tabg.cpp G
numdlgg.cpp G
textdlgg.cpp G textdlgg.cpp G
tipdlg.cpp G tipdlg.cpp G
treectrl.cpp G 16 treectrl.cpp G 16

View File

@@ -1307,11 +1307,10 @@ public:
virtual void OnCommand(wxWindow& WXUNUSED(win), virtual void OnCommand(wxWindow& WXUNUSED(win),
wxCommandEvent& WXUNUSED(event)) wxCommandEvent& WXUNUSED(event))
{ {
wxFAIL_MSG("shouldn't be called any more");
} }
// Called if child control has no // Called if child control has no callback function
// callback function
// Default behaviour
virtual long Default() virtual long Default()
{ return GetNextHandler() ? GetNextHandler()->Default() : 0; }; { return GetNextHandler() ? GetNextHandler()->Default() : 0; };
#endif // WXWIN_COMPATIBILITY_2 #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 wxString WXDLLEXPORT
@@ -65,15 +65,5 @@ wxGetTextFromUser(const wxString& message,
int y = -1, int y = -1,
bool centre = TRUE); 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 #endif
// __TEXTDLGH_G__ // __TEXTDLGH_G__

View File

@@ -61,7 +61,7 @@ enum {
GSOCK_INPUT_FLAG = 1 << GSOCK_INPUT, GSOCK_INPUT_FLAG = 1 << GSOCK_INPUT,
GSOCK_OUTPUT_FLAG = 1 << GSOCK_OUTPUT, GSOCK_OUTPUT_FLAG = 1 << GSOCK_OUTPUT,
GSOCK_CONNECTION_FLAG = 1 << GSOCK_CONNECTION, GSOCK_CONNECTION_FLAG = 1 << GSOCK_CONNECTION,
GSOCK_LOST_FLAG = 1 << GSOCK_LOST, GSOCK_LOST_FLAG = 1 << GSOCK_LOST
}; };
typedef int GSocketEventFlags; typedef int GSocketEventFlags;

View File

@@ -15,49 +15,35 @@
#pragma interface #pragma interface
#endif #endif
#include "wx/defs.h"
#ifdef wxUSE_SPINBTN
#include "wx/object.h"
#include "wx/control.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxSpinButton;
class wxSpinEvent;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxSpinButton // wxSpinButton
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxSpinButton : public wxControl class wxSpinButton : public wxSpinButtonBase
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
public: public:
wxSpinButton(); wxSpinButton() { }
inline wxSpinButton( wxWindow *parent, wxWindowID id = -1, wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton") long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
~wxSpinButton(); ~wxSpinButton();
bool Create( wxWindow *parent, wxWindowID id = -1, bool Create( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton" ); long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton" );
int GetValue() const; virtual int GetValue() const;
void SetValue( int value ); virtual void SetValue( int value );
void SetRange( int minVal, int maxVal ); virtual void SetRange( int minVal, int maxVal );
int GetMin() const; virtual int GetMin() const;
int GetMax() const; virtual int GetMax() const;
// implementation // implementation
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
@@ -66,38 +52,9 @@ public:
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;
private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
class 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
#endif #endif
// __GTKSPINBUTTH__ // __GTKSPINBUTTH__

View File

@@ -15,49 +15,35 @@
#pragma interface #pragma interface
#endif #endif
#include "wx/defs.h"
#ifdef wxUSE_SPINBTN
#include "wx/object.h"
#include "wx/control.h"
//-----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
class wxSpinButton;
class wxSpinEvent;
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxSpinButton // wxSpinButton
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxSpinButton : public wxControl class wxSpinButton : public wxSpinButtonBase
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
public: public:
wxSpinButton(); wxSpinButton() { }
inline wxSpinButton( wxWindow *parent, wxWindowID id = -1, wxSpinButton( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton") long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton")
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
~wxSpinButton(); ~wxSpinButton();
bool Create( wxWindow *parent, wxWindowID id = -1, bool Create( wxWindow *parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton" ); long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton" );
int GetValue() const; virtual int GetValue() const;
void SetValue( int value ); virtual void SetValue( int value );
void SetRange( int minVal, int maxVal ); virtual void SetRange( int minVal, int maxVal );
int GetMin() const; virtual int GetMin() const;
int GetMax() const; virtual int GetMax() const;
// implementation // implementation
void OnSize( wxSizeEvent &event ); void OnSize( wxSizeEvent &event );
bool IsOwnGtkWindow( GdkWindow *window ); bool IsOwnGtkWindow( GdkWindow *window );
@@ -66,38 +52,9 @@ public:
GtkAdjustment *m_adjust; GtkAdjustment *m_adjust;
float m_oldPos; float m_oldPos;
private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
//-----------------------------------------------------------------------------
// wxSpinEvent
//-----------------------------------------------------------------------------
class 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
#endif #endif
// __GTKSPINBUTTH__ // __GTKSPINBUTTH__

View File

@@ -25,9 +25,12 @@ WXDLLEXPORT_DATA(extern const char*) wxButtonNameStr;
class WXDLLEXPORT wxButton: public wxControl class WXDLLEXPORT wxButton: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxButton) DECLARE_DYNAMIC_CLASS(wxButton)
public: public:
inline wxButton() {} wxButton() { }
inline wxButton(wxWindow *parent, wxWindowID id, const wxString& label, wxButton(wxWindow *parent,
wxWindowID id,
const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = 0, const wxSize& size = wxDefaultSize, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,

View File

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

View File

@@ -39,9 +39,15 @@ extern void wxDeleteWindowFromTable(Widget w);
extern wxWindow *wxGetWindowFromTable(Widget w); extern wxWindow *wxGetWindowFromTable(Widget w);
extern bool wxAddWindowToTable(Widget w, wxWindow *win); extern bool wxAddWindowToTable(Widget w, wxWindow *win);
// ----------------------------------------------------------------------------
// key events related functions
// ----------------------------------------------------------------------------
extern char wxFindMnemonic(const char* s); 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 int wxCharCodeXToWX(KeySym keySym);
extern KeySym wxCharCodeWXToX(int id); extern KeySym wxCharCodeWXToX(int id);

View File

@@ -16,55 +16,43 @@
#pragma interface "spinbutt.h" #pragma interface "spinbutt.h"
#endif #endif
#include "wx/control.h" class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
#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
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
public: public:
/* wxSpinButton() { }
* Public interface
*/
wxSpinButton(); wxSpinButton(wxWindow *parent,
wxWindowID id = -1,
inline wxSpinButton(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, const wxPoint& pos = wxDefaultPosition,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton") const wxSize& size = wxDefaultSize,
long style = wxSP_VERTICAL,
const wxString& name = "wxSpinButton")
{ {
Create(parent, id, pos, size, style, name); Create(parent, id, pos, size, style, name);
} }
~wxSpinButton(); ~wxSpinButton();
bool Create(wxWindow *parent, wxWindowID id = -1, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, bool Create(wxWindow *parent,
long style = wxSP_VERTICAL, const wxString& name = "wxSpinButton"); 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 GetValue() const;
int GetMin() const { return m_min; }
int GetMax() const { return m_max; }
// operations
void SetValue(int val); void SetValue(int val);
void SetRange(int minVal, int maxVal); void SetRange(int minVal, int maxVal);
inline int GetMin() const { return m_min; }
inline int GetMax() const { return m_max; }
// Operations
////////////////////////////////////////////////////////////////////////////
void Command(wxCommandEvent& event) { ProcessCommand(event); };
// Implementation // Implementation
virtual void Command(wxCommandEvent& event) { (void)ProcessCommand(event); };
virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour(); virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour(); virtual void ChangeForegroundColour();
@@ -74,29 +62,5 @@ protected:
int m_max; 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 #endif
// _WX_SPINBUTT_H_ // _WX_SPINBUTT_H_

View File

@@ -47,8 +47,10 @@ public:
virtual void SetBitmap(const wxBitmap& bitmap); virtual void SetBitmap(const wxBitmap& bitmap);
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; {
return FALSE;
}
wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; } wxBitmap& GetBitmap() const { return (wxBitmap&) m_messageBitmap; }

View File

@@ -45,8 +45,10 @@ public:
long style = 0, long style = 0,
const wxString& name = wxStaticBoxNameStr); const wxString& name = wxStaticBoxNameStr);
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {}; {
return FALSE;
}
void SetLabel(const wxString& label); void SetLabel(const wxString& label);
wxString GetLabel() const; wxString GetLabel() const;

View File

@@ -23,10 +23,11 @@ WXDLLEXPORT_DATA(extern const char*) wxStaticTextNameStr;
class WXDLLEXPORT wxStaticText: public wxControl class WXDLLEXPORT wxStaticText: public wxControl
{ {
DECLARE_DYNAMIC_CLASS(wxStaticText) DECLARE_DYNAMIC_CLASS(wxStaticText)
public:
inline wxStaticText() { }
inline wxStaticText(wxWindow *parent, wxWindowID id, public:
wxStaticText() { }
wxStaticText(wxWindow *parent, wxWindowID id,
const wxString& label, const wxString& label,
const wxPoint& pos = wxDefaultPosition, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, const wxSize& size = wxDefaultSize,
@@ -43,11 +44,15 @@ class WXDLLEXPORT wxStaticText: public wxControl
long style = 0, long style = 0,
const wxString& name = wxStaticTextNameStr); const wxString& name = wxStaticTextNameStr);
// operations // implementation
virtual void Command(wxCommandEvent& WXUNUSED(event)) {}; // --------------
virtual void ProcessCommand(wxCommandEvent& WXUNUSED(event)) {};
// operations
virtual bool ProcessCommand(wxCommandEvent& WXUNUSED(event))
{
return FALSE;
}
// Implementation
virtual void ChangeFont(bool keepOriginalSize = TRUE); virtual void ChangeFont(bool keepOriginalSize = TRUE);
virtual void ChangeBackgroundColour(); virtual void ChangeBackgroundColour();
virtual void ChangeForegroundColour(); virtual void ChangeForegroundColour();

View File

@@ -16,22 +16,11 @@
#pragma interface "textctrl.h" #pragma interface "textctrl.h"
#endif #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*) wxTextCtrlNameStr;
WXDLLEXPORT_DATA(extern const char*) wxEmptyString; WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
// Single-line text item // Single-line text item
class WXDLLEXPORT wxTextCtrl : public wxControl class WXDLLEXPORT wxTextCtrl : public wxControl
#ifndef NO_TEXT_WINDOW_STREAM
, public streambuf
#endif
{ {
DECLARE_DYNAMIC_CLASS(wxTextCtrl) DECLARE_DYNAMIC_CLASS(wxTextCtrl)
@@ -47,9 +36,6 @@ public:
long style = 0, long style = 0,
const wxValidator& validator = wxDefaultValidator, const wxValidator& validator = wxDefaultValidator,
const wxString& name = wxTextCtrlNameStr) const wxString& name = wxTextCtrlNameStr)
#ifndef NO_TEXT_WINDOW_STREAM
: streambuf()
#endif
{ {
Create(parent, id, value, pos, size, style, validator, name); Create(parent, id, value, pos, size, style, validator, name);
} }
@@ -101,20 +87,6 @@ public:
virtual void GetSelection(long* from, long* to) const; virtual void GetSelection(long* from, long* to) const;
virtual bool IsEditable() 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 LoadFile(const wxString& file);
virtual bool SaveFile(const wxString& file); virtual bool SaveFile(const wxString& file);
virtual void WriteText(const wxString& text); virtual void WriteText(const wxString& text);

View File

@@ -21,17 +21,8 @@
#if defined(__WIN95__) #if defined(__WIN95__)
/*
The wxSpinButton is like a small scrollbar than is often placed next
to a text control.
wxSP_HORIZONTAL: horizontal spin button class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase
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
{ {
DECLARE_DYNAMIC_CLASS(wxSpinButton) DECLARE_DYNAMIC_CLASS(wxSpinButton)
@@ -64,49 +55,16 @@ public:
// Attributes // Attributes
//////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////
int GetValue() const ; virtual int GetValue() const;
void SetValue(int val) ; virtual void SetValue(int val);
void SetRange(int minVal, int maxVal); virtual void SetRange(int minVal, int maxVal);
int GetMin() const { return m_min; }
int GetMax() const { return m_max; }
// Operations
////////////////////////////////////////////////////////////////////////////
// IMPLEMENTATION // IMPLEMENTATION
virtual bool MSWCommand(WXUINT param, WXWORD id); virtual bool MSWCommand(WXUINT param, WXWORD id);
virtual bool MSWOnScroll(int orientation, WXWORD wParam, virtual bool MSWOnScroll(int orientation, WXWORD wParam,
WXWORD pos, WXHWND control); 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 #endif
// _WX_WIN95__ // _WX_WIN95__
#endif #endif

View File

@@ -1,6 +1,74 @@
/////////////////////////////////////////////////////////////////////////////
// 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_ #ifndef _WX_SPINBUTT_H_BASE_
#define _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__) #if defined(__WXMSW__)
#include "wx/msw/spinbutt.h" #include "wx/msw/spinbutt.h"
#elif defined(__WXMOTIF__) #elif defined(__WXMOTIF__)
@@ -15,5 +83,37 @@
#include "wx/stubs/spinbutt.h" #include "wx/stubs/spinbutt.h"
#endif #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 #endif
// _WX_SPINBUTT_H_BASE_ // _WX_SPINBUTT_H_BASE_

View File

@@ -7,5 +7,19 @@
#include "wx/generic/textdlgg.h" #include "wx/generic/textdlgg.h"
#endif #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 #endif
// _WX_TEXTDLG_H_BASE_ // _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 // ... and attach this menu bar to the frame
SetMenuBar(menuBar); SetMenuBar(menuBar);
(void)new wxTextCtrl(this, -1, "Hi!", wxPoint(20, 20),
wxSize(100, 30));
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
// create a status bar just for fun (by default with 1 pane only) // create a status bar just for fun (by default with 1 pane only)
CreateStatusBar(2); CreateStatusBar(2);

View File

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

View File

@@ -16,6 +16,13 @@
#pragma hdrstop #pragma hdrstop
#endif #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 #if (wxUSE_FS_INET || wxUSE_FS_ZIP) && wxUSE_STREAMS
#include "wx/wfstream.h" #include "wx/wfstream.h"

View File

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

View File

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

View File

@@ -87,7 +87,9 @@ bool wxBMPHandler::LoadFile( wxImage *image, wxInputStream& stream )
stream.Read( &bbuf, 2 ); stream.Read( &bbuf, 2 );
stream.Read( dbuf, 4 * 4 ); stream.Read( dbuf, 4 * 4 );
#if 0 // unused
wxInt32 size = wxINT32_SWAP_ON_BE( dbuf[0] ); wxInt32 size = wxINT32_SWAP_ON_BE( dbuf[0] );
#endif
wxInt32 offset = wxINT32_SWAP_ON_BE( dbuf[2] ); wxInt32 offset = wxINT32_SWAP_ON_BE( dbuf[2] );
stream.Read(dbuf, 4 * 2); stream.Read(dbuf, 4 * 2);

View File

@@ -19,6 +19,8 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_HELP
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/string.h" #include "wx/string.h"
@@ -122,4 +124,5 @@ wxExtHelpController::DisplayHelp(wxString const &relativeURL)
#endif #endif
} }
#endif // wxUSE_HELP

View File

@@ -19,6 +19,8 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
#if wxUSE_HELP
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/setup.h" #include "wx/setup.h"
#include "wx/string.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" #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 // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -89,11 +60,6 @@ static const int wxID_TEXT = 3000;
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#if !USE_SHARED_LIBRARY #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) BEGIN_EVENT_TABLE(wxTextEntryDialog, wxDialog)
EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK) EVT_BUTTON(wxID_OK, wxTextEntryDialog::OnOK)
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -168,129 +134,3 @@ void wxTextEntryDialog::OnOK(wxCommandEvent& WXUNUSED(event) )
EndModal(wxID_OK); 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 \ imaglist.cpp \
laywin.cpp \ laywin.cpp \
listctrl.cpp \ listctrl.cpp \
numdlgg.cpp \
panelg.cpp \ panelg.cpp \
printps.cpp \ printps.cpp \
prntdlgg.cpp \ prntdlgg.cpp \

View File

@@ -360,8 +360,6 @@ int wxComboBox::GetSelection() const
} }
} }
wxFAIL_MSG( _T("wxComboBox: no selection") );
return -1; return -1;
} }

View File

@@ -21,15 +21,18 @@
IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow)
wxControl::wxControl(void) wxControl::wxControl()
{ {
m_needParent = TRUE; m_needParent = TRUE;
} }
wxControl::wxControl( wxWindow *parent, wxWindowID id, wxControl::wxControl( wxWindow *parent,
const wxPoint &pos, const wxSize &size, wxWindowID id,
long style, const wxString &name ) : const wxPoint &pos,
wxWindow( parent, id, pos, size, style, name ) const wxSize &size,
long style,
const wxString &name )
: wxWindow( parent, id, pos, size, style, name )
{ {
} }

View File

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

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

View File

@@ -360,8 +360,6 @@ int wxComboBox::GetSelection() const
} }
} }
wxFAIL_MSG( _T("wxComboBox: no selection") );
return -1; return -1;
} }

View File

@@ -21,15 +21,18 @@
IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow) IMPLEMENT_DYNAMIC_CLASS(wxControl,wxWindow)
wxControl::wxControl(void) wxControl::wxControl()
{ {
m_needParent = TRUE; m_needParent = TRUE;
} }
wxControl::wxControl( wxWindow *parent, wxWindowID id, wxControl::wxControl( wxWindow *parent,
const wxPoint &pos, const wxSize &size, wxWindowID id,
long style, const wxString &name ) : const wxPoint &pos,
wxWindow( parent, id, pos, size, style, name ) const wxSize &size,
long style,
const wxString &name )
: wxWindow( parent, id, pos, size, style, name )
{ {
} }

View File

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

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

View File

@@ -340,6 +340,12 @@ void wxApp::ProcessXEvent(WXEvent* _event)
if (event->type == KeyPress) 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)) if (CheckForAccelerator(_event))
{ {
// Do nothing! We intercepted and processed the event as an // Do nothing! We intercepted and processed the event as an
@@ -632,10 +638,6 @@ bool wxApp::CheckForAccelerator(WXEvent* event)
bool wxApp::CheckForKeyDown(WXEvent* event) bool wxApp::CheckForKeyDown(WXEvent* event)
{ {
XEvent* xEvent = (XEvent*) 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) if (xEvent->xany.type == KeyPress)
{ {
Widget widget = XtWindowToWidget((Display*) wxGetDisplay(), Widget widget = XtWindowToWidget((Display*) wxGetDisplay(),
@@ -655,7 +657,6 @@ bool wxApp::CheckForKeyDown(WXEvent* event)
win->ProcessEvent( keyEvent ); win->ProcessEvent( keyEvent );
return (keyEvent.GetSkipped() != TRUE); return (keyEvent.GetSkipped() != TRUE);
} }
#endif // 0
return FALSE; return FALSE;
} }

View File

@@ -26,7 +26,7 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
#if wxUSE_XPM #if wxHAVE_LIB_XPM
#include <X11/xpm.h> #include <X11/xpm.h>
#endif #endif
@@ -577,7 +577,7 @@ bool wxXBMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
return TRUE; return TRUE;
} }
#if wxUSE_XPM #if wxHAVE_LIB_XPM
class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler class WXDLLEXPORT wxXPMFileHandler: public wxBitmapHandler
{ {
DECLARE_DYNAMIC_CLASS(wxXPMFileHandler) DECLARE_DYNAMIC_CLASS(wxXPMFileHandler)
@@ -769,7 +769,7 @@ bool wxXPMDataHandler::Create( wxBitmap *bitmap, void *data, long WXUNUSED(flags
return M_BITMAPHANDLERDATA->m_ok ; return M_BITMAPHANDLERDATA->m_ok ;
} }
#endif #endif // wxHAVE_LIB_XPM
void wxBitmap::CleanUpHandlers() void wxBitmap::CleanUpHandlers()
{ {
@@ -790,12 +790,12 @@ void wxBitmap::InitStandardHandlers()
AddHandler(new wxXBMFileHandler); AddHandler(new wxXBMFileHandler);
AddHandler(new wxXBMDataHandler); AddHandler(new wxXBMDataHandler);
// XPM is considered standard for Motif, although it can be omitted if absolutely // XPM is considered standard for Motif, although it can be omitted if
// necessary. // libXpm is not installed
#if wxUSE_XPM #if wxHAVE_LIB_XPM
AddHandler(new wxXPMFileHandler); AddHandler(new wxXPMFileHandler);
AddHandler(new wxXPMDataHandler); AddHandler(new wxXPMDataHandler);
#endif #endif // wxHAVE_LIB_XPM
} }
WXPixmap wxBitmap::GetLabelPixmap (WXWidget w) WXPixmap wxBitmap::GetLabelPixmap (WXWidget w)

View File

@@ -70,7 +70,7 @@ bool wxChoice::Create(wxWindow *parent, wxWindowID id,
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
m_formWidget = (WXWidget) XtVaCreateManagedWidget ((char*) (const char*) name, m_formWidget = (WXWidget) XtVaCreateManagedWidget(name.c_str(),
xmRowColumnWidgetClass, parentWidget, xmRowColumnWidgetClass, parentWidget,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,
@@ -164,8 +164,7 @@ wxChoice::~wxChoice()
void wxChoice::Append(const wxString& item) void wxChoice::Append(const wxString& item)
{ {
wxStripMenuCodes ((char *)(const char *)item, wxBuffer); Widget w = XtVaCreateManagedWidget (wxStripMenuCodes(item),
Widget w = XtVaCreateManagedWidget (wxBuffer,
#if USE_GADGETS #if USE_GADGETS
xmPushButtonGadgetClass, (Widget) m_menuWidget, xmPushButtonGadgetClass, (Widget) m_menuWidget,
#else #else

View File

@@ -53,7 +53,7 @@ bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
Widget parentWidget = (Widget) parent->GetClientWidget(); Widget parentWidget = (Widget) parent->GetClientWidget();
Widget buttonWidget = XtVaCreateManagedWidget((char*) (const char*) name, Widget buttonWidget = XtVaCreateManagedWidget(name.c_str(),
xmComboBoxWidgetClass, parentWidget, xmComboBoxWidgetClass, parentWidget,
XmNmarginHeight, 0, XmNmarginHeight, 0,
XmNmarginWidth, 0, XmNmarginWidth, 0,

View File

@@ -31,7 +31,11 @@ wxControl::wxControl()
{ {
m_backgroundColour = *wxWHITE; m_backgroundColour = *wxWHITE;
m_foregroundColour = *wxBLACK; m_foregroundColour = *wxBLACK;
#if WXWIN_COMPATIBILITY
m_callback = 0; m_callback = 0;
#endif // WXWIN_COMPATIBILITY
m_inSetValue = FALSE; m_inSetValue = FALSE;
} }
@@ -89,43 +93,17 @@ wxString wxControl::GetLabel() const
} }
} }
void wxControl::ProcessCommand (wxCommandEvent & event) bool wxControl::ProcessCommand(wxCommandEvent & event)
{ {
// Tries: #if WXWIN_COMPATIBILITY
// 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 ( m_callback )
{ {
(void) (*(m_callback)) (*this, event); (void)(*m_callback)(this, event);
return TRUE;
} }
else else
{ #endif // WXWIN_COMPATIBILITY
GetEventHandler()->OnCommand(*this, event);
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 wxList wxModelessWindows; // Frames and modeless dialogs
extern wxList wxPendingDelete; extern wxList wxPendingDelete;
extern wxHashTable *wxWidgetHashTable;
#define wxUSE_INVISIBLE_RESIZE 1 #define wxUSE_INVISIBLE_RESIZE 1
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY

View File

@@ -50,8 +50,6 @@
#include "wx/motif/private.h" #include "wx/motif/private.h"
extern wxHashTable *wxWidgetHashTable;
void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs);
void wxFrameFocusProc(Widget workArea, XtPointer clientData, void wxFrameFocusProc(Widget workArea, XtPointer clientData,
XmAnyCallbackStruct *cbs); XmAnyCallbackStruct *cbs);
@@ -150,8 +148,18 @@ bool wxFrame::Create(wxWindow *parent,
int width = size.x; int height = size.y; int width = size.x; int height = size.y;
if (wxTopLevelUsed) if (wxTopLevelUsed)
{
// Change suggested by Matthew Flatt // 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 else
{ {
m_frameShell = wxTheApp->GetTopLevelWidget(); m_frameShell = wxTheApp->GetTopLevelWidget();
@@ -192,6 +200,9 @@ bool wxFrame::Create(wxWindow *parent,
// XmNresizePolicy, XmRESIZE_ANY, // XmNresizePolicy, XmRESIZE_ANY,
NULL); 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, XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE,
wxUniversalRepaintProc, (XtPointer) this); wxUniversalRepaintProc, (XtPointer) this);
@@ -202,9 +213,6 @@ bool wxFrame::Create(wxWindow *parent,
XtManageChild((Widget) m_clientArea); XtManageChild((Widget) m_clientArea);
XtManageChild((Widget) m_workArea); XtManageChild((Widget) m_workArea);
wxASSERT_MSG( !wxGetWindowFromTable((Widget)m_workArea),
"Widget table clash in frame.cpp") ;
wxAddWindowToTable((Widget) m_workArea, this); wxAddWindowToTable((Widget) m_workArea, this);
XtTranslations ptr ; XtTranslations ptr ;

View File

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

View File

@@ -142,22 +142,22 @@ void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMen
if (GetId() == -2) if (GetId() == -2)
{ {
// Id=-2 identifies a Title item. // Id=-2 identifies a Title item.
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer); m_buttonWidget = (WXWidget) XtVaCreateManagedWidget
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, (wxStripMenuCodes(m_strName),
xmLabelGadgetClass, (Widget) menu, NULL); xmLabelGadgetClass, (Widget) menu, NULL);
} }
else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu)) else if ((!m_strName.IsNull() && m_strName != "") && (!m_pSubMenu))
{ {
wxStripMenuCodes ((char*) (const char*) m_strName, wxBuffer); wxString strName = wxStripMenuCodes(m_strName);
if (IsCheckable()) if (IsCheckable())
{ {
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
xmToggleButtonGadgetClass, (Widget) menu, xmToggleButtonGadgetClass, (Widget) menu,
NULL); NULL);
XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNset, (Boolean) IsChecked(), NULL);
} }
else else
m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (wxBuffer, m_buttonWidget = (WXWidget) XtVaCreateManagedWidget (strName,
xmPushButtonGadgetClass, (Widget) menu, xmPushButtonGadgetClass, (Widget) menu,
NULL); NULL);
char mnem = wxFindMnemonic (m_strName); char mnem = wxFindMnemonic (m_strName);
@@ -166,14 +166,13 @@ void wxMenuItem::CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMen
//// TODO: proper accelerator treatment. What does wxFindAccelerator //// TODO: proper accelerator treatment. What does wxFindAccelerator
//// look for? //// look for?
strcpy(wxBuffer, (char*) (const char*) m_strName); strName = m_strName;
char *accel = wxFindAccelerator (wxBuffer); char *accel = wxFindAccelerator (strName);
if (accel) if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
// TODO: What does this do? // TODO: What does this do?
strcpy(wxBuffer, (char*) (const char*) m_strName); XmString accel_str = wxFindAcceleratorText (strName);
XmString accel_str = wxFindAcceleratorText (wxBuffer);
if (accel_str) if (accel_str)
{ {
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);
@@ -267,26 +266,23 @@ void wxMenuItem::DestroyItem(bool full)
void wxMenuItem::SetLabel(const wxString& label) void wxMenuItem::SetLabel(const wxString& label)
{ {
char mnem = wxFindMnemonic (label); char mnem = wxFindMnemonic (label);
wxStripMenuCodes ((char*) (const char*) label, wxBuffer); wxString label2 = wxStripMenuCodes(label);
m_strName = label; m_strName = label;
if (m_buttonWidget) if (m_buttonWidget)
{ {
XmString label_str = XmStringCreateSimple (wxBuffer); wxXmString label_str(label2);
XtVaSetValues ((Widget) m_buttonWidget, XtVaSetValues ((Widget) m_buttonWidget,
XmNlabelString, label_str, XmNlabelString, label_str,
NULL); NULL);
XmStringFree (label_str);
if (mnem != 0) if (mnem != 0)
XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNmnemonic, mnem, NULL);
strcpy(wxBuffer, (char*) (const char*) label); char *accel = wxFindAccelerator (label2);
char *accel = wxFindAccelerator (wxBuffer);
if (accel) if (accel)
XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNaccelerator, accel, NULL);
strcpy(wxBuffer, (char*) (const char*) label); XmString accel_str = wxFindAcceleratorText (label2);
XmString accel_str = wxFindAcceleratorText (wxBuffer);
if (accel_str) if (accel_str)
{ {
XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL); XtVaSetValues ((Widget) m_buttonWidget, XmNacceleratorText, accel_str, NULL);

View File

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

View File

@@ -17,14 +17,9 @@
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
#endif #endif
wxSpinButton::wxSpinButton()
{
m_min = 0;
m_max = 100;
}
bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
long style, const wxString& name) long style, const wxString& name)
{ {
@@ -34,8 +29,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
if (parent) parent->AddChild(this); if (parent) parent->AddChild(this);
m_min = 0; InitBase();
m_max = 100;
m_windowId = (id == -1) ? NewControlId() : id; m_windowId = (id == -1) ? NewControlId() : id;
@@ -63,9 +57,8 @@ void wxSpinButton::SetValue(int val)
void wxSpinButton::SetRange(int minVal, int maxVal) void wxSpinButton::SetRange(int minVal, int maxVal)
{ {
m_min = minVal;
m_max = maxVal;
// TODO // TODO
wxSpinButtonBase::SetRange(minVal, maxVal);
} }
void wxSpinButton::ChangeFont(bool keepOriginalSize) void wxSpinButton::ChangeFont(bool keepOriginalSize)
@@ -82,12 +75,3 @@ void wxSpinButton::ChangeForegroundColour()
{ {
// TODO // TODO
} }
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id):
wxScrollEvent(commandType, id)
{
}

View File

@@ -83,9 +83,6 @@ static void wxTextWindowActivateProc(Widget w, XtPointer clientData, XmAnyCallba
// Text item // Text item
wxTextCtrl::wxTextCtrl() wxTextCtrl::wxTextCtrl()
#ifndef NO_TEXT_WINDOW_STREAM
: streambuf()
#endif
{ {
m_tempCallbackStruct = (void*) NULL; m_tempCallbackStruct = (void*) NULL;
m_modified = FALSE; 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) void wxTextCtrl::OnChar(wxKeyEvent& event)
{ {
// Indicates that we should generate a normal command, because // Indicates that we should generate a normal command, because

View File

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

View File

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

View File

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

View File

@@ -38,16 +38,15 @@
#if !USE_SHARED_LIBRARY #if !USE_SHARED_LIBRARY
IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinButton, wxControl)
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent);
#endif #endif
wxSpinButton::wxSpinButton() bool wxSpinButton::Create(wxWindow *parent,
{ wxWindowID id,
m_min = 0; const wxPoint& pos,
m_max = 100; 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; wxSystemSettings settings;
m_backgroundColour = parent->GetBackgroundColour() ; m_backgroundColour = parent->GetBackgroundColour() ;
@@ -73,8 +72,7 @@ bool wxSpinButton::Create(wxWindow *parent, wxWindowID id, const wxPoint& pos, c
if (y < 0) if (y < 0)
y = 0; y = 0;
m_min = 0; InitBase();
m_max = 100;
m_windowId = (id == -1) ? NewControlId() : id; m_windowId = (id == -1) ? NewControlId() : id;
@@ -127,8 +125,7 @@ void wxSpinButton::SetValue(int val)
void wxSpinButton::SetRange(int minVal, int maxVal) void wxSpinButton::SetRange(int minVal, int maxVal)
{ {
m_min = minVal; wxSpinButtonBase::SetRange(minVal, maxVal);
m_max = maxVal;
::SendMessage(GetHwnd(), UDM_SETRANGE, 0, ::SendMessage(GetHwnd(), UDM_SETRANGE, 0,
(LPARAM) MAKELONG((short)maxVal, (short)minVal)); (LPARAM) MAKELONG((short)maxVal, (short)minVal));
} }
@@ -188,12 +185,4 @@ bool wxSpinButton::MSWCommand(WXUINT cmd, WXWORD id)
return FALSE; return FALSE;
} }
// Spin event
IMPLEMENT_DYNAMIC_CLASS(wxSpinEvent, wxScrollEvent)
wxSpinEvent::wxSpinEvent(wxEventType commandType, int id)
: wxScrollEvent(commandType, id)
{
}
#endif // __WIN95__ #endif // __WIN95__