当前位置: 首页>>代码示例>>C++>>正文


C++ Profile::GetId方法代码示例

本文整理汇总了C++中Profile::GetId方法的典型用法代码示例。如果您正苦于以下问题:C++ Profile::GetId方法的具体用法?C++ Profile::GetId怎么用?C++ Profile::GetId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Profile的用法示例。


在下文中一共展示了Profile::GetId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetSelectedProfile

void ProfileManager::SetSelectedProfile(const int & id) {
	for (int i = 0; i < item_lb_->GetCount(); ++i) {
		Profile* profile = static_cast<Profile*>(item_lb_->GetClientData(i));
		if (profile->GetId() == id) {
			item_lb_->SetSelection(i);
			break;
		}
	}
}
开发者ID:KeyserSosse,项目名称:CEBMMS,代码行数:9,代码来源:ProfileManager.cpp

示例2: profile_editor

ProfileManager::ProfileManager(wxWindow* parent)
	: wxDialog(parent, -1, "Profile Manager", wxDefaultPosition, 
		wxSize(kDialogWidth, kDialogHeight)), current_profile_(0, "", "") {
	// Setup the listbox
	item_lb_ = new wxListBox(this, -1, wxDefaultPosition);

	// Setup buttons and the button panel
	wxPanel* btn_panel = new wxPanel(this);
	wxBoxSizer* ver_sizer = new wxBoxSizer(wxVERTICAL);

	wxButton* new_profile_btn = new wxButton(btn_panel, -1, "New");
	new_profile_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
		ProfileEditor profile_editor(this, Profile::Profile(-1, "", ""));

		if (profile_editor.ShowModal() == wxID_OK) {
			Profile profile = profile_editor.GetProfile();
			database_.AddProfile(profile.GetName(), profile.GetSerializedMap());
			UpdateListBox();
		}
	});

	wxButton* edit_profile_btn = new wxButton(btn_panel, -1, "Edit");
	edit_profile_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
		int sel = item_lb_->GetSelection();

		if (sel != -1) {
			Profile* profile = static_cast<Profile*>(item_lb_->GetClientData(sel));
			ProfileEditor profile_editor(this, *profile);

			if (profile_editor.ShowModal() == wxID_OK) {
				Profile profile = profile_editor.GetProfile();

				// Remove the old profile
				database_.RemoveProfile(profile.GetId());
				database_.AddProfile(profile.GetName(), profile.GetSerializedMap());

				UpdateListBox();
			}
		}
	});

	wxButton* removeProfileBtn = new wxButton(btn_panel, -1, "Remove");
	removeProfileBtn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
		int sel = item_lb_->GetSelection();

		if (sel != -1) {
			Profile* profile = static_cast<Profile*>(item_lb_->GetClientData(sel));

			database_.RemoveProfile(profile->GetId());
			item_lb_->Delete(sel);

			delete profile;
		}
	});

	ver_sizer->Add(new_profile_btn, 0, wxBOTTOM, 5);
	ver_sizer->Add(edit_profile_btn, 0, wxBOTTOM, 5);
	ver_sizer->Add(removeProfileBtn, 0);

	btn_panel->SetSizer(ver_sizer);

	wxBoxSizer* upper_hor_sizer = new wxBoxSizer(wxHORIZONTAL);
	upper_hor_sizer->Add(item_lb_, 1, wxEXPAND | wxALL, 10);
	upper_hor_sizer->Add(btn_panel, 0, wxALL, 10);

	// Setup ok/cancel button panel
	wxPanel* bottom_btn_panel = new wxPanel(this);

	wxButton* ok_btn = new wxButton(bottom_btn_panel, -1, "OK");
	ok_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
		Profile* profile;

		int sel = item_lb_->GetSelection();
		if (sel != -1) {
			profile = static_cast<Profile*>(item_lb_->GetClientData(sel));
			current_profile_ = *profile;
		}

		EndModal(wxID_OK);
		Destroy();
	});

	wxButton* cancel_btn = new wxButton(bottom_btn_panel, -1, "Cancel");
	cancel_btn->Bind(wxEVT_BUTTON, [=](wxCommandEvent&) {
		EndModal(wxID_CANCEL);
		Destroy();
	});

	wxBoxSizer* bottom_hor_sizer = new wxBoxSizer(wxHORIZONTAL);
	bottom_hor_sizer->Add(ok_btn, 0, wxALL, 10);
	bottom_hor_sizer->Add(cancel_btn, 0, wxALL, 10);

	bottom_btn_panel->SetSizer(bottom_hor_sizer);

	// Setup the outermost vertical layout/sizer
	wxBoxSizer* super_sizer = new wxBoxSizer(wxVERTICAL);

	super_sizer->Add(upper_hor_sizer, 1, wxEXPAND);
	super_sizer->Add(bottom_btn_panel, 0);

//.........这里部分代码省略.........
开发者ID:KeyserSosse,项目名称:CEBMMS,代码行数:101,代码来源:ProfileManager.cpp


注:本文中的Profile::GetId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。