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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [finddlg.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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