Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Removed stray carddav.h from frmActivityMgr.h
[xestiaab/.git] / source / widgets / XABAccountView.cpp
1 // XABAccountView.cpp - XABAccountView widget
2 //
3 // (c) 2012-2015 Xestia Software Development.
4 //
5 // This file is part of Xestia Address Book.
6 //
7 // Xestia Address Book 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 Address Book 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 Address Book. If not, see <http://www.gnu.org/licenses/>
19 #include "XABAccountView.h"
21 BEGIN_EVENT_TABLE(XABAccountView, wxTreeCtrl)
22 EVT_LEFT_DCLICK(XABAccountView::OnMouseClick)
23 EVT_TREE_ITEM_EXPANDED(-1, XABAccountView::ExpColProc)
24 EVT_TREE_ITEM_COLLAPSED(-1, XABAccountView::ExpColProc)
25 END_EVENT_TABLE()
27 void XABAccountView::Init(){
29         // Initialise the XABAccountView object.
30         
31         idx = -1;
33 }
35 bool XABAccountView::Create(wxWindow* parent){
37         // Create the XABAccountView control.
38         
39         return wxTreeCtrl::Create(parent, 1, wxPoint(0,0), wxSize(100,100), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
41 }
43 wxWindow* XABAccountView::GetControl(){
45         // Get the control pointer.
46         
47         return this;
49 }
51 void XABAccountView::SetStringValue(const wxString& s){
53         // Set the string value for the XABAccountView control.
54         
55         tid = wxTreeCtrl::GetSelection();
57 }
59 wxString XABAccountView::GetStringValue() const{
61         // Get the string value for the XABAccountView control.
62         
63         if (tid.IsOk()){
64                 wxString wxStrName = wxTreeCtrl::GetItemText(tid);
65                 return wxStrName;
66         }
67         return wxEmptyString;
69 }
71 void XABAccountView::OnMouseClick(wxMouseEvent& WXUNUSED(event)){
73         // Update control.
75         // Check if item expanding or collapsed
76         // has occured before dismissing.
78         if (ixp == FALSE){
80                 // Item expansion/collapsing didn't occur.
82                 tid = wxTreeCtrl::GetSelection();
83                 Dismiss();
85         }
87         ixp = FALSE;
88         
89 }
91 void XABAccountView::SetAccount(){
93         // Set the account for the XABAccountView control.
94         
95         tid = wxTreeCtrl::GetSelection();
96         Dismiss();
98 }
100 wxTreeItemId XABAccountView::FindItemByText(wxTreeItemId parent, const wxString& text)
102         
103         // Find an item based on the supplied wxString value.
104         // Return a wxTreeItemId object if found.
105         
106         wxTreeItemIdValue cookie;
107         wxTreeItemId child = GetFirstChild(parent, cookie);
108         while (child.IsOk())
109         {
110                 if (GetItemText(child) == text)
111                 {
112                         return child;
113                 }
114                 if (ItemHasChildren(child))
115                 {
116                         wxTreeItemId found = FindItemByText(child, text);
117                         if (found.IsOk())
118                                 return found;
119                 }
120                 child = GetNextChild(parent, cookie);
121         }
122         return wxTreeItemId();
125 void XABAccountView::ExpColProc(wxTreeEvent& event){
127         // Function when pressing the down button on the
128         // XABAccountView control.
129         
130         ixp = TRUE;
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