1 // XABAccountView.cpp - XABAccountView widget
3 // (c) 2012-2015 Xestia Software Development.
5 // This file is part of Xestia Address Book.
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.
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.
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)
28 void XABAccountView::Init(){
34 bool XABAccountView::Create(wxWindow* parent){
36 return wxTreeCtrl::Create(parent, 1, wxPoint(0,0), wxSize(100,100), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
40 wxWindow* XABAccountView::GetControl(){
46 void XABAccountView::SetStringValue(const wxString& s){
48 tid = wxTreeCtrl::GetSelection();
52 wxString XABAccountView::GetStringValue() const{
55 wxString wxStrName = wxTreeCtrl::GetItemText(tid);
62 void XABAccountView::OnMouseClick(wxMouseEvent& WXUNUSED(event)){
66 // Check if item expanding or collapsed
67 // has occured before dismissing.
71 // Item expansion/collapsing didn't occur.
73 tid = wxTreeCtrl::GetSelection();
82 void XABAccountView::SetAccount(){
84 tid = wxTreeCtrl::GetSelection();
89 // Needed by SetStringValue
90 wxTreeItemId XABAccountView::FindItemByText(wxTreeItemId parent, const wxString& text)
92 wxTreeItemIdValue cookie;
93 wxTreeItemId child = GetFirstChild(parent, cookie);
96 if (GetItemText(child) == text)
100 if (ItemHasChildren(child))
102 wxTreeItemId found = FindItemByText(child, text);
106 child = GetNextChild(parent, cookie);
108 return wxTreeItemId();
111 void XABAccountView::ExpColProc(wxTreeEvent& event){