added wxStaticLine and wxStaticBitmap
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/wxUNIVERSAL@8189 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -1196,6 +1196,11 @@ enum wxBorder
|
||||
*/
|
||||
#define wxST_NO_AUTORESIZE 0x0001
|
||||
|
||||
/*
|
||||
* wxStaticBitmap flags
|
||||
*/
|
||||
#define wxBI_EXPAND wxEXPAND
|
||||
|
||||
/*
|
||||
* wxStaticLine flags
|
||||
*/
|
||||
|
@@ -181,6 +181,7 @@ enum wxStockCursor
|
||||
// ---------------------------------------------------------------------------
|
||||
// wxSize
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
class WXDLLEXPORT wxSize
|
||||
{
|
||||
public:
|
||||
@@ -194,7 +195,9 @@ public:
|
||||
wxSize(int xx, int yy) { Set(xx, yy); }
|
||||
|
||||
// no copy ctor or assignment operator - the defaults are ok
|
||||
|
||||
bool operator==(const wxSize& sz) const { return x == sz.x && y == sz.y; }
|
||||
bool operator!=(const wxSize& sz) const { return x != sz.x || y != sz.y; }
|
||||
|
||||
// FIXME are these really useful? If they're, we should have += &c as well
|
||||
wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); }
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: statbmp.h
|
||||
// Name: wx/gtk/statbmp.h
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
@@ -17,33 +17,17 @@
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// classes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticBitmap;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char* wxStaticBitmapNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxStaticBitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticBitmap: public wxControl
|
||||
class wxStaticBitmap : public wxStaticBitmapBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
|
||||
public:
|
||||
wxStaticBitmap();
|
||||
wxStaticBitmap( wxWindow *parent,
|
||||
@@ -62,6 +46,7 @@ public:
|
||||
const wxString& name = wxStaticBitmapNameStr);
|
||||
|
||||
virtual void SetBitmap( const wxBitmap& bitmap );
|
||||
virtual void etIcon(const wxIcon& icon) { SetBitmap( icon ); }
|
||||
|
||||
wxBitmap& GetBitmap() { return m_bitmap; }
|
||||
const wxBitmap& GetBitmap() const { return m_bitmap; }
|
||||
@@ -74,22 +59,13 @@ public:
|
||||
return (const wxIcon &)m_bitmap;
|
||||
}
|
||||
|
||||
// for compatibility with wxMSW
|
||||
void SetIcon(const wxIcon& icon)
|
||||
{
|
||||
SetBitmap( icon );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
// creates the new pixmap widget
|
||||
void CreatePixmapWidget();
|
||||
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __GTKSTATICBITMAPH__
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: statbmp.h
|
||||
// Name: wx/gtk/statbmp.h
|
||||
// Purpose:
|
||||
// Author: Robert Roebling
|
||||
// Id: $Id$
|
||||
@@ -17,33 +17,17 @@
|
||||
|
||||
#include "wx/defs.h"
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
#include "wx/object.h"
|
||||
#include "wx/control.h"
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/icon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// classes
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticBitmap;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char* wxStaticBitmapNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxStaticBitmap
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticBitmap: public wxControl
|
||||
class wxStaticBitmap : public wxStaticBitmapBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
|
||||
public:
|
||||
wxStaticBitmap();
|
||||
wxStaticBitmap( wxWindow *parent,
|
||||
@@ -62,6 +46,7 @@ public:
|
||||
const wxString& name = wxStaticBitmapNameStr);
|
||||
|
||||
virtual void SetBitmap( const wxBitmap& bitmap );
|
||||
virtual void etIcon(const wxIcon& icon) { SetBitmap( icon ); }
|
||||
|
||||
wxBitmap& GetBitmap() { return m_bitmap; }
|
||||
const wxBitmap& GetBitmap() const { return m_bitmap; }
|
||||
@@ -74,22 +59,13 @@ public:
|
||||
return (const wxIcon &)m_bitmap;
|
||||
}
|
||||
|
||||
// for compatibility with wxMSW
|
||||
void SetIcon(const wxIcon& icon)
|
||||
{
|
||||
SetBitmap( icon );
|
||||
}
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
|
||||
private:
|
||||
// creates the new pixmap widget
|
||||
void CreatePixmapWidget();
|
||||
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // __GTKSTATICBITMAPH__
|
||||
|
@@ -1,6 +1,6 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: statbmp.h
|
||||
// Purpose: wxStaticBitmap class
|
||||
// Name: wx/msw/statbmp.h
|
||||
// Purpose: wxStaticBitmap class for wxMSW
|
||||
// Author: Julian Smart
|
||||
// Modified by:
|
||||
// Created: 01/02/97
|
||||
@@ -16,8 +16,6 @@
|
||||
#pragma interface "statbmp.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
#include "wx/control.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/bitmap.h"
|
||||
@@ -25,10 +23,8 @@
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
|
||||
|
||||
// a control showing an icon or a bitmap
|
||||
class WXDLLEXPORT wxStaticBitmap : public wxControl
|
||||
class WXDLLEXPORT wxStaticBitmap : public wxStaticBitmapBase
|
||||
{
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
|
||||
public:
|
||||
wxStaticBitmap() { Init(); }
|
||||
|
||||
@@ -53,8 +49,8 @@ public:
|
||||
|
||||
virtual ~wxStaticBitmap() { Free(); }
|
||||
|
||||
void SetIcon(const wxIcon& icon) { SetImage(&icon); }
|
||||
void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
|
||||
virtual void SetIcon(const wxIcon& icon) { SetImage(&icon); }
|
||||
virtual void SetBitmap(const wxBitmap& bitmap) { SetImage(&bitmap); }
|
||||
|
||||
// assert failure is provoked by an attempt to get an icon from bitmap or
|
||||
// vice versa
|
||||
@@ -63,9 +59,6 @@ public:
|
||||
const wxBitmap& GetBitmap() const
|
||||
{ wxASSERT( !m_isIcon ); return *(wxBitmap *)m_image; }
|
||||
|
||||
// overriden base class virtuals
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
||||
// IMPLEMENTATION
|
||||
#ifdef __WIN16__
|
||||
virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
|
||||
@@ -86,9 +79,10 @@ protected:
|
||||
// we can have either an icon or a bitmap
|
||||
bool m_isIcon;
|
||||
wxGDIImage *m_image;
|
||||
};
|
||||
|
||||
#endif // wxUSE_STATBMP
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
};
|
||||
|
||||
#endif
|
||||
// _WX_STATBMP_H_
|
||||
|
@@ -1,21 +1,65 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/statbmp.h
|
||||
// Purpose: wxStaticBitmap class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_STATBMP_H_BASE_
|
||||
#define _WX_STATBMP_H_BASE_
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#include "wx/msw/statbmp.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/statbmp.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/statbmp.h"
|
||||
#elif defined(__WXQT__)
|
||||
#include "wx/qt/statbmp.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/statbmp.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/statbmp.h"
|
||||
#elif defined(__WXSTUBS__)
|
||||
#include "wx/stubs/statbmp.h"
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "statbmpbase.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
#include "wx/control.h"
|
||||
|
||||
class WXDLLEXPORT wxIcon;
|
||||
class WXDLLEXPORT wxBitmap;
|
||||
|
||||
WXDLLEXPORT_DATA(extern const wxChar*) wxStaticBitmapNameStr;
|
||||
|
||||
// a control showing an icon or a bitmap
|
||||
class WXDLLEXPORT wxStaticBitmapBase : public wxControl
|
||||
{
|
||||
public:
|
||||
// our interface
|
||||
virtual void SetIcon(const wxIcon& icon) = 0;
|
||||
virtual void SetBitmap(const wxBitmap& bitmap) = 0;
|
||||
virtual wxBitmap GetBitmap() const = 0;
|
||||
|
||||
// overriden base class virtuals
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
||||
protected:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
};
|
||||
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/statbmp.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/statbmp.h"
|
||||
#elif defined(__WXMOTIF__)
|
||||
#include "wx/motif/statbmp.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/statbmp.h"
|
||||
#elif defined(__WXQT__)
|
||||
#include "wx/qt/statbmp.h"
|
||||
#elif defined(__WXMAC__)
|
||||
#include "wx/mac/statbmp.h"
|
||||
#elif defined(__WXPM__)
|
||||
#include "wx/os2/statbmp.h"
|
||||
#elif defined(__WXSTUBS__)
|
||||
#include "wx/stubs/statbmp.h"
|
||||
#endif
|
||||
|
||||
#endif // wxUSE_STATBMP
|
||||
|
||||
#endif
|
||||
// _WX_STATBMP_H_BASE_
|
||||
|
@@ -1,3 +1,13 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/statline.h
|
||||
// Purpose: wxStaticLine class interface
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 28.06.99
|
||||
// Version: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_STATLINE_H_BASE_
|
||||
#define _WX_STATLINE_H_BASE_
|
||||
|
||||
@@ -36,9 +46,12 @@ public:
|
||||
// get the default size for the "lesser" dimension of the static line
|
||||
static int GetDefaultSize() { return 2; }
|
||||
|
||||
// overriden base class virtuals
|
||||
virtual bool AcceptsFocus() const { return FALSE; }
|
||||
|
||||
protected:
|
||||
// set the right size for the right dimension
|
||||
wxSize AdjustSize(const wxSize& size)
|
||||
wxSize AdjustSize(const wxSize& size) const
|
||||
{
|
||||
wxSize sizeReal(size);
|
||||
if ( IsVertical() )
|
||||
@@ -54,13 +67,20 @@ protected:
|
||||
|
||||
return sizeReal;
|
||||
}
|
||||
|
||||
virtual wxSize DoGetBestSize() const
|
||||
{
|
||||
return AdjustSize(wxDefaultSize);
|
||||
}
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// now include the actual class declaration
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if defined(__WXMSW__)
|
||||
#if defined(__WXUNIVERSAL__)
|
||||
#include "wx/univ/statline.h"
|
||||
#elif defined(__WXMSW__)
|
||||
#include "wx/msw/statline.h"
|
||||
#elif defined(__WXGTK__)
|
||||
#include "wx/gtk/statline.h"
|
||||
|
@@ -97,6 +97,14 @@ public:
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL) = 0;
|
||||
|
||||
// draw a horizontal line
|
||||
virtual void DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2) = 0;
|
||||
|
||||
// draw a vertical line
|
||||
virtual void DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2) = 0;
|
||||
|
||||
// draw a frame with the label (horizontal alignment can be specified)
|
||||
virtual void DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
@@ -198,6 +206,12 @@ public:
|
||||
int align = wxALIGN_LEFT,
|
||||
int indexAccel = -1)
|
||||
{ m_renderer->DrawFrame(dc, label, rect, flags, align, indexAccel); }
|
||||
virtual void DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2)
|
||||
{ m_renderer->DrawHorizontalLine(dc, y, x1, x2); }
|
||||
virtual void DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2)
|
||||
{ m_renderer->DrawVerticalLine(dc, x, y1, y2); }
|
||||
virtual void DrawButtonBorder(wxDC& dc,
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
@@ -248,7 +262,10 @@ public:
|
||||
void DrawLabel();
|
||||
void DrawBorder();
|
||||
void DrawButtonBorder();
|
||||
// the line must be either horizontal or vertical
|
||||
void DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2);
|
||||
void DrawFrame();
|
||||
void DrawBitmap(const wxBitmap& bitmap);
|
||||
void DrawBackgroundBitmap();
|
||||
void DrawScrollbar(const wxScrollBar *scrollbar);
|
||||
|
||||
@@ -260,6 +277,9 @@ public:
|
||||
const wxRect& GetRect() const { return m_rect; }
|
||||
wxRect& GetRect() { return m_rect; }
|
||||
|
||||
protected:
|
||||
void DoDrawBitmap(const wxBitmap& bmp, int alignment, wxStretch stretch);
|
||||
|
||||
private:
|
||||
wxControl *m_ctrl;
|
||||
wxRenderer *m_renderer;
|
||||
|
76
include/wx/univ/statbmp.h
Normal file
76
include/wx/univ/statbmp.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/univ/statbmp.h
|
||||
// Purpose: wxStaticBitmap class for wxUniversal
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifndef _WX_UNIV_STATBMP_H_
|
||||
#define _WX_UNIV_STATBMP_H_
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "univstatbmp.h"
|
||||
#endif
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStaticBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxStaticBitmap : public wxStaticBitmapBase
|
||||
{
|
||||
public:
|
||||
wxStaticBitmap()
|
||||
{
|
||||
}
|
||||
|
||||
wxStaticBitmap(wxWindow *parent,
|
||||
const wxBitmap& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0)
|
||||
{
|
||||
Create(parent, -1, label, pos, size, style);
|
||||
}
|
||||
|
||||
wxStaticBitmap(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxBitmap& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxStaticBitmapNameStr)
|
||||
{
|
||||
Create(parent, id, label, pos, size, style, name);
|
||||
}
|
||||
|
||||
bool Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxBitmap& label,
|
||||
const wxPoint& pos = wxDefaultPosition,
|
||||
const wxSize& size = wxDefaultSize,
|
||||
long style = 0,
|
||||
const wxString& name = wxStaticBitmapNameStr);
|
||||
|
||||
virtual void SetBitmap(const wxBitmap& bitmap);
|
||||
virtual void SetIcon(const wxIcon& icon);
|
||||
virtual wxBitmap GetBitmap() const { return m_bitmap; }
|
||||
|
||||
wxIcon GetIcon() const;
|
||||
|
||||
private:
|
||||
virtual wxSize DoGetBestSize() const;
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
// the bitmap which we show
|
||||
wxBitmap m_bitmap;
|
||||
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticBitmap)
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_STATBMP_H_
|
60
include/wx/univ/statline.h
Normal file
60
include/wx/univ/statline.h
Normal file
@@ -0,0 +1,60 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: wx/univ/statline.h
|
||||
// Purpose: wxStaticLine class for wxUniversal
|
||||
// Author: Vadim Zeitlin
|
||||
// Created: 28.06.99
|
||||
// Version: $Id$
|
||||
// Copyright: (c) 1999 Vadim Zeitlin
|
||||
// Licence: wxWindows licence
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma interface "univstatline.h"
|
||||
#endif
|
||||
|
||||
#ifndef _WX_UNIV_STATLINE_H_
|
||||
#define _WX_UNIV_STATLINE_H_
|
||||
|
||||
class WXDLLEXPORT wxStaticLine : public wxStaticLineBase
|
||||
{
|
||||
public:
|
||||
// constructors and pseudo-constructors
|
||||
wxStaticLine() { }
|
||||
|
||||
wxStaticLine(wxWindow *parent,
|
||||
const wxPoint &pos,
|
||||
wxCoord length,
|
||||
long style = wxLI_HORIZONTAL)
|
||||
{
|
||||
Create(parent, -1, pos,
|
||||
style & wxLI_VERTICAL ? wxSize(-1, length)
|
||||
: wxSize(length, -1),
|
||||
style);
|
||||
}
|
||||
|
||||
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:
|
||||
virtual void DoDraw(wxControlRenderer *renderer);
|
||||
|
||||
private:
|
||||
DECLARE_DYNAMIC_CLASS(wxStaticLine)
|
||||
};
|
||||
|
||||
#endif // _WX_UNIV_STATLINE_H_
|
||||
|
@@ -36,10 +36,18 @@
|
||||
|
||||
#include "wx/button.h"
|
||||
#include "wx/scrolbar.h"
|
||||
#include "wx/statbmp.h"
|
||||
#include "wx/statbox.h"
|
||||
#include "wx/statline.h"
|
||||
#include "wx/stattext.h"
|
||||
#endif
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// resources
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#include "wx/generic/tip.xpm"
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// constants
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -135,11 +143,15 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
||||
|
||||
(new wxStaticText(this, _T("&Disabled text"), wxPoint(10, 30)))->Disable();
|
||||
|
||||
new wxStaticLine(this, wxPoint(190, 10), 50, wxLI_VERTICAL);
|
||||
|
||||
text = new wxStaticText(this, _T("Demo of &border styles:"), wxPoint(10, 60));
|
||||
text->SetFont(*wxITALIC_FONT);
|
||||
text->SetBackgroundColour(*wxWHITE);
|
||||
text->SetForegroundColour(*wxBLUE);
|
||||
|
||||
new wxStaticLine(this, wxPoint(10, 80), 120, wxLI_HORIZONTAL);
|
||||
|
||||
wxCoord x = 10;
|
||||
#define CREATE_STATIC_BORDER_DEMO(border) \
|
||||
(new wxStaticText(this, -1, _T(#border), \
|
||||
@@ -180,6 +192,10 @@ MyUnivFrame::MyUnivFrame(const wxString& title)
|
||||
new wxButton(this, Univ_Button1, _T("&Press me"), wxPoint(10, 300));
|
||||
new wxButton(this, Univ_Button2, _T("&And me"), wxPoint(100, 300));
|
||||
|
||||
new wxStaticBitmap(this, wxBitmap(tipIcon), wxPoint(10, 350));
|
||||
new wxStaticBitmap(this, -1, wxBitmap(tipIcon), wxPoint(50, 350),
|
||||
wxDefaultSize, wxSUNKEN_BORDER);
|
||||
|
||||
wxScrollBar *sb;
|
||||
sb = new wxScrollBar(this, -1, wxPoint(200, 300), wxSize(300, -1));
|
||||
sb->SetScrollbar(0, 10, 100, 10);
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "controlbase.h"
|
||||
#pragma implementation "statbmpbase.h"
|
||||
#endif
|
||||
|
||||
// For compilers that support precompilation, includes "wx.h".
|
||||
@@ -35,6 +36,11 @@
|
||||
#include "wx/log.h"
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/statbmp.h"
|
||||
#endif // wxUSE_STATBMP
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
@@ -139,5 +145,23 @@ wxBorder wxControlBase::GetDefaultBorder() const
|
||||
return wxBORDER_NONE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStaticBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
wxSize wxStaticBitmapBase::DoGetBestSize() const
|
||||
{
|
||||
wxBitmap bmp = GetBitmap();
|
||||
if ( bmp.Ok() )
|
||||
return wxSize(bmp.GetWidth(), bmp.GetHeight());
|
||||
|
||||
// this is completely arbitrary
|
||||
return wxSize(16, 16);
|
||||
}
|
||||
|
||||
#endif // wxUSE_STATBMP
|
||||
|
||||
#endif // wxUSE_CONTROLS
|
||||
|
||||
|
@@ -5,7 +5,9 @@ UNIVOBJS = \
|
||||
inphand.o \
|
||||
renderer.o \
|
||||
scrolbar.o \
|
||||
statbmp.o \
|
||||
statbox.o \
|
||||
statline.o \
|
||||
stattext.o \
|
||||
theme.o \
|
||||
gtk.o \
|
||||
@@ -18,7 +20,9 @@ UNIVDEPS = \
|
||||
inphand.d \
|
||||
renderer.d \
|
||||
scrolbar.d \
|
||||
statbmp.d \
|
||||
statbox.d \
|
||||
statline.d \
|
||||
stattext.d \
|
||||
theme.d \
|
||||
gtk.d \
|
||||
|
@@ -222,12 +222,28 @@ void wxControlRenderer::DrawButtonBorder()
|
||||
m_renderer->DrawBackground(m_dc, m_rect, flags);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
int style = m_ctrl->GetWindowStyle();
|
||||
DoDrawBitmap(bitmap,
|
||||
style & wxALIGN_MASK,
|
||||
style & wxBI_EXPAND ? wxEXPAND : wxSTRETCH_NOT);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawBackgroundBitmap()
|
||||
{
|
||||
// get the bitmap and the flags
|
||||
int alignment;
|
||||
wxStretch stretch;
|
||||
wxBitmap bmp = m_ctrl->GetBackgroundBitmap(&alignment, &stretch);
|
||||
|
||||
DoDrawBitmap(bmp, alignment, stretch);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DoDrawBitmap(const wxBitmap& bmp,
|
||||
int alignment,
|
||||
wxStretch stretch)
|
||||
{
|
||||
if ( !bmp.Ok() )
|
||||
return;
|
||||
|
||||
@@ -282,7 +298,7 @@ void wxControlRenderer::DrawBackgroundBitmap()
|
||||
}
|
||||
|
||||
// do draw it
|
||||
m_dc.DrawBitmap(bmp, x, y);
|
||||
m_dc.DrawBitmap(bmp, x, y, TRUE /* use mask */);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar)
|
||||
@@ -316,3 +332,14 @@ void wxControlRenderer::DrawScrollbar(const wxScrollBar *scrollbar)
|
||||
thumbStart, thumbEnd, m_rect,
|
||||
flags);
|
||||
}
|
||||
|
||||
void wxControlRenderer::DrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
|
||||
{
|
||||
wxASSERT_MSG( x1 == x2 || y1 == y2,
|
||||
_T("line must be either horizontal or vertical") );
|
||||
|
||||
if ( x1 == x2 )
|
||||
m_renderer->DrawVerticalLine(m_dc, x1, y1, y2);
|
||||
else // horizontal
|
||||
m_renderer->DrawHorizontalLine(m_dc, y1, x1, x2);
|
||||
}
|
||||
|
128
src/univ/statbmp.cpp
Normal file
128
src/univ/statbmp.cpp
Normal file
@@ -0,0 +1,128 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: univ/statbmp.cpp
|
||||
// Purpose: wxStaticBitmap implementation
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "univstatbmp.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/icon.h"
|
||||
#include "wx/statbmp.h"
|
||||
#include "wx/validate.h"
|
||||
#endif
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
#include "wx/univ/theme.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticBitmap, wxControl)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStaticBitmap
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxStaticBitmap::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxBitmap &label,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style,
|
||||
const wxString &name)
|
||||
{
|
||||
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return FALSE;
|
||||
|
||||
// set bitmap first
|
||||
SetBitmap(label);
|
||||
|
||||
// and adjust our size to fit it after this
|
||||
if ( size.x == -1 || size.y == -1 )
|
||||
{
|
||||
wxSize sizeBest = DoGetBestSize();
|
||||
if ( size.x != -1 )
|
||||
sizeBest.x = size.x;
|
||||
if ( size.y != -1 )
|
||||
sizeBest.y = size.y;
|
||||
|
||||
SetSize(sizeBest);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// bitmap/icon setting/getting and converting between
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
|
||||
{
|
||||
m_bitmap = bitmap;
|
||||
}
|
||||
|
||||
void wxStaticBitmap::SetIcon(const wxIcon& icon)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
m_bitmap.CopyFromIcon(icon);
|
||||
#else
|
||||
m_bitmap = (const wxBitmap&)icon;
|
||||
#endif
|
||||
}
|
||||
|
||||
wxIcon wxStaticBitmap::GetIcon() const
|
||||
{
|
||||
wxIcon icon;
|
||||
#ifdef __WXMSW__
|
||||
icon.CopyFromBitmap(m_bitmap);
|
||||
#else
|
||||
icon = (const wxIcon&)m_bitmap;
|
||||
#endif
|
||||
return icon;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// drawing
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
wxSize wxStaticBitmap::DoGetBestSize() const
|
||||
{
|
||||
wxSize sz = wxStaticBitmapBase::DoGetBestSize();
|
||||
wxTheme::Get()->GetRenderer()->AdjustSize(&sz, this);
|
||||
return sz;
|
||||
}
|
||||
|
||||
void wxStaticBitmap::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
wxControl::DoDraw(renderer);
|
||||
renderer->DrawBitmap(GetBitmap());
|
||||
}
|
||||
|
||||
#endif // wxUSE_STATBMP
|
||||
|
@@ -3,7 +3,7 @@
|
||||
// Purpose: wxStaticBox implementation
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 15.08.00
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
@@ -27,7 +27,7 @@
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATTEXT
|
||||
#if wxUSE_STATBOX
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
@@ -70,5 +70,5 @@ void wxStaticBox::DoDraw(wxControlRenderer *renderer)
|
||||
renderer->DrawFrame();
|
||||
}
|
||||
|
||||
#endif // wxUSE_STATTEXT
|
||||
#endif // wxUSE_STATBOX
|
||||
|
||||
|
88
src/univ/statline.cpp
Normal file
88
src/univ/statline.cpp
Normal file
@@ -0,0 +1,88 @@
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// Name: univ/statline.cpp
|
||||
// Purpose: wxStaticLine implementation
|
||||
// Author: Vadim Zeitlin
|
||||
// Modified by:
|
||||
// Created: 25.08.00
|
||||
// RCS-ID: $Id$
|
||||
// Copyright: (c) 2000 Vadim Zeitlin
|
||||
// Licence: wxWindows license
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// ============================================================================
|
||||
// declarations
|
||||
// ============================================================================
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// headers
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#ifdef __GNUG__
|
||||
#pragma implementation "univstatline.h"
|
||||
#endif
|
||||
|
||||
#include "wx/wxprec.h"
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
#pragma hdrstop
|
||||
#endif
|
||||
|
||||
#if wxUSE_STATLINE
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/dc.h"
|
||||
#include "wx/statline.h"
|
||||
#include "wx/validate.h"
|
||||
#endif
|
||||
|
||||
#include "wx/univ/renderer.h"
|
||||
|
||||
// ============================================================================
|
||||
// implementation
|
||||
// ============================================================================
|
||||
|
||||
IMPLEMENT_DYNAMIC_CLASS(wxStaticLine, wxControl)
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxStaticLine
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
bool wxStaticLine::Create(wxWindow *parent,
|
||||
wxWindowID id,
|
||||
const wxPoint &pos,
|
||||
const wxSize &size,
|
||||
long style,
|
||||
const wxString &name)
|
||||
{
|
||||
if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) )
|
||||
return FALSE;
|
||||
|
||||
wxSize sizeReal = AdjustSize(size);
|
||||
if ( sizeReal != size )
|
||||
SetSize(sizeReal);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void wxStaticLine::DoDraw(wxControlRenderer *renderer)
|
||||
{
|
||||
// we never have a border, so don't call the base class version whcih draws
|
||||
// it
|
||||
wxSize sz = GetSize();
|
||||
wxCoord x2, y2;
|
||||
if ( IsVertical() )
|
||||
{
|
||||
x2 = 0;
|
||||
y2 = sz.y;
|
||||
}
|
||||
else // horizontal
|
||||
{
|
||||
x2 = sz.x;
|
||||
y2 = 0;
|
||||
}
|
||||
|
||||
renderer->DrawLine(0, 0, x2, y2);
|
||||
}
|
||||
|
||||
#endif // wxUSE_STATLINE
|
||||
|
@@ -66,6 +66,10 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL);
|
||||
virtual void DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2);
|
||||
virtual void DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2);
|
||||
virtual void DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
@@ -492,9 +496,29 @@ void wxGTKRenderer::DrawButtonBorder(wxDC& dc,
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame
|
||||
// lines and frames
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxGTKRenderer::DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2)
|
||||
{
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(x1, y, x2 + 1, y);
|
||||
dc.SetPen(m_penHighlight);
|
||||
y++;
|
||||
dc.DrawLine(x1, y, x2 + 1, y);
|
||||
}
|
||||
|
||||
void wxGTKRenderer::DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2)
|
||||
{
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(x, y1, x, y2 + 1);
|
||||
dc.SetPen(m_penHighlight);
|
||||
x++;
|
||||
dc.DrawLine(x, y1, x, y2 + 1);
|
||||
}
|
||||
|
||||
void wxGTKRenderer::DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
@@ -520,25 +544,22 @@ void wxGTKRenderer::DrawFrame(wxDC& dc,
|
||||
// and overwrite it with label (if any)
|
||||
if ( !label.empty() )
|
||||
{
|
||||
// TODO: the +5 and space insertion should be customizable
|
||||
// TODO: the +2 should be customizable
|
||||
|
||||
wxRect rectText;
|
||||
rectText.x = rectFrame.x + 5;
|
||||
rectText.x = rectFrame.x + 2;
|
||||
rectText.y = rect.y;
|
||||
rectText.width = rectFrame.width - 7; // +2 border width
|
||||
rectText.width = rectFrame.width - 4; // +2 border width
|
||||
rectText.height = height;
|
||||
|
||||
wxString label2;
|
||||
label2 << _T(' ') << label << _T(' ');
|
||||
if ( indexAccel != -1 )
|
||||
{
|
||||
// adjust it as we prepended a space
|
||||
indexAccel++;
|
||||
}
|
||||
|
||||
dc.SetBackgroundMode(wxSOLID);
|
||||
DrawLabel(dc, label2, rectText, flags, alignment, indexAccel);
|
||||
DrawLabel(dc, label, rectText, flags, alignment, indexAccel);
|
||||
dc.SetBackgroundMode(wxTRANSPARENT);
|
||||
|
||||
// GTK+ does this - don't know if this is intentional or not
|
||||
dc.SetPen(m_penHighlight);
|
||||
dc.DrawPoint(rectFrame.GetPosition());
|
||||
dc.DrawPoint(rectFrame.x + rectText.width, rectFrame.y);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -83,6 +83,10 @@ public:
|
||||
const wxRect& rect,
|
||||
int flags = 0,
|
||||
wxRect *rectIn = (wxRect *)NULL);
|
||||
virtual void DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2);
|
||||
virtual void DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2);
|
||||
virtual void DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
@@ -727,9 +731,29 @@ void wxWin32Renderer::DrawButtonBorder(wxDC& dc,
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// frame
|
||||
// lines and frame
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxWin32Renderer::DrawHorizontalLine(wxDC& dc,
|
||||
wxCoord y, wxCoord x1, wxCoord x2)
|
||||
{
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(x1, y, x2 + 1, y);
|
||||
dc.SetPen(m_penHighlight);
|
||||
y++;
|
||||
dc.DrawLine(x1, y, x2 + 1, y);
|
||||
}
|
||||
|
||||
void wxWin32Renderer::DrawVerticalLine(wxDC& dc,
|
||||
wxCoord x, wxCoord y1, wxCoord y2)
|
||||
{
|
||||
dc.SetPen(m_penDarkGrey);
|
||||
dc.DrawLine(x, y1, x, y2 + 1);
|
||||
dc.SetPen(m_penHighlight);
|
||||
x++;
|
||||
dc.DrawLine(x, y1, x, y2 + 1);
|
||||
}
|
||||
|
||||
void wxWin32Renderer::DrawFrame(wxDC& dc,
|
||||
const wxString& label,
|
||||
const wxRect& rect,
|
||||
|
Reference in New Issue
Block a user