1 // Copyright (C) 2014 Michael McMaster <michael@codesrc.com>
3 // This file is part of SCSI2SD.
5 // SCSI2SD is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // SCSI2SD is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with SCSI2SD. If not, see <http://www.gnu.org/licenses/>.
17 #ifndef TargetPanel_hh
18 #define TargetPanel_hh
24 #include <wx/valnum.h>
26 #include <wx/checkbox.h>
27 #include <wx/choice.h>
28 #include <wx/spinctrl.h>
29 #include <wx/textctrl.h>
31 #if __cplusplus >= 201103L
43 // A parent class needs to call evaluate on all SCSI targets to sort
44 // out conflicting SCSI IDs and overlapping memory card use.
45 // Our custom event is fired whenever a new evaluation is required.
46 wxDECLARE_EVENT(ConfigChangedEvent, wxCommandEvent);
48 class TargetPanel : public wxPanel
51 TargetPanel(wxWindow* parent, const S2S_TargetCfg& initialConfig);
53 S2S_TargetCfg getConfig() const;
54 void setConfig(const S2S_TargetCfg& config);
56 bool evaluate(); // Return true if current config is valid.
58 bool isEnabled() const;
59 uint8_t getSCSIId() const;
60 std::pair<uint32_t, uint64_t> getSDSectorRange() const;
62 // Error messages set by external validation
63 void setDuplicateID(bool duplicate);
64 void setSDSectorOverlap(bool overlap);
65 void setAutoStartSector(uint32_t start);
68 template<typename EvtType> void onInput(EvtType& event);
69 void onSizeInput(wxCommandEvent& event);
72 std::pair<uint32_t, bool> convertUnitsToSectors() const;
78 ID_enableCtrl = wxID_HIGHEST + 1,
82 ID_autoStartSectorCtrl,
93 enum // Must match the order given to the mySizeUnitCtrl ctor.
101 wxWindow* myChangedEventHandler;
103 S2S_TargetCfg myConfig;
104 uint32_t myAutoStartSector;
106 wxCheckBox* myEnableCtrl;
107 wxSpinCtrl* myScsiIdCtrl;
108 wxStaticText* myScsiIdMsg;
110 wxChoice* myDeviceTypeCtrl;
112 std::unique_ptr<wxIntegerValidator<uint32_t>> myStartSDSectorValidator;
113 wxTextCtrl* myStartSDSectorCtrl;
114 wxCheckBox* myAutoStartSectorCtrl;
115 wxStaticText* myStartSDSectorMsg;
117 std::unique_ptr<wxIntegerValidator<uint16_t>> mySectorSizeValidator;
118 wxTextCtrl* mySectorSizeCtrl;
119 wxStaticText* mySectorSizeMsg;
121 std::unique_ptr<wxIntegerValidator<uint32_t>> myNumSectorValidator;
122 wxTextCtrl* myNumSectorCtrl;
123 wxStaticText* myNumSectorMsg;
125 std::unique_ptr<wxFloatingPointValidator<float>> mySizeValidator;
126 wxTextCtrl* mySizeCtrl;
127 wxChoice* mySizeUnitCtrl;
129 wxTextCtrl* myVendorCtrl;
130 wxStaticText* myVendorMsg;
131 wxTextCtrl* myProductCtrl;
132 wxStaticText* myProductMsg;
133 wxTextCtrl* myRevisionCtrl;
134 wxStaticText* myRevisionMsg;
135 wxTextCtrl* mySerialCtrl;
136 wxStaticText* mySerialMsg;
139 } // namespace SCSI2SD