1. wxStaticLine implemented (generic (ugly) and MSW versions)

2. wxTextDialog looks fine under MSW again
3. startup tips added: code, sample, docs
4. read-only text controls don't participate in TAB traversal


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2919 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-06-28 21:39:49 +00:00
parent b6bff3019e
commit c50f1fb922
61 changed files with 5596 additions and 1092 deletions

View File

@@ -1,18 +1,59 @@
#ifndef _WX_DIALOG_H_BASE_
#define _WX_DIALOG_H_BASE_
class WXDLLEXPORT wxDialogBase : public wxPanel
{
protected:
// functions to help with dialog layout
// ------------------------------------
// constants used in dialog layout
static const long LAYOUT_X_MARGIN;
static const long LAYOUT_Y_MARGIN;
static const long MARGIN_BETWEEN_BUTTONS;
// Split the message in lines putting them into the array and calculating
// the maximum line width/height which is returned as wxSize.
wxSize SplitTextMessage(const wxString& message, wxArrayString *lines);
// Creates the (possibly multiline) message, assuming each line has the
// size sizeText (which can be retrieved from SplitTextMessage). Returns
// the bottom border of the multiline text zone.
long CreateTextMessage(const wxArrayString& lines,
const wxPoint& posText,
const wxSize& sizeText);
// Returns the preferred size for the buttons in the dialog
wxSize GetStandardButtonSize(bool hasCancel = TRUE);
// Create the standard [Ok] and [Cancel] (if hasCancel) buttons centering
// them with respect to the dialog width wDialog at vertical position y.
// wButton and hButton is the size of the button (which can be retrieved
// from GetStandardButtonSize)
void CreateStandardButtons(long wDialog,
long y,
long wButton,
long hButton,
bool hasCancel = TRUE);
// Returns the standard height of single line text ctrl (it's not the same
// as the height of just text which may be retrieved from
// wxGetCharHeight())
long GetStandardTextHeight();
};
#if defined(__WXMSW__)
#include "wx/msw/dialog.h"
#include "wx/msw/dialog.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/dialog.h"
#include "wx/motif/dialog.h"
#elif defined(__WXGTK__)
#include "wx/gtk/dialog.h"
#include "wx/gtk/dialog.h"
#elif defined(__WXQT__)
#include "wx/qt/dialog.h"
#include "wx/qt/dialog.h"
#elif defined(__WXMAC__)
#include "wx/mac/dialog.h"
#include "wx/mac/dialog.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/dialog.h"
#include "wx/stubs/dialog.h"
#endif
#endif

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c)
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __CHOICEDLGH_G__
@@ -79,7 +79,6 @@ public:
void OnListBoxDClick(wxCommandEvent& event);
protected:
long m_dialogStyle;
int m_selection;
wxString m_stringSelection;
void *m_clientData;

View File

@@ -0,0 +1,53 @@
/////////////////////////////////////////////////////////////////////////////
// Name: generic/statline.h
// Purpose: a generic wxStaticLine class
// Author: Vadim Zeitlin
// Created: 28.06.99
// Version: $Id$
// Copyright: (c) 1998 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_STATLINE_H_
#define _WX_GENERIC_STATLINE_H_
#ifdef __GNUG__
#pragma interface
#endif
// ----------------------------------------------------------------------------
// wxStaticLine
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStaticLine : public wxStaticLineBase
{
DECLARE_DYNAMIC_CLASS(wxStaticLine)
public:
// constructors and pseudo-constructors
wxStaticLine() { }
wxStaticLine( wxWindow *parent,
wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxStaticTextNameStr )
{
Create(parent, id, pos, size, style, name);
}
bool Create( wxWindow *parent,
wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxStaticTextNameStr );
protected:
// we implement the static line using a static box
wxStaticBox *m_statbox;
};
#endif // _WX_GENERIC_STATLINE_H_

View File

