OpenASIP  2.0
AboutDialog.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 AboutDialog.cc
26  *
27  * Definition of AboutDialog class.
28  *
29  * @author Veli-Pekka Jääskeläinen (vjaaskel-no.spam-cs.tut.fi)
30  */
31 
32 #include <string>
33 #include <boost/format.hpp>
34 
35 #include "AboutDialog.hh"
36 #include "ProDeConstants.hh"
37 #include "WxConversion.hh"
38 #include "ProDe.hh"
39 #include "GUITextGenerator.hh"
40 #include "ProDeTextGenerator.hh"
41 #include "WidgetTools.hh"
42 #include "tce_config.h"
43 
44 using boost::format;
45 using std::string;
46 
47 /**
48  * The Constructor.
49  *
50  * @param parent Parent window of the dialog.
51  */
52 AboutDialog::AboutDialog(wxWindow* parent):
53  wxDialog(parent, -1, _T(""), wxDefaultPosition) {
54 
55  createContents(this, true, true);
56 
57  // set widget texts
58  setTexts();
59 }
60 
61 /**
62  * The Destructor.
63  */
65 }
66 
67 
68 /**
69  * Sets texts for widgets.
70  */
71 void
75 
76  // Dialog title
77  format fmt = prodeTexts->text(ProDeTextGenerator::TXT_ABOUT_DIALOG_TITLE);
78  string title = fmt.str();
80  SetTitle(WxConversion::toWxString(title));
81 
82  // buttons
83  WidgetTools::setLabel(generator, FindWindow(wxID_OK),
85 }
86 
87 
88 /**
89  * Creates contents of the dialog window. Initially generated with
90  * wxDesigner, the code will be cleaned up later.
91  *
92  * @param parent Parent dialog of the contents.
93  * @param call_fit If true, fits sizer in dialog window.
94  * @param set_sizer If true, sets sizer as dialog's sizer.
95  * @return Top level sizer of the contents.
96  */
97 wxSizer*
99  wxWindow *parent, bool call_fit, bool set_sizer) {
100 
101  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
102  wxBitmap logo;
103 
104  wxString filename = WxConversion::toWxString(
106 
107  logo.LoadFile(filename, wxBITMAP_TYPE_PNG);
108  wxStaticBitmap* dialogLogo = new wxStaticBitmap(parent, -1, logo);
109 
110  item0->Add(dialogLogo, 0, wxALIGN_CENTER|wxALL, 5 );
111  wxBoxSizer *item3 = new wxBoxSizer( wxVERTICAL );
112  wxStaticText *item4 =
113  new wxStaticText(parent, -1, ProDeConstants::EDITOR_NAME,
114  wxDefaultPosition, wxDefaultSize, 0);
115  item3->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
116  wxStaticText *item5 =
117  new wxStaticText(parent, -1, _T("OpenASIP ") +
118  WxConversion::toWxString(VERSION),
119  wxDefaultPosition, wxDefaultSize, 0);
120  item3->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
121  wxStaticText *item6 =
122  new wxStaticText(parent, -1,
124  wxDefaultPosition, wxDefaultSize, 0);
125  item3->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
126  item0->Add( item3, 0, wxALIGN_CENTER|wxALL, 5 );
127  wxStaticLine *item7 =
128  new wxStaticLine(parent, -1, wxDefaultPosition,
129  wxSize(20,-1), wxLI_HORIZONTAL);
130  item0->Add( item7, 0, wxGROW|wxALL, 5 );
131  wxButton *item8 =
132  new wxButton(parent, wxID_OK, wxT("&OK"), wxDefaultPosition,
133  wxDefaultSize, 0);
134  item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
135  if (set_sizer) {
136  parent->SetAutoLayout( TRUE );
137  parent->SetSizer( item0 );
138  if (call_fit)
139  {
140  item0->Fit( parent );
141  item0->SetSizeHints( parent );
142  }
143  }
144 
145  return item0;
146 }
ProDe.hh
WxConversion::toWxString
static wxString toWxString(const std::string &source)
AboutDialog::createContents
wxSizer * createContents(wxWindow *parent, bool call_fit, bool set_sizer)
Definition: AboutDialog.cc:98
WidgetTools::setLabel
static void setLabel(Texts::TextGenerator *generator, wxWindow *widget, int textID)
Definition: WidgetTools.cc:92
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
ProDe::bitmapsDirPath
static std::string bitmapsDirPath()
Definition: ProDe.cc:427
ProDeTextGenerator.hh
ProDeTextGenerator
Definition: ProDeTextGenerator.hh:49
AboutDialog.hh
ProDeConstants::EDITOR_COPYRIGHT_TEXT
static const wxString EDITOR_COPYRIGHT_TEXT
Copyright text of the Editor.
Definition: ProDeConstants.hh:384
AboutDialog::~AboutDialog
virtual ~AboutDialog()
Definition: AboutDialog.cc:64
AboutDialog::AboutDialog
AboutDialog(wxWindow *parent)
Definition: AboutDialog.cc:52
ProDeTextGenerator::TXT_ABOUT_DIALOG_TITLE
@ TXT_ABOUT_DIALOG_TITLE
About dialog title.
Definition: ProDeTextGenerator.hh:220
TRUE
const string TRUE
Value used for true in attribute and element values.
Definition: GUIOptionsSerializer.cc:65
AboutDialog::setTexts
void setTexts()
Definition: AboutDialog.cc:72
ProDeConstants::EDITOR_NAME
static const wxString EDITOR_NAME
Full name of the Editor.
Definition: ProDeConstants.hh:386
ProDeConstants.hh
GUITextGenerator.hh
ProDeConstants::EDITOR_LOGO_PATH
static const std::string EDITOR_LOGO_PATH
Location of the logo picture of the Editor.
Definition: ProDeConstants.hh:388
ProDeTextGenerator::instance
static ProDeTextGenerator * instance()
Definition: ProDeTextGenerator.cc:382
WxConversion.hh
WxConversion::toString
static std::string toString(const wxString &source)
GUITextGenerator::TXT_BUTTON_OK
@ TXT_BUTTON_OK
Label for OK button.
Definition: GUITextGenerator.hh:59