Debian Codegraph @

wxcrafter/src/DefineCustomControlWizard.cpp

raw
1 #include "DefineCustomControlWizard.h"
2 #include "NewCustomEventDlg.h"
3 #include <globals.h>
4 #include <json_node.h>
5 #include <wx/msgdlg.h>
6
7 DefineCustomControlWizard::DefineCustomControlWizard(wxWindow* parent)
8 : DefineCustomControlWizardBaseClass(parent)
9 {
10 }
11
12 DefineCustomControlWizard::~DefineCustomControlWizard() {}
13
14 void DefineCustomControlWizard::OnPageChanging(wxWizardEvent& event)
15 {
16 if(event.GetDirection()) {
17 if(event.GetPage() == m_wizardPageGeneral && !::IsValidCppIndetifier(m_textClassName->GetValue())) {
18 wxMessageBox(_("Invalid C++ class name provided!"), wxT("wxCrafter"), wxOK | wxICON_WARNING | wxCENTER);
19 event.Veto();
20 return;
21
22 } else if(event.GetPage() == m_wizardPageHeader && m_textCtrlIncludeLine->IsEmpty()) {
23 wxMessageBox(_("Please set an include file for this control"), wxT("wxCrafter"),
24 wxOK | wxICON_WARNING | wxCENTER);
25 event.Veto();
26 return;
27
28 } else if(event.GetPage() == m_wizardPageCpp && m_textCtrlInstantiationLine->IsEmpty()) {
29 wxMessageBox(_("Control instantiation code is missing"), wxT("wxCrafter"),
30 wxOK | wxICON_WARNING | wxCENTER);
31 event.Veto();
32 return;
33 }
34 }
35 event.Skip();
36 }
37
38 CustomControlTemplate DefineCustomControlWizard::GetControl() const
39 {
40 CustomControlTemplate controlData;
41 controlData.SetAllocationLine(m_textCtrlInstantiationLine->GetValue());
42 controlData.SetClassName(m_textClassName->GetValue());
43 controlData.SetIncludeFile(m_textCtrlIncludeLine->GetValue());
44 controlData.SetXrcPreviewClass(m_textCtrlXRCPreviewClass->GetValue());
45
46 wxStringMap_t events;
47 int count = m_dvListCtrlEvents->GetItemCount();
48 for(int i = 0; i < count; ++i) {
49 wxString eventtype = m_dvListCtrlEvents->GetTextValue(i, 0);
50 wxString eventclss = m_dvListCtrlEvents->GetTextValue(i, 1);
51
52 events.insert(std::make_pair(eventtype, eventclss));
53 }
54 controlData.SetEvents(events);
55 return controlData;
56 }
57
58 void DefineCustomControlWizard::OnDeleteEvent(wxCommandEvent& event)
59 {
60 m_dvListCtrlEvents->DeleteItem(m_dvListCtrlEvents->GetSelectedRow());
61 }
62
63 void DefineCustomControlWizard::OnDeleteEventUI(wxUpdateUIEvent& event)
64 {
65 event.Enable(m_dvListCtrlEvents->GetSelection().IsOk());
66 }
67
68 void DefineCustomControlWizard::OnNewEvent(wxCommandEvent& event)
69 {
70 NewCustomEventDlg dlg(this);
71 if(dlg.ShowModal() == wxID_OK) {
72 wxVector<wxVariant> cols;
73 cols.push_back(dlg.GetEventType());
74 cols.push_back(dlg.GetEventClass());
75 m_dvListCtrlEvents->AppendItem(cols, (wxUIntPtr)NULL);
76 }
77 }