File: DeclarationSelectorDialog.h

package info (click to toggle)
darkradiant 3.9.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 41,080 kB
  • sloc: cpp: 264,743; ansic: 10,659; python: 1,852; xml: 1,650; sh: 92; makefile: 21
file content (74 lines) | stat: -rw-r--r-- 2,009 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#pragma once

#include <wx/dataview.h>

#include "ui/iwindowstate.h"
#include "idecltypes.h"
#include "../dialog/DialogBase.h"

class wxSizer;
class wxButton;
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.
 *
 * It will attempt to restore the last selected item from the registry when shown,
 * unless the SetSelectedDeclName() method is called, which always takes precedence.
 */
class DeclarationSelectorDialog :
    public DialogBase,
    public ui::IPersistableObject
{
private:
    decl::Type _declType;

    DeclarationSelector* _selector;
    wxSizer* _mainSizer;
    wxSizer* _bottomRowSizer;
    wxStdDialogButtonSizer* _buttonSizer;
    wxButton* _reloadDeclsButton;

    bool _restoreSelectionFromRegistry;

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);

    int ShowModal() override;

    void loadFromPath(const std::string& registryKey) override;
    void saveToPath(const std::string& registryKey) override;

protected:
    void SetSelector(DeclarationSelector* selector);

    // Adds a widget to the bottom row, to the left of the standard buttons
    void AddItemToBottomRow(wxWindow* widget);
    // Adds a widget to the bottom row, to the left of the standard buttons
    void AddItemToBottomRow(wxSizer* sizer);

    wxButton* GetAffirmativeButton();

private:
    void HandleTreeViewSelectionChanged();
    void onDeclSelectionChanged(wxDataViewEvent& ev);
    void onDeclItemActivated(wxDataViewEvent& ev);
    void onReloadDecls(wxCommandEvent& ev);
};

}