]>
git.saurik.com Git - wxWidgets.git/blob - user/wxConvert/wxConvert.cpp
4 * Author: Robert Roebling
6 * Copyright: (C) 1997, GNU (Robert Roebling)
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
22 * You may not use this program without clapping twice at every
28 #pragma implementation "wxConvert.h"
31 #include "wxConvert.h"
32 #include "wx/textfile.h"
34 //-----------------------------------------------------------------------------
36 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 //-----------------------------------------------------------------------------
49 IMPLEMENT_DYNAMIC_CLASS( MyFrame
, wxFrame
)
51 BEGIN_EVENT_TABLE(MyFrame
,wxFrame
)
52 EVT_BUTTON (ID_QUIT
, MyFrame::OnCommand
)
53 EVT_BUTTON (ID_2UNIX
, MyFrame::OnCommand
)
54 EVT_BUTTON (ID_2DOS
, MyFrame::OnCommand
)
55 EVT_BUTTON (ID_2MAC
, MyFrame::OnCommand
)
58 MyFrame::MyFrame(void) :
59 wxFrame( (wxFrame
*) NULL
, -1, (char *) "wxConvert", wxPoint(20,20), wxSize(400,160) )
63 SetStatusText( "wxConvert v0.1 by Robert Roebling." );
66 wxGetWorkingDirectory( buf
, 500 );
67 wxString
s( "Dir: " );
70 m_text
= new wxStaticText( this, -1, s
, wxPoint(10,50), wxSize(380,-1) );
72 (void*)new wxButton( this, ID_QUIT
, "Quit", wxPoint(10,100), wxSize(60,25) );
74 (void*)new wxButton( this, ID_2UNIX
, "To Unix", wxPoint(180,100), wxSize(60,25) );
76 (void*)new wxButton( this, ID_2DOS
, "To Dos", wxPoint(250,100), wxSize(60,25) );
78 (void*)new wxButton( this, ID_2MAC
, "To Mac", wxPoint(320,100), wxSize(60,25) );
81 void MyFrame::OnCommand( wxCommandEvent
&event
)
83 switch (event
.GetId())
92 wxGetWorkingDirectory( buf
, 500 );
94 Recurse( event
.GetId(), s
);
99 void MyFrame::Convert( int id
, const wxString
&fname
)
101 wxTextFile
text(fname
);
108 text
.Write( wxTextFile::Type_Unix
);
111 text
.Write( wxTextFile::Type_Dos
);
114 text
.Write( wxTextFile::Type_Mac
);
120 void MyFrame::Recurse( int id
, const wxString
&curdir
)
123 wxString search
,path
;
128 path
= wxFindFirstFile( search
, wxDIR
);
129 while (!path
.IsNull())
131 paths
.Add( path
); // ref counting in action !
132 path
= wxFindNextFile();
139 path
= wxFindFirstFile( search
, wxFILE
);
140 while (!path
.IsNull())
142 m_text
->SetLabel( path
);
145 path
= wxFindNextFile();
148 for (int i
= 0; i
< paths
.Count(); i
++)
151 Recurse( id
, search
);
155 //-----------------------------------------------------------------------------
157 //-----------------------------------------------------------------------------
164 bool MyApp::OnInit(void)
166 wxFrame
*frame
= new MyFrame();