Home | News | Projects | Releases
Bugs | RFE | Repositories | Help
Initial import of code already done for Xestia Address Book
[xestiaab/.git] / source / widgets / XABAccountView.cpp
1 #include "XABAccountView.h"
3 BEGIN_EVENT_TABLE(XABAccountView, wxTreeCtrl)
4         //EVT_LEFT_UP(XABAccountView::OnMouseClick)
5         EVT_LEFT_DCLICK(XABAccountView::OnMouseClick)
6         EVT_TREE_ITEM_EXPANDED(-1, XABAccountView::ExpColProc)
7         EVT_TREE_ITEM_COLLAPSED(-1, XABAccountView::ExpColProc)
8 END_EVENT_TABLE()
10 void XABAccountView::Init(){
12         idx = -1;
14 }
16 bool XABAccountView::Create(wxWindow* parent){
18         return wxTreeCtrl::Create(parent, 1, wxPoint(0,0), wxSize(100,100), wxTR_DEFAULT_STYLE|wxTR_HIDE_ROOT);
20 }
22 wxWindow* XABAccountView::GetControl(){
24         return this;
26 }
28 void XABAccountView::SetStringValue(const wxString& s){
30         tid = wxTreeCtrl::GetSelection();
32 }
34 wxString XABAccountView::GetStringValue() const{
36         if (tid.IsOk()){
37                 wxString wxStrName = wxTreeCtrl::GetItemText(tid);
38                 return wxStrName;
39         }
40         return wxEmptyString;
42 }
44 void XABAccountView::OnMouseClick(wxMouseEvent& WXUNUSED(event)){
46         // Update control.
48         // Check if item expanding or collapsed
49         // has occured before dismissing.
51         if (ixp == FALSE){
53                 // Item expansion/collapsing didn't occur.
55                 tid = wxTreeCtrl::GetSelection();
56                 Dismiss();
58         }
60         ixp = FALSE;
61         
62 }
64 void XABAccountView::SetAccount(){
66         tid = wxTreeCtrl::GetSelection();
67         Dismiss();
69 }
71 // Needed by SetStringValue
72 wxTreeItemId XABAccountView::FindItemByText(wxTreeItemId parent, const wxString& text)
73 {
74         wxTreeItemIdValue cookie;
75         wxTreeItemId child = GetFirstChild(parent, cookie);
76         while (child.IsOk())
77         {
78                 if (GetItemText(child) == text)
79                 {
80                         return child;
81                 }
82                 if (ItemHasChildren(child))
83                 {
84                         wxTreeItemId found = FindItemByText(child, text);
85                         if (found.IsOk())
86                                 return found;
87                 }
88                 child = GetNextChild(parent, cookie);
89         }
90         return wxTreeItemId();
91 }
93 void XABAccountView::ExpColProc(wxTreeEvent& event){
95         ixp = TRUE;
97 }
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