Made icons configurable via a wxMApp virtual function. Tested on wxGTK only,

added it for all ports, though.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2953 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Karsten Ballüder
1999-07-05 11:22:45 +00:00
parent 13315b0cd3
commit ebea0891d0
22 changed files with 200 additions and 92 deletions

View File

@@ -29,6 +29,7 @@
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/icon.h"
# include "wx/app.h"
#endif
#include <stdio.h>
@@ -44,13 +45,6 @@
// icons
// ----------------------------------------------------------------------------
// MSW icons are in the ressources, for all other platforms - in XPM files
#ifndef __WXMSW__
#include "wx/generic/info.xpm"
#include "wx/generic/question.xpm"
#include "wx/generic/warning.xpm"
#include "wx/generic/error.xpm"
#endif // __WXMSW__
#if !USE_SHARED_LIBRARY
@@ -63,6 +57,46 @@ END_EVENT_TABLE()
IMPLEMENT_CLASS(wxGenericMessageDialog, wxDialog)
#endif
#ifdef _WXGTK__
# include "wx/gtk/info.xpm"
# include "wx/gtk/error.xpm"
# include "wx/gtk/question.xpm"
# include "wx/gtk/warning.xpm"
#else
// MSW icons are in the ressources, for all other platforms - in XPM files
# ifndef __WXMSW__
# include "wx/generic/info.xpm"
# include "wx/generic/question.xpm"
# include "wx/generic/warning.xpm"
# include "wx/generic/error.xpm"
# endif // __WXMSW__
#endif
wxIcon
wxApp::GetStdIcon(int which) const
{
switch(which)
{
case wxICON_INFORMATION:
return wxIcon(info_xpm);
break;
case wxICON_HAND:
return wxIcon(error_xpm);
break;
case wxICON_QUESTION:
return wxIcon(question_xpm);
break;
case wxICON_EXCLAMATION:
return wxIcon(warning_xpm);
break;
default:
wxFAIL_MSG("requested non existent standard icon");
return wxIcon(error_xpm);
break;
}
}
wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
const wxString& message,
const wxString& caption,
@@ -77,43 +111,8 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent,
wxLayoutConstraints *c;
SetAutoLayout(TRUE);
// create an icon
enum
{
Icon_Information,
Icon_Question,
Icon_Warning,
Icon_Error
} which;
#ifdef __WXMSW__
static char *icons[] =
{
"wxICON_INFO",
"wxICON_QUESTION",
"wxICON_WARNING",
"wxICON_ERROR",
};
#else // XPM icons
static char **icons[] =
{
info,
question,
warning,
error,
};
#endif // !XPM/XPM
if ( style & wxICON_EXCLAMATION )
which = Icon_Warning;
else if ( style & wxICON_HAND )
which = Icon_Error;
else if ( style & wxICON_QUESTION )
which = Icon_Question;
else
which = Icon_Information;
wxStaticBitmap *icon = new wxStaticBitmap(this, -1, wxIcon(icons[which]));
wxStaticBitmap *icon = new wxStaticBitmap(this, -1,
wxTheApp->GetStdIcon(style & wxICON_MASK));
const int iconSize = icon->GetBitmap().GetWidth();
// split the message in lines

View File

@@ -81,8 +81,8 @@ wxProgressDialog::wxProgressDialog(wxString const &title,
m_msg = new wxStaticText(this, -1, message);
c = new wxLayoutConstraints;
c->left.SameAs(this, wxLeft, 10);
c->top.SameAs(this, wxTop, 10);
c->left.SameAs(this, wxLeft, 2*LAYOUT_X_MARGIN);
c->top.SameAs(this, wxTop, 2*LAYOUT_Y_MARGIN);
c->width.AsIs();
c->height.AsIs();
m_msg->SetConstraints(c);
@@ -254,12 +254,16 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
m_btnAbort->SetLabel(_("Close"));
}
if ( !newmsg )
/*I think the default should be the other way round. If the
application wants to set a "Done." message at the end, it should
supply it. Any serious objections to this change? Makes the
application programmers' work a little easier.
if ( !newmsg )
{
// also provide the finishing message if the application didn't
m_msg->SetLabel(_("Done."));
}
*/
m_state = Finished;
// so that we return TRUE below

View File

@@ -779,3 +779,31 @@ int wxEntry( int argc, char *argv[] )
return retValue;
}
# include "wx/gtk/info.xpm"
# include "wx/gtk/error.xpm"
# include "wx/gtk/question.xpm"
# include "wx/gtk/warning.xpm"
wxIcon
wxApp::GetStdIcon(int which) const
{
switch(which)
{
case wxICON_INFORMATION:
return wxIcon(info_xpm);
break;
case wxICON_HAND:
return wxIcon(error_xpm);
break;
case wxICON_QUESTION:
return wxIcon(question_xpm);
break;
case wxICON_EXCLAMATION:
return wxIcon(warning_xpm);
break;
default:
wxFAIL_MSG("requested non existent standard icon");
return wxIcon(error_xpm);
break;
}
}

View File

@@ -120,7 +120,8 @@ void wxButton::SetDefault(void)
SetSize( m_x, m_y, m_width, m_height );
}
static wxSize wxButton::GetDefaultSize()
/* static */
wxSize wxButton::GetDefaultSize()
{
return wxSize(80,26);
}

