1 #ifndef FILEZILLA_INTERFACE_DIALOGEX_HEADER
2 #define FILEZILLA_INTERFACE_DIALOGEX_HEADER
3 
4 #include "wrapengine.h"
5 
6 class wxGridBagSizer;
7 struct DialogLayout final
8 {
9 public:
10 	int gap{};
11 	int border{};
12 	int indent{};
13 
14 	int dlgUnits(int num) const;
15 
16 	static wxSizerFlags const grow;
17 	static wxSizerFlags const halign;
18 	static wxSizerFlags const valign;
19 	static wxSizerFlags const valigng;
20 	static wxSizerFlags const ralign;
21 
22 	wxFlexGridSizer* createMain(wxWindow* parent, int cols, int rows = 0) const;
23 	wxFlexGridSizer* createFlex(int cols, int rows = 0) const;
24 	wxGridSizer* createGrid(int cols, int rows = 0) const;
25 	wxGridBagSizer* createGridBag(int cols, int rows = 0) const;
26 	wxStdDialogButtonSizer* createButtonSizer(wxWindow* parent, wxSizer * sizer, bool hline) const;
27 
28 	std::tuple<wxStaticBox*, wxFlexGridSizer*> createStatBox(wxSizer* parent, wxString const& title, int cols, int rows = 0) const;
29 
30 	DialogLayout(wxTopLevelWindow * parent);
31 
32 	void gbNewRow(wxGridBagSizer * gb) const;
33 	wxSizerItem* gbAddRow(wxGridBagSizer * gb, wxWindow* wnd, wxSizerFlags const& flags = wxSizerFlags()) const;
34 	wxSizerItem* gbAdd(wxGridBagSizer * gb, wxWindow* wnd, wxSizerFlags const& flags = wxSizerFlags()) const;
35 	wxSizerItem* gbAdd(wxGridBagSizer* gb, wxSizer* sizer, wxSizerFlags const& flags = wxSizerFlags()) const;
36 
37 protected:
38 	wxTopLevelWindow * parent_;
39 };
40 
41 class wxDialogEx : public wxDialog, public CWrapEngine
42 {
43 public:
44 	bool Create(wxWindow * parent, int id, wxString const& title, wxPoint const& pos = wxDefaultPosition, wxSize const& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE);
45 
46 	bool Load(wxWindow *pParent, wxString const& name, std::wstring const& file = std::wstring());
47 
48 	bool SetChildLabel(int id, const wxString& label, unsigned long maxLength = 0);
49 	bool SetChildLabel(char const* id, const wxString& label, unsigned long maxLength = 0);
50 	wxString GetChildLabel(int id);
51 
52 	virtual int ShowModal();
53 
54 	bool ReplaceControl(wxWindow* old, wxWindow* wnd);
55 
56 	static bool CanShowPopupDialog(wxTopLevelWindow * parent = 0);
57 
58 	DialogLayout const& layout();
59 
EndDialog(int rc)60 	void EndDialog(int rc) {
61 		wxDialog::EndDialog(rc);
62 	}
63 
64 protected:
65 	virtual void InitDialog();
66 
67 	DECLARE_EVENT_TABLE()
68 	virtual void OnChar(wxKeyEvent& event);
69 	void OnMenuEvent(wxCommandEvent& event);
70 
71 #ifdef __WXMAC__
72 	virtual bool ProcessEvent(wxEvent& event);
73 
74 	static std::vector<void*> shown_dialogs_creation_events_;
75 #endif
76 
77 	static std::vector<wxDialogEx*> shown_dialogs_;
78 
79 	std::unique_ptr<DialogLayout> layout_;
80 
81 	std::vector<wxAcceleratorEntry> acceleratorTable_;
82 };
83 
84 wxWindowID const nullID = wxID_HIGHEST;
85 
86 std::wstring LabelEscape(std::wstring const& label);
87 
88 #ifdef __WXMAC__
89 void FixPasswordPaste(std::vector<wxAcceleratorEntry> & entries);
90 #endif
91 
92 #endif
93