1 // XCCalendarListAccountCtrl.cpp - XCCalendarListAccountCtrl class
3 // (c) 2016 Xestia Software Development.
5 // This file is part of Xestia Calendar.
7 // Xestia Calendar is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by the
9 // Free Software Foundation, version 3 of the license.
11 // Xestia Calendar is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with Xestia Calendar. If not, see <http://www.gnu.org/licenses/>
19 #include "XCCalendarListAccountCtrl.h"
21 BEGIN_EVENT_TABLE(XCCalendarListAccountCtrl, wxPanel)
26 XCCalendarListAccountCtrl::XCCalendarListAccountCtrl(wxWindow* parent, string accountName) :
27 wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ""){
31 szrMain = new wxBoxSizer( wxHORIZONTAL );
32 this->SetSizer(szrMain);
34 // Setup the checkbox.
36 chkShowAll = new wxCheckBox(this, wxID_ANY, "", wxPoint(0,0), wxDefaultSize, wxCHK_3STATE, wxDefaultValidator, "");
40 lblAccountName = new wxStaticText(this, wxID_ANY, wxString(accountName), wxDefaultPosition, wxDefaultSize, 0, "");
44 wxFont accountFont = lblAccountName->GetFont();
45 accountFont.MakeBold();
46 lblAccountName->SetFont(accountFont);
48 // Connect events to the controls.
50 chkShowAll->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListAccountCtrl::ShowAllCheckboxClick), NULL, this);
51 chkShowAll->SetValue(wxCHK_CHECKED);
53 // Connect them to the sizer.
55 szrMain->Add(chkShowAll, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
56 szrMain->Add(lblAccountName, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
60 XCCalendarListAccountCtrl::~XCCalendarListAccountCtrl(){
62 // Delete the calendar controls.
64 for (std::vector<XCCalendarListCalendarCtrl*>::iterator calendarIter = calendarControlList.begin();
65 calendarIter != calendarControlList.end(); calendarIter++){
71 // Clear the list of deleted controls.
73 calendarControlList.clear();
75 // Clear the widget controls.
79 void XCCalendarListAccountCtrl::AddCalendar(XCCalendarListCalendarCtrl *calendarControl){
81 // Add the calendar control to the sizer.
83 //szrMain->Add(calendarControl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
85 // Add the calendar control to the list.
87 calendarControlList.push_back(calendarControl);
91 void XCCalendarListAccountCtrl::ShowAllCheckboxClick( wxMouseEvent &mouseEvent ){
93 if (chkShowAll->Get3StateValue() == wxCHK_CHECKED){
95 wxCommandEvent event(XCCALENDARCTRL_SHOWACCOUNTENTRIES);
96 event.SetInt(accountID);
97 event.SetId(ID_SHOWENTRIES);
98 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
102 wxCommandEvent event(XCCALENDARCTRL_HIDEACCOUNTENTRIES);
103 event.SetInt(accountID);
104 event.SetId(ID_HIDEENTRIES);
105 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
111 wxCheckBoxState XCCalendarListAccountCtrl::GetShowCheckboxState(){
113 return chkShowAll->Get3StateValue();
117 int XCCalendarListAccountCtrl::GetAccountID(){
123 void XCCalendarListAccountCtrl::SetAccountID(int accountID){
125 this->accountID = accountID;
129 void XCCalendarListAccountCtrl::SetAccountPreferencesID(int accountID){
131 this->accountPreferencesID = accountPreferencesID;
135 vector<int> XCCalendarListAccountCtrl::GetHiddenCalendarList(){
137 vector<int> calendarList;
139 for (vector<XCCalendarListCalendarCtrl*>::iterator calendarControlListIter = calendarControlList.begin();
140 calendarControlListIter != calendarControlList.end(); calendarControlListIter++){
142 if ((*calendarControlListIter)->GetShowCheckboxState() == wxCHK_UNCHECKED){
144 calendarList.push_back((*calendarControlListIter)->GetCalendarID());
154 void XCCalendarListAccountCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
156 if (newValue == wxCHK_CHECKED){
159 showAccounts = false;
162 chkShowAll->SetValue(newValue);