Advanced Strategic Command
locatefile.cpp
Go to the documentation of this file.
1 /*
2  This file is part of Advanced Strategic Command; http://www.asc-hq.de
3  Copyright (C) 1994-2010 Martin Bickel and Marc Schellenberger
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; see the file COPYING. If not, write to the
17  Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18  Boston, MA 02111-1307 USA
19 */
20 
21 #include "../paradialog.h"
22 #include "../widgets/textrenderer.h"
23 
25  private:
26  TextRenderer* location;
27  PG_LineEdit* le;
28  bool find( )
29  {
30  location->SetText("searching ...");
31  ASCString filename = le->GetText();
32  tfindfile ff( filename );
34  if ( ff.getnextname( fi )) {
35  location->SetText( fi.location );
36  } else {
37  location->SetText( "-not found-" );
38  }
39  return true;
40  }
41  public:
42  FileFindDialog () : ASC_PG_Dialog( NULL, PG_Rect( -1, -1, 500, 200 ), "Locate File")
43  {
44  le = new PG_LineEdit( this, PG_Rect( 20, 40, 460, 25 ));
45  le->sigEditEnd.connect( sigc::mem_fun( *this, &FileFindDialog::find ));
46 
47  location = new TextRenderer ( this, PG_Rect( 20, 90, 460, 90 ));
48  }
49 
50  int RunModal() {
51  le->EditBegin();
52  return ASC_PG_Dialog::RunModal();
53  }
54 };
55 
56 
57 void locateFile()
58 {
59  FileFindDialog fd;
60  fd.Show();
61  fd.RunModal();
62 }
ASCString getnextname(int *loc=NULL, bool *inContainer=NULL, ASCString *location=NULL)
Returns the next entry of the internal file list.
Definition: basestrm.cpp:2211
The ASCString class provides an abstract way to manipulate strings.
Definition: ascstring.h:14
void SetText(const std::string &text)
Adapter class for using Paragui Dialogs in ASC. This class transfers the event control from ASC to Pa...
Definition: paradialog.h:127
Searching for files.
Definition: basestrm.h:484
ASCString location
Definition: basestrm.h:492
void locateFile()
Definition: locatefile.cpp:57