1 //
2 // C++ Implementation: BoxFind
3 //
4 // Description: Implements the Find file box.
5 //
6 //
7 // Author: Max Magalhães Velasques <maxvelasques@gmail.com>, (C) 2006
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12
13 #include "wxDFast.h"
14
BEGIN_EVENT_TABLE(mBoxFind,wxFindReplaceDialog)15 BEGIN_EVENT_TABLE(mBoxFind, wxFindReplaceDialog)
16 EVT_FIND(-1, mBoxFind::OnFind)
17 EVT_FIND_NEXT(-1, mBoxFind::OnFind)
18 EVT_FIND_CLOSE(-1, mBoxFind::OnClose)
19 END_EVENT_TABLE()
20
21 void mBoxFind::OnFind(wxFindDialogEvent& event)
22 {
23 int i = -1, index = -1, flags, countitems;
24 int column;
25 bool found = FALSE;
26 wxListCtrl *list;
27 mInProgressList *list01 = XRCCTRL(*(wxGetApp().mainframe), "inprogresslist",mInProgressList );
28 mFinishedList *list02 = XRCCTRL(*(wxGetApp().mainframe), "finishedlist",mFinishedList);
29 wxNotebook *notebook = XRCCTRL(*(wxGetApp().mainframe), "notebook01",wxNotebook );
30 if (notebook->GetSelection() == 0) //DOWNLOADS IN PROGRESS
31
32 {
33 index = list01->GetCurrentLastSelection();
34 column = INPROGRESS_NAME;
35 list = (wxListCtrl*)list01;
36 }
37 else if (notebook->GetSelection() == 1) //FINISHED DOWNLOADS
38 {
39 index = list02->GetCurrentLastSelection();
40 column = FINISHED_NAME;
41 list = (wxListCtrl*)list02;
42 }
43 else
44 {
45 wxMessageBox(_("Unable to search in this page.\nChange to another page and try again"),_("Error..."),wxOK | wxICON_ERROR, this);
46 return ;
47 }
48
49 flags = event.GetFlags();
50 if (flags & wxFR_DOWN)
51 {
52 i = index+1;
53 countitems = list->GetItemCount();
54 }
55 else
56 {
57 if (index > -1)
58 i = index-1;
59 countitems = -1;
60 }
61 while (i != countitems)
62 {
63 wxListItem item;
64 item.SetId(i);
65 item.SetMask(wxLIST_MASK_STATE|wxLIST_MASK_TEXT);
66
67 item.SetColumn(column);
68
69 list->GetItem(item);
70 if (flags & wxFR_WHOLEWORD)
71 {
72 if (flags & wxFR_MATCHCASE)
73 {
74 if (item.GetText() == event.GetFindString())
75 found = TRUE;
76 }
77 else
78 {
79 if (item.GetText().Lower() == event.GetFindString().Lower())
80 found = TRUE;
81 }
82 }
83 else
84 {
85 if (flags & wxFR_MATCHCASE)
86 {
87 if (item.GetText().Find(event.GetFindString()) >= 0)
88 found = TRUE;
89 }
90 else
91 {
92 if (item.GetText().Lower().Find(event.GetFindString().Lower()) >= 0)
93 found = TRUE;
94 }
95 }
96 if (found)
97 {
98 list->SetItemState(i,wxLIST_STATE_SELECTED,wxLIST_STATE_SELECTED);
99 break;
100 }
101 if (flags & wxFR_DOWN)
102 i++;
103 else
104 i--;
105 }
106 if (!found)
107 wxMessageBox(_("File not found."), _("Information..."),wxOK | wxICON_INFORMATION, this);
108
109 return ;
110 }
111
OnClose(wxFindDialogEvent & event)112 void mBoxFind::OnClose(wxFindDialogEvent& event)
113 {
114 this->Destroy();
115 return ;
116 }
117