View File

@@ -30,6 +30,7 @@
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/bitmap.h"
#include "wx/app.h"
#endif
#include <stdio.h>
@@ -38,11 +39,6 @@
#include "wx/gtk/msgdlg.h"
#include "wx/statline.h"
#include "wx/gtk/info.xpm"
#include "wx/gtk/error.xpm"
#include "wx/gtk/question.xpm"
#include "wx/gtk/warning.xpm"
///////////////////////////////////////////////////////////////////
// New dialog box implementations
@@ -107,19 +103,13 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
if (m_dialogStyle & wxICON_MASK)
if (message_size.y < 50) message_size.y = 50;
if (m_dialogStyle & wxICON_INFORMATION)
(void) new wxStaticBitmap( this, -1, wxBitmap( info_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_HAND)
(void) new wxStaticBitmap( this, -1, wxBitmap( error_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_QUESTION)
(void) new wxStaticBitmap( this, -1, wxBitmap( question_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_EXCLAMATION)
(void) new wxStaticBitmap( this, -1, wxBitmap( warning_xpm ), wxPoint(15,message_size.y/2-16) );
{
if (message_size.y < 50) message_size.y = 50;
(void) new wxStaticBitmap( this, -1,
wxTheApp->GetStdIcon(m_dialogStyle
& wxICON_MASK),
wxPoint(15,message_size.y/2-16) );
}
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;

View File

@@ -779,3 +779,31 @@ int wxEntry( int argc, char *argv[] )
return retValue;
}
# include "wx/gtk/info.xpm"
# include "wx/gtk/error.xpm"
# include "wx/gtk/question.xpm"
# include "wx/gtk/warning.xpm"
wxIcon
wxApp::GetStdIcon(int which) const
{
switch(which)
{
case wxICON_INFORMATION:
return wxIcon(info_xpm);
break;
case wxICON_HAND:
return wxIcon(error_xpm);
break;
case wxICON_QUESTION:
return wxIcon(question_xpm);
break;
case wxICON_EXCLAMATION:
return wxIcon(warning_xpm);
break;
default:
wxFAIL_MSG("requested non existent standard icon");
return wxIcon(error_xpm);
break;
}
}

View File

@@ -120,7 +120,8 @@ void wxButton::SetDefault(void)
SetSize( m_x, m_y, m_width, m_height );
}
static wxSize wxButton::GetDefaultSize()
/* static */
wxSize wxButton::GetDefaultSize()
{
return wxSize(80,26);
}

View File

@@ -30,6 +30,7 @@
#include "wx/layout.h"
#include "wx/intl.h"
#include "wx/bitmap.h"
#include "wx/app.h"
#endif
#include <stdio.h>
@@ -38,11 +39,6 @@
#include "wx/gtk/msgdlg.h"
#include "wx/statline.h"
#include "wx/gtk/info.xpm"
#include "wx/gtk/error.xpm"
#include "wx/gtk/question.xpm"
#include "wx/gtk/warning.xpm"
///////////////////////////////////////////////////////////////////
// New dialog box implementations
@@ -107,19 +103,13 @@ wxGenericMessageDialog::wxGenericMessageDialog( wxWindow *parent, const wxString
wxSize message_size( wxSplitMessage2( message, this, text_pos_x ) );
if (m_dialogStyle & wxICON_MASK)
if (message_size.y < 50) message_size.y = 50;
if (m_dialogStyle & wxICON_INFORMATION)
(void) new wxStaticBitmap( this, -1, wxBitmap( info_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_HAND)
(void) new wxStaticBitmap( this, -1, wxBitmap( error_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_QUESTION)
(void) new wxStaticBitmap( this, -1, wxBitmap( question_xpm ), wxPoint(15,message_size.y/2-16) );
else
if (m_dialogStyle & wxICON_EXCLAMATION)
(void) new wxStaticBitmap( this, -1, wxBitmap( warning_xpm ), wxPoint(15,message_size.y/2-16) );
{
if (message_size.y < 50) message_size.y = 50;
(void) new wxStaticBitmap( this, -1,
wxTheApp->GetStdIcon(m_dialogStyle
& wxICON_MASK),
wxPoint(15,message_size.y/2-16) );
}
wxButton *ok = (wxButton *) NULL;
wxButton *cancel = (wxButton *) NULL;

View File

@@ -43,7 +43,8 @@
#include "wx/msgdlg.h"
#include "wx/intl.h"
#include "wx/dynarray.h"
#include "wx/wxchar.h"
# include "wx/wxchar.h"
# include "wx/icon.h"
#endif
#include "wx/log.h"
@@ -1148,6 +1149,30 @@ bool wxYield()
return TRUE;
}
wxIcon
wxApp::GetStdIcon(int which) const
{
switch(which)
{
case wxICON_INFORMATION:
return wxIcon("wxICON_INFO");
break;
case wxICON_HAND:
return wxIcon("wxICON_ERROR");
break;
case wxICON_QUESTION:
return wxIcon("wxICON_QUESTION");
break;
case wxICON_EXCLAMATION:
return wxIcon("wxICON_WARNING");
break;
default:
wxFAIL_MSG("requested non existent standard icon");
return wxIcon("wxICON_ERROR");
break;
}
}
HINSTANCE wxGetInstance()
{