OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [configtool/] [standalone/] [wxwin/] [msgdlgex.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
/////////////////////////////////////////////////////////////////////////////
2
// Name:        msgdlgex.cpp
3
// Purpose:     wxMessageDialogEx
4
// Author:      Julian Smart
5
// Modified by:
6
// Created:     12/12/2000
7
// RCS-ID:      $Id: msgdlgex.cpp,v 1.1.1.1 2004-02-14 13:28:54 phoenix Exp $
8
// Copyright:   (c) Julian Smart
9
//
10
// This program is part of the eCos host tools.
11
//
12
// This program is free software; you can redistribute it and/or modify it
13
// under the terms of the GNU General Public License as published by the Free
14
// Software Foundation; either version 2 of the License, or (at your option)
15
// any later version.
16
//
17
// This program is distributed in the hope that it will be useful, but WITHOUT
18
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
// more details.
21
//
22
// You should have received a copy of the GNU General Public License along with
23
// this program; if not, write to the Free Software Foundation, Inc.,
24
// 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25
//
26
/////////////////////////////////////////////////////////////////////////////
27
 
28
#ifdef __GNUG__
29
    #pragma implementation "msgdlgex.cpp"
30
#endif
31
 
32
// For compilers that support precompilation, includes "wx/wx.h".
33
//#include "wx/wxprec.h"
34
#include "ecpch.h"
35
 
36
#ifdef __BORLANDC__
37
    #pragma hdrstop
38
#endif
39
 
40
#include "msgdlgex.h"
41
 
42
// Include wxWindow's headers
43
 
44
#include "wx/sizer.h"
45
#include "wx/statline.h"
46
#include "wx/statbox.h"
47
#include "wx/stattext.h"
48
#include "wx/statbmp.h"
49
#include "wx/bmpbuttn.h"
50
 
51
//----------------------------------------------------------------------------
52
// wxMessageDialogEx
53
//----------------------------------------------------------------------------
54
 
55
IMPLEMENT_CLASS(wxMessageDialogEx,wxDialog)
56
 
57
BEGIN_EVENT_TABLE(wxMessageDialogEx,wxDialog)
58
    EVT_BUTTON( -1, wxMessageDialogEx::OnCommand )
59
END_EVENT_TABLE()
60
 
61
wxMessageDialogEx::wxMessageDialogEx( wxWindow *parent, const wxString& message, const wxString &caption,
62
    long style, const wxPoint& position) :
63
    wxDialog( parent, -1, caption, position, wxDefaultSize, wxDEFAULT_DIALOG_STYLE )
64
{
65
    m_dialogStyle = style;
66
 
67
    wxBeginBusyCursor();
68
 
69
    wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );
70
 
71
    wxBoxSizer *icon_text = new wxBoxSizer( wxHORIZONTAL );
72
 
73
    // 1) icon
74
    if (style & wxICON_MASK)
75
    {
76
         wxStaticBitmap *icon = new wxStaticBitmap(
77
            this, -1, wxTheApp->GetStdIcon((int)(style & wxICON_MASK)));
78
         icon_text->Add( icon, 0, wxCENTER );
79
    }
80
 
81
    // 2) text
82
    icon_text->Add( CreateTextSizer( message ), 0, wxCENTER | wxLEFT, 10 );
83
 
84
    topsizer->Add( icon_text, 0, wxCENTER | wxLEFT|wxRIGHT|wxTOP, 10 );
85
 
86
#if wxUSE_STATLINE
87
    // 3) static line
88
    topsizer->Add( new wxStaticLine( this, -1 ), 0, wxEXPAND | wxLEFT|wxRIGHT|wxTOP, 10 );
89
#endif
90
 
91
    // 4) buttons
92
    topsizer->Add( CreateButtonSizer( style ), 0, wxCENTRE | wxALL, 10 );
93
 
94
    SetAutoLayout( TRUE );
95
    SetSizer( topsizer );
96
 
97
    topsizer->SetSizeHints( this );
98
    topsizer->Fit( this );
99
    wxSize size( GetSize() );
100
    if (size.x < size.y*3/2)
101
    {
102
        size.x = size.y*3/2;
103
        SetSize( size );
104
    }
105
 
106
    Centre( wxBOTH | wxCENTER_FRAME);
107
 
108
    wxEndBusyCursor();
109
}
110
 
111
wxMessageDialogEx::wxMessageDialogEx()
112
{
113
    m_dialogStyle = 0;
114
}
115
 
116
wxMessageDialogEx::~wxMessageDialogEx()
117
{
118
}
119
 
120
void wxMessageDialogEx::OnCommand(wxCommandEvent &event)
121
{
122
    EndModal(event.GetId());
123
}
124
 
