OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [configtool/] [standalone/] [wxwin/] [finddlg.cpp] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// appsettings.cpp :
23
//
24
//===========================================================================
25
//#####DESCRIPTIONBEGIN####
26
//
27
// Author(s):   julians
28
// Contact(s):  julians
29
// Date:        2000/09/11
30
// Version:     $Id: finddlg.cpp,v 1.5 2002/02/28 18:30:35 julians Exp $
31
// Purpose:
32
// Description: Implementation file for ecFindDialog
33
// Requires:
34
// Provides:
35
// See also:
36
// Known bugs:
37
// Usage:
38
//
39
//####DESCRIPTIONEND####
40
//
41
//===========================================================================
42
 
43
#ifdef __GNUG__
44
    #pragma implementation "finddlg.cpp"
45
#endif
46
 
47
#include "ecpch.h"
48
 
49
#ifdef __BORLANDC__
50
    #pragma hdrstop
51
#endif
52
 
53
#include "wx/cshelp.h"
54
#include "wx/valgen.h"
55
 
56
#include "finddlg.h"
57
#include "configtool.h"
58
#include "configtooldoc.h"
59
#include "configtoolview.h"
60
#include "configtree.h"
61
#include "mainwin.h"
62
#include "appsettings.h"
63
 
64
//----------------------------------------------------------------------------
65
// ecFindDialog
66
//----------------------------------------------------------------------------
67
 
68
BEGIN_EVENT_TABLE(ecFindDialog,wxDialog)
69
    EVT_BUTTON(ecID_FIND_DIALOG_NEXT, ecFindDialog::OnFindNext)
70
    EVT_CLOSE(ecFindDialog::OnCloseWindow)
71
    EVT_BUTTON(wxID_CANCEL, ecFindDialog::OnCancel)
72
END_EVENT_TABLE()
73
 
74
ecFindDialog::ecFindDialog( wxWindow *parent, wxWindowID id, const wxString &title,
75
    const wxPoint &position, const wxSize& size, long style ) :
76
    wxDialog( )
77
{
78
    m_directionSelection = 1;
79
 
80
    SetExtraStyle(wxDIALOG_EX_CONTEXTHELP);
81
 
82
    wxDialog::Create( parent, id, title, position, size, style );
83
 
84
    AddControls(this);
85
 
86
    if (wxGetApp().GetSettings().m_findDialogPos.x == -1 && wxGetApp().GetSettings().m_findDialogPos.y == -1)
87
        Centre(wxBOTH);
88
    else
89
        Move(wxGetApp().GetSettings().m_findDialogPos);
90
}
91
 
