1. added a brief overview of Unicode support

2. added and documented wxBITMAP() macros (as wxICON)
3. restructured wxFont class, added support of encoding parameter
4. regenerated makefiles to compile the new fontcmn.cpp file
5. corrected bug with non existing files in document-view history


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3753 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1999-09-29 19:02:07 +00:00
parent 7a3ac80489
commit 0c5d3e1ccd
24 changed files with 1848 additions and 750 deletions

View File

@@ -362,6 +362,7 @@ public:
// File history management
virtual void AddFileToHistory(const wxString& file);
virtual void RemoveFileFromHistory(int i);
virtual int GetNoHistoryFiles() const;
virtual wxString GetHistoryFile(int i) const;
virtual void FileHistoryUseMenu(wxMenu *menu);
@@ -553,6 +554,7 @@ public:
// Operations
virtual void AddFileToHistory(const wxString& file);
virtual void RemoveFileFromHistory(int i);
virtual int GetMaxFiles() const { return m_fileMaxFiles; }
virtual void UseMenu(wxMenu *menu);

View File

@@ -1,21 +1,202 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/font.h
// Purpose: wxFontBase class: the interface of wxFont
// Author: Vadim Zeitlin
// Modified by:
// Created: 20.09.99
// RCS-ID: $Id$
// Copyright: (c) wxWindows team
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_FONT_H_BASE_
#define _WX_FONT_H_BASE_
// ----------------------------------------------------------------------------
// headers
// ----------------------------------------------------------------------------
#include "wx/defs.h" // for wxDEFAULT &c
#include "wx/gdiobj.h" // the base class
// ----------------------------------------------------------------------------
// forward declarations
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFontBase;
class WXDLLEXPORT wxFont;
// ----------------------------------------------------------------------------
// font constants
// ----------------------------------------------------------------------------
// standard font families
enum wxFontFamily
{
wxFONTFAMILY_DEFAULT = wxDEFAULT,
wxFONTFAMILY_DECORATIVE = wxDECORATIVE,
wxFONTFAMILY_ROMAN = wxROMAN,
wxFONTFAMILY_SCRIPT = wxSCRIPT,
wxFONTFAMILY_SWISS = wxSWISS,
wxFONTFAMILY_MODERN = wxMODERN,
wxFONTFAMILY_TELETYPE = wxTELETYPE,
wxFONTFAMILY_MAX
};
// font styles
enum wxFontStyle
{
wxFONTSTYLE_NORMAL = wxNORMAL,
wxFONTSTYLE_ITALIC = wxITALIC,
wxFONTSTYLE_SLANT = wxSLANT,
wxFONTSTYLE_MAX
};
// font weights
enum wxFontWeight
{
wxFONTWEIGHT_NORMAL = wxNORMAL,
wxFONTWEIGHT_LIGHT = wxLIGHT,
wxFONTWEIGHT_BOLD = wxBOLD,
wxFONTWEIGHT_MAX
};
// font encodings
enum wxFontEncoding
{
wxFONTENCODING_SYSTEM = -1, // system default
wxFONTENCODING_DEFAULT, // current default encoding
// ISO8859 standard defines a number of single-byte charsets
wxFONTENCODING_ISO8859_1, // West European (Latin1)
wxFONTENCODING_ISO8859_2, // Central and East European (Latin2)
wxFONTENCODING_ISO8859_3, // Esperanto (Latin3)
wxFONTENCODING_ISO8859_4, // Baltic languages (Estonian) (Latin4)
wxFONTENCODING_ISO8859_5, // Cyrillic
wxFONTENCODING_ISO8859_6, // Arabic
wxFONTENCODING_ISO8859_7, // Greek
wxFONTENCODING_ISO8859_8, // Hebrew
wxFONTENCODING_ISO8859_9, // Turkish (Latin5)
wxFONTENCODING_ISO8859_10, // Variation of Latin4 (Latin6)
wxFONTENCODING_ISO8859_11, // Thai
wxFONTENCODING_ISO8859_12, // doesn't exist currently, but put it
// here anyhow to make all ISO8859
// consecutive numbers
wxFONTENCODING_ISO8859_13, // Latin7
wxFONTENCODING_ISO8859_14, // Latin8
wxFONTENCODING_ISO8859_15, // Latin9 (a.k.a. Latin0, includes euro)
// Cyrillic charset soup (see http://czyborra.com/charsets/cyrillic.html)
wxFONTENCODING_KOI8, // we don't support any of KOI8 variants
wxFONTENCODING_ALTERNATIVE, // same as MS-DOS CP866
wxFONTENCODING_BULGARIAN, // used under Linux in Bulgaria
// what would we do without Microsoft? They have their own encodings
// for DOS
wxFONTENCODING_CP437, // original MS-DOS codepage
wxFONTENCODING_CP850, // CP437 merged with Latin1
wxFONTENCODING_CP852, // CP437 merged with Latin2
wxFONTENCODING_CP855, // another cyrillic encoding
wxFONTENCODING_CP866 = wxFONTENCODING_ALTERNATIVE,
// and for Windows
wxFONTENCODING_CP1250, // WinLatin2
wxFONTENCODING_CP1251, // WinCyrillic
wxFONTENCODING_CP1252, // WinLatin1
wxFONTENCODING_MAX
};
// ----------------------------------------------------------------------------
// wxFontBase represents a font object
// ----------------------------------------------------------------------------
class wxFontBase : public wxGDIObject
{
public:
// creator function
static wxFont *New(
int pointSize, // size of the font in points
int family, // see wxFontFamily enum
int style, // see wxFontStyle enum
int weight, // see wxFontWeight enum
bool underlined = FALSE, // not underlined by default
const wxString& face = wxEmptyString, // facename
wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
// was the font successfully created?
bool Ok() const { return m_refData != NULL; }
// comparison
bool operator == (const wxFont& font) const;
bool operator != (const wxFont& font) const;
// accessors: get the font characteristics
virtual int GetPointSize() const = 0;
virtual int GetFamily() const = 0;
virtual int GetStyle() const = 0;
virtual int GetWeight() const = 0;
virtual bool GetUnderlined() const = 0;
virtual wxString GetFaceName() const = 0;
virtual wxFontEncoding GetEncoding() const = 0;
// change the font characteristics
virtual void SetPointSize( int pointSize ) = 0;
virtual void SetFamily( int family ) = 0;
virtual void SetStyle( int style ) = 0;
virtual void SetWeight( int weight ) = 0;
virtual void SetFaceName( const wxString& faceName ) = 0;
virtual void SetUnderlined( bool underlined ) = 0;
virtual void SetEncoding(wxFontEncoding encoding) = 0;
// translate the fonts into human-readable string (i.e. GetStyleString()
// will return "wxITALIC" for an italic font, ...)
wxString GetFamilyString() const;
wxString GetStyleString() const;
wxString GetWeightString() const;
// the default encoding is used for creating all fonts with default
// encoding parameter
static wxFontEncoding GetDefaultEncoding()
{ return ms_encodingDefault; }
static void SetDefaultEncoding(wxFontEncoding encoding)
{ ms_encodingDefault = encoding; }
protected:
// get the internal data
class WXDLLEXPORT wxFontRefData *GetFontData() const
{ return (wxFontRefData *)m_refData; }
private:
// the currently default encoding: by default, it's the default system
// encoding, but may be changed by the application using
// SetDefaultEncoding() to make all subsequent fonts created without
// specifing encoding parameter using this encoding
static wxFontEncoding ms_encodingDefault;
};
// include the real class declaration
#if defined(__WXMSW__)
#include "wx/msw/font.h"
#include "wx/msw/font.h"
#elif defined(__WXMOTIF__)
#include "wx/motif/font.h"
#include "wx/motif/font.h"
#elif defined(__WXGTK__)
#include "wx/gtk/font.h"
#include "wx/gtk/font.h"
#elif defined(__WXQT__)
#include "wx/qt/font.h"
#include "wx/qt/font.h"
#elif defined(__WXMAC__)
#include "wx/mac/font.h"
#include "wx/mac/font.h"
#elif defined(__WXPM__)
#include "wx/os2/font.h"
#include "wx/os2/font.h"
#elif defined(__WXSTUBS__)
#include "wx/stubs/font.h"
#include "wx/stubs/font.h"
#endif
// ----------------------------------------------------------------------------
// macros
// ----------------------------------------------------------------------------
// VZ: this is ugly (FIXME)
#define M_FONTDATA GetFontData()
#endif
// _WX_FONT_H_BASE_

View File

@@ -149,6 +149,16 @@ enum wxStockCursor
#define wxICON(X) wxIcon("" #X "")
#endif // platform
/* Another macro: this one is for portable creation of bitmaps. We assume that
under Unix bitmaps live in XPMs and under Windows they're in ressources.
*/
#if defined(__WXMSW__) || defined(__WXPM__)
#define wxBITMAP(name) wxBitmap(#name, wxBITMAP_TYPE_RESOURCE)
#else // !(Windows || OS2)
#define wxBITMAP(name) wxBitmap(name##_xpm, wxBITMAP_TYPE_XPM)
#endif // platform
// ===========================================================================
// classes
// ===========================================================================

View File

@@ -7,12 +7,11 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKFONTH__
#define __GTKFONTH__
#ifdef __GNUG__
#pragma interface
#pragma interface
#endif
#include "wx/defs.h"
@@ -21,79 +20,111 @@
#include "wx/hash.h"
#include "wx/gdiobj.h"
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
#define wxUSE_FONTNAMEDIRECTORY 0
// ----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxDC;
class wxPaintDC;
class wxWindow;
class wxFont;
/*
class wxFontNameDirectory;
*/
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
class wxFontNameDirectory;
#endif
// ----------------------------------------------------------------------------
// global variables
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/*
extern wxFontNameDirectory *wxTheFontNameDirectory;
*/
extern const wxChar* wxEmptyString;
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
extern wxFontNameDirectory *wxTheFontNameDirectory;
#endif
// ----------------------------------------------------------------------------
// wxFont
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxFont: public wxGDIObject
class wxFont : public wxFontBase
{
DECLARE_DYNAMIC_CLASS(wxFont)
public:
wxFont();
wxFont( int pointSize, int family, int style, int weight, bool underlined = FALSE,
const wxString& face = wxEmptyString );
wxFont( const wxFont& font );
~wxFont();
wxFont& operator = ( const wxFont& font );
bool operator == ( const wxFont& font ) const;
bool operator != ( const wxFont& font ) const;
bool Ok() const;
// ctors and such
wxFont() { Init(); }
wxFont(const wxFont& font) { Init(); Ref(font); }
int GetPointSize() const;
int GetFamily() const;
int GetStyle() const;
int GetWeight() const;
bool GetUnderlined() const;
// assignment
wxFont& operator=(const wxFont& font);
void SetPointSize( int pointSize );
void SetFamily( int family );
void SetStyle( int style );
void SetWeight( int weight );
void SetFaceName( const wxString& faceName );
void SetUnderlined( bool underlined );
wxString GetFaceName() const;
wxString GetFamilyString() const;
wxString GetStyleString() const;
wxString GetWeightString() const;
// implementation
wxFont( GdkFont* font, char *xFontName );
void Unshare();
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Init();
GdkFont* GetInternalFont(float scale = 1.0) const;
(void)Create(size, family, style, weight, underlined, face, encoding);
}
// no data :-)
bool Create(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual int GetFamily() const;
virtual int GetStyle() const;
virtual int GetWeight() const;
virtual wxString GetFaceName() const;
virtual bool GetUnderlined() const;
virtual wxFontEncoding GetEncoding() const;
virtual void SetPointSize( int pointSize );
virtual void SetFamily( int family );
virtual void SetStyle( int style );
virtual void SetWeight( int weight );
virtual void SetFaceName( const wxString& faceName );
virtual void SetUnderlined( bool underlined );
virtual void SetEncoding(wxFontEncoding encoding);
// implementation from now on
wxFont( GdkFont* font, char *xFontName );
void Unshare();
GdkFont* GetInternalFont(float scale = 1.0) const;
// no data :-)
protected:
// common part of all ctors
void Init();
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
/*
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
// ----------------------------------------------------------------------------
// wxFontDirectory
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxFontNameDirectory: public wxObject
{
@@ -118,6 +149,7 @@ class wxFontNameDirectory: public wxObject
class wxHashTable *table;
int nextFontId;
};
*/
#endif // wxUSE_FONTNAMEDIRECTORY
#endif // __GTKFONTH__

View File

@@ -7,12 +7,11 @@
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef __GTKFONTH__
#define __GTKFONTH__
#ifdef __GNUG__
#pragma interface
#pragma interface
#endif
#include "wx/defs.h"
@@ -21,79 +20,111 @@
#include "wx/hash.h"
#include "wx/gdiobj.h"
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
// conditional compilation
// ----------------------------------------------------------------------------
#define wxUSE_FONTNAMEDIRECTORY 0
// ----------------------------------------------------------------------------
// classes
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxDC;
class wxPaintDC;
class wxWindow;
class wxFont;
/*
class wxFontNameDirectory;
*/
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
class wxFontNameDirectory;
#endif
// ----------------------------------------------------------------------------
// global variables
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
/*
extern wxFontNameDirectory *wxTheFontNameDirectory;
*/
extern const wxChar* wxEmptyString;
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
extern wxFontNameDirectory *wxTheFontNameDirectory;
#endif
// ----------------------------------------------------------------------------
// wxFont
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxFont: public wxGDIObject
class wxFont : public wxFontBase
{
DECLARE_DYNAMIC_CLASS(wxFont)
public:
wxFont();
wxFont( int pointSize, int family, int style, int weight, bool underlined = FALSE,
const wxString& face = wxEmptyString );
wxFont( const wxFont& font );
~wxFont();
wxFont& operator = ( const wxFont& font );
bool operator == ( const wxFont& font ) const;
bool operator != ( const wxFont& font ) const;
bool Ok() const;
// ctors and such
wxFont() { Init(); }
wxFont(const wxFont& font) { Init(); Ref(font); }
int GetPointSize() const;
int GetFamily() const;
int GetStyle() const;
int GetWeight() const;
bool GetUnderlined() const;
// assignment
wxFont& operator=(const wxFont& font);
void SetPointSize( int pointSize );
void SetFamily( int family );
void SetStyle( int style );
void SetWeight( int weight );
void SetFaceName( const wxString& faceName );
void SetUnderlined( bool underlined );
wxString GetFaceName() const;
wxString GetFamilyString() const;
wxString GetStyleString() const;
wxString GetWeightString() const;
// implementation
wxFont( GdkFont* font, char *xFontName );
void Unshare();
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Init();
GdkFont* GetInternalFont(float scale = 1.0) const;
(void)Create(size, family, style, weight, underlined, face, encoding);
}
// no data :-)
bool Create(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
~wxFont();
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual int GetFamily() const;
virtual int GetStyle() const;
virtual int GetWeight() const;
virtual wxString GetFaceName() const;
virtual bool GetUnderlined() const;
virtual wxFontEncoding GetEncoding() const;
virtual void SetPointSize( int pointSize );
virtual void SetFamily( int family );
virtual void SetStyle( int style );
virtual void SetWeight( int weight );
virtual void SetFaceName( const wxString& faceName );
virtual void SetUnderlined( bool underlined );
virtual void SetEncoding(wxFontEncoding encoding);
// implementation from now on
wxFont( GdkFont* font, char *xFontName );
void Unshare();
GdkFont* GetInternalFont(float scale = 1.0) const;
// no data :-)
protected:
// common part of all ctors
void Init();
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
/*
//-----------------------------------------------------------------------------
#if wxUSE_FONTNAMEDIRECTORY
// ----------------------------------------------------------------------------
// wxFontDirectory
//-----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
class wxFontNameDirectory: public wxObject
{
@@ -118,6 +149,7 @@ class wxFontNameDirectory: public wxObject
class wxHashTable *table;
int nextFontId;
};
*/
#endif // wxUSE_FONTNAMEDIRECTORY
#endif // __GTKFONTH__

View File

@@ -13,88 +13,85 @@
#define _WX_FONT_H_
#ifdef __GNUG__
#pragma interface "font.h"
#pragma interface "font.h"
#endif
#include "wx/gdiobj.h"
class WXDLLEXPORT wxFont;
class WXDLLEXPORT wxFontRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxFont;
public:
wxFontRefData(void);
wxFontRefData(const wxFontRefData& data);
~wxFontRefData(void);
protected:
bool m_temporary; // If TRUE, the pointer to the actual font
// is temporary and SHOULD NOT BE DELETED by
// destructor
int m_pointSize;
int m_family;
int m_fontId;
int m_style;
int m_weight;
bool m_underlined;
wxString m_faceName;
WXHFONT m_hFont;
};
#define M_FONTDATA ((wxFontRefData *)m_refData)
WXDLLEXPORT_DATA(extern const wxChar*) wxEmptyString;
// Font
class WXDLLEXPORT wxFont: public wxGDIObject
// ----------------------------------------------------------------------------
// wxFont
// ----------------------------------------------------------------------------
class WXDLLEXPORT wxFont : public wxFontBase
{
DECLARE_DYNAMIC_CLASS(wxFont)
public:
wxFont(void);
wxFont(int PointSize, int Family, int Style, int Weight, bool underlined = FALSE, const wxString& Face = wxEmptyString);
inline wxFont(const wxFont& font) { Ref(font); }
// ctors and such
wxFont() { Init(); }
wxFont(const wxFont& font) { Init(); Ref(font); }
~wxFont(void);
wxFont(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT)
{
Init();
bool Create(int PointSize, int Family, int Style, int Weight, bool underlined = FALSE, const wxString& Face = wxEmptyString);
(void)Create(size, family, style, weight, underlined, face, encoding);
}
// Internal
virtual bool RealizeResource(void);
virtual WXHANDLE GetResourceHandle(void) ;
virtual bool FreeResource(bool force = FALSE);
/*
virtual bool UseResource(void);
virtual bool ReleaseResource(void);
*/
bool Create(int size,
int family,
int style,
int weight,
bool underlined = FALSE,
const wxString& face = wxEmptyString,
wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
virtual bool IsFree() const;
virtual bool Ok(void) const { return (m_refData != NULL) ; }
virtual ~wxFont();
inline int GetPointSize(void) const { return M_FONTDATA->m_pointSize; }
inline int GetFamily(void) const { return M_FONTDATA->m_family; }
inline int GetFontId(void) const { return M_FONTDATA->m_fontId; } /* New font system */
inline int GetStyle(void) const { return M_FONTDATA->m_style; }
inline int GetWeight(void) const { return M_FONTDATA->m_weight; }
wxString GetFamilyString(void) const ;
wxString GetFaceName(void) const ;
wxString GetStyleString(void) const ;
wxString GetWeightString(void) const ;
inline bool GetUnderlined(void) const { return M_FONTDATA->m_underlined; }
// implement base class pure virtuals
virtual int GetPointSize() const;
virtual int GetFamily() const;
virtual int GetStyle() const;
virtual int GetWeight() const;
virtual bool GetUnderlined() const;
virtual wxString GetFaceName() const;
virtual wxFontEncoding GetEncoding() const;
void SetPointSize(int pointSize);
void SetFamily(int family);
void SetStyle(int style);
void SetWeight(int weight);
void SetFaceName(const wxString& faceName);
void SetUnderlined(bool underlined);
virtual void SetPointSize(int pointSize);
virtual void SetFamily(int family);
virtual void SetStyle(int style);
virtual void SetWeight(int weight);
virtual void SetFaceName(const wxString& faceName);
virtual void SetUnderlined(bool underlined);
virtual void SetEncoding(wxFontEncoding encoding);
wxFont& operator = (const wxFont& font) { if (*this == font) return (*this); Ref(font); return *this; }
bool operator == (const wxFont& font) const { return m_refData == font.m_refData; }
bool operator != (const wxFont& font) const { return m_refData != font.m_refData; }
// implementation only from now on
// -------------------------------
int GetFontId() const;
virtual bool IsFree() const;
virtual bool RealizeResource();
virtual WXHANDLE GetResourceHandle();
virtual bool FreeResource(bool force = FALSE);
/*
virtual bool UseResource();
virtual bool ReleaseResource();
*/
protected:
void Unshare();
// common part of all ctors
void Init();
void Unshare();
private:
DECLARE_DYNAMIC_CLASS(wxFont)
};
#endif