more files added
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8103 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
46
include/wx/univ/control.h
Normal file
46
include/wx/univ/control.h
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/univ/control.h
|
||||||
|
// Purpose: universal wxControl: adds handling of mnemonics
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 14.08.00
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2000 Vadim Zeitlin <vadim@wxwindows.org>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_UNIV_CONTROL_H_
|
||||||
|
#define _WX_UNIV_CONTROL_H_
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "control.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxControl : public wxControlBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxControl();
|
||||||
|
|
||||||
|
wxControl(wxWindow *parent, wxWindowID id,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
|
const wxString& name = wxControlNameStr)
|
||||||
|
{
|
||||||
|
Create(parent, id, pos, size, style, validator, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// this function will filter out '&' characters and will put the
|
||||||
|
// accelerator char (the one immediately after '&') into m_chAccel
|
||||||
|
virtual void SetLabel(const wxString &label);
|
||||||
|
virtual wxString GetLabel() const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxString m_label;
|
||||||
|
wxChar m_chAccel;
|
||||||
|
|
||||||
|
private:
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxControl)
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_UNIV_CONTROL_H_
|
60
include/wx/univ/stattext.h
Normal file
60
include/wx/univ/stattext.h
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: wx/univ/stattext.h
|
||||||
|
// Purpose: wxStaticText
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 14.08.00
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2000 Vadim Zeitlin
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef _WX_UNIV_STATTEXT_H_
|
||||||
|
#define _WX_UNIV_STATTEXT_H_
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma interface "stattext.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxStaticText : wxStaticTextBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// usual ctor
|
||||||
|
wxStaticText(wxWindow *parent,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize)
|
||||||
|
{
|
||||||
|
Create(parent, -1, label, pos, size, 0, wxStaticTextNameStr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// full form
|
||||||
|
wxStaticText(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString& label,
|
||||||
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
|
const wxSize& size = wxDefaultSize,
|
||||||
|
long style = 0,
|
||||||
|
const wxString &name = wxStaticTextNameStr)
|
||||||
|
{
|
||||||
|
Create(parent, id, label, pos, size, style, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
// function ctor
|
||||||
|
bool Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString &label,
|
||||||
|
const wxPoint &pos = wxDefaultPosition,
|
||||||
|
const wxSize &size = wxDefaultSize,
|
||||||
|
long style = 0,
|
||||||
|
const wxString &name = wxStaticTextNameStr);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
// calculate the optimal size for the label
|
||||||
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
|
// draw the control
|
||||||
|
virtual void DoDraw(wxDC& dc, wxRenderer *renderer);
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // _WX_UNIV_STATTEXT_H_
|
79
src/univ/control.cpp
Normal file
79
src/univ/control.cpp
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: src/univ/control.cpp
|
||||||
|
// Purpose: universal wxControl: adds handling of mnemonics
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 14.08.00
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2000 Vadim Zeitlin <vadim@wxwindows.org>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "control.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_CONTROLS
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/control.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxControl, wxWindow)
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// creation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxControl::wxControl()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// mnemonics handling
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxControl::SetLabel( const wxString &label )
|
||||||
|
{
|
||||||
|
// the character following MNEMONIC_PREFIX is the accelerator for this
|
||||||
|
// control unless it is MNEMONIC_PREFIX too - this allows to insert
|
||||||
|
// literal MNEMONIC_PREFIX chars into the label
|
||||||
|
static const wxChar MNEMONIC_PREFIX = _T('&');
|
||||||
|
|
||||||
|
m_label.Empty();
|
||||||
|
for ( const wxChar *pc = label; *pc != wxT('\0'); pc++ )
|
||||||
|
{
|
||||||
|
if ( *pc == MNEMONIC_PREFIX )
|
||||||
|
{
|
||||||
|
pc++; // skip it
|
||||||
|
if ( *pc != MNEMONIC_PREFIX )
|
||||||
|
m_chAccel = *pc;
|
||||||
|
}
|
||||||
|
m_label << *pc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxControl::GetLabel() const
|
||||||
|
{
|
||||||
|
return m_label;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_CONTROLS
|
6
src/univ/files.lst
Normal file
6
src/univ/files.lst
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
UNIVOBJS = winuniv.o \
|
||||||
|
control.o \
|
||||||
|
stattext.o \
|
||||||
|
theme.o
|
||||||
|
|
||||||
|
# themes/win32.cpp
|
155
src/univ/stattext.cpp
Normal file
155
src/univ/stattext.cpp
Normal file
@@ -0,0 +1,155 @@
|
|||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: univ/stattext.cpp
|
||||||
|
// Purpose: wxStaticText
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 14.08.00
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2000 Vadim Zeitlin
|
||||||
|
// Licence: wxWindows license
|
||||||
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "stattext.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if wxUSE_STATTEXT
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/dc.h"
|
||||||
|
#include "wx/stattext.h"
|
||||||
|
#include "wx/validate.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// creation
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxStaticText::Create(wxWindow *parent,
|
||||||
|
wxWindowID id,
|
||||||
|
const wxString &label,
|
||||||
|
const wxPoint &pos,
|
||||||
|
const wxSize &size,
|
||||||
|
long style,
|
||||||
|
const wxString &name)
|
||||||
|
{
|
||||||
|
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
SetLabel(label);
|
||||||
|
|
||||||
|
if ( size.x == -1 || size.y == -1 )
|
||||||
|
{
|
||||||
|
wxSize sizeBest = DoGetBestSize();
|
||||||
|
SetSize(size.x == -1 ? sizeBest.x : size.x,
|
||||||
|
size.y == -1 ? sizeBest.y : size.y);
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// size management
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxSize wxStaticText::DoGetBestSize() const
|
||||||
|
{
|
||||||
|
wxString text = GetLabel();
|
||||||
|
|
||||||
|
int widthTextMax = 0, widthLine,
|
||||||
|
heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
|
||||||
|
|
||||||
|
wxString curLine;
|
||||||
|
for ( const wxChar *pc = text; ; pc++ ) {
|
||||||
|
if ( *pc == _T('\n') || *pc == _T('\0') ) {
|
||||||
|
if ( !curLine ) {
|
||||||
|
// we can't use GetTextExtent - it will return 0 for both width
|
||||||
|
// and height and an empty line should count in height
|
||||||
|
// calculation
|
||||||
|
if ( !heightLineDefault )
|
||||||
|
heightLineDefault = heightLine;
|
||||||
|
if ( !heightLineDefault )
|
||||||
|
GetTextExtent(_T("W"), NULL, &heightLineDefault);
|
||||||
|
|
||||||
|
heightTextTotal += heightLineDefault;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
GetTextExtent(curLine, &widthLine, &heightLine);
|
||||||
|
if ( widthLine > widthTextMax )
|
||||||
|
widthTextMax = widthLine;
|
||||||
|
heightTextTotal += heightLine;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( *pc == _T('\n') ) {
|
||||||
|
curLine.Empty();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// the end of string
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
curLine += *pc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxSize(widthTextMax, heightTextTotal);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// drawing
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxStaticText::DoDraw(wxDC& dc, wxRenderer *renderer)
|
||||||
|
{
|
||||||
|
// get the position of the label start
|
||||||
|
const wxString text = GetLabel();
|
||||||
|
|
||||||
|
wxCoord heightLine;
|
||||||
|
dc.GetTextExtent(text[0u], NULL, &heightLine);
|
||||||
|
|
||||||
|
wxCoord x = 0,
|
||||||
|
y = heightLine;
|
||||||
|
|
||||||
|
// split the string into lines and draw each of them separately
|
||||||
|
wxString curLine;
|
||||||
|
for ( const wxChar *pc = text; ; pc++ )
|
||||||
|
{
|
||||||
|
if ( *pc == _T('\n') || *pc == _T('\0') )
|
||||||
|
{
|
||||||
|
if ( !curLine.empty() )
|
||||||
|
{
|
||||||
|
dc.DrawText(curLine, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( *pc == _T('\0') )
|
||||||
|
break;
|
||||||
|
|
||||||
|
y += heightLine;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
curLine += *pc;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // wxUSE_STATTEXT
|
98
src/univ/theme.cpp
Normal file
98
src/univ/theme.cpp
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: univ/theme.cpp
|
||||||
|
// Purpose: implementation of wxTheme
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 06.08.00
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ===========================================================================
|
||||||
|
// declarations
|
||||||
|
// ===========================================================================
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "theme.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/univ/renderer.h"
|
||||||
|
#include "wx/univ/theme.h"
|
||||||
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// dummy theme class
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxDummyRenderer : public wxRenderer
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void DrawLabel(wxDC& dc, wxWindow *window) { }
|
||||||
|
virtual void DrawBorder(wxDC& dc, wxWindow *window) { }
|
||||||
|
};
|
||||||
|
|
||||||
|
class wxDummyTheme : public wxTheme
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxDummyTheme()
|
||||||
|
{
|
||||||
|
m_renderer = new wxDummyRenderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual ~wxDummyTheme()
|
||||||
|
{
|
||||||
|
delete m_renderer;
|
||||||
|
}
|
||||||
|
|
||||||
|
virtual wxRenderer *GetRenderer() { return m_renderer; }
|
||||||
|
virtual wxInputHandler *GetInputHandler() { return NULL; }
|
||||||
|
virtual wxColourScheme *GetColourScheme() { return NULL; }
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxDummyRenderer *m_renderer;
|
||||||
|
};
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// creation of the default theme (called by wxApp::OnInitGui)
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxTheme *wxTheme::ms_theme = (wxTheme *)NULL;
|
||||||
|
|
||||||
|
/* static */ bool wxTheme::CreateDefault()
|
||||||
|
{
|
||||||
|
ms_theme = new wxDummyTheme;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* static */ wxTheme *wxTheme::Set(wxTheme *theme)
|
||||||
|
{
|
||||||
|
wxTheme *themeOld = ms_theme;
|
||||||
|
ms_theme = theme;
|
||||||
|
return themeOld;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxTheme dtor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxTheme::~wxTheme()
|
||||||
|
{
|
||||||
|
}
|
Reference in New Issue
Block a user