Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Added copyright and license header for the C++ source and header files in the widgets...
[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_UP(XABAccountView::OnMouseClick)
23         EVT_LEFT_DCLICK(XABAccountView::OnMouseClick)
24         EVT_TREE_ITEM_EXPANDED(-1, XABAccountView::ExpColProc)
25         EVT_TREE_ITEM_COLLAPSED(-1, XABAccountView::ExpColProc)
26 END_EVENT_TABLE()
28 void XABAccountView::Init(){
30         idx = -1;
32 }
34 bool XABAccountView::Create(wxWindow* parent){
36         return wxTreeCtrl::Create(parent, 1, wxPoint(0,0), wxSize(100,100), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
38 }
40 wxWindow* XABAccountView::GetControl(){
42         return this;
44 }
46 void XABAccountView::SetStringValue(const wxString& s){
48         tid = wxTreeCtrl::GetSelection();
50 }
52 wxString XABAccountView::GetStringValue() const{
54         if (tid.IsOk()){
55                 wxString wxStrName = wxTreeCtrl::GetItemText(tid);
56                 return wxStrName;
57         }
58         return wxEmptyString;
60 }
62 void XABAccountView::OnMouseClick(wxMouseEvent& WXUNUSED(event)){
64         // Update control.
66         // Check if item expanding or collapsed
67         // has occured before dismissing.
69         if (ixp == FALSE){
71                 // Item expansion/collapsing didn't occur.
73                 tid = wxTreeCtrl::GetSelection();
74                 Dismiss();
76         }
78         ixp = FALSE;
79         
80 }
82 void XABAccountView::SetAccount(){
84         tid = wxTreeCtrl::GetSelection();
85         Dismiss();
87 }
89 // Needed by SetStringValue
90 wxTreeItemId XABAccountView::FindItemByText(wxTreeItemId parent, const wxString& text)
91 {
92         wxTreeItemIdValue cookie;
93         wxTreeItemId child = GetFirstChild(parent, cookie);
94         while (child.IsOk())
95         {
96                 if (GetItemText(child) == text)
97                 {
98                         return child;
99                 }
100                 if (ItemHasChildren(child))
101                 {
102                         wxTreeItemId found = FindItemByText(child, text);
103                         if (found.IsOk())
104                                 return found;
105                 }
106                 child = GetNextChild(parent, cookie);
107         }
108         return wxTreeItemId();
111 void XABAccountView::ExpColProc(wxTreeEvent& event){
113         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