wxWidgets教程(14)——书签控件wxBookCtrl

一、wxBookCtrlBase介绍

这是个抽象类,有七个子类,他们的成员函数基本差不多,分别:

wxAuiNotebook

wxNotebook

wxChoicebook

wxListbook

wxSimplebook

wxToolbook

wxTreebook

二、wxAuiNotebook

需要开启Aui布局管理器,常用的成员函数如下:

	wxAuiNotebook *notebook = new wxAuiNotebook();
	notebook->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE);
	// 页面增删函数
	wxPanel * m_panel = new wxPanel(m_auinotebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	notebook->AddPage(m_panel,wxT("page 1"),true);
	notebook->InsertPage(1,m_panel, wxT("page 1"), true);
	notebook->RemovePage(1);
	notebook->DeletePage(1);
	notebook->DeleteAllPages();
	// 关于页面索引
	notebook->SetSelection(2);
	notebook->AdvanceSelection(true);
	notebook->ChangeSelection(1);
	notebook->GetCurrentPage();
	notebook->GetPageIndex(m_panel);
	notebook->GetPage(1);
	// 页面字体函数
	wxFont m_font;
	notebook->SetFont(m_font);
	notebook->SetMeasuringFont(m_font);
	notebook->SetNormalFont(m_font);
	// 页面属性设置函数,获取函数为getxxx
	notebook->SetPageBitmap();
	notebook->SetPageImage();
	notebook->SetPageSize();
	notebook->SetPageText();
	notebook->SetPageToolTip();


三、wxNotebook

比较通用的notebook,比上面的少了几个函数,tab也可以选择上下左右放置,常用函数如下:

	wxNotebook *notebook = new wxNotebook();
	notebook->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE);
	// 页面增删函数
	wxPanel * m_panel = new wxPanel(m_auinotebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	notebook->AddPage(m_panel,wxT("page 1"),true);
	notebook->InsertPage(1,m_panel, wxT("page 1"), true);
	notebook->RemovePage(1);
	notebook->DeletePage(1);
	notebook->DeleteAllPages();
	// 关于页面索引
	notebook->SetSelection(2);
	notebook->AdvanceSelection(true);
	notebook->ChangeSelection(1);
	notebook->GetCurrentPage();
	notebook->GetPage(1);
	// 页面字体函数
	wxFont m_font;
	notebook->SetFont(m_font);
	// 页面属性设置函数,获取函数为getxxx
	notebook->SetPageImage();
	notebook->SetPageSize();
	notebook->SetPageText();
	// 可以有多行,计算行数
	notebook->GetRowCount();
	// 设置图标和文字的padding
	notebook->SetPadding(wxSize(5,5));

添加图标

	wxImageList * imgList = new wxImageList(16, 16);
	imgList->Add(wxICON(LOG_ICON));
	imgList->Add(wxICON(LIST_ICON));
	imgList->Add(wxICON(PREVIEW_ICON));
	m_notebook2->AssignImageList(imgList);
	m_notebook2->SetPageImage(0, 0);
	m_notebook2->SetPageImage(1, 1);
	m_notebook2->SetPageImage(2, 2);

四、wxChoicebook

这个类似于wxChoice控件,只是多个了选中切换页面的功能。

	wxChoicebook *notebook = new wxChoicebook();
	notebook->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE);
	// 获取wxChoice控件
	wxChoice * choiceCtrl = notebook->GetChoiceCtrl();
	// 页面增删函数
	wxPanel * m_panel = new wxPanel(m_auinotebook1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
	notebook->AddPage(m_panel,wxT("page 1"),true);
	notebook->InsertPage(1,m_panel, wxT("page 1"), true);
	notebook->RemovePage(1);
	notebook->DeletePage(1);
	notebook->DeleteAllPages();
	// 关于页面索引
	notebook->SetSelection(2);
	notebook->AdvanceSelection(true);
	notebook->ChangeSelection(1);
	notebook->GetCurrentPage();
	notebook->GetPage(1);
	// 页面字体函数
	wxFont m_font;
	notebook->SetFont(m_font);
	// 页面属性设置函数,获取函数为getxxx
	notebook->SetPageImage();
	notebook->SetPageSize();
	notebook->SetPageText();

五、wxListbook

	wxListbook *notebook = new wxListbook();
	notebook->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE);
	// 获取wxListView
	wxListView * list_view = notebook->GetListView();
	// ……其他和wxChoiceBook一样


六、wxSimplebook

幻灯片,用户不能手动切换页面,可以通过其他按钮事件来切换,而且有切换效果

	wxSimplebook *notebook = new wxSimplebook();
	notebook->Create(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxAUI_NB_DEFAULT_STYLE);
	// 效果设置,滚动到底部
	notebook->SetEffect(wxSHOW_EFFECT_ROLL_TO_BOTTOM);
	notebook->SetEffectsTimeouts(10, 5);
	// ……其他和wxChoiceBook一样


七、wxToolbook

下次分解

八、wxTreebook

下次分解










猜你喜欢

转载自blog.csdn.net/wyansai/article/details/78491564
今日推荐