Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Widget controls updated
[xestiacalendar/.git] / source / widgets / XCCalendarListAccountCtrl.cpp
1 // XCCalendarListAccountCtrl.cpp - XCCalendarListAccountCtrl class
2 //
3 // (c) 2016 Xestia Software Development.
4 //
5 // This file is part of Xestia Calendar.
6 //
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.
10 //
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.
15 //
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)
22 END_EVENT_TABLE()
24 using namespace std;
26 XCCalendarListAccountCtrl::XCCalendarListAccountCtrl(wxWindow* parent, string accountName) : 
27         wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ""){
29         // Create the sizer.
30         
31         szrMain = new wxBoxSizer( wxHORIZONTAL );
32         this->SetSizer(szrMain);
33         
34         // Setup the checkbox.
35         
36         chkShowAll = new wxCheckBox(this, wxID_ANY, "", wxPoint(0,0), wxDefaultSize, wxCHK_3STATE, wxDefaultValidator, "");
37         
38         // Setup the label.
39         
40         lblAccountName = new wxStaticText(this, wxID_ANY, wxString(accountName), wxDefaultPosition, wxDefaultSize, 0, "");
41                 
42         // Setup the font.
43                 
44         wxFont accountFont = lblAccountName->GetFont();
45         accountFont.MakeBold();
46         lblAccountName->SetFont(accountFont);
47                 
48         // Connect events to the controls.
49         
50         chkShowAll->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListAccountCtrl::ShowAllCheckboxClick), NULL, this);
51         chkShowAll->SetValue(wxCHK_CHECKED);
52         
53         // Connect them to the sizer.
54         
55         szrMain->Add(chkShowAll, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
56         szrMain->Add(lblAccountName, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
57         
58 }
60 XCCalendarListAccountCtrl::~XCCalendarListAccountCtrl(){
61         
62         // Delete the calendar controls.
63         
64         for (std::vector<XCCalendarListCalendarCtrl*>::iterator calendarIter = calendarControlList.begin();
65                 calendarIter != calendarControlList.end(); calendarIter++){
66         
67                 delete *calendarIter;
68                         
69         }
70         
71         // Clear the list of deleted controls.
72         
73         calendarControlList.clear();
74         
75         // Clear the widget controls.
76         
77 }
79 void XCCalendarListAccountCtrl::AddCalendar(XCCalendarListCalendarCtrl *calendarControl){
81         // Add the calendar control to the sizer.
82         
83         //szrMain->Add(calendarControl, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
84         
85         // Add the calendar control to the list.
86         
87         calendarControlList.push_back(calendarControl);
88         
89 }
91 void XCCalendarListAccountCtrl::ShowAllCheckboxClick( wxMouseEvent &mouseEvent ){
92         
93         if (chkShowAll->Get3StateValue() == wxCHK_CHECKED){
94                 
95                 wxCommandEvent event(XCCALENDARCTRL_SHOWACCOUNTENTRIES);
96                 event.SetInt(accountID);
97                 event.SetId(ID_SHOWENTRIES);
98                 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
99                 
100         } else {
101                 
102                 wxCommandEvent event(XCCALENDARCTRL_HIDEACCOUNTENTRIES);
103                 event.SetInt(accountID);
104                 event.SetId(ID_HIDEENTRIES);
105                 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
106                 
107         }
108         
111 wxCheckBoxState XCCalendarListAccountCtrl::GetShowCheckboxState(){
112         
113         return chkShowAll->Get3StateValue();
114         
117 int XCCalendarListAccountCtrl::GetAccountID(){
118         
119         return accountID;
120         
123 void XCCalendarListAccountCtrl::SetAccountID(int accountID){
124         
125         this->accountID = accountID;
126         
129 void XCCalendarListAccountCtrl::SetAccountPreferencesID(int accountID){
130         
131         this->accountPreferencesID = accountPreferencesID;
132         
135 vector<int> XCCalendarListAccountCtrl::GetHiddenCalendarList(){
136         
137         vector<int> calendarList;
138         
139         for (vector<XCCalendarListCalendarCtrl*>::iterator calendarControlListIter = calendarControlList.begin(); 
140                 calendarControlListIter != calendarControlList.end(); calendarControlListIter++){
141                 
142                 if ((*calendarControlListIter)->GetShowCheckboxState() == wxCHK_UNCHECKED){
143                         
144                         calendarList.push_back((*calendarControlListIter)->GetCalendarID());
145                         
146                 }
147                         
148         }
149         
150         return calendarList;
151         
154 void XCCalendarListAccountCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
155         
156         if (newValue == wxCHK_CHECKED){
157                 showAccounts = true;
158         } else {
159                 showAccounts = false;           
160         }
161         
162         chkShowAll->SetValue(newValue);
163         
Xestia Software Development
Yn Maystri
© 2006 - 2019 Xestia Software Development
Software

Xestia Address Book
Xestia Calendar
Development

Xestia Gelforn
Everything else

About
News
Privacy Policy