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

@@ -441,3 +441,15 @@ needs to use the top window.
\helpref{wxApp::GetTopWindow}{wxappgettopwindow}, \helpref{wxApp::OnInit}{wxapponinit}
\membersection{wxApp::GetStdIcon}\label{wxappgetstdicon}
\func{virtual wxIcon}{GetStdIcon}{\param{int }{which}} const
Returns the icons used by wxWindows internally, e.g. the ones used for
message boxes. This function is used internally and
can be overridden by the user to change the default icons.
\wxheading{Parameters}
\docparam{which}{One of the wxICON_XXX defines and chooses which icon to return.}

View File

@@ -402,7 +402,7 @@ enum
wxMGL_UNIX, // MGL with direct hardware access
wxMGL_X, // MGL on X
wxMGL_WIN32, // MGL on Win32
wxMGL_OS2, // MGL on OS/2
wxMGL_OS2 // MGL on OS/2
};
// ----------------------------------------------------------------------------
@@ -862,6 +862,8 @@ typedef wxUint16 wxWord;
#define wxICON_EXCLAMATION 0x00000040
#define wxICON_HAND 0x00000080
#define wxICON_WARNING wxICON_EXCLAMATION
#define wxICON_ERROR wxICON_HAND
#define wxICON_QUESTION 0x00000100
#define wxICON_INFORMATION 0x00000200
#define wxICON_STOP wxICON_HAND

View File

@@ -1,5 +1,5 @@
/* XPM */
static char * error[] = {
static char * error_xpm[] = {
"48 48 78 1",
" c None",
". c #000000",

View File

@@ -1,5 +1,5 @@
/* XPM */
static char * info[] = {
static char * info_xpm[] = {
"48 48 159 2",
" c None",
". c #12165C",

View File

@@ -1,5 +1,5 @@
/* XPM */
static char * question[] = {
static char * question_xpm[] = {
"48 48 165 2",
" c None",
". c #000000",

View File

@@ -1,5 +1,5 @@
/* XPM */
static char * warning[] = {
static char * warning_xpm[] = {
"48 48 151 2",
" c None",
". c #C70707",

View File

@@ -17,6 +17,7 @@
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/icon.h"
//-----------------------------------------------------------------------------
// classes
@@ -81,6 +82,9 @@ class wxApp: public wxEvtHandler
virtual bool Pending();
virtual void Dispatch();
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; }
inline bool GetWantDebugOutput() { return m_wantDebugOutput; }

View File

@@ -17,6 +17,7 @@
#include "wx/defs.h"
#include "wx/window.h"
#include "wx/frame.h"
#include "wx/icon.h"
//-----------------------------------------------------------------------------
// classes
@@ -81,6 +82,9 @@ class wxApp: public wxEvtHandler
virtual bool Pending();
virtual void Dispatch();
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetWantDebugOutput( bool flag ) { m_wantDebugOutput = flag; }
inline bool GetWantDebugOutput() { return m_wantDebugOutput; }

View File

@@ -67,6 +67,11 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; }
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetPrintMode(int mode) { m_printMode = mode; }
inline int GetPrintMode() const { return m_printMode; }

View File

@@ -67,6 +67,10 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; }
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetPrintMode(int mode) { m_printMode = mode; }
inline int GetPrintMode() const { return m_printMode; }

View File

@@ -19,6 +19,7 @@
#include "wx/defs.h"
#include "wx/object.h"
#include "wx/event.h"
#include "wx/icon.h"
class WXDLLEXPORT wxFrame;
class WXDLLEXPORT wxWindow;
@@ -67,6 +68,9 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
// Called to set off the main loop
virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; }
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
// called when a fatal exception occurs, this function should take care not
// to do anything which might provoke a nested exception!

View File

@@ -68,6 +68,9 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
// Called to set off the main loop
virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; }
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetPrintMode(int mode) { m_printMode = mode; }
inline int GetPrintMode() const { return m_printMode; }

View File

@@ -67,6 +67,10 @@ class WXDLLEXPORT wxApp: public wxEvtHandler
virtual int OnRun() { return MainLoop(); };
virtual int OnExit() { return 0; }
/** Returns the standard icons for the msg dialogs, implemented in
src/generic/msgdlgg.cpp and src/gtk/app.cpp. */
virtual wxIcon GetStdIcon(int which) const;
inline void SetPrintMode(int mode) { m_printMode = mode; }
inline int GetPrintMode() const { return m_printMode; }

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()
{