Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
widgets: Widget controls updated
[xestiacalendar/.git] / source / widgets / XCCalendarListCalendarCtrl.cpp
1 // XCCalendarListCalendarCtrl.cpp - XCCalendarListCalendarCtrl 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 "XCCalendarListCalendarCtrl.h"
21 using namespace std; 
23 XCCalendarListCalendarCtrl::XCCalendarListCalendarCtrl(wxWindow* parent, string calendarName, Colour calendarColour) : 
24         wxPanel(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, ""){
26         // Create the sizer.
27         
28         szrMain = new wxBoxSizer( wxHORIZONTAL );
29         this->SetSizer(szrMain);
30         
31         // Setup the checkbox.
32         
33         chkShowCalendar = new wxCheckBox(this, wxID_ANY, "", wxPoint(0,0), wxDefaultSize, wxCHK_3STATE, wxDefaultValidator, "");
34         
35         // Setup the label.
36         
37         lblCalendarName = new wxStaticText(this, wxID_ANY, wxString(calendarName), wxDefaultPosition, wxDefaultSize, 0, "");
38         
39         // Setup the colour.
40                 
41         pnlColour = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(16,16), 0, "");
42         pnlColour->SetBackgroundColour(wxColour(calendarColour.red, calendarColour.green, calendarColour.blue, calendarColour.alpha));
43                 
44         // Setup the popup menu.
45                 
46         calendarMenu = new XCCalendarMenu();
47         calendarMenu->SetWindowPointer(this);
48         calendarMenu->SetPopupPointer((wxPopupTransientWindow*)this->GetParent());
49                 
50         // Connect them to the sizer.
51         
52         szrMain->Add(15, 0, 0, 0, 5);
53         szrMain->Add(chkShowCalendar, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
54         szrMain->Add(lblCalendarName, 1, wxALL|wxALIGN_CENTER_VERTICAL, 5);
55         szrMain->Add(pnlColour, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5);
56         
57         // Connect the events to the controls.
58         
59         chkShowCalendar->Connect(wxEVT_COMMAND_CHECKBOX_CLICKED, wxMouseEventHandler(XCCalendarListCalendarCtrl::ShowAllCheckboxClick), NULL, this);
60         chkShowCalendar->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
61         lblCalendarName->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
62         pnlColour->Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
63         Connect(wxEVT_RIGHT_UP, wxMouseEventHandler(XCCalendarListCalendarCtrl::PopupMenu), NULL, this);
64         chkShowCalendar->SetValue(wxCHK_CHECKED);
65         
66 }
68 XCCalendarListCalendarCtrl::~XCCalendarListCalendarCtrl(){
69         
70         // Delete the controls.
71         
72 }
74 wxCheckBoxState XCCalendarListCalendarCtrl::GetShowCheckboxState(){
75         
76         return chkShowCalendar->Get3StateValue();
77         
78 }
80 int XCCalendarListCalendarCtrl::GetCalendarID(){
81         
82         return calendarID;
83         
84 }
86 void XCCalendarListCalendarCtrl::SetCalendarID(int calendarID){
87         
88         this->calendarID = calendarID;
89         calendarMenu->SetCalendarID(this->calendarID);
90         
91 }
93 void XCCalendarListCalendarCtrl::SetAccountPreferencesID(int accountPreferencesID){
94         
95         this->accountPreferencesID = accountPreferencesID;
96         calendarMenu->SetAccountPreferencesID(this->accountPreferencesID);
97         
98 }
100 void XCCalendarListCalendarCtrl::ShowAllCheckboxClick( wxMouseEvent &mouseEvent ){
101         
102         if (chkShowCalendar->Get3StateValue() == wxCHK_CHECKED){
103                 
104                 wxCommandEvent event(XCCALENDARCTRL_SHOWCALENDARENTRIES);
105                 event.SetInt(calendarID);
106                 event.SetId(ID_SHOWCALENDARENTRIES);
107                 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
108                 
109         } else {
110                 
111                 wxCommandEvent event(XCCALENDARCTRL_HIDECALENDARENTRIES);
112                 event.SetInt(calendarID);
113                 event.SetId(ID_HIDECALENDARENTRIES);
114                 wxPostEvent(this->GetParent()->GetParent()->GetParent(), event);
115                 
116         }
117         
120 void XCCalendarListCalendarCtrl::SetCheckBoxValue(wxCheckBoxState newValue){
121         
122         if (newValue == wxCHK_CHECKED){
123                 showCalendar = true;
124         } else {
125                 showCalendar = false;           
126         }
127         
128         chkShowCalendar->SetValue(newValue);
129         
132 void XCCalendarListCalendarCtrl::PopupMenu( wxMouseEvent &mouseEvent ){
133         
134         this->GetParent()->GetParent()->GetParent()->GetParent()->PopupMenu(calendarMenu->MenuPointer(), wxDefaultPosition);
135         
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