Add a very simple page showing wxHeaderCtrl in the widgets sample

This is mostly in order to test that changing font and colours works for this
control (or, rather, that currently it doesn't in wxMSW).
This commit is contained in:
Vadim Zeitlin 2016-04-17 16:01:11 +02:00
parent 246ae58c19
commit 64196306bc
11 changed files with 200 additions and 0 deletions

View File

@ -70,6 +70,7 @@ WIDGETS_OBJECTS = \
widgets_filepicker.o \
widgets_fontpicker.o \
widgets_gauge.o \
widgets_headerctrl.o \
widgets_hyperlnk.o \
widgets_itemcontainer.o \
widgets_listbox.o \
@ -265,6 +266,9 @@ widgets_fontpicker.o: $(srcdir)/fontpicker.cpp
widgets_gauge.o: $(srcdir)/gauge.cpp
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/gauge.cpp
widgets_headerctrl.o: $(srcdir)/headerctrl.cpp
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/headerctrl.cpp
widgets_hyperlnk.o: $(srcdir)/hyperlnk.cpp
$(CXXC) -c -o $@ $(WIDGETS_CXXFLAGS) $(srcdir)/hyperlnk.cpp

View File

@ -0,0 +1,114 @@
/////////////////////////////////////////////////////////////////////////////
// Program: wxWidgets Widgets Sample
// Name: headerctrl.cpp
// Purpose: Part of the widgets sample showing wxHeaderCtrl
// Author: Vadim Zeitlin
// Created: 2016-04-17
// Copyright: (c) 2016 wxWindows team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// ============================================================================
// declarations
// ============================================================================
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
// for compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#if wxUSE_HEADERCTRL
// for all others, include the necessary headers
#ifndef WX_PRECOMP
#include "wx/button.h"
#include "wx/sizer.h"
#include "wx/stattext.h"
#endif
#include "wx/headerctrl.h"
#include "widgets.h"
#include "icons/header.xpm"
// ----------------------------------------------------------------------------
// HeaderCtrlWidgetsPage
// ----------------------------------------------------------------------------
class HeaderCtrlWidgetsPage : public WidgetsPage
{
public:
HeaderCtrlWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
: WidgetsPage(book, imaglist, header_xpm)
{
m_header = NULL;
m_sizerHeader = NULL;
}
virtual wxWindow *GetWidget() const wxOVERRIDE { return m_header; }
virtual void RecreateWidget() wxOVERRIDE;
// lazy creation of the content
virtual void CreateContent() wxOVERRIDE;
protected:
// the control itself and the sizer it is in
wxHeaderCtrlSimple *m_header;
wxSizer *m_sizerHeader;
private:
DECLARE_WIDGETS_PAGE(HeaderCtrlWidgetsPage)
};
// ============================================================================
// implementation
// ============================================================================
#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
#define HEADER_CTRL_FAMILY NATIVE_CTRLS
#else
#define HEADER_CTRL_FAMILY GENERIC_CTRLS
#endif
IMPLEMENT_WIDGETS_PAGE(HeaderCtrlWidgetsPage,
wxT("Header"), HEADER_CTRL_FAMILY);
void HeaderCtrlWidgetsPage::CreateContent()
{
m_sizerHeader = new wxStaticBoxSizer(wxVERTICAL, this, "Header");
RecreateWidget();
wxSizer* const sizerTop = new wxBoxSizer(wxHORIZONTAL);
sizerTop->Add(m_sizerHeader, wxSizerFlags(1).Expand().DoubleBorder());
SetSizer(sizerTop);
}
void HeaderCtrlWidgetsPage::RecreateWidget()
{
m_sizerHeader->Clear(true /* delete windows */);
int flags = GetAttrs().m_defaultFlags;
flags |= wxHD_DEFAULT_STYLE;
m_header = new wxHeaderCtrlSimple(this, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
flags);
m_header->AppendColumn(wxHeaderColumnSimple("First", 100));
m_header->AppendColumn(wxHeaderColumnSimple("Second", 200));
m_sizerHeader->AddStretchSpacer();
m_sizerHeader->Add(m_header, wxSizerFlags().Expand());
m_sizerHeader->AddStretchSpacer();
m_sizerHeader->Layout();
}
#endif // wxUSE_HEADERCTRL

View File

@ -0,0 +1,54 @@
/* XPM */
static const char *const header_xpm[] = {
/* columns rows colors chars-per-pixel */
"32 32 16 1",
" c Gray0",
". c #808000",
"X c #000080",
"o c #808080",
"O c #000000",
"+ c #808000",
"@ c #000080",
"# c none",
"$ c #808080",
"% c Red",
"& c Green",
"* c Yellow",
"= c Blue",
"- c Magenta",
"; c Cyan",
": c Gray100",
/* pixels */
" ",
" ############################## ",
" #&&&&&&&&&&&&&&&&&&&&&&&&&&&&# ",
" #&&&&&&&&&&&&&&&&&&&&&&&&&&&&# ",
" #&&&&&&&&&&&&&&&&&&&&&&&&&&&&# ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" ############################## ",
" "
};

View File

@ -51,6 +51,7 @@ WIDGETS_OBJECTS = \
$(OBJS)\widgets_filepicker.obj \
$(OBJS)\widgets_fontpicker.obj \
$(OBJS)\widgets_gauge.obj \
$(OBJS)\widgets_headerctrl.obj \
$(OBJS)\widgets_hyperlnk.obj \
$(OBJS)\widgets_itemcontainer.obj \
$(OBJS)\widgets_listbox.obj \
@ -310,6 +311,9 @@ $(OBJS)\widgets_fontpicker.obj: .\fontpicker.cpp
$(OBJS)\widgets_gauge.obj: .\gauge.cpp
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\gauge.cpp
$(OBJS)\widgets_headerctrl.obj: .\headerctrl.cpp
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\headerctrl.cpp
$(OBJS)\widgets_hyperlnk.obj: .\hyperlnk.cpp
$(CXX) -q -c -P -o$@ $(WIDGETS_CXXFLAGS) .\hyperlnk.cpp

View File

@ -44,6 +44,7 @@ WIDGETS_OBJECTS = \
$(OBJS)\widgets_filepicker.o \
$(OBJS)\widgets_fontpicker.o \
$(OBJS)\widgets_gauge.o \
$(OBJS)\widgets_headerctrl.o \
$(OBJS)\widgets_hyperlnk.o \
$(OBJS)\widgets_itemcontainer.o \
$(OBJS)\widgets_listbox.o \
@ -299,6 +300,9 @@ $(OBJS)\widgets_fontpicker.o: ./fontpicker.cpp
$(OBJS)\widgets_gauge.o: ./gauge.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\widgets_headerctrl.o: ./headerctrl.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\widgets_hyperlnk.o: ./hyperlnk.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<

View File

@ -68,6 +68,7 @@ WIDGETS_OBJECTS = \
widgets_filepicker.o \
widgets_fontpicker.o \
widgets_gauge.o \
widgets_headerctrl.o \
widgets_hyperlnk.o \
widgets_itemcontainer.o \
widgets_listbox.o \
@ -165,6 +166,9 @@ widgets_fontpicker.o: ./fontpicker.cpp
widgets_gauge.o: ./gauge.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
widgets_headerctrl.o: ./headerctrl.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<
widgets_hyperlnk.o: ./hyperlnk.cpp
$(CXX) -c -o $@ $(WIDGETS_CXXFLAGS) $(CPPDEPS) $<

View File

@ -46,6 +46,7 @@ WIDGETS_OBJECTS = \
$(OBJS)\widgets_filepicker.obj \
$(OBJS)\widgets_fontpicker.obj \
$(OBJS)\widgets_gauge.obj \
$(OBJS)\widgets_headerctrl.obj \
$(OBJS)\widgets_hyperlnk.obj \
$(OBJS)\widgets_itemcontainer.obj \
$(OBJS)\widgets_listbox.obj \
@ -433,6 +434,9 @@ $(OBJS)\widgets_fontpicker.obj: .\fontpicker.cpp
$(OBJS)\widgets_gauge.obj: .\gauge.cpp
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\gauge.cpp
$(OBJS)\widgets_headerctrl.obj: .\headerctrl.cpp
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\headerctrl.cpp
$(OBJS)\widgets_hyperlnk.obj: .\hyperlnk.cpp
$(CXX) /c /nologo /TP /Fo$@ $(WIDGETS_CXXFLAGS) .\hyperlnk.cpp

View File

@ -37,6 +37,7 @@
filepicker.cpp
fontpicker.cpp
gauge.cpp
headerctrl.cpp
hyperlnk.cpp
itemcontainer.cpp
listbox.cpp

View File

@ -328,6 +328,9 @@
<File
RelativePath=".\gauge.cpp">
</File>
<File
RelativePath=".\headerctrl.cpp">
</File>
<File
RelativePath=".\hyperlnk.cpp">
</File>

View File

@ -866,6 +866,10 @@
RelativePath=".\gauge.cpp"
>
</File>
<File
RelativePath=".\headerctrl.cpp"
>
</File>
<File
RelativePath=".\hyperlnk.cpp"
>

View File

@ -838,6 +838,10 @@
RelativePath=".\gauge.cpp"
>
</File>
<File
RelativePath=".\headerctrl.cpp"
>
</File>
<File
RelativePath=".\hyperlnk.cpp"
>