@@ -6,46 +6,58 @@
// Created: 01/02/97
// RCS-ID: $Id$
// Copyright: (c) Julian Smart and Markus Holzem
// Licence: wxWindows license
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef __TEXTDLGH_G__
#define __TEXTDLGH_G__
#ifdef __GNUG__
#pragma interface "textdlgg.h"
#pragma interface "textdlgg.h"
#endif
#include "wx/setup.h"
#include "wx/defs.h"
#include "wx/dialog.h"
// Handy dialog functions (will be converted into classes at some point)
WXDLLEXPORT_DATA(extern const wxChar*) wxGetTextFromUserPromptStr;
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
#define wxID_TEXT 3000
class WXDLLEXPORT wxTextEntryDialog: public wxDialog
class WXDLLEXPORT wxTextEntryDialog : public wxDialog
{
DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
protected:
long m_dialogStyle;
wxString m_value;
DECLARE_DYNAMIC_CLASS(wxTextEntryDialog)
public:
wxTextEntryDialog(wxWindow *parent, const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& value = wxEmptyString, long style = wxOK|wxCANCEL|wxCENTRE, const wxPoint& pos = wxDefaultPosition);
wxTextEntryDialog(wxWindow *parent,
const wxString& message,
const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& value = wxEmptyString,
long style = wxOK | wxCANCEL | wxCENTRE,
const wxPoint& pos = wxDefaultPosition);
inline void SetValue(const wxString& val) { m_value = val; }
inline wxString GetValue(void) const { return m_value; }
void SetValue(const wxString& val) { m_value = val; }
wxString GetValue() const { return m_value; }
// implementation only
void OnOK(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
protected:
wxTextCtrl *m_textctrl;
wxString m_value;
private:
DECLARE_EVENT_TABLE()
};
wxString WXDLLEXPORT wxGetTextFromUser(const wxString& message, const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& default_value = wxEmptyString, wxWindow *parent = (wxWindow *) NULL,
int x = -1, int y = -1, bool centre = TRUE);
wxString WXDLLEXPORT
wxGetTextFromUser(const wxString& message,
const wxString& caption = wxGetTextFromUserPromptStr,
const wxString& default_value = wxEmptyString,
wxWindow *parent = (wxWindow *) NULL,
int x = -1,
int y = -1,
bool centre = TRUE);
#endif
// __TEXTDLGH_G__

View File

@@ -35,7 +35,7 @@ extern const wxChar *wxDialogNameStr;
// wxDialog
//-----------------------------------------------------------------------------
class wxDialog: public wxPanel
class wxDialog: public wxDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDialog)

View File

@@ -4,7 +4,7 @@
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -12,12 +12,12 @@
#define __GTKSTATICLINEH__
#ifdef __GNUG__
#pragma interface
#pragma interface
#endif
#include "wx/defs.h"
#if wxUSE_STATLINE
#if !wxUSE_STATLINE
#error "This file should only be included if wxUSE_STATLINE == 1"
#endif
#include "wx/object.h"
#include "wx/list.h"
@@ -29,32 +29,24 @@
class wxStaticLine;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const char *wxStaticTextNameStr;
//-----------------------------------------------------------------------------
// wxStaticLine
//-----------------------------------------------------------------------------
class wxStaticLine: public wxControl
class wxStaticLine : public wxStaticLineBase
{
DECLARE_DYNAMIC_CLASS(wxStaticLine)
DECLARE_DYNAMIC_CLASS(wxStaticLine)
public:
wxStaticLine(void);
public:
wxStaticLine();
wxStaticLine( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
};
#endif
#endif // wxUSE_STATLINE
#endif // __GTKSTATICLINEH__

View File

@@ -35,7 +35,7 @@ extern const wxChar *wxDialogNameStr;
// wxDialog
//-----------------------------------------------------------------------------
class wxDialog: public wxPanel
class wxDialog: public wxDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDialog)

View File

