// Copyright (C) 2014 Michael McMaster // // This file is part of SCSI2SD. // // SCSI2SD is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // SCSI2SD is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with SCSI2SD. If not, see . #ifndef TargetPanel_hh #define TargetPanel_hh #include "scsi2sd.h" #include #include #include #include #include #include #if __cplusplus >= 201103L #include #else #include #endif #include namespace SCSI2SD { // A parent class needs to call evaluate on all SCSI targets to sort // out conflicting SCSI IDs and overlapping memory card use. // Our custom event is fired whenever a new evaluation is required. wxDECLARE_EVENT(ConfigChangedEvent, wxCommandEvent); class TargetPanel : public wxPanel { public: TargetPanel(wxWindow* parent, const TargetConfig& initialConfig); TargetConfig getConfig() const; void setConfig(const TargetConfig& config); bool evaluate(); // Return true if current config is valid. bool isEnabled() const; uint8_t getSCSIId() const; std::pair getSDSectorRange() const; // Error messages set by external validation void setDuplicateID(bool duplicate); void setSDSectorOverlap(bool overlap); void setAutoStartSector(uint32_t start); private: template void onInput(EvtType& event); void onSizeInput(wxCommandEvent& event); void evaluateSize(); std::pair convertUnitsToSectors() const; void initConfig(); enum { ID_enableCtrl = wxID_HIGHEST + 1, ID_scsiIdCtrl, ID_deviceTypeCtrl, ID_parityCtrl, ID_unitAttCtrl, ID_startSDSectorCtrl, ID_autoStartSectorCtrl, ID_sectorSizeCtrl, ID_numSectorCtrl, ID_sizeCtrl, ID_sizeUnitCtrl, ID_vendorCtrl, ID_productCtrl, ID_revisionCtrl, ID_serialCtrl }; enum // Must match the order given to the mySizeUnitCtrl ctor. { UNIT_KB, UNIT_MB, UNIT_GB }; wxWindow* myParent; wxWindow* myChangedEventHandler; TargetConfig myConfig; uint32_t myAutoStartSector; wxCheckBox* myEnableCtrl; wxSpinCtrl* myScsiIdCtrl; wxStaticText* myScsiIdMsg; wxChoice* myDeviceTypeCtrl; wxCheckBox* myParityCtrl; wxCheckBox* myUnitAttCtrl; wxIntegerValidator* myStartSDSectorValidator; wxTextCtrl* myStartSDSectorCtrl; wxCheckBox* myAutoStartSectorCtrl; wxStaticText* myStartSDSectorMsg; wxIntegerValidator* mySectorSizeValidator; wxTextCtrl* mySectorSizeCtrl; wxStaticText* mySectorSizeMsg; wxIntegerValidator* myNumSectorValidator; wxTextCtrl* myNumSectorCtrl; wxStaticText* myNumSectorMsg; wxFloatingPointValidator* mySizeValidator; wxTextCtrl* mySizeCtrl; wxChoice* mySizeUnitCtrl; wxTextCtrl* myVendorCtrl; wxStaticText* myVendorMsg; wxTextCtrl* myProductCtrl; wxStaticText* myProductMsg; wxTextCtrl* myRevisionCtrl; wxStaticText* myRevisionMsg; wxTextCtrl* mySerialCtrl; wxStaticText* mySerialMsg; }; } // namespace SCSI2SD #endif