OpenASIP  2.0
OSEdAboutDialog.cc
Go to the documentation of this file.
1 /*
2  Copyright (c) 2002-2009 Tampere University.
3 
4  This file is part of TTA-Based Codesign Environment (TCE).
5 
6  Permission is hereby granted, free of charge, to any person obtaining a
7  copy of this software and associated documentation files (the "Software"),
8  to deal in the Software without restriction, including without limitation
9  the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  and/or sell copies of the Software, and to permit persons to whom the
11  Software is furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in
14  all copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  DEALINGS IN THE SOFTWARE.
23  */
24 /**
25  * @file OSEdAboutDialog.cc
26  *
27  * Definition of OSEdAboutDialog class.
28  *
29  * @author Jussi Nyk�nen 2004 (nykanen-no.spam-cs.tut.fi)
30  * @note rating: red
31  */
32 
33 #include <boost/format.hpp>
34 #include <string>
35 #include <wx/statline.h>
36 
37 #include "OSEdAboutDialog.hh"
38 #include "WidgetTools.hh"
39 #include "Environment.hh"
40 #include "FileSystem.hh"
41 #include "WxConversion.hh"
42 #include "OSEdTextGenerator.hh"
43 #include "GUITextGenerator.hh"
44 #include "OSEdConstants.hh"
45 #include "DialogPosition.hh"
46 #include "tce_config.h"
47 
48 using boost::format;
49 using std::string;
50 
51 /**
52  * Constructor.
53  *
54  * @param parent Parent window.
55  */
57  wxDialog(parent, -1, _T(""),
58  DialogPosition::getPosition(DialogPosition::DIALOG_ABOUT),
59  wxDefaultSize) {
60 
61  createContents(this, true, true);
62  setTexts();
63 }
64 
65 /**
66  * Destructor.
67  */
69  int x, y;
70  GetPosition(&x, &y);
71  wxPoint point(x, y);
73 }
74 
75 /**
76  * Sets the texts for the dialog.
77  */
78 void
80 
83 
84  // title
85  format fmt = osedTexts.text(OSEdTextGenerator::TXT_ABOUT_DIALOG_TITLE);
86  SetTitle(WxConversion::toWxString(fmt.str()));
87 
88  // static texts
91 
92  // buttons
93  WidgetTools::setLabel(&guiTexts, FindWindow(wxID_OK),
95 }
96 
97 /**
98  * Creates the contents of the dialog.
99  *
100  * @param parent Parent window.
101  * @param call_fit If true fits the contents inside the dialog.
102  * @param set_sizer If true, sets the sizer as dialog contents.
103  * @return The created sizer.
104  */
105 wxSizer*
107  wxWindow *parent, bool call_fit, bool set_sizer) {
108 
109  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
110  wxBitmap logo;
111 
112  string dir = Environment::bitmapsDirPath(
114 
115  string fileName = dir + FileSystem::DIRECTORY_SEPARATOR +
117 
118  logo.LoadFile(WxConversion::toWxString(fileName), wxBITMAP_TYPE_PNG);
119  wxStaticBitmap* dialogLogo = new wxStaticBitmap(parent, -1, logo);
120 
121  item0->Add(dialogLogo, 0, wxALIGN_CENTER|wxALL, 5 );
122  wxBoxSizer *item3 = new wxBoxSizer( wxVERTICAL );
123  wxStaticText *item4 =
124  new wxStaticText(parent, ID_ABOUT_TEXT, wxT("Operation Set Editor"),
125  wxDefaultPosition, wxDefaultSize, 0);
126  item3->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
127  wxStaticText *item5 =
128  new wxStaticText(parent, -1, _T("OpenASIP ") + WxConversion::toWxString(VERSION),
129  wxDefaultPosition, wxDefaultSize, 0);
130  item3->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
131 
132  wxStaticText *item6 =
133  new wxStaticText(parent, -1, OSEdConstants::OSED_COPYRIGHT,
134  wxDefaultPosition, wxDefaultSize, 0);
135  item3->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
136 
137  item0->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
138  wxStaticLine *item7 =
139  new wxStaticLine(parent, -1, wxDefaultPosition,
140  wxSize(20,-1), wxLI_HORIZONTAL);
141  item0->Add( item7, 0, wxGROW|wxALL, 5 );
142  wxButton *item8 =
143  new wxButton(parent, wxID_OK, wxT("&OK"), wxDefaultPosition,
144  wxDefaultSize, 0);
145  item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
146  if (set_sizer) {
147  parent->SetAutoLayout( TRUE );
148  parent->SetSizer( item0 );
149  if (call_fit)
150  {
151  item0->Fit( parent );
152  item0->SetSizeHints( parent );
153  }
154  }
155 
156  return item0;
157 }
OSEdAboutDialog::ID_ABOUT_TEXT
@ ID_ABOUT_TEXT
Definition: OSEdAboutDialog.hh:59
OSEdConstants::APPLICATION_NAME
static const wxString APPLICATION_NAME
The name of the application.
Definition: OSEdConstants.hh:110
FileSystem.hh
WxConversion::toWxString
static wxString toWxString(const std::string &source)
OSEdTextGenerator::TXT_ABOUT
@ TXT_ABOUT
About text.
Definition: OSEdTextGenerator.hh:161
OSEdAboutDialog::~OSEdAboutDialog
virtual ~OSEdAboutDialog()
Definition: OSEdAboutDialog.cc:68
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
OSEdAboutDialog::OSEdAboutDialog
OSEdAboutDialog(wxWindow *parent)
Definition: OSEdAboutDialog.cc:56
GUITextGenerator::instance
static GUITextGenerator * instance()
Definition: GUITextGenerator.cc:67
GUITextGenerator
Definition: GUITextGenerator.hh:46
WidgetTools.hh
FindWindow
Definition: FindWindow.hh:49
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
DialogPosition::setPosition
static void setPosition(Dialogs dialog, wxPoint point)
Definition: DialogPosition.cc:63
OSEdConstants.hh
Environment::bitmapsDirPath
static std::string bitmapsDirPath(const std::string &prog)
Definition: Environment.cc:201
OSEdConstants::OSED_COPYRIGHT
static const wxString OSED_COPYRIGHT
Copyright string.
Definition: OSEdConstants.hh:119
OSEdTextGenerator::TXT_ABOUT_DIALOG_TITLE
@ TXT_ABOUT_DIALOG_TITLE
About dialog title.
Definition: OSEdTextGenerator.hh:118
DialogPosition
Definition: DialogPosition.hh:42
Environment.hh
DialogPosition::DIALOG_ABOUT
@ DIALOG_ABOUT
About dialog.
Definition: DialogPosition.hh:57
OSEdAboutDialog::setTexts
void setTexts()
Definition: OSEdAboutDialog.cc:79
TRUE
const string TRUE
Value used for true in attribute and element values.
Definition: GUIOptionsSerializer.cc:65
FileSystem::DIRECTORY_SEPARATOR
static const std::string DIRECTORY_SEPARATOR
Definition: FileSystem.hh:189
GUITextGenerator.hh
OSEdTextGenerator::instance
static OSEdTextGenerator & instance()
Definition: OSEdTextGenerator.cc:214
OSEdAboutDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: OSEdAboutDialog.cc:106
OSEdTextGenerator
Definition: OSEdTextGenerator.hh:42
WxConversion.hh
OSEdConstants::LOGO_NAME
static const std::string LOGO_NAME
Name of the logo.
Definition: OSEdConstants.hh:116
WxConversion::toString
static std::string toString(const wxString &source)
OSEdTextGenerator.hh
OSEdAboutDialog.hh
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59
DialogPosition.hh