125
wxSizer *wxMessageDialogEx::CreateButtonSizer( long flags )
126
{
127
    wxBoxSizer *box = new wxBoxSizer( wxHORIZONTAL );
128
 
129
#if defined(__WXMSW__) || defined(__WXMAC__)
130
    static const int margin = 6;
131
#else
132
    static const int margin = 10;
133
#endif
134
 
135
    wxButton *ok = (wxButton *) NULL;
136
    wxButton *cancel = (wxButton *) NULL;
137
    wxButton *yes = (wxButton *) NULL;
138
    wxButton *no = (wxButton *) NULL;
139
    wxButton *yestoall = (wxButton *) NULL;
140
    wxButton *notoall = (wxButton *) NULL;
141
    wxButton *abort = (wxButton *) NULL;
142
    wxButton *retry = (wxButton *) NULL;
143
    wxButton *ignore = (wxButton *) NULL;
144
 
145
    // always show an OK button, unless only YES_NO is given
146
    // NO, not in this dialog.
147
    //if ((flags & wxYES_NO) == 0) flags = flags | wxOK;
148
 
149
    if (flags & wxMD_YES_NO)
150
    {
151
        yes = new wxButton( this, wxID_YES, _("Yes") );
152
        box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
153
        no = new wxButton( this, wxID_NO, _("No") );
154
        box->Add( no, 0, wxLEFT|wxRIGHT, margin );
155
    }
156
 
157
    if (flags & wxMD_YES)
158
    {
159
        if (!yes)
160
        {
161
            yes = new wxButton( this, wxID_YES, _("Yes") );
162
            box->Add( yes, 0, wxLEFT|wxRIGHT, margin );
163
        }
164
    }
165
 
166
    if (flags & wxMD_YESTOALL)
167
    {
168
        yestoall = new wxButton( this, wxID_YESTOALL, _("Yes to All") );
169
        box->Add( yestoall, 0, wxLEFT|wxRIGHT, margin );
170
    }
171
 
172
    if (flags & wxMD_NO)
173
    {
174
        if (!no)
175
        {
176
            no = new wxButton( this, wxID_NO, _("No") );
177
            box->Add( no, 0, wxLEFT|wxRIGHT, margin );
178
        }
179
    }
180
 
181
    if (flags & wxMD_NOTOALL)
182
    {
183
        notoall = new wxButton( this, wxID_NOTOALL, _("No to All") );
184
        box->Add( notoall, 0, wxLEFT|wxRIGHT, margin );
185
    }
186
 
187
    if (flags & wxMD_ABORT)
188
    {
189
        abort = new wxButton( this, wxID_ABORT, _("Abort") );
190
        box->Add( abort, 0, wxLEFT|wxRIGHT, margin );
191
    }
192
 
193
    if (flags & wxMD_RETRY)
194
    {
195
        retry = new wxButton( this, wxID_RETRY, _("Retry") );
196
        box->Add( retry, 0, wxLEFT|wxRIGHT, margin );
197
    }
198
 
199
    if (flags & wxMD_IGNORE)
200
    {
201
        ignore = new wxButton( this, wxID_IGNORE, _("Ignore") );
202
        box->Add( ignore, 0, wxLEFT|wxRIGHT, margin );
203
    }
204
 
205
    if (flags & wxMD_OK)
206
    {
207
        ok = new wxButton( this, wxID_OK, _("OK") );
208
        box->Add( ok, 0, wxLEFT|wxRIGHT, margin );
209
    }
210
 
211
    if (flags & wxMD_CANCEL)
212
    {
213
        cancel = new wxButton( this, wxID_CANCEL, _("Cancel") );
214
        box->Add( cancel, 0, wxLEFT|wxRIGHT, margin );
215
    }
216
 
217
    if (flags & wxMD_HELP)
218
        box->Add( new wxButton( this, wxID_HELP, _("Help")  ), 0, wxLEFT|wxRIGHT, margin );
219
 
220
    bool setDefault = FALSE;
221
 
222
    if (flags & wxMD_NO_DEFAULT)
223
    {
224
        if (no)
225
        {
226
            no->SetDefault();
227
            no->SetFocus();
228
            setDefault = TRUE;
229
        }
230
    }
231
    else if (flags & wxMD_YES_DEFAULT)
232
    {
233
        if (yes)
234
        {
235
            yes->SetDefault();
236
            yes->SetFocus();
237
            setDefault = TRUE;
238
        }
239
    }
240
    else if (flags & wxMD_YESTOALL_DEFAULT)
241
    {
242
        if (yestoall)
243
        {
244
            yestoall->SetDefault();
245
            yestoall->SetFocus();
246
            setDefault = TRUE;
247
        }
248
    }
249
    else if (flags & wxMD_NOTOALL_DEFAULT)
250
    {
251
        if (notoall)
252
        {
253
            notoall->SetDefault();
254
            notoall->SetFocus();
255
            setDefault = TRUE;
256
        }
257
    }
258
    else if (flags & wxMD_ABORT_DEFAULT)
259
    {
260
        if (abort)
261
        {
262
            abort->SetDefault();
263
            abort->SetFocus();
264
            setDefault = TRUE;
265
        }
266
    }
267
    else if (flags & wxMD_RETRY_DEFAULT)
268
    {
269
        if (retry)
270
        {
271
            retry->SetDefault();
272
            retry->SetFocus();
273
            setDefault = TRUE;
274
        }
275
    }
276
    else if (flags & wxMD_IGNORE_DEFAULT)
277
    {
278
        if (ignore)
279
        {
280
            ignore->SetDefault();
281
            ignore->SetFocus();
282
            setDefault = TRUE;
283
        }
284
    }
285
 
286
    if (!setDefault)
287
    {
288
        if (ok)
289
        {
290
            ok->SetDefault();
291
            ok->SetFocus();
292
        }
293
        else if (yes)
294
        {
295
            yes->SetDefault();
296
            yes->SetFocus();
297
        }
298
    }
299
 
300
    return box;
301
}
302
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.