]> git.saurik.com Git - wxWidgets.git/commitdiff
added ctor taking wxFontFlags
authorVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 Nov 2002 23:58:52 +0000 (23:58 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sat, 2 Nov 2002 23:58:52 +0000 (23:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@17669 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/latex/wx/font.tex
include/wx/font.h
src/common/fontcmn.cpp

index 88e178c68ac029e7c8117687cce7b047b1247c1f..8d920e7c3b2eb3c14585e2f66035784f11a7a355 100644 (file)
@@ -15,6 +15,32 @@ a window's text.
 
 \wxheading{Constants}
 
+The font flags which can be used during the font creation are:
+\begin{verbatim}
+enum
+{
+    // no special flags: font with default weight/slant/anti-aliasing
+    wxFONTFLAG_DEFAULT          = 0,
+
+    // slant flags (default: no slant)
+    wxFONTFLAG_ITALIC           = 1 << 0,
+    wxFONTFLAG_SLANT            = 1 << 1,
+
+    // weight flags (default: medium)
+    wxFONTFLAG_LIGHT            = 1 << 2,
+    wxFONTFLAG_BOLD             = 1 << 3,
+
+    // anti-aliasing flag: force on or off (default: the current system default)
+    wxFONTFLAG_ANTIALIASED      = 1 << 4,
+    wxFONTFLAG_NOT_ANTIALIASED  = 1 << 5,
+
+    // underlined/strikethrough flags (default: no lines)
+    wxFONTFLAG_UNDERLINED       = 1 << 6,
+    wxFONTFLAG_STRIKETHROUGH    = 1 << 7,
+};
+\end{verbatim}
+
+The known font encodings are:
 \begin{verbatim}
 enum wxFontEncoding
 {
index c627010124406d5edfa7ca4f1bd25755c3c86212..e519bad84d2ca5a72a6b115d529b283159d08071 100644 (file)
@@ -71,6 +71,39 @@ enum wxFontWeight
     wxFONTWEIGHT_MAX
 };
 
+// the font flag bits for the new font ctor accepting one combined flags word
+enum
+{
+    // no special flags: font with default weight/slant/anti-aliasing
+    wxFONTFLAG_DEFAULT          = 0,
+
+    // slant flags (default: no slant)
+    wxFONTFLAG_ITALIC           = 1 << 0,
+    wxFONTFLAG_SLANT            = 1 << 1,
+
+    // weight flags (default: medium)
+    wxFONTFLAG_LIGHT            = 1 << 2,
+    wxFONTFLAG_BOLD             = 1 << 3,
+
+    // anti-aliasing flag: force on or off (default: the current system default)
+    wxFONTFLAG_ANTIALIASED      = 1 << 4,
+    wxFONTFLAG_NOT_ANTIALIASED  = 1 << 5,
+
+    // underlined/strikethrough flags (default: no lines)
+    wxFONTFLAG_UNDERLINED       = 1 << 6,
+    wxFONTFLAG_STRIKETHROUGH    = 1 << 7,
+
+    // the mask of all currently used flags
+    wxFONTFLAG_MASK = wxFONTFLAG_ITALIC             |
+                      wxFONTFLAG_SLANT              |
+                      wxFONTFLAG_LIGHT              |
+                      wxFONTFLAG_BOLD               |
+                      wxFONTFLAG_ANTIALIASED        |
+                      wxFONTFLAG_NOT_ANTIALIASED    |
+                      wxFONTFLAG_UNDERLINED         |
+                      wxFONTFLAG_STRIKETHROUGH
+};
+
 // ----------------------------------------------------------------------------
 // wxFontBase represents a font object
 // ----------------------------------------------------------------------------
@@ -94,6 +127,14 @@ public:
         const wxString& face = wxEmptyString,              // facename
         wxFontEncoding encoding = wxFONTENCODING_DEFAULT); // ISO8859-X, ...
 
+    // from the font components but using the font flags instead of separate
+    // parameters for each flag
+    static wxFont *New(int pointSize,
+                       wxFontFamily family,
+                       int flags = wxFONTFLAG_DEFAULT,
+                       const wxString& face = wxEmptyString,
+                       wxFontEncoding encoding = wxFONTENCODING_DEFAULT);
+
     // from the (opaque) native font description object
     static wxFont *New(const wxNativeFontInfo& nativeFontDesc);
 
index 9f09b4c8e188814e8f936c7ca7daa02877808329..df7590c8061c919f29136aa07f2fee4f86bb5b25 100644 (file)
@@ -77,6 +77,33 @@ wxFont *wxFontBase::New(int size,
     return new wxFont(size, family, style, weight, underlined, face, encoding);
 }
 
+/* static */
+wxFont *wxFontBase::New(int pointSize,
+                        wxFontFamily family,
+                        int flags,
+                        const wxString& face,
+                        wxFontEncoding encoding)
+{
+    return New
+           (
+                pointSize,
+                family,
+                flags & wxFONTFLAG_ITALIC
+                    ? wxFONTSTYLE_ITALIC
+                    : flags & wxFONTFLAG_SLANT
+                        ? wxFONTSTYLE_SLANT
+                        : wxFONTSTYLE_NORMAL,
+                flags & wxFONTFLAG_LIGHT
+                    ? wxFONTWEIGHT_LIGHT
+                    : flags & wxFONTFLAG_BOLD
+                        ? wxFONTWEIGHT_BOLD
+                        : wxFONTWEIGHT_NORMAL,
+                (flags & wxFONTFLAG_UNDERLINED) != 0,
+                face,
+                encoding
+           );
+}
+
 /* static */
 wxFont *wxFontBase::New(const wxNativeFontInfo& info)
 {