-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#5537: Introduce DeclarationSelectorDialog as new base type for decla…
…ration choosers. Start refactoring EntityClassChooser, moving common code to the base.
- Loading branch information
1 parent
db00b16
commit 7001d58
Showing
7 changed files
with
126 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#include "DeclarationSelectorDialog.h" | ||
|
||
#include "DeclarationSelector.h" | ||
#include <wx/sizer.h> | ||
|
||
namespace wxutil | ||
{ | ||
|
||
DeclarationSelectorDialog::DeclarationSelectorDialog(decl::Type declType, | ||
const std::string& title, const std::string& windowName, wxWindow* parent) : | ||
DialogBase(title, parent, windowName), | ||
_declType(declType) | ||
{ | ||
SetSizer(new wxBoxSizer(wxVERTICAL)); | ||
|
||
// Inner sizer with 12-pixel padding | ||
_mainSizer = new wxBoxSizer(wxVERTICAL); | ||
GetSizer()->Add(_mainSizer, 1, wxEXPAND | wxALL, 12); | ||
|
||
// Button row | ||
_buttonSizer = CreateStdDialogButtonSizer(wxOK | wxCANCEL); | ||
_mainSizer->Add(_buttonSizer, 0, wxALIGN_RIGHT, 12); | ||
} | ||
|
||
void DeclarationSelectorDialog::SetSelector(DeclarationSelector* selector) | ||
{ | ||
_selector = selector; | ||
_selector->Reparent(this); | ||
|
||
_mainSizer->Prepend(_selector, 1, wxEXPAND | wxBOTTOM, 12); | ||
|
||
// The selector state should be persisted on dialog close | ||
RegisterPersistableObject(_selector); | ||
} | ||
|
||
std::string DeclarationSelectorDialog::GetSelectedDeclName() | ||
{ | ||
return _selector->GetSelectedDeclName(); | ||
} | ||
|
||
void DeclarationSelectorDialog::SetSelectedDeclName(const std::string& declName) | ||
{ | ||
_selector->SetSelectedDeclName(declName); | ||
} | ||
|
||
wxButton* DeclarationSelectorDialog::GetAffirmativeButton() | ||
{ | ||
return _buttonSizer->GetAffirmativeButton(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#pragma once | ||
|
||
#include "idecltypes.h" | ||
#include "../dialog/DialogBase.h" | ||
|
||
class wxSizer; | ||
class wxStdDialogButtonSizer; | ||
|
||
namespace wxutil | ||
{ | ||
|
||
class DeclarationSelector; | ||
|
||
/** | ||
* Base implementation of a Declaration chooser dialog. | ||
* | ||
* Provides a tree view of available declaration items plus optional previews | ||
* of the active selection. | ||
*/ | ||
class DeclarationSelectorDialog : | ||
public DialogBase | ||
{ | ||
private: | ||
decl::Type _declType; | ||
|
||
DeclarationSelector* _selector; | ||
wxSizer* _mainSizer; | ||
wxStdDialogButtonSizer* _buttonSizer; | ||
|
||
public: | ||
DeclarationSelectorDialog(decl::Type declType, const std::string& title, | ||
const std::string& windowName, wxWindow* parent = nullptr); | ||
|
||
// Get the currently selected declaration name | ||
virtual std::string GetSelectedDeclName(); | ||
|
||
// Set the declaration selection in the selector | ||
virtual void SetSelectedDeclName(const std::string& declName); | ||
|
||
protected: | ||
virtual void SetSelector(DeclarationSelector* selector); | ||
|
||
wxButton* GetAffirmativeButton(); | ||
}; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters