wxIconBundle implementation.

wxTLW::SetIcons() properly implemented for wxMotif, wxGTK, wxMSW, wxX11, wxUniversal
Placeholders that just call SetIcon for wxOS2 and wxMac.
Regenerated makefiles.
Added hardwired wxSYS_ICON_X/Y = 32 for wxGTK.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14809 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Mattia Barbon
2002-03-26 21:54:23 +00:00
parent 6b3d51cc35
commit f618020a15
51 changed files with 566 additions and 68 deletions

View File

@@ -161,7 +161,8 @@ public:
#endif
// no icon
void SetIcon( const wxIcon &icon ) { m_icon = icon; }
void SetIcon( const wxIcon &icon ) { m_icons = wxIconBundle( icon ); }
void SetIcons( const wxIconBundle &icons ) { m_icons = icons; }
// no title
void SetTitle( const wxString &title );

View File

@@ -54,6 +54,7 @@ public:
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons);
virtual void Restore();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
@@ -71,6 +72,9 @@ public:
// from both DoSetSize() and DoSetClientSize()
virtual void DoMoveWindow(int x, int y, int width, int height);
// set the icon for this window
void DoSetIcon( const wxIcon& icon );
// GTK callbacks
virtual void GtkOnSize( int x, int y, int width, int height );
virtual void OnInternalIdle();

View File

@@ -161,7 +161,8 @@ public:
#endif
// no icon
void SetIcon( const wxIcon &icon ) { m_icon = icon; }
void SetIcon( const wxIcon &icon ) { m_icons = wxIconBundle( icon ); }
void SetIcons( const wxIconBundle &icons ) { m_icons = icons; }
// no title
void SetTitle( const wxString &title );

View File

@@ -54,6 +54,7 @@ public:
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons);
virtual void Restore();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL);
@@ -71,6 +72,9 @@ public:
// from both DoSetSize() and DoSetClientSize()
virtual void DoMoveWindow(int x, int y, int width, int height);
// set the icon for this window
void DoSetIcon( const wxIcon& icon );
// GTK callbacks
virtual void GtkOnSize( int x, int y, int width, int height );
virtual void OnInternalIdle();

73
include/wx/iconbndl.h Normal file
View File

@@ -0,0 +1,73 @@
///////////////////////////////////////////////////////////////////////////////
// Name: wx/iconbndl.h
// Purpose: wxIconBundle
// Author: Mattia barbon
// Modified by:
// Created: 23.03.02
// RCS-ID: $Id$
// Copyright: (c) Mattia Barbon
// Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////////
#ifndef _WX_ICONBNDL_H_
#define _WX_ICONBNDL_H_
#ifdef __GNUG__
#pragma interface "iconbndl.h"
#endif
#include "dynarray.h"
// for wxSize
#include "wx/gdicmn.h"
class WXDLLEXPORT wxIcon;
class WXDLLEXPORT wxString;
WX_DECLARE_EXPORTED_OBJARRAY( wxIcon, wxIconArray );
// this class can't load bitmaps of type wxBITMAP_TYPE_ICO_RESOURCE,
// if you need them, you have to load them manually and call
// wxIconCollection::AddIcon
class WXDLLEXPORT wxIconBundle
{
public:
// default constructor
wxIconBundle() {}
// initializes the bundle with the icon(s) found in the file
wxIconBundle( const wxString& file, long type )
{ AddIcon( file, type ); }
// initializes the bundle with a single icon
wxIconBundle( const wxIcon& icon )
{ AddIcon( icon ); }
const wxIconBundle& operator =( const wxIconBundle& ic );
wxIconBundle( const wxIconBundle& ic )
{ *this = ic; }
~wxIconBundle() { DeleteIcons(); }
// adds all the icons contained in the file to the collection,
// if the collection already contains icons with the same
// width and height, they are replaced
void AddIcon( const wxString& file, long type );
// adds the icon to the collection, if the collection already
// contains an icon with the same width and height, it is
// replaced
void AddIcon( const wxIcon& icon );
// returns the icon with the given size; if no such icon exists,
// returns the icon with size wxSYS_ICON_[XY]; if no such icon exists,
// returns the first icon in the bundle
const wxIcon& GetIcon( const wxSize& size ) const;
// equivalent to GetIcon( wxSize( size, size ) )
const wxIcon& GetIcon( wxCoord size = -1 ) const
{ return GetIcon( wxSize( size, size ) ); }
private:
// delete all icons
void DeleteIcons();
public:
wxIconArray m_icons;
};
#endif
// _WX_ICONBNDL_H_

View File

@@ -55,6 +55,7 @@ public:
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
virtual void Restore();
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) { return FALSE; }

View File

@@ -54,7 +54,8 @@ public:
// Set icon
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons);
#if wxUSE_STATUSBAR
virtual void PositionStatusBar();
#endif // wxUSE_STATUSBAR
@@ -107,7 +108,10 @@ public:
protected:
// common part of all ctors
void Init();
// set a single icon for the frame
void DoSetIcon( const wxIcon& icon );
//// Motif-specific
WXWidget m_frameShell;
WXWidget m_frameWidget;

View File

@@ -152,7 +152,8 @@ public:
// Set icon
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons );
// Override wxFrame operations
void CaptureMouse();
void ReleaseMouse();

View File

@@ -55,6 +55,7 @@ public:
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcons(const wxIconBundle& icons );
virtual void Restore();
virtual bool Show(bool show = TRUE);

View File

@@ -67,6 +67,8 @@ public:
virtual void Restore(void);
virtual void SendSizeEvent(void);
virtual void SetIcon(const wxIcon& rIcon);
inline virtual void SetIcons(const wxIconBundle& icons) { SetIcon( icons.GetIcon( -1 ) ); }
virtual bool Show(bool bShow = TRUE);
virtual bool ShowFullScreen( bool bShow
,long lStyle = wxFULLSCREEN_ALL

View File

@@ -23,7 +23,7 @@
#endif
#include "wx/window.h"
#include "wx/icon.h"
#include "wx/iconbndl.h"
// the default names for various classs
WXDLLEXPORT_DATA(extern const wxChar*) wxFrameNameStr;
@@ -83,10 +83,16 @@ public:
virtual bool IsIconized() const = 0;
// get the frame icon
const wxIcon& GetIcon() const { return m_icon; }
const wxIcon& GetIcon() const { return m_icons.GetIcon( -1 ); }
// get the frame icons
const wxIconBundle& GetIcons() const { return m_icons; }
// set the frame icon
virtual void SetIcon(const wxIcon& icon) { m_icon = icon; }
virtual void SetIcon(const wxIcon& icon) { m_icons = wxIconBundle( icon ); }
// set the frame icons
virtual void SetIcons(const wxIconBundle& icons ) { m_icons = icons; }
// maximize the window to cover entire screen
virtual bool ShowFullScreen(bool show, long style = wxFULLSCREEN_ALL) = 0;
@@ -133,7 +139,7 @@ protected:
bool SendIconizeEvent(bool iconized = TRUE);
// the frame icon
wxIcon m_icon;
wxIconBundle m_icons;
// test whether this window makes part of the frame
// (menubar, toolbar and statusbar are excluded from automatic layout)

View File

@@ -123,7 +123,8 @@ public:
virtual wxPoint GetClientAreaOrigin() const;
virtual void DoGetClientSize(int *width, int *height) const;
virtual void DoSetClientSize(int width, int height);
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); }
virtual void SetIcons(const wxIconBundle& icons);
// implementation from now on
// --------------------------

View File

@@ -0,0 +1,33 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/unix/utilsx11.h
// Purpose: Miscellaneous X11 functions
// Author: Mattia Barbon
// Modified by:
// Created: 25.03.02
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_UNIX_UTILSX11_H_
#define _WX_UNIX_UTILSX11_H_
#include "wx/defs.h"
#if defined(__WXMOTIF__) || defined(__WXGTK__) || defined(__WXX11__)
#if defined(__WXGTK__)
typedef void WXDisplay;
typedef void* WXWindow;
#endif
class wxIconBundle;
void wxSetIconsX11( WXDisplay* display, WXWindow window,
const wxIconBundle& ib );
#endif
// __WXMOTIF__, __WXGTK__, __WXX11__
#endif
// _WX_UNIX_UTILSX11_H_

View File

@@ -65,7 +65,8 @@ enum wxFSIconType
wxFS_VOL_ICO_MAX
};
WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray);
// already in wx/iconbndl.h
// WX_DECLARE_EXPORTED_OBJARRAY(wxIcon, wxIconArray);
#endif // wxUSE_GUI

View File

@@ -54,7 +54,8 @@ public:
virtual bool IsMaximized() const;
virtual void Iconize(bool iconize = TRUE);
virtual bool IsIconized() const;
virtual void SetIcon(const wxIcon& icon);
virtual void SetIcon(const wxIcon& icon) { SetIcons( wxIconBundle( icon ) ); }
virtual void SetIcons(const wxIconBundle& icons);
virtual void Restore();
virtual bool Show( bool show = TRUE );
@@ -72,6 +73,9 @@ protected:
// common part of all ctors
void Init();
// set the icon for the window
void DoSetIcon( const wxIcon& icon );
// For implementation purposes - sometimes decorations make the
// client area smaller
virtual wxPoint GetClientAreaOrigin() const;