| 1 |
/* |
| 2 |
Copyright (C) 2009-2010 wxLauncher Team |
| 3 |
|
| 4 |
This program is free software; you can redistribute it and/or |
| 5 |
modify it under the terms of the GNU General Public License |
| 6 |
as published by the Free Software Foundation; either version 2 |
| 7 |
of the License, or (at your option) any later version. |
| 8 |
|
| 9 |
This program is distributed in the hope that it will be useful, |
| 10 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 |
GNU General Public License for more details. |
| 13 |
|
| 14 |
You should have received a copy of the GNU General Public License |
| 15 |
along with this program; if not, write to the Free Software |
| 16 |
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 |
*/ |
| 18 |
|
| 19 |
#ifndef FLAGLISTBOX_H |
| 20 |
#define FLAGLISTBOX_H |
| 21 |
|
| 22 |
#include <wx/wx.h> |
| 23 |
#include <wx/vlbox.h> |
| 24 |
|
| 25 |
#include "apis/EventHandlers.h" |
| 26 |
#include "apis/FlagListManager.h" |
| 27 |
|
| 28 |
class FlagListCheckBox: public wxCheckBox { |
| 29 |
public: |
| 30 |
FlagListCheckBox( |
| 31 |
wxWindow* parent, |
| 32 |
const wxString& label, |
| 33 |
const wxString& flagString); |
| 34 |
void OnClicked(wxCommandEvent &event); |
| 35 |
private: |
| 36 |
FlagListCheckBox(); |
| 37 |
wxString flagString; |
| 38 |
}; |
| 39 |
|
| 40 |
class FlagListCheckBoxItem { |
| 41 |
public: |
| 42 |
FlagListCheckBoxItem(const wxString& fsoCategory); |
| 43 |
FlagListCheckBoxItem(FlagListCheckBox& checkBox, wxSizer& checkBoxSizer, |
| 44 |
const wxString& shortDescription, const wxString& flagString, |
| 45 |
bool isRecommendedFlag); |
| 46 |
~FlagListCheckBoxItem(); |
| 47 |
const wxString& GetFsoCategory() const { return this->fsoCategory; } |
| 48 |
FlagListCheckBox* GetCheckBox() { return this->checkBox; } |
| 49 |
wxSizer* GetCheckBoxSizer() { return this->checkBoxSizer; } |
| 50 |
const wxString& GetShortDescription() const { return this->shortDescription; } |
| 51 |
const wxString& GetFlagString() const { return this->flagString; } |
| 52 |
bool IsRecommendedFlag() const { return this->isRecommendedFlag; } |
| 53 |
private: |
| 54 |
FlagListCheckBoxItem(); |
| 55 |
wxString fsoCategory; |
| 56 |
FlagListCheckBox* checkBox; |
| 57 |
wxSizer* checkBoxSizer; |
| 58 |
wxString shortDescription; |
| 59 |
wxString flagString; |
| 60 |
bool isRecommendedFlag; |
| 61 |
}; |
| 62 |
|
| 63 |
WX_DECLARE_LIST(FlagListCheckBoxItem, FlagListCheckBoxItems); |
| 64 |
|
| 65 |
/** Flag list box is ready for use. */ |
| 66 |
LAUNCHER_DECLARE_EVENT_TYPE(EVT_FLAG_LIST_BOX_READY); |
| 67 |
|
| 68 |
class FlagListBox: public wxVListBox { |
| 69 |
public: |
| 70 |
FlagListBox(wxWindow* parent); |
| 71 |
~FlagListBox(); |
| 72 |
|
| 73 |
void RegisterFlagListBoxReady(wxEvtHandler *handler); |
| 74 |
void UnRegisterFlagListBoxReady(wxEvtHandler *handler); |
| 75 |
|
| 76 |
virtual void OnDrawItem(wxDC &dc, const wxRect &rect, size_t n) const; |
| 77 |
virtual void OnDrawBackground(wxDC &dc, const wxRect &rect, size_t n) const; |
| 78 |
virtual wxCoord OnMeasureItem(size_t n) const; |
| 79 |
|
| 80 |
void OnDoubleClickFlag(wxCommandEvent &event); |
| 81 |
|
| 82 |
/** Loads enabled flags from the proxy and checks the corresponding boxes. */ |
| 83 |
void LoadEnabledFlags(); |
| 84 |
|
| 85 |
/** Tries to find the flagSet specified and then set or unset all flags |
| 86 |
contained in the flag set, returns true on success, returns false |
| 87 |
iff it cannot find the flagset. That is, will return true if none of |
| 88 |
the flags in the flag set are real flags. */ |
| 89 |
bool SetFlagSet(const wxString& setToFind); |
| 90 |
|
| 91 |
void GetFlagSets(wxArrayString& arr) const; |
| 92 |
|
| 93 |
void AcceptFlagData(FlagFileData* flagData); |
| 94 |
|
| 95 |
bool IsReady() const { return this->isReady; } |
| 96 |
|
| 97 |
bool FlagsLoaded() const { return this->flagsLoaded; } |
| 98 |
|
| 99 |
private: |
| 100 |
EventHandlers flagListBoxReadyHandlers; |
| 101 |
void GenerateFlagListBoxReady(); |
| 102 |
bool isReadyEventGenerated; |
| 103 |
bool isReady; |
| 104 |
bool flagsLoaded; |
| 105 |
|
| 106 |
/** Tries to find flagString in the list of flags and set it to state. |
| 107 |
returns true on successful set, returns false if cannot find flag. |
| 108 |
Will update the proxy if updateProxy is true. */ |
| 109 |
bool SetFlag(const wxString& flagString, bool state, bool updateProxy = false); |
| 110 |
|
| 111 |
FlagFileData* flagData; |
| 112 |
FlagListCheckBoxItems checkBoxes; |
| 113 |
void GenerateCheckBoxes(const FlagListBoxData& data); |
| 114 |
bool areCheckBoxesGenerated; |
| 115 |
|
| 116 |
FlagListCheckBoxItem* FindFlagAt(size_t n) const; |
| 117 |
|
| 118 |
DECLARE_EVENT_TABLE(); |
| 119 |
|
| 120 |
}; |
| 121 |
|
| 122 |
#endif |