@@ -4,7 +4,7 @@
// Author: Robert Roebling
// Id: $Id$
// Copyright: (c) 1998 Robert Roebling
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
@@ -12,12 +12,12 @@
#define __GTKSTATICLINEH__
#ifdef __GNUG__
#pragma interface
#pragma interface
#endif
#include "wx/defs.h"
#if wxUSE_STATLINE
#if !wxUSE_STATLINE
#error "This file should only be included if wxUSE_STATLINE == 1"
#endif
#include "wx/object.h"
#include "wx/list.h"
@@ -29,32 +29,24 @@
class wxStaticLine;
//-----------------------------------------------------------------------------
// global data
//-----------------------------------------------------------------------------
extern const char *wxStaticTextNameStr;
//-----------------------------------------------------------------------------
// wxStaticLine
//-----------------------------------------------------------------------------
class wxStaticLine: public wxControl
class wxStaticLine : public wxStaticLineBase
{
DECLARE_DYNAMIC_CLASS(wxStaticLine)
DECLARE_DYNAMIC_CLASS(wxStaticLine)
public:
wxStaticLine(void);
public:
wxStaticLine();
wxStaticLine( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
bool Create( wxWindow *parent, wxWindowID id,
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
const wxPoint &pos = wxDefaultPosition, const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL, const wxString &name = wxStaticTextNameStr );
};
#endif
#endif // wxUSE_STATLINE
#endif // __GTKSTATICLINEH__

View File

@@ -6,20 +6,24 @@
// Created: 31/7/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ACCEL_H_
#define _WX_ACCEL_H_
#ifdef __GNUG__
#pragma interface "accel.h"
#pragma interface "accel.h"
#endif
#include "wx/object.h"
class WXDLLEXPORT wxAcceleratorTable;
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
// Hold Ctrl key down
#define wxACCEL_ALT 0x01
@@ -32,27 +36,38 @@ class WXDLLEXPORT wxAcceleratorTable;
// Hold no other key
#define wxACCEL_NORMAL 0x00
// ----------------------------------------------------------------------------
// an entry in wxAcceleratorTable corresponds to one accelerator
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorEntry
{
public:
wxAcceleratorEntry(int flags = 0, int keyCode = 0, int cmd = 0)
{
Set(flags, keyCode, cmd);
}
void Set(int flags, int keyCode, int cmd)
{
m_flags = flags; m_keyCode = keyCode; m_command = cmd;
}
inline void Set(int flags, int keyCode, int cmd)
{ m_flags = flags; m_keyCode = keyCode; m_command = cmd; }
int GetFlags() const { return m_flags; }
int GetKeyCode() const { return m_keyCode; }
int GetCommand() const { return m_command; }
inline int GetFlags() const { return m_flags; }
inline int GetKeyCode() const { return m_keyCode; }
inline int GetCommand() const { return m_command; }
int m_flags;
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
//private:
int m_flags;
int m_keyCode; // ASCII or virtual keycode
int m_command; // Command id to generate
};
class WXDLLEXPORT wxAcceleratorTable: public wxObject
// ----------------------------------------------------------------------------
// the accel table has all accelerators for a given window or menu
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxAcceleratorTable : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxAcceleratorTable)
public:
@@ -61,18 +76,25 @@ public:
wxAcceleratorTable(int n, const wxAcceleratorEntry entries[]); // Load from array
// Copy constructors
inline wxAcceleratorTable(const wxAcceleratorTable& accel) { Ref(accel); }
inline wxAcceleratorTable(const wxAcceleratorTable* accel) { if (accel) Ref(*accel); }
wxAcceleratorTable(const wxAcceleratorTable& accel)
{ Ref(accel); }
~wxAcceleratorTable();
inline wxAcceleratorTable& operator = (const wxAcceleratorTable& accel) { if (*this == accel) return (*this); Ref(accel); return *this; }
inline bool operator == (const wxAcceleratorTable& accel) { return m_refData == accel.m_refData; }
inline bool operator != (const wxAcceleratorTable& accel) { return m_refData != accel.m_refData; }
wxAcceleratorTable& operator = (const wxAcceleratorTable& accel)
{ if ( *this != accel ) Ref(accel); return *this; }
bool Ok(void) const;
bool operator == (const wxAcceleratorTable& accel) const
{ return m_refData == accel.m_refData; }
bool operator != (const wxAcceleratorTable& accel) const
{ return m_refData != accel.m_refData; }
bool Ok() const;
void SetHACCEL(WXHACCEL hAccel);
WXHACCEL GetHACCEL() const;
// translate the accelerator, return TRUE if done
bool Translate(wxWindow *window, WXMSG *msg) const;
};
WXDLLEXPORT_DATA(extern wxAcceleratorTable) wxNullAcceleratorTable;

View File