92
bool ecFindDialog::AddControls(wxWindow* parent)
93
{
94
    //// Start of sizer-based control creation
95
 
96
    wxSizer *item0 = new wxBoxSizer( wxHORIZONTAL );
97
 
98
    wxSizer *item1 = new wxBoxSizer( wxVERTICAL );
99
 
100
    wxSizer *item2 = new wxBoxSizer( wxHORIZONTAL );
101
 
102
    wxStaticText *item3 = new wxStaticText( parent, wxID_STATIC, _(" Fi&nd what:"), wxDefaultPosition, wxDefaultSize, 0 );
103
    item2->Add( item3, 0, wxALIGN_CENTRE|wxLEFT|wxTOP|wxBOTTOM, 5 );
104
 
105
    wxTextCtrl *item4 = new wxTextCtrl( parent, ecID_FIND_DIALOG_WHAT, _(""), wxDefaultPosition, wxSize(200,-1), 0 );
106
    item2->Add( item4, 1, wxALIGN_CENTRE|wxALL, 5 );
107
 
108
    item1->Add( item2, 1, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 0 );
109
 
110
    wxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
111
 
112
    wxSizer *item6 = new wxBoxSizer( wxVERTICAL );
113
 
114
    wxCheckBox *item7 = new wxCheckBox( parent, ecID_FIND_DIALOG_MATCH_WHOLE, _("Match &whole word only"), wxDefaultPosition, wxDefaultSize, 0 );
115
    item6->Add( item7, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
116
 
117
    wxCheckBox *item8 = new wxCheckBox( parent, ecID_FIND_DIALOG_MATCH_CASE, _("Match &case"), wxDefaultPosition, wxDefaultSize, 0 );
118
    item6->Add( item8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
119
 
120
    item5->Add( item6, 0, wxALIGN_CENTRE|wxALL, 5 );
121
 
122
    wxString strs9[] =
123
    {
124
        _("&Up"),
125
        _("&Down")
126
    };
127
    wxRadioBox *item9 = new wxRadioBox( parent, ecID_FIND_DIALOG_DIRECTION, _("Direction"), wxDefaultPosition, wxDefaultSize, 2, strs9, 1, wxRA_SPECIFY_ROWS );
128
    item5->Add( item9, 0, wxALIGN_CENTRE|wxALL, 5 );
129
 
130
    item1->Add( item5, 0, wxALIGN_CENTRE|wxRIGHT, 5 );
131
 
132
    wxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
133
 
134
    wxStaticText *item11 = new wxStaticText( parent, wxID_STATIC, _("&Search in:"), wxDefaultPosition, wxDefaultSize, 0 );
135
    item10->Add( item11, 0, wxALIGN_CENTRE|wxALL, 5 );
136
 
137
    wxString strs12[] =
138
    {
139
        _("Macro names"),
140
        _("Item names"),
141
        _("Short descriptions"),
142
        _("Current Values"),
143
        _("Default Values")
144
    };
145
    wxChoice *item12 = new wxChoice( parent, ecID_FIND_DIALOG_SEARCH_IN, wxDefaultPosition, wxSize(130,-1), 5, strs12, 0 );
146
    item10->Add( item12, 0, wxALIGN_CENTRE|wxALL, 5 );
147
 
148
    item1->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
149
 
150
    item0->Add( item1, 0, wxALIGN_CENTRE|wxTOP|wxBOTTOM, 5 );
151
 
152
    wxSizer *item13 = new wxBoxSizer( wxVERTICAL );
153
 
154
    wxButton *item14 = new wxButton( parent, ecID_FIND_DIALOG_NEXT, _("&Find Next"), wxDefaultPosition, wxDefaultSize, 0 );
155
    item14->SetDefault();
156
    item13->Add( item14, 0, wxALIGN_CENTRE|wxALL, 5 );
157
 
158
    wxButton *item15 = new wxButton( parent, wxID_CANCEL, _("&Close"), wxDefaultPosition, wxDefaultSize, 0 );
159
    item13->Add( item15, 0, wxALIGN_CENTRE|wxALL, 5 );
160
 
161
#ifdef __WXGTK__
162
    wxButton *contextButton = new wxContextHelpButton( parent );
163
    item13->Add( contextButton, 0, wxALIGN_CENTRE|wxALL, 5 );
164
#endif
165
 
166
    item0->Add( item13, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxTOP|wxBOTTOM, 5 );
167
 
168
    FindWindow(ecID_FIND_DIALOG_WHAT)->SetFocus();
169
 
170
    // Add validators
171
    FindWindow(ecID_FIND_DIALOG_WHAT)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_findText));
172
    FindWindow(ecID_FIND_DIALOG_MATCH_WHOLE)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_findMatchWholeWord));
173
    FindWindow(ecID_FIND_DIALOG_MATCH_CASE)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_findMatchCase));
174
    FindWindow(ecID_FIND_DIALOG_SEARCH_IN)->SetValidator(wxGenericValidator(& wxGetApp().GetSettings().m_findSearchWhat));
175
    FindWindow(ecID_FIND_DIALOG_DIRECTION)->SetValidator(wxGenericValidator(& m_directionSelection));
176
 
177
    // Add help text
