Unicode fixes, wxWidgets coding standards, source cleaning for wxFoldBar samples.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33159 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba 2005-03-29 18:03:57 +00:00
parent 90694388b4
commit c74ca0c0ce
5 changed files with 176 additions and 180 deletions

View File

@ -25,7 +25,7 @@
#include "wx/spinctrl.h"
#include "wx/slider.h"
#include "../../../../samples/sample.xpm"
#include "sample.xpm"
#include "extended.h"
@ -45,7 +45,7 @@ bool MyApp::OnInit(void)
{
// Create the main frame window
frame = new MyFrame(NULL, -1, _T("FoldPanelBar Extended Demo"), wxPoint(-1, -1), wxSize(500, 600),
frame = new MyFrame(NULL, wxID_ANY, _T("FoldPanelBar Extended Demo"), wxDefaultPosition, wxSize(500, 600),
wxDEFAULT_FRAME_STYLE |
wxNO_FULL_REPAINT_ON_RESIZE |
wxHSCROLL | wxVSCROLL);
@ -57,11 +57,11 @@ bool MyApp::OnInit(void)
frame->CreateStatusBar();
frame->Show(TRUE);
frame->Show(true);
SetTopWindow(frame);
return TRUE;
return true;
}
BEGIN_EVENT_TABLE(MyFrame, wxMDIParentFrame)
@ -88,7 +88,7 @@ END_EVENT_TABLE()
MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style)
: wxMDIParentFrame(parent, id, title, pos, size, style)
, _flags(0)
, m_flags(0)
{
m_leftWindow1 = new wxSashLayoutWindow(this, ID_WINDOW_LEFT1,
wxDefaultPosition, wxSize(200, 30),
@ -97,16 +97,16 @@ MyFrame::MyFrame(wxWindow *parent, const wxWindowID id, const wxString& title, c
m_leftWindow1->SetDefaultSize(wxSize(160, 1000));
m_leftWindow1->SetOrientation(wxLAYOUT_VERTICAL);
m_leftWindow1->SetAlignment(wxLAYOUT_LEFT);
m_leftWindow1->SetSashVisible(wxSASH_RIGHT, TRUE);
m_leftWindow1->SetSashVisible(wxSASH_RIGHT, true);
m_leftWindow1->SetExtraBorderSize(0);
_pnl = 0;
m_pnl = NULL;
ReCreateFoldPanel(0);
}
void MyFrame::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
Close(true);
}
void MyFrame::OnAbout(wxCommandEvent& WXUNUSED(event))
@ -147,11 +147,6 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event))
subframe->SetTitle(wxString::Format(_T("Canvas Frame %d"), winNumber));
winNumber ++;
// Give it an icon (this is ignored in MDI mode: uses resources)
#ifdef __WXMSW__
subframe->SetIcon(wxIcon(_T("sashtest_icn")));
#endif
// Give it a status line
subframe->CreateStatusBar();
@ -167,7 +162,7 @@ void MyFrame::OnNewWindow(wxCommandEvent& WXUNUSED(event))
// Give it scrollbars
canvas->SetScrollbars(20, 20, 50, 50);
subframe->Show(TRUE);
subframe->Show(true);
}
void MyFrame::ReCreateFoldPanel(int fpb_flags)
@ -177,89 +172,89 @@ void MyFrame::ReCreateFoldPanel(int fpb_flags)
// recreate the foldpanelbar
_pnl = new wxFoldPanelBar(m_leftWindow1, -1, wxDefaultPosition, wxSize(-1,-1), wxFPB_DEFAULT_STYLE, fpb_flags);
m_pnl = new wxFoldPanelBar(m_leftWindow1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFPB_DEFAULT_STYLE, fpb_flags);
wxFoldPanel item = _pnl->AddFoldPanel("Caption colours", false);
wxFoldPanel item = m_pnl->AddFoldPanel(_T("Caption colours"), false);
_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Adjust the first colour")),
m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Adjust the first colour")),
wxFPB_ALIGN_WIDTH, 5, 20);
// RED color spin control
_rslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _rslider1, wxFPB_ALIGN_WIDTH,
m_rslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_rslider1, wxFPB_ALIGN_WIDTH,
2, 20);
// GREEN color spin control
_gslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _gslider1, wxFPB_ALIGN_WIDTH,
m_gslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_gslider1, wxFPB_ALIGN_WIDTH,
0, 20);
// BLUE color spin control
_bslider1 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _bslider1, wxFPB_ALIGN_WIDTH,
m_bslider1 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_bslider1, wxFPB_ALIGN_WIDTH,
0, 20);
_pnl->AddFoldPanelSeperator(item);
m_pnl->AddFoldPanelSeperator(item);
_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Adjust the second colour")),
m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Adjust the second colour")),
wxFPB_ALIGN_WIDTH, 5, 20);
// RED color spin control
_rslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _rslider2, wxFPB_ALIGN_WIDTH,
m_rslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_rslider2, wxFPB_ALIGN_WIDTH,
2, 20);
// GREEN color spin control
_gslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _gslider2, wxFPB_ALIGN_WIDTH,
m_gslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_gslider2, wxFPB_ALIGN_WIDTH,
0, 20);
// BLUE color spin control
_bslider2 = new wxSlider(item.GetParent(), -1, 0, 0, 255);
_pnl->AddFoldPanelWindow(item, _bslider2, wxFPB_ALIGN_WIDTH,
m_bslider2 = new wxSlider(item.GetParent(), wxID_ANY, 0, 0, 255);
m_pnl->AddFoldPanelWindow(item, m_bslider2, wxFPB_ALIGN_WIDTH,
0, 20);
_pnl->AddFoldPanelSeperator(item);
m_pnl->AddFoldPanelSeperator(item);
_btn = new wxButton(item.GetParent(), ID_APPLYTOALL, "Apply to all");
_pnl->AddFoldPanelWindow(item, _btn);
m_btn = new wxButton(item.GetParent(), ID_APPLYTOALL, _T("Apply to all"));
m_pnl->AddFoldPanelWindow(item, m_btn);
// read back current gradients and set the sliders
// for the colour which is now taken as default
wxCaptionBarStyle style = _pnl->GetCaptionStyle(item);
wxCaptionBarStyle style = m_pnl->GetCaptionStyle(item);
wxColour col = style.GetFirstColour();
_rslider1->SetValue(col.Red());
_gslider1->SetValue(col.Green());
_bslider1->SetValue(col.Blue());
m_rslider1->SetValue(col.Red());
m_gslider1->SetValue(col.Green());
m_bslider1->SetValue(col.Blue());
col = style.GetSecondColour();
_rslider2->SetValue(col.Red());
_gslider2->SetValue(col.Green());
_bslider2->SetValue(col.Blue());
m_rslider2->SetValue(col.Red());
m_gslider2->SetValue(col.Green());
m_bslider2->SetValue(col.Blue());
// put down some caption styles from which the user can
// select to show how the current or all caption bars will look like
item = _pnl->AddFoldPanel("Caption style", false);
item = m_pnl->AddFoldPanel(_T("Caption style"), false);
wxRadioButton *currStyle = new wxRadioButton(item.GetParent(), ID_USE_VGRADIENT, "&Vertical gradient");
_pnl->AddFoldPanelWindow(item, currStyle, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
wxRadioButton *currStyle = new wxRadioButton(item.GetParent(), ID_USE_VGRADIENT, _T("&Vertical gradient"));
m_pnl->AddFoldPanelWindow(item, currStyle, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
currStyle->SetValue(true);
_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_HGRADIENT, "&Horizontal gradient"),
m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_HGRADIENT, _T("&Horizontal gradient")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_SINGLE, "&Single colour"),
m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_SINGLE, _T("&Single colour")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_RECTANGLE, "&Rectangle box"),
m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_RECTANGLE, _T("&Rectangle box")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_FILLED_RECTANGLE, "&Filled rectangle box"),
m_pnl->AddFoldPanelWindow(item, new wxRadioButton(item.GetParent(), ID_USE_FILLED_RECTANGLE, _T("&Filled rectangle box")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
_pnl->AddFoldPanelSeperator(item);
m_pnl->AddFoldPanelSeperator(item);
_single = new wxCheckBox(item.GetParent(), -1, "&Only this caption");
_pnl->AddFoldPanelWindow(item, _single, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
m_single = new wxCheckBox(item.GetParent(), wxID_ANY, _T("&Only this caption"));
m_pnl->AddFoldPanelWindow(item, m_single, wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
// one more panel to finish it
@ -267,14 +262,14 @@ void MyFrame::ReCreateFoldPanel(int fpb_flags)
wxCaptionBarStyle cs;
cs.SetCaptionStyle(wxCAPTIONBAR_RECTANGLE);
item = _pnl->AddFoldPanel("Misc stuff", true, cs);
item = m_pnl->AddFoldPanel(_T("Misc stuff"), true, cs);
_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, "Collapse All"));
m_pnl->AddFoldPanelWindow(item, new wxButton(item.GetParent(), ID_COLLAPSEME, _T("Collapse All")));
_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), -1, _T("Enter some comments")),
m_pnl->AddFoldPanelWindow(item, new wxStaticText(item.GetParent(), wxID_ANY, _T("Enter some comments")),
wxFPB_ALIGN_WIDTH, 5, 20);
_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), -1, "Comments"),
m_pnl->AddFoldPanelWindow(item, new wxTextCtrl(item.GetParent(), wxID_ANY, _T("Comments")),
wxFPB_ALIGN_WIDTH, wxFPB_DEFAULT_SPACING, 10);
m_leftWindow1->SizeWindows();
@ -288,11 +283,11 @@ void MyFrame::OnCreateBottomStyle(wxCommandEvent& event)
// or normal
if(event.IsChecked())
_flags |= wxFPB_COLLAPSE_TO_BOTTOM;
m_flags |= wxFPB_COLLAPSE_TO_BOTTOM;
else
_flags &= ~wxFPB_COLLAPSE_TO_BOTTOM;
m_flags &= ~wxFPB_COLLAPSE_TO_BOTTOM;
ReCreateFoldPanel(_flags);
ReCreateFoldPanel(m_flags);
}
void MyFrame::OnCreateNormalStyle(wxCommandEvent& event)
@ -303,34 +298,38 @@ void MyFrame::OnCreateNormalStyle(wxCommandEvent& event)
// TODO: Not yet implemented!
if(event.IsChecked())
_flags |= wxFPB_SINGLE_FOLD;
m_flags |= wxFPB_SINGLE_FOLD;
else
_flags &= ~wxFPB_SINGLE_FOLD;
m_flags &= ~wxFPB_SINGLE_FOLD;
ReCreateFoldPanel(_flags);
ReCreateFoldPanel(m_flags);
}
void MyFrame::OnCollapseMe(wxCommandEvent &event)
void MyFrame::OnCollapseMe(wxCommandEvent &WXUNUSED(event))
{
wxFoldPanel item(0);
for(size_t i = 0; i < _pnl->GetCount(); i++)
for(size_t i = 0; i < m_pnl->GetCount(); i++)
{
item = _pnl->Item(i);
_pnl->Collapse(item);
item = m_pnl->Item(i);
m_pnl->Collapse(item);
}
}
void MyFrame::OnExpandMe(wxCommandEvent &event)
void MyFrame::OnExpandMe(wxCommandEvent &WXUNUSED(event))
{
wxColour col1(_rslider1->GetValue(), _gslider1->GetValue(), _bslider1->GetValue()),
col2(_rslider2->GetValue(), _gslider2->GetValue(), _bslider2->GetValue());
wxColour col1((unsigned char)m_rslider1->GetValue(),
(unsigned char)m_gslider1->GetValue(),
(unsigned char)m_bslider1->GetValue()),
col2((unsigned char)m_rslider2->GetValue(),
(unsigned char)m_gslider2->GetValue(),
(unsigned char)m_bslider2->GetValue());
wxCaptionBarStyle style;
style.SetFirstColour(col1);
style.SetSecondColour(col2);
_pnl->ApplyCaptionStyleAll(style);
m_pnl->ApplyCaptionStyleAll(style);
}
wxMenuBar *CreateMenuBar(bool with_window)
@ -376,19 +375,23 @@ wxMenuBar *CreateMenuBar(bool with_window)
return menu_bar;
}
void MyFrame::OnSlideColour(wxScrollEvent &event)
void MyFrame::OnSlideColour(wxScrollEvent &WXUNUSED(event))
{
wxColour col1(_rslider1->GetValue(), _gslider1->GetValue(), _bslider1->GetValue()),
col2(_rslider2->GetValue(), _gslider2->GetValue(), _bslider2->GetValue());
//_btn->SetBackgroundColour(col);
wxColour col1((unsigned char)m_rslider1->GetValue(),
(unsigned char)m_gslider1->GetValue(),
(unsigned char)m_bslider1->GetValue()),
col2((unsigned char)m_rslider2->GetValue(),
(unsigned char)m_gslider2->GetValue(),
(unsigned char)m_bslider2->GetValue());
//m_btn->SetBackgroundColour(col);
wxCaptionBarStyle style;
style.SetFirstColour(col1);
style.SetSecondColour(col2);
wxFoldPanel item = _pnl->Item(0);
_pnl->ApplyCaptionStyle(item, style);
wxFoldPanel item = m_pnl->Item(0);
m_pnl->ApplyCaptionStyle(item, style);
}
void MyFrame::OnStyleChange(wxCommandEvent &event)
@ -420,14 +423,15 @@ void MyFrame::OnStyleChange(wxCommandEvent &event)
break;
}
if(_single->GetValue())
if(m_single->GetValue())
{
wxFoldPanel item = _pnl->Item(1);
_pnl->ApplyCaptionStyle(item, style);
wxFoldPanel item = m_pnl->Item(1);
m_pnl->ApplyCaptionStyle(item, style);
}
else
_pnl->ApplyCaptionStyleAll(style);
{
m_pnl->ApplyCaptionStyleAll(style);
}
}
/* ----------------------------------------------------------------------------------------------- */
@ -438,7 +442,7 @@ END_EVENT_TABLE()
// Define a constructor for my canvas
MyCanvas::MyCanvas(wxWindow *parent, const wxPoint& pos, const wxSize& size)
: wxScrolledWindow(parent, -1, pos, size,
:wxScrolledWindow(parent, wxID_ANY, pos, size,
wxSUNKEN_BORDER | wxNO_FULL_REPAINT_ON_RESIZE)
{
SetBackgroundColour(* wxWHITE);
@ -504,9 +508,10 @@ BEGIN_EVENT_TABLE(MyChild, wxMDIChildFrame)
EVT_MENU(FPBTEST_CHILD_QUIT, MyChild::OnQuit)
END_EVENT_TABLE()
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title, const wxPoint& pos, const wxSize& size,
const long style):
wxMDIChildFrame(parent, -1, title, pos, size, style)
MyChild::MyChild(wxMDIParentFrame *parent, const wxString& title,
const wxPoint& pos, const wxSize& size,
const long style)
:wxMDIChildFrame(parent, wxID_ANY, title, pos, size, style)
{
canvas = NULL;
my_children.Append(this);
@ -519,7 +524,7 @@ MyChild::~MyChild(void)
void MyChild::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
Close(true);
}
void MyChild::OnActivate(wxActivateEvent& event)

View File

@ -69,11 +69,11 @@ protected:
private:
void ReCreateFoldPanel(int fpb_flags);
wxFoldPanelBar *_pnl;
wxButton *_btn;
wxCheckBox *_single;
wxSlider *_rslider1, *_gslider1, *_bslider1, *_rslider2, *_gslider2, *_bslider2;
int _flags;
wxFoldPanelBar *m_pnl;
wxButton *m_btn;
wxCheckBox *m_single;
wxSlider *m_rslider1, *m_gslider1, *m_bslider1, *m_rslider2, *m_gslider2, *m_bslider2;
int m_flags;
DECLARE_EVENT_TABLE()
};

View File

@ -1,3 +1 @@
aaaa ICON "..\..\..\..\samples\sample.ico"
#include "wx/msw/wx.rc"

View File

@ -28,9 +28,7 @@
// ----------------------------------------------------------------------------
// the application icon (under Windows and OS/2 it is in resources)
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "mondrian.xpm"
#endif
#include "sample.xpm"
// ----------------------------------------------------------------------------
// MyApp Class
@ -128,7 +126,7 @@ bool MyApp::OnInit()
MyAppFrame::MyAppFrame(const wxString& title, const wxPoint& pos, const wxSize& size, long style)
: wxFrame(NULL, wxID_ANY, title, pos, size, style), m_pnl(NULL)
{
SetIcon(wxICON(mondrian));
SetIcon(wxIcon(sample_xpm));
SetMenuBar(CreateMenuBar());

View File

@ -1,6 +1 @@
mondrian ICON "sample.ico"
#define FOLDPANELBARTEST_QUIT 1
#define FOLDPANELBARTEST_ABOUT 102
#include "wx/msw/wx.rc"