]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/configtool/standalone/wxwin/aboutdlg.cpp
unified MX27, MX25, MX37 trees
[karo-tx-redboot.git] / tools / src / tools / configtool / standalone / wxwin / aboutdlg.cpp
1 //####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$
34 // Purpose:
35 // Description: Implementation file for ecAboutDialog
36 // Requires:
37 // Provides:
38 // See also:
39 // Known bugs:
40 // Usage:
41 //
42 //####DESCRIPTIONEND####
43 //
44 //===========================================================================
45
46 #ifdef __GNUG__
47     #pragma implementation "aboutdlg.cpp"
48 #endif
49
50 #include "ecpch.h"
51
52 #include "wx/wxhtml.h"
53 #include "wx/datetime.h"
54 #include "wx/file.h"
55 #include "wx/fs_mem.h"
56
57 #ifdef __BORLANDC__
58     #pragma hdrstop
59 #endif
60
61 #include "aboutdlg.h"
62 #include "configtool.h"
63 #include "symbols.h"
64
65 //----------------------------------------------------------------------------
66 // ecAboutDialog
67 //----------------------------------------------------------------------------
68
69 // WDR: event table for ecAboutDialog
70
71 BEGIN_EVENT_TABLE(ecAboutDialog,wxDialog)
72 END_EVENT_TABLE()
73
74 ecAboutDialog::ecAboutDialog( wxWindow *parent, wxWindowID id, const wxString &title,
75     const wxPoint &position, const wxSize& size, long style ) :
76     wxDialog( parent, id, title, position, size, style )
77 {
78     AddControls(this);
79
80     Centre(wxBOTH);
81 }
82
83 bool ecAboutDialog::AddControls(wxWindow* parent)
84 {
85     wxString htmlText;
86
87     if (!wxGetApp().GetMemoryTextResource(wxT("about.htm"), htmlText))
88     {
89         wxSetWorkingDirectory(wxGetApp().GetAppDir());
90         wxString htmlFile(wxGetApp().GetFullAppPath(wxT("about.htm")));
91         
92         if (wxFileExists(htmlFile))
93         {
94             wxFile file;
95             file.Open(htmlFile, wxFile::read);
96             long len = file.Length();
97             char* buf = htmlText.GetWriteBuf(len + 1);
98             file.Read(buf, len);
99             buf[len] = 0;
100             htmlText.UngetWriteBuf();
101         }
102     }
103
104     if (htmlText.IsEmpty())
105     {
106         htmlText.Printf(wxT("<html><head><title>Warning</title></head><body><P>Sorry, could not find resource for About dialog<P></body></html>"));
107     }
108
109     // Customize the HTML
110     wxString verString;
111     verString.Printf("%.2f", ecCONFIGURATION_TOOL_VERSION);
112     htmlText.Replace(wxT("$VERSION$"), verString);
113     htmlText.Replace(wxT("$DATE$"), __DATE__);
114     
115     wxSize htmlSize(420, 390);
116
117     // Note: in later versions of wxWin this will be fixed so wxRAISED_BORDER
118     // does the right thing. Meanwhile, this is a workaround.
119 #ifdef __WXMSW__
120     long borderStyle = wxDOUBLE_BORDER;
121 #else
122     long borderStyle = wxRAISED_BORDER;
123 #endif
124
125     wxHtmlWindow* html = new wxHtmlWindow(this, ecID_ABOUT_DIALOG_HTML_WINDOW, wxDefaultPosition, htmlSize, borderStyle);
126     html -> SetBorders(0);
127     html -> SetPage(htmlText);
128         
129     //// Start of sizer-based control creation
130
131     wxSizer *item0 = new wxBoxSizer( wxVERTICAL );
132
133     wxWindow *item1 = parent->FindWindow( ecID_ABOUT_DIALOG_HTML_WINDOW );
134     wxASSERT( item1 );
135     item0->Add( item1, 0, wxALIGN_CENTRE|wxALL, 5 );
136
137     wxButton *item2 = new wxButton( parent, wxID_CANCEL, "&OK", wxDefaultPosition, wxDefaultSize, 0 );
138     item2->SetDefault();
139
140     item0->Add( item2, 0, wxALIGN_RIGHT|wxALL, 10 );
141
142     parent->SetAutoLayout( TRUE );
143     parent->SetSizer( item0 );
144     parent->Layout();
145     item0->Fit( parent );
146     item0->SetSizeHints( parent );
147     return TRUE;
148 }
149
150 /*
151  * ecSplashScreen.
152  */
153
154
155 ecSplashScreen::ecSplashScreen(const wxBitmap& bitmap, long splashStyle, int milliseconds, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style):
156     wxSplashScreen(bitmap, splashStyle, milliseconds, parent, id, pos, size, style)
157 {
158 }
159
160 ecSplashScreen::~ecSplashScreen()
161 {
162     wxGetApp().m_splashScreen = NULL;
163 }
164
165
166