@@ -21,7 +21,7 @@
WXDLLEXPORT_DATA(extern const wxChar*) wxDialogNameStr;
// Dialog boxes
class WXDLLEXPORT wxDialog : public wxPanel
class WXDLLEXPORT wxDialog : public wxDialogBase
{
DECLARE_DYNAMIC_CLASS(wxDialog)

View File

@@ -207,20 +207,27 @@ extern LONG APIENTRY _EXPORT
// ---------------------------------------------------------------------------
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
// returns Foo cast to the Windows type for oruselves, while GetFoosFoo() takes
// an argument which should be a pointer to wxFoo (is this really clear?)
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
// an argument which should be a pointer or reference to the object of the
// corresponding class (this depends on the macro)
// ---------------------------------------------------------------------------
#define GetHwnd() ((HWND)GetHWND())
#define GetWinHwnd(win) ((HWND)((win)->GetHWND()))
#define GetHwndOf(win) ((HWND)((win)->GetHWND()))
// old name
#define GetWinHwnd GetHwndOf
#define GetHdc() ((HDC)GetHDC())
#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
#define GetHicon() ((HICON)GetHICON())
#define GetIconHicon(icon) ((HICON)(icon).GetHICON())
#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
#define GetHaccel() ((HACCEL)GetHACCEL())
#define GetTableHaccel(table) ((HACCEL)((table).GetHACCEL()))
#define GetHaccelOf(table) ((HACCEL)((table).GetHACCEL()))
#define GetHmenu() ((HMENU)GetHMenu())
#define GetHmenuOf(menu) ((HMENU)menu->GetHMenu())
// ---------------------------------------------------------------------------
// global data

View File

@@ -86,6 +86,9 @@
#define wxUSE_SPINBTN 1
// Define 1 to compile spin button
// use wxStaticLine class (separator line in the dialog)?
#define wxUSE_STATLINE 1
#define wxUSE_CHECKLISTBOX 1
// Define 1 to compile check listbox
@@ -104,6 +107,9 @@
#define wxUSE_WX_RESOURCES 1
// Use .wxr resource mechanism (requires PrologIO library)
// support for startup tips (wxShowTip &c)
#define wxUSE_STARTUP_TIPS 1
// BC++/Win16 can't cope with the amount of data in resource.cpp
#if defined(__WIN16__) && defined(__BORLANDC__)
#undef wxUSE_WX_RESOURCES

50
include/wx/msw/statline.h Normal file
View File

@@ -0,0 +1,50 @@
/////////////////////////////////////////////////////////////////////////////
// Name: msw/statline.h
// Purpose: MSW version of wxStaticLine class
// Author: Vadim Zeitlin
// Created: 28.06.99
// Version: $Id$
// Copyright: (c) 1998 Vadim Zeitlin
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_MSW_STATLINE_H_
#define _WX_MSW_STATLINE_H_
#ifdef __GNUG__
#pragma interface
#endif
// ----------------------------------------------------------------------------
// wxStaticLine
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStaticLine : public wxStaticLineBase
{
DECLARE_DYNAMIC_CLASS(wxStaticLine)
public:
// constructors and pseudo-constructors
wxStaticLine() { }
wxStaticLine( wxWindow *parent,
wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxStaticTextNameStr )
{
Create(parent, id, pos, size, style, name);
}
bool Create( wxWindow *parent,
wxWindowID id,
const wxPoint &pos = wxDefaultPosition,
const wxSize &size = wxDefaultSize,
long style = wxLI_HORIZONTAL,
const wxString &name = wxStaticTextNameStr );
};
#endif // _WX_MSW_STATLINE_H_

View File

@@ -182,6 +182,8 @@ public:
virtual void AdoptAttributesFromHWND();
virtual void SetupColours();
virtual bool AcceptsFocus() const;
protected:
#if wxUSE_RICHEDIT
bool m_isRich; // Are we using rich text edit to implement this?

BIN
include/wx/msw/tip.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 766 B

View File

@@ -114,6 +114,7 @@ wxICON_QUESTION ICON "wx/msw/question.ico"
wxICON_WARNING ICON "wx/msw/warning.ico"
wxICON_ERROR ICON "wx/msw/error.ico"
wxICON_INFO ICON "wx/msw/info.ico"
wxICON_TIP ICON "wx/msw/tip.ico"
//////////////////////////////////////////////////////////////////////////////
//

View File

@@ -1,19 +1,74 @@
#ifndef _WX_STATLINE_H_BASE_
#define _WX_STATLINE_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// this defines wxUSE_STATLINE
#include "wx/defs.h"
#if wxUSE_STATLINE
// the base class declaration
#include "wx/control.h"
// ----------------------------------------------------------------------------
// global variables
// ----------------------------------------------------------------------------
// the default name for objects of class wxStaticLine
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticTextNameStr;
// ----------------------------------------------------------------------------
// wxStaticLine - a line in a dialog
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxStaticLineBase : public wxControl
{
public:
// constructor
wxStaticLineBase() { }
// is the line vertical?
bool IsVertical() const { return (GetWindowStyle() & wxLI_VERTICAL) != 0; }
// get the default size for the "lesser" dimension of the static line
static int GetDefaultSize() { return 2; }
protected:
// set the right size for the right dimension
wxSize AdjustSize(const wxSize& size)
{
wxSize sizeReal(size);
if ( IsVertical() )
{
if ( size.x == -1 )
sizeReal.x = GetDefaultSize();
}
else
{
if ( size.y == -1 )
sizeReal.y = GetDefaultSize();
}
return sizeReal;
}
};
// ----------------------------------------------------------------------------
// now include the actual class declaration
// ----------------------------------------------------------------------------
#if defined(__WXMSW__)
#include "wx/msw/statline.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/statline.h"
#include "wx/msw/statline.h"
#elif defined(__WXGTK__)
#include "wx/gtk/statline.h"
#elif defined(__WXQT__)
#include "wx/qt/statline.h"
#elif defined(__WXMAC__)
#include "wx/mac/statline.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/statline.h"
#include "wx/gtk/statline.h"
#else // use generic implementation for all other platforms
#include "wx/generic/statline.h"
#endif
#endif // wxUSE_STATLINE
#endif
// _WX_STATLINE_H_BASE_