178
    FindWindow(ecID_FIND_DIALOG_WHAT)->SetHelpText(_("Enter your search text here."));
179
    FindWindow(ecID_FIND_DIALOG_MATCH_WHOLE)->SetHelpText(_("Check to match whole words, clear to match parts of words."));
180
    FindWindow(ecID_FIND_DIALOG_MATCH_CASE)->SetHelpText(_("Check if you want upper and lower case to be significant, clear otherwise."));
181
    FindWindow(ecID_FIND_DIALOG_SEARCH_IN)->SetHelpText(_("Choose the category for your search."));
182
    FindWindow(ecID_FIND_DIALOG_DIRECTION)->SetHelpText(_("Choose the direction of your search."));
183
    FindWindow(ecID_FIND_DIALOG_NEXT)->SetHelpText(_("Click Find Next to search for the next match."));
184
    FindWindow(wxID_CANCEL)->SetHelpText(_("Click Close to close the dialog."));
185
 
186
    parent->SetAutoLayout( TRUE );
187
    parent->SetSizer( item0 );
188
    parent->Layout();
189
    item0->Fit( parent );
190
    item0->SetSizeHints( parent );
191
    return TRUE;
192
}
193
 
194
bool ecFindDialog::TransferDataToWindow()
195
{
196
    // Convert to radiobox selection index from bool
197
    m_directionSelection = wxGetApp().GetSettings().m_findDirection ? 1 : 0 ;
198
 
199
    wxWindow::TransferDataToWindow();
200
 
201
    return TRUE;
202
}
203
 
204
bool ecFindDialog::TransferDataFromWindow()
205
{
206
    wxWindow::TransferDataFromWindow();
207
 
208
    // Convert from radiobox selection index to bool
209
    wxGetApp().GetSettings().m_findDirection = (m_directionSelection == 1);
210
 
211
    return TRUE;
212
}
213
 
214
void ecFindDialog::OnFindNext(wxCommandEvent& event)
215
{
216
    if (!TransferDataFromWindow())
217
        return;
218
    if (!wxGetApp().GetConfigToolDoc())
219
        return;
220
 
221
    ecConfigToolView *pControlView = (ecConfigToolView*) wxGetApp().GetConfigToolDoc()->GetFirstView();
222
 
223
    ecConfigItem* item = pControlView->DoFind(wxGetApp().GetSettings().m_findText, this);
224
 
225
    if (item)
226
    {
227
        // Is the find window on top of the item?
228
        wxRect rect1, rect2;
229
 
230
        if (wxGetApp().GetTreeCtrl()->GetBoundingRect(item->GetTreeItem(), rect1))
231
        {
232
            wxPoint topLeft(rect1.x, rect1.y);
233
            wxPoint bottomRight(rect1.GetRight(), rect1.GetBottom());
234
 
235
            topLeft = wxGetApp().GetTreeCtrl()->ClientToScreen(topLeft);
236
            bottomRight = wxGetApp().GetTreeCtrl()->ClientToScreen(bottomRight);
237
 
238
            rect2 = GetRect(); // screen coords
239
 
240
            if (rect2.Inside(topLeft) || rect2.Inside(bottomRight))
241
            {
242
                Move(wxPoint(topLeft.x + rect1.width, rect2.y));
243
            }
244
        }
245
    }
246
}
247
 
248
void ecFindDialog::OnCloseWindow(wxCloseEvent& event)
249
{
250
    wxGetApp().GetSettings().m_findDialogPos = GetPosition();
251
    wxGetApp().GetMainFrame()->m_findDialog = NULL;
252
 
253
    event.Skip();
254
}
255
 
256
void ecFindDialog::OnCancel(wxCommandEvent& event)
257
{
258
    wxGetApp().GetSettings().m_findDialogPos = GetPosition();
259
    wxGetApp().GetMainFrame()->m_findDialog = NULL;
260
 
261
    event.Skip();
262
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.