1. wxFontMapper seems to work for wxMSW
2. font functions moved into a separate file, duplicated code in font.cpp and fontdlg.cpp removed 3. wxCustomDataObject docs finished git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4382 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -7,6 +7,25 @@ ones). The only restriction is that it is supposed that this data can be
|
|||||||
copied bitwise (i.e. with {\tt memcpy()}), so it would be a bad idea to make
|
copied bitwise (i.e. with {\tt memcpy()}), so it would be a bad idea to make
|
||||||
it contain a C++ object (though C struct is fine).
|
it contain a C++ object (though C struct is fine).
|
||||||
|
|
||||||
|
By default, wxCustomDataObject stores the data inside in a buffer. To put the
|
||||||
|
data into the buffer you may use either
|
||||||
|
\helpref{SetData}{wxcustomdataobjectsetdata} or
|
||||||
|
\helpref{TakeData}{wxcustomdataobjecttakedata} depending on whether you want
|
||||||
|
the object to make a copy of data or not.
|
||||||
|
|
||||||
|
If you already store the data in another place, it may be more convenient and
|
||||||
|
efficient to provide the data on-demand which is possible too if you override
|
||||||
|
the virtual functions mentioned below.
|
||||||
|
|
||||||
|
\wxheading{Virtual functions to override}
|
||||||
|
|
||||||
|
This class may be used as is, but if you don't want store the data inside the
|
||||||
|
object but provide it on demand instead, you should override
|
||||||
|
\helpref{GetSize}{wxcustomdataobjectgetsize},
|
||||||
|
\helpref{GetData}{wxcustomdataobjectgetdata} and
|
||||||
|
\helpref{SetData}{wxcustomdataobjectsetdata} (or may be only the first two or
|
||||||
|
only the last one if you only allow reading/writing the data)
|
||||||
|
|
||||||
\wxheading{Derived from}
|
\wxheading{Derived from}
|
||||||
|
|
||||||
\helpref{wxDataObjectSimple}{wxdataobjectsimple}
|
\helpref{wxDataObjectSimple}{wxdataobjectsimple}
|
||||||
@@ -41,22 +60,48 @@ functions from constructors or destructors), so if you override {\tt Free()}, yo
|
|||||||
should override the destructor in your class as well (which would probably
|
should override the destructor in your class as well (which would probably
|
||||||
just call the derived class' version of {\tt Free()}).
|
just call the derived class' version of {\tt Free()}).
|
||||||
|
|
||||||
|
\membersection{wxCustomDataObject::Alloc}\label{wxcustomdataobjectalloc}
|
||||||
|
|
||||||
\membersection{wxCustomDataObject::SetData}\label{wxcustomdataobjectsetdata}
|
\func{virtual void *}{Alloc}{\param{size\_t }{size}}
|
||||||
|
|
||||||
\func{virtual void}{SetData}{\param{const char }{*data}, \param{size\_t }{size}}
|
This function is called to allocate {\it size} bytes of memory from SetData().
|
||||||
|
The default version just uses the operator new.
|
||||||
|
|
||||||
Set the data. The data object will make an internal copy.
|
\membersection{wxCustomDataObject::Free}\label{wxcustomdataobjectfree}
|
||||||
|
|
||||||
|
\func{virtual void}{Free}{\void}
|
||||||
|
|
||||||
|
This function is called when the data is freed, you may override it to anything
|
||||||
|
you want (or may be nothing at all). The default version calls operator
|
||||||
|
delete\[\] on the data.
|
||||||
|
|
||||||
\membersection{wxCustomDataObject::GetSize}\label{wxcustomdataobjectgetsize}
|
\membersection{wxCustomDataObject::GetSize}\label{wxcustomdataobjectgetsize}
|
||||||
|
|
||||||
\constfunc{virtual size\_t}{GetDataSize}{\void}
|
\constfunc{virtual size\_t}{GetSize}{\void}
|
||||||
|
|
||||||
Returns the data size.
|
Returns the data size in bytes.
|
||||||
|
|
||||||
\membersection{wxCustomDataObject::GetData}\label{wxcustomdataobjectgetdata}
|
\membersection{wxCustomDataObject::GetData}\label{wxcustomdataobjectgetdata}
|
||||||
|
|
||||||
\func{virtual char*}{GetData}{\void}
|
\constfunc{virtual void *}{GetData}{\void}
|
||||||
|
|
||||||
Returns a pointer to the data.
|
Returns a pointer to the data.
|
||||||
|
|
||||||
|
\membersection{wxCustomDataObject::SetData}\label{wxcustomdataobjectsetdata}
|
||||||
|
|
||||||
|
\func{virtual void}{SetData}{
|
||||||
|
\param{size\_t }{size},
|
||||||
|
\param{const void }{*data}
|
||||||
|
}
|
||||||
|
|
||||||
|
Set the data. The data object will make an internal copy.
|
||||||
|
|
||||||
|
\membersection{wxCustomDataObject::TakeData}\label{wxcustomdataobjecttakedata}
|
||||||
|
|
||||||
|
\func{virtual void}{TakeData}{
|
||||||
|
\param{size\_t }{size},
|
||||||
|
\param{const void }{*data}
|
||||||
|
}
|
||||||
|
|
||||||
|
Like \helpref{SetData}{wxcustomdataobjectsetdata}, but doesn't copy the data -
|
||||||
|
instead the object takes ownership of the pointer.
|
||||||
|
@@ -54,6 +54,8 @@ struct wxNativeEncodingInfo
|
|||||||
wxString facename; // may be empty meaning "any"
|
wxString facename; // may be empty meaning "any"
|
||||||
|
|
||||||
#if defined(__WXMSW__)
|
#if defined(__WXMSW__)
|
||||||
|
wxNativeEncodingInfo() { charset = 0; /* ANSI_CHARSET */ }
|
||||||
|
|
||||||
int charset;
|
int charset;
|
||||||
#elif defined(_WX_X_FONTLIKE)
|
#elif defined(_WX_X_FONTLIKE)
|
||||||
wxString xregistry,
|
wxString xregistry,
|
||||||
|
@@ -16,15 +16,6 @@
|
|||||||
#pragma interface "font.h"
|
#pragma interface "font.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// public functions
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
// convert wxFontEncoding into one of Windows XXX_CHARSET constants (fill exact
|
|
||||||
// parameter if it's not NULL with TRUE if encoding is realyl supported under
|
|
||||||
// Windows and FALSE if not and we just chose something close to it)
|
|
||||||
extern int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact = NULL);
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxFont
|
// wxFont
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -9,38 +9,38 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#ifndef _WX_FONTDLG_H_
|
#ifndef _WX_MSW_FONTDLG_H_
|
||||||
#define _WX_FONTDLG_H_
|
#define _WX_MSW_FONTDLG_H_
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma interface "fontdlg.h"
|
#pragma interface "fontdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/dialog.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/cmndata.h"
|
#include "wx/cmndata.h"
|
||||||
|
|
||||||
/*
|
// ----------------------------------------------------------------------------
|
||||||
* FONT DIALOG
|
// wxFontDialog
|
||||||
*/
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxFontDialog: public wxDialog
|
class WXDLLEXPORT wxFontDialog : public wxDialog
|
||||||
{
|
{
|
||||||
DECLARE_DYNAMIC_CLASS(wxFontDialog)
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxFontDialog(void);
|
wxFontDialog();
|
||||||
wxFontDialog(wxWindow *parent, wxFontData *data = NULL);
|
wxFontDialog(wxWindow *parent, wxFontData *data = NULL);
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxFontData *data = NULL);
|
bool Create(wxWindow *parent, wxFontData *data = NULL);
|
||||||
|
|
||||||
int ShowModal(void);
|
virtual int ShowModal();
|
||||||
wxFontData& GetFontData(void) { return m_fontData; }
|
|
||||||
|
wxFontData& GetFontData() { return m_fontData; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxWindow *m_dialogParent;
|
|
||||||
wxFontData m_fontData;
|
wxFontData m_fontData;
|
||||||
|
|
||||||
|
DECLARE_DYNAMIC_CLASS(wxFontDialog)
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
// _WX_FONTDLG_H_
|
// _WX_MSW_FONTDLG_H_
|
||||||
|
|
||||||
|
@@ -52,10 +52,15 @@ WXDLLEXPORT_DATA(extern HICON) wxDEFAULT_MDICHILDFRAME_ICON;
|
|||||||
WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
|
WXDLLEXPORT_DATA(extern HFONT) wxSTATUS_LINE_FONT;
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// this defines a CASTWNDPROC macro which casts a pointer to the type of a
|
// define things missing from some compilers' headers
|
||||||
// window proc
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
|
||||||
|
inline void ZeroMemory(void *buf, size_t len) { memset(buf, 0, len); }
|
||||||
|
#endif // old mingw32
|
||||||
|
|
||||||
|
// this defines a CASTWNDPROC macro which casts a pointer to the type of a
|
||||||
|
// window proc
|
||||||
#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
|
#if defined(__GNUWIN32__) && !defined(wxUSE_NORLANDER_HEADERS)
|
||||||
# define CASTWNDPROC (long unsigned)
|
# define CASTWNDPROC (long unsigned)
|
||||||
#else
|
#else
|
||||||
@@ -205,6 +210,24 @@ extern LONG APIENTRY _EXPORT
|
|||||||
extern void OutputDebugStringW95(const wxChar*, ...);
|
extern void OutputDebugStringW95(const wxChar*, ...);
|
||||||
#endif // USE_DBWIN32
|
#endif // USE_DBWIN32
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// useful macros and functions
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// a wrapper macro for ZeroMemory()
|
||||||
|
#define wxZeroMemory(obj) ::ZeroMemory(&obj, sizeof(obj))
|
||||||
|
|
||||||
|
// make conversion from wxColour and COLORREF a bit less painful
|
||||||
|
inline COLORREF wxColourToRGB(const wxColour& c)
|
||||||
|
{
|
||||||
|
return RGB(c.Red(), c.Green(), c.Blue());
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void wxRGBToColour(wxColour& c, COLORREF rgb)
|
||||||
|
{
|
||||||
|
c.Set(GetRValue(rgb), GetGValue(rgb), GetBValue(rgb));
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
|
// macros to make casting between WXFOO and FOO a bit easier: the GetFoo()
|
||||||
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
|
// returns Foo cast to the Windows type for oruselves, while GetFooOf() takes
|
||||||
@@ -220,6 +243,9 @@ extern LONG APIENTRY _EXPORT
|
|||||||
#define GetHdc() ((HDC)GetHDC())
|
#define GetHdc() ((HDC)GetHDC())
|
||||||
#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
|
#define GetHdcOf(dc) ((HDC)(dc).GetHDC())
|
||||||
|
|
||||||
|
#define GetHbitmap() ((HBITMAP)GetHBITMAP())
|
||||||
|
#define GetHbitmapOf(bmp) ((HBITMAP)(bmp).GetHBITMAP())
|
||||||
|
|
||||||
#define GetHicon() ((HICON)GetHICON())
|
#define GetHicon() ((HICON)GetHICON())
|
||||||
#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
|
#define GetHiconOf(icon) ((HICON)(icon).GetHICON())
|
||||||
|
|
||||||
@@ -252,8 +278,8 @@ WXDLLEXPORT void wxSetInstance(HINSTANCE hInst);
|
|||||||
WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
|
WXDLLEXPORT wxWindow* wxFindWinFromHandle(WXHWND hWnd);
|
||||||
|
|
||||||
WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
|
WXDLLEXPORT void wxGetCharSize(WXHWND wnd, int *x, int *y,wxFont *the_font);
|
||||||
WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, wxFont *font);
|
WXDLLEXPORT void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
|
||||||
WXDLLEXPORT wxFont wxCreateFontFromLogFont(LOGFONT *logFont);
|
WXDLLEXPORT wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
|
||||||
|
|
||||||
WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
|
WXDLLEXPORT void wxSliderEvent(WXHWND control, WXWORD wParam, WXWORD pos);
|
||||||
WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
|
WXDLLEXPORT void wxScrollBarEvent(WXHWND hbar, WXWORD wParam, WXWORD pos);
|
||||||
|
@@ -305,7 +305,7 @@ bool MyFrame::DoEnumerateFamilies(bool fixedWidthOnly,
|
|||||||
facenames[n] = fontEnumerator.GetFacenames().Item(n);
|
facenames[n] = fontEnumerator.GetFacenames().Item(n);
|
||||||
|
|
||||||
if ( silent )
|
if ( silent )
|
||||||
n = 1;
|
n = 0;
|
||||||
else
|
else
|
||||||
n = wxGetSingleChoiceIndex("Choose a facename", "Font demo",
|
n = wxGetSingleChoiceIndex("Choose a facename", "Font demo",
|
||||||
nFacenames, facenames, this);
|
nFacenames, facenames, this);
|
||||||
@@ -542,10 +542,9 @@ BEGIN_EVENT_TABLE(MyCanvas, wxWindow)
|
|||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
MyCanvas::MyCanvas( wxWindow *parent )
|
MyCanvas::MyCanvas( wxWindow *parent )
|
||||||
: wxWindow( parent, -1 )
|
: wxWindow( parent, -1 ),
|
||||||
|
m_colour(*wxRED), m_font(*wxNORMAL_FONT)
|
||||||
{
|
{
|
||||||
m_font = *wxNORMAL_FONT;
|
|
||||||
m_colour = *wxRED;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MyCanvas::~MyCanvas()
|
MyCanvas::~MyCanvas()
|
||||||
|
@@ -438,9 +438,9 @@ wxFontEncoding wxFontMapper::CharsetToEncoding(const wxString& charset,
|
|||||||
|
|
||||||
wxString *encodingNamesTranslated = new wxString[count];
|
wxString *encodingNamesTranslated = new wxString[count];
|
||||||
|
|
||||||
for ( size_t n = 0; n < count; n++ )
|
for ( size_t i = 0; i < count; i++ )
|
||||||
{
|
{
|
||||||
encodingNamesTranslated[n] = wxGetTranslation(gs_encodingDescs[n]);
|
encodingNamesTranslated[i] = wxGetTranslation(gs_encodingDescs[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// the parent window
|
// the parent window
|
||||||
@@ -564,8 +564,7 @@ bool wxFontMapper::GetAltForEncoding(wxFontEncoding encoding,
|
|||||||
wxFontData retData = dialog.GetFontData();
|
wxFontData retData = dialog.GetFontData();
|
||||||
wxFont font = retData.GetChosenFont();
|
wxFont font = retData.GetChosenFont();
|
||||||
|
|
||||||
info->xregistry = retData.EncodingInfo().xregistry;
|
*info = retData.EncodingInfo();
|
||||||
info->xencoding = retData.EncodingInfo().xencoding;
|
|
||||||
|
|
||||||
// remember this in the config
|
// remember this in the config
|
||||||
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) )
|
if ( ChangePath(FONTMAPPER_FONT_FROM_ENCODING_PATH, &pathOld) )
|
||||||
|
233
src/msw/font.cpp
233
src/msw/font.cpp
@@ -205,156 +205,17 @@ bool wxFont::RealizeResource()
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int ff_family = 0;
|
LOGFONT lf;
|
||||||
wxString ff_face;
|
wxFillLogFont(&lf, this);
|
||||||
|
M_FONTDATA->m_hFont = (WXHFONT)::CreateFontIndirect(&lf);
|
||||||
switch ( M_FONTDATA->m_family )
|
if ( !M_FONTDATA->m_hFont )
|
||||||
{
|
|
||||||
case wxSCRIPT:
|
|
||||||
ff_family = FF_SCRIPT ;
|
|
||||||
ff_face = wxT("Script") ;
|
|
||||||
break ;
|
|
||||||
|
|
||||||
case wxDECORATIVE:
|
|
||||||
ff_family = FF_DECORATIVE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxROMAN:
|
|
||||||
ff_family = FF_ROMAN;
|
|
||||||
ff_face = wxT("Times New Roman") ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxTELETYPE:
|
|
||||||
case wxMODERN:
|
|
||||||
ff_family = FF_MODERN;
|
|
||||||
ff_face = wxT("Courier New") ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxSWISS:
|
|
||||||
ff_family = FF_SWISS;
|
|
||||||
ff_face = wxT("Arial") ;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxDEFAULT:
|
|
||||||
default:
|
|
||||||
ff_family = FF_SWISS;
|
|
||||||
ff_face = wxT("Arial") ;
|
|
||||||
}
|
|
||||||
|
|
||||||
BYTE ff_italic;
|
|
||||||
switch ( M_FONTDATA->m_style )
|
|
||||||
{
|
|
||||||
case wxITALIC:
|
|
||||||
case wxSLANT:
|
|
||||||
ff_italic = 1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG(wxT("unknown font slant"));
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case wxNORMAL:
|
|
||||||
ff_italic = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ff_weight = 0;
|
|
||||||
switch ( M_FONTDATA->m_weight )
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG(wxT("unknown font weight"));
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case wxNORMAL:
|
|
||||||
ff_weight = FW_NORMAL;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxLIGHT:
|
|
||||||
ff_weight = FW_LIGHT;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxBOLD:
|
|
||||||
ff_weight = FW_BOLD;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wxChar* pzFace;
|
|
||||||
if ( M_FONTDATA->m_faceName.IsEmpty() )
|
|
||||||
pzFace = ff_face;
|
|
||||||
else
|
|
||||||
pzFace = M_FONTDATA->m_faceName ;
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* Always calculate fonts using the screen DC (is this the best strategy?)
|
|
||||||
* There may be confusion if a font is selected into a printer
|
|
||||||
* DC (say), because the height will be calculated very differently.
|
|
||||||
*/
|
|
||||||
// What sort of display is it?
|
|
||||||
int technology = ::GetDeviceCaps(dc, TECHNOLOGY);
|
|
||||||
|
|
||||||
int nHeight;
|
|
||||||
|
|
||||||
if (technology != DT_RASDISPLAY && technology != DT_RASPRINTER)
|
|
||||||
{
|
|
||||||
// Have to get screen DC Caps, because a metafile will return 0.
|
|
||||||
HDC dc2 = ::GetDC(NULL);
|
|
||||||
nHeight = M_FONTDATA->m_pointSize*GetDeviceCaps(dc2, LOGPIXELSY)/72;
|
|
||||||
::ReleaseDC(NULL, dc2);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
nHeight = M_FONTDATA->m_pointSize*GetDeviceCaps(dc, LOGPIXELSY)/72;
|
|
||||||
}
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
#if 0
|
|
||||||
// Have to get screen DC Caps, because a metafile will return 0.
|
|
||||||
HDC dc2 = ::GetDC(NULL);
|
|
||||||
ppInch = ::GetDeviceCaps(dc2, LOGPIXELSY);
|
|
||||||
::ReleaseDC(NULL, dc2);
|
|
||||||
#endif // 0
|
|
||||||
|
|
||||||
// New behaviour: apparently ppInch varies according to Large/Small Fonts
|
|
||||||
// setting in Windows. This messes up fonts. So, set ppInch to a constant
|
|
||||||
// 96 dpi.
|
|
||||||
static const int ppInch = 96;
|
|
||||||
|
|
||||||
#if wxFONT_SIZE_COMPATIBILITY
|
|
||||||
// Incorrect, but compatible with old wxWindows behaviour
|
|
||||||
int nHeight = (M_FONTDATA->m_pointSize*ppInch/72);
|
|
||||||
#else
|
|
||||||
// Correct for Windows compatibility
|
|
||||||
int nHeight = - (M_FONTDATA->m_pointSize*ppInch/72);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
BYTE ff_underline = M_FONTDATA->m_underlined;
|
|
||||||
|
|
||||||
DWORD charset = wxCharsetFromEncoding(GetEncoding());
|
|
||||||
HFONT hFont = ::CreateFont
|
|
||||||
(
|
|
||||||
nHeight, // height
|
|
||||||
0, // width (choose best)
|
|
||||||
0, // escapement
|
|
||||||
0, // orientation
|
|
||||||
ff_weight, // weight
|
|
||||||
ff_italic, // italic?
|
|
||||||
ff_underline, // underlined?
|
|
||||||
0, // strikeout?
|
|
||||||
charset, // charset
|
|
||||||
OUT_DEFAULT_PRECIS, // precision
|
|
||||||
CLIP_DEFAULT_PRECIS, // clip precision
|
|
||||||
PROOF_QUALITY, // quality of match
|
|
||||||
DEFAULT_PITCH | // fixed or variable
|
|
||||||
ff_family, // family id
|
|
||||||
pzFace // face name
|
|
||||||
);
|
|
||||||
|
|
||||||
M_FONTDATA->m_hFont = (WXHFONT)hFont;
|
|
||||||
if ( !hFont )
|
|
||||||
{
|
{
|
||||||
wxLogLastError("CreateFont");
|
wxLogLastError("CreateFont");
|
||||||
|
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return hFont != 0;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::FreeResource(bool force)
|
bool wxFont::FreeResource(bool force)
|
||||||
@@ -378,7 +239,7 @@ WXHANDLE wxFont::GetResourceHandle()
|
|||||||
if ( !M_FONTDATA )
|
if ( !M_FONTDATA )
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
return (WXHANDLE)M_FONTDATA->m_hFont ;
|
return (WXHANDLE)M_FONTDATA->m_hFont;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFont::IsFree() const
|
bool wxFont::IsFree() const
|
||||||
@@ -506,7 +367,7 @@ wxString wxFont::GetFaceName() const
|
|||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
if ( M_FONTDATA )
|
if ( M_FONTDATA )
|
||||||
str = M_FONTDATA->m_faceName ;
|
str = M_FONTDATA->m_faceName;
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -515,79 +376,3 @@ wxFontEncoding wxFont::GetEncoding() const
|
|||||||
return M_FONTDATA->m_encoding;
|
return M_FONTDATA->m_encoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
// public functions
|
|
||||||
// ----------------------------------------------------------------------------
|
|
||||||
|
|
||||||
int wxCharsetFromEncoding(wxFontEncoding encoding, bool *exact)
|
|
||||||
{
|
|
||||||
if ( encoding == wxFONTENCODING_DEFAULT )
|
|
||||||
{
|
|
||||||
encoding = wxFont::GetDefaultEncoding();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( exact )
|
|
||||||
*exact = TRUE;
|
|
||||||
|
|
||||||
int charset;
|
|
||||||
switch ( encoding )
|
|
||||||
{
|
|
||||||
case wxFONTENCODING_ISO8859_1:
|
|
||||||
case wxFONTENCODING_ISO8859_15:
|
|
||||||
case wxFONTENCODING_CP1250:
|
|
||||||
charset = ANSI_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
#if !defined(__WIN16__)
|
|
||||||
case wxFONTENCODING_ISO8859_2:
|
|
||||||
case wxFONTENCODING_CP1252:
|
|
||||||
charset = EASTEUROPE_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_4:
|
|
||||||
case wxFONTENCODING_ISO8859_10:
|
|
||||||
charset = BALTIC_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_5:
|
|
||||||
case wxFONTENCODING_CP1251:
|
|
||||||
charset = RUSSIAN_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_6:
|
|
||||||
charset = ARABIC_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_7:
|
|
||||||
charset = GREEK_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_8:
|
|
||||||
charset = HEBREW_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_9:
|
|
||||||
charset = TURKISH_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case wxFONTENCODING_ISO8859_11:
|
|
||||||
charset = THAI_CHARSET;
|
|
||||||
break;
|
|
||||||
#endif // BC++ 16-bit
|
|
||||||
|
|
||||||
case wxFONTENCODING_CP437:
|
|
||||||
charset = OEM_CHARSET;
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
if ( exact )
|
|
||||||
*exact = FALSE;
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case wxFONTENCODING_SYSTEM:
|
|
||||||
charset = ANSI_CHARSET;
|
|
||||||
}
|
|
||||||
|
|
||||||
return charset;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@@ -9,30 +9,35 @@
|
|||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation "fontdlg.h"
|
#pragma implementation "fontdlg.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// For compilers that support precompilation, includes "wx.h".
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
#include "wx/wxprec.h"
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
#ifdef __BORLANDC__
|
#ifdef __BORLANDC__
|
||||||
#pragma hdrstop
|
#pragma hdrstop
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
#include "wx/defs.h"
|
||||||
#include "wx/defs.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/utils.h"
|
#include "wx/dialog.h"
|
||||||
#include "wx/dialog.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/fontdlg.h"
|
#include "wx/fontdlg.h"
|
||||||
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
|
#if !defined(__WIN32__) || defined(__SALFORDC__) || defined(__WXWINE__)
|
||||||
#include <commdlg.h>
|
#include <commdlg.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
@@ -42,21 +47,25 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define wxDIALOG_DEFAULT_X 300
|
// ----------------------------------------------------------------------------
|
||||||
#define wxDIALOG_DEFAULT_Y 300
|
// wxWin macros
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
#if !USE_SHARED_LIBRARY
|
#if !USE_SHARED_LIBRARY
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
|
IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/*
|
// ============================================================================
|
||||||
* wxFontDialog
|
// implementation
|
||||||
*/
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFontDialog
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxFontDialog::wxFontDialog(void)
|
wxFontDialog::wxFontDialog()
|
||||||
{
|
{
|
||||||
m_dialogParent = NULL;
|
m_parent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontDialog::wxFontDialog(wxWindow *parent, wxFontData *data)
|
wxFontDialog::wxFontDialog(wxWindow *parent, wxFontData *data)
|
||||||
@@ -66,42 +75,54 @@ wxFontDialog::wxFontDialog(wxWindow *parent, wxFontData *data)
|
|||||||
|
|
||||||
bool wxFontDialog::Create(wxWindow *parent, wxFontData *data)
|
bool wxFontDialog::Create(wxWindow *parent, wxFontData *data)
|
||||||
{
|
{
|
||||||
m_dialogParent = parent;
|
m_parent = parent;
|
||||||
|
|
||||||
|
wxCHECK_MSG( data, FALSE, _T("no font data in wxFontDialog") );
|
||||||
|
|
||||||
if (data)
|
|
||||||
m_fontData = *data;
|
m_fontData = *data;
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxFontDialog::ShowModal(void)
|
int wxFontDialog::ShowModal()
|
||||||
{
|
{
|
||||||
CHOOSEFONT chooseFontStruct;
|
DWORD flags = CF_SCREENFONTS | CF_NOSIMULATIONS;
|
||||||
|
|
||||||
LOGFONT logFont;
|
LOGFONT logFont;
|
||||||
|
|
||||||
DWORD flags = CF_TTONLY | CF_SCREENFONTS | CF_NOSIMULATIONS;
|
CHOOSEFONT chooseFontStruct;
|
||||||
|
wxZeroMemory(chooseFontStruct);
|
||||||
memset(&chooseFontStruct, 0, sizeof(CHOOSEFONT));
|
|
||||||
|
|
||||||
chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
|
chooseFontStruct.lStructSize = sizeof(CHOOSEFONT);
|
||||||
chooseFontStruct.hwndOwner = (HWND) (m_dialogParent ? (HWND) m_dialogParent->GetHWND() : NULL);
|
if ( m_parent )
|
||||||
|
chooseFontStruct.hwndOwner = GetHwndOf(m_parent);
|
||||||
chooseFontStruct.lpLogFont = &logFont;
|
chooseFontStruct.lpLogFont = &logFont;
|
||||||
|
|
||||||
if (m_fontData.initialFont.Ok())
|
if ( m_fontData.initialFont.Ok() )
|
||||||
{
|
{
|
||||||
flags |= CF_INITTOLOGFONTSTRUCT;
|
flags |= CF_INITTOLOGFONTSTRUCT;
|
||||||
wxFillLogFont(&logFont, & m_fontData.initialFont);
|
wxFillLogFont(&logFont, &m_fontData.initialFont);
|
||||||
}
|
}
|
||||||
|
|
||||||
chooseFontStruct.iPointSize = 0;
|
chooseFontStruct.rgbColors = wxColourToRGB(m_fontData.fontColour);
|
||||||
chooseFontStruct.rgbColors = RGB((BYTE)m_fontData.fontColour.Red(), (BYTE)m_fontData.fontColour.Green(), (BYTE)m_fontData.fontColour.Blue());
|
|
||||||
|
|
||||||
if (!m_fontData.GetAllowSymbols())
|
// CF_ANSIONLY flag is obsolete for Win32
|
||||||
|
if ( !m_fontData.GetAllowSymbols() )
|
||||||
|
{
|
||||||
|
#ifdef __WIN16__
|
||||||
flags |= CF_ANSIONLY;
|
flags |= CF_ANSIONLY;
|
||||||
if (m_fontData.GetEnableEffects())
|
#else // Win32
|
||||||
|
flags |= CF_SELECTSCRIPT;
|
||||||
|
logFont.lfCharSet = ANSI_CHARSET;
|
||||||
|
#endif // Win16/32
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( m_fontData.GetEnableEffects() )
|
||||||
flags |= CF_EFFECTS;
|
flags |= CF_EFFECTS;
|
||||||
if (m_fontData.GetShowHelp())
|
if ( m_fontData.GetShowHelp() )
|
||||||
flags |= CF_SHOWHELP;
|
flags |= CF_SHOWHELP;
|
||||||
if (!(m_fontData.minSize == 0 && m_fontData.maxSize == 0))
|
|
||||||
|
if ( m_fontData.minSize != 0 || m_fontData.maxSize != 0 )
|
||||||
{
|
{
|
||||||
chooseFontStruct.nSizeMin = m_fontData.minSize;
|
chooseFontStruct.nSizeMin = m_fontData.minSize;
|
||||||
chooseFontStruct.nSizeMax = m_fontData.maxSize;
|
chooseFontStruct.nSizeMax = m_fontData.maxSize;
|
||||||
@@ -109,220 +130,30 @@ int wxFontDialog::ShowModal(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
chooseFontStruct.Flags = flags;
|
chooseFontStruct.Flags = flags;
|
||||||
chooseFontStruct.nFontType = SCREEN_FONTTYPE;
|
|
||||||
bool success = (ChooseFont(&(chooseFontStruct)) != 0);
|
|
||||||
|
|
||||||
// Restore values
|
if ( ChooseFont(&chooseFontStruct) != 0 )
|
||||||
if (success)
|
|
||||||
{
|
{
|
||||||
m_fontData.fontColour.Set(GetRValue(chooseFontStruct.rgbColors), GetGValue(chooseFontStruct.rgbColors),
|
wxRGBToColour(m_fontData.fontColour, chooseFontStruct.rgbColors);
|
||||||
GetBValue(chooseFontStruct.rgbColors));
|
|
||||||
m_fontData.chosenFont = wxCreateFontFromLogFont(&logFont);
|
m_fontData.chosenFont = wxCreateFontFromLogFont(&logFont);
|
||||||
|
m_fontData.EncodingInfo().facename = logFont.lfFaceName;
|
||||||
|
m_fontData.EncodingInfo().charset = logFont.lfCharSet;
|
||||||
|
|
||||||
|
return wxID_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
return success ? wxID_OK : wxID_CANCEL;
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxFillLogFont(LOGFONT *logFont, wxFont *font)
|
|
||||||
{
|
|
||||||
BYTE ff_italic;
|
|
||||||
int ff_weight = 0;
|
|
||||||
int ff_family = 0;
|
|
||||||
wxString ff_face("");
|
|
||||||
|
|
||||||
switch (font->GetFamily())
|
|
||||||
{
|
|
||||||
case wxSCRIPT: ff_family = FF_SCRIPT ;
|
|
||||||
ff_face = "Script" ;
|
|
||||||
break ;
|
|
||||||
case wxDECORATIVE: ff_family = FF_DECORATIVE;
|
|
||||||
break;
|
|
||||||
case wxROMAN: ff_family = FF_ROMAN;
|
|
||||||
ff_face = "Times New Roman" ;
|
|
||||||
break;
|
|
||||||
case wxTELETYPE:
|
|
||||||
case wxMODERN: ff_family = FF_MODERN;
|
|
||||||
ff_face = "Courier New" ;
|
|
||||||
break;
|
|
||||||
case wxSWISS: ff_family = FF_SWISS;
|
|
||||||
ff_face = "Arial";
|
|
||||||
break;
|
|
||||||
case wxDEFAULT:
|
|
||||||
default: ff_family = FF_SWISS;
|
|
||||||
ff_face = "MS Sans Serif" ;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (font->GetStyle() == wxITALIC || font->GetStyle() == wxSLANT)
|
|
||||||
ff_italic = 1;
|
|
||||||
else
|
else
|
||||||
ff_italic = 0;
|
{
|
||||||
|
// common dialog failed - why?
|
||||||
if (font->GetWeight() == wxNORMAL)
|
#ifdef __WXDEBUG__
|
||||||
ff_weight = FW_NORMAL;
|
DWORD dwErr = CommDlgExtendedError();
|
||||||
else if (font->GetWeight() == wxLIGHT)
|
if ( dwErr != 0 )
|
||||||
ff_weight = FW_LIGHT;
|
{
|
||||||
else if (font->GetWeight() == wxBOLD)
|
// this msg is only for developers
|
||||||
ff_weight = FW_BOLD;
|
wxLogError(wxT("Common dialog failed with error code %0lx."),
|
||||||
|
dwErr);
|
||||||
// Have to get screen DC Caps, because a metafile will return 0.
|
}
|
||||||
HDC dc2 = ::GetDC(NULL);
|
//else: it was just cancelled
|
||||||
int ppInch = ::GetDeviceCaps(dc2, LOGPIXELSY);
|
|
||||||
::ReleaseDC(NULL, dc2);
|
|
||||||
|
|
||||||
// New behaviour: apparently ppInch varies according to
|
|
||||||
// Large/Small Fonts setting in Windows. This messes
|
|
||||||
// up fonts. So, set ppInch to a constant 96 dpi.
|
|
||||||
ppInch = 96;
|
|
||||||
|
|
||||||
#if wxFONT_SIZE_COMPATIBILITY
|
|
||||||
// Incorrect, but compatible with old wxWindows behaviour
|
|
||||||
int nHeight = (font->GetPointSize()*ppInch/72);
|
|
||||||
#else
|
|
||||||
// Correct for Windows compatibility
|
|
||||||
int nHeight = - (font->GetPointSize()*ppInch/72);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool ff_underline = font->GetUnderlined();
|
return wxID_CANCEL;
|
||||||
|
}
|
||||||
ff_face = font->GetFaceName();
|
|
||||||
|
|
||||||
logFont->lfHeight = nHeight;
|
|
||||||
logFont->lfWidth = 0;
|
|
||||||
logFont->lfEscapement = 0;
|
|
||||||
logFont->lfOrientation = 0;
|
|
||||||
logFont->lfWeight = ff_weight;
|
|
||||||
logFont->lfItalic = ff_italic;
|
|
||||||
logFont->lfUnderline = (BYTE)ff_underline;
|
|
||||||
logFont->lfStrikeOut = 0;
|
|
||||||
logFont->lfCharSet = wxCharsetFromEncoding(font->GetEncoding());
|
|
||||||
logFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
|
|
||||||
logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
|
||||||
logFont->lfQuality = PROOF_QUALITY;
|
|
||||||
logFont->lfPitchAndFamily = DEFAULT_PITCH | ff_family;
|
|
||||||
wxStrcpy(logFont->lfFaceName, ff_face);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFont wxCreateFontFromLogFont(LOGFONT *logFont)
|
|
||||||
{
|
|
||||||
int fontFamily = wxSWISS;
|
|
||||||
int fontStyle = wxNORMAL;
|
|
||||||
int fontWeight = wxNORMAL;
|
|
||||||
int fontPoints = 10;
|
|
||||||
bool fontUnderline = FALSE;
|
|
||||||
wxChar *fontFace = NULL;
|
|
||||||
|
|
||||||
int lfFamily = logFont->lfPitchAndFamily;
|
|
||||||
if (lfFamily & FIXED_PITCH)
|
|
||||||
lfFamily -= FIXED_PITCH;
|
|
||||||
if (lfFamily & VARIABLE_PITCH)
|
|
||||||
lfFamily -= VARIABLE_PITCH;
|
|
||||||
|
|
||||||
switch (lfFamily)
|
|
||||||
{
|
|
||||||
case FF_ROMAN:
|
|
||||||
fontFamily = wxROMAN;
|
|
||||||
break;
|
|
||||||
case FF_SWISS:
|
|
||||||
fontFamily = wxSWISS;
|
|
||||||
break;
|
|
||||||
case FF_SCRIPT:
|
|
||||||
fontFamily = wxSCRIPT;
|
|
||||||
break;
|
|
||||||
case FF_MODERN:
|
|
||||||
fontFamily = wxMODERN;
|
|
||||||
break;
|
|
||||||
case FF_DECORATIVE:
|
|
||||||
fontFamily = wxDECORATIVE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fontFamily = wxSWISS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch (logFont->lfWeight)
|
|
||||||
{
|
|
||||||
case FW_LIGHT:
|
|
||||||
fontWeight = wxLIGHT;
|
|
||||||
break;
|
|
||||||
case FW_NORMAL:
|
|
||||||
fontWeight = wxNORMAL;
|
|
||||||
break;
|
|
||||||
case FW_BOLD:
|
|
||||||
fontWeight = wxBOLD;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
fontWeight = wxNORMAL;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (logFont->lfItalic)
|
|
||||||
fontStyle = wxITALIC;
|
|
||||||
else
|
|
||||||
fontStyle = wxNORMAL;
|
|
||||||
|
|
||||||
if (logFont->lfUnderline)
|
|
||||||
fontUnderline = TRUE;
|
|
||||||
|
|
||||||
if (logFont->lfFaceName)
|
|
||||||
fontFace = logFont->lfFaceName;
|
|
||||||
|
|
||||||
wxFontEncoding fontEncoding;
|
|
||||||
switch ( logFont->lfCharSet )
|
|
||||||
{
|
|
||||||
default:
|
|
||||||
wxFAIL_MSG(wxT("unsupported charset"));
|
|
||||||
// fall through
|
|
||||||
|
|
||||||
case ANSI_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_1;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case EASTEUROPE_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_2;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BALTIC_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_4;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case RUSSIAN_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_CP1251;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ARABIC_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_6;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case GREEK_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_7;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case HEBREW_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_8;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case TURKISH_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_9;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case THAI_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_ISO8859_11;
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
|
||||||
case OEM_CHARSET:
|
|
||||||
fontEncoding = wxFONTENCODING_CP437;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
HDC dc2 = ::GetDC(NULL);
|
|
||||||
|
|
||||||
if ( logFont->lfHeight < 0 )
|
|
||||||
logFont->lfHeight = - logFont->lfHeight;
|
|
||||||
fontPoints = abs(72*logFont->lfHeight/GetDeviceCaps(dc2, LOGPIXELSY));
|
|
||||||
::ReleaseDC(NULL, dc2);
|
|
||||||
|
|
||||||
return wxFont(fontPoints, fontFamily, fontStyle,
|
|
||||||
fontWeight, fontUnderline, fontFace,
|
|
||||||
fontEncoding);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -33,6 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/fontenum.h"
|
#include "wx/fontenum.h"
|
||||||
|
#include "wx/fontmap.h"
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
@@ -63,6 +64,9 @@ private:
|
|||||||
// if != -1, enum only fonts which have this encoding
|
// if != -1, enum only fonts which have this encoding
|
||||||
int m_charset;
|
int m_charset;
|
||||||
|
|
||||||
|
// if not empty, enum only the fonts with this facename
|
||||||
|
wxString m_facename;
|
||||||
|
|
||||||
// if TRUE, enum only fixed fonts
|
// if TRUE, enum only fixed fonts
|
||||||
bool m_fixedOnly;
|
bool m_fixedOnly;
|
||||||
};
|
};
|
||||||
@@ -91,16 +95,20 @@ wxFontEnumeratorHelper::wxFontEnumeratorHelper(wxFontEnumerator *fontEnum)
|
|||||||
|
|
||||||
bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
|
bool wxFontEnumeratorHelper::SetEncoding(wxFontEncoding encoding)
|
||||||
{
|
{
|
||||||
bool exact;
|
wxNativeEncodingInfo info;
|
||||||
m_charset = wxCharsetFromEncoding(encoding, &exact);
|
if ( !wxGetNativeFontEncoding(encoding, &info) )
|
||||||
#ifdef __WIN32__
|
|
||||||
if ( !exact )
|
|
||||||
{
|
{
|
||||||
m_charset = DEFAULT_CHARSET;
|
if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
|
||||||
|
{
|
||||||
|
// no such encodings at all
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
#endif // Win32
|
|
||||||
|
|
||||||
return exact;
|
m_charset = info.charset;
|
||||||
|
m_facename = info.facename;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxFontEnumeratorHelper::DoEnumerate()
|
void wxFontEnumeratorHelper::DoEnumerate()
|
||||||
@@ -110,7 +118,7 @@ void wxFontEnumeratorHelper::DoEnumerate()
|
|||||||
#ifdef __WIN32__
|
#ifdef __WIN32__
|
||||||
LOGFONT lf;
|
LOGFONT lf;
|
||||||
lf.lfCharSet = m_charset;
|
lf.lfCharSet = m_charset;
|
||||||
lf.lfFaceName[0] = _T('\0');
|
wxStrncpy(lf.lfFaceName, m_facename, WXSIZEOF(lf.lfFaceName));
|
||||||
lf.lfPitchAndFamily = 0;
|
lf.lfPitchAndFamily = 0;
|
||||||
::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)wxFontEnumeratorProc,
|
::EnumFontFamiliesEx(hDC, &lf, (FONTENUMPROC)wxFontEnumeratorProc,
|
||||||
(LPARAM)this, 0 /* reserved */) ;
|
(LPARAM)this, 0 /* reserved */) ;
|
||||||
|
438
src/msw/fontutil.cpp
Normal file
438
src/msw/fontutil.cpp
Normal file
@@ -0,0 +1,438 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Name: msw/fontutil.cpp
|
||||||
|
// Purpose: font-related helper functions for wxMSW
|
||||||
|
// Author: Vadim Zeitlin
|
||||||
|
// Modified by:
|
||||||
|
// Created: 05.11.99
|
||||||
|
// RCS-ID: $Id$
|
||||||
|
// Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
|
||||||
|
// Licence: wxWindows license
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// declarations
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// headers
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#ifdef __GNUG__
|
||||||
|
#pragma implementation "fontutil.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// For compilers that support precompilation, includes "wx.h".
|
||||||
|
#include "wx/wxprec.h"
|
||||||
|
|
||||||
|
#ifdef __BORLANDC__
|
||||||
|
#pragma hdrstop
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef WX_PRECOMP
|
||||||
|
#include "wx/string.h"
|
||||||
|
#include "wx/log.h"
|
||||||
|
#include "wx/intl.h"
|
||||||
|
#endif //WX_PRECOMP
|
||||||
|
|
||||||
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
#include "wx/fontutil.h"
|
||||||
|
#include "wx/fontmap.h"
|
||||||
|
|
||||||
|
#include "wx/tokenzr.h"
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxNativeEncodingInfo
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// convert to/from the string representation: format is
|
||||||
|
// facename[;charset]
|
||||||
|
|
||||||
|
bool wxNativeEncodingInfo::FromString(const wxString& s)
|
||||||
|
{
|
||||||
|
wxStringTokenizer tokenizer(s, _T(";"));
|
||||||
|
|
||||||
|
facename = tokenizer.GetNextToken();
|
||||||
|
if ( !facename )
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
|
wxString tmp = tokenizer.GetNextToken();
|
||||||
|
if ( !tmp )
|
||||||
|
{
|
||||||
|
// default charset (don't use DEFAULT_CHARSET though because of subtle
|
||||||
|
// Windows 9x/NT differences in handling it)
|
||||||
|
charset = ANSI_CHARSET;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( wxSscanf(tmp, _T("%u"), &charset) != 1 )
|
||||||
|
{
|
||||||
|
// should be a number!
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxString wxNativeEncodingInfo::ToString() const
|
||||||
|
{
|
||||||
|
wxString s(facename);
|
||||||
|
if ( charset != ANSI_CHARSET )
|
||||||
|
{
|
||||||
|
s << _T(';') << charset;
|
||||||
|
}
|
||||||
|
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// helper functions
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxGetNativeFontEncoding(wxFontEncoding encoding,
|
||||||
|
wxNativeEncodingInfo *info)
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( info, FALSE, _T("bad pointer in wxGetNativeFontEncoding") );
|
||||||
|
|
||||||
|
if ( encoding == wxFONTENCODING_DEFAULT )
|
||||||
|
{
|
||||||
|
encoding = wxFont::GetDefaultEncoding();
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( encoding )
|
||||||
|
{
|
||||||
|
// although this function is supposed to return an exact match, do do
|
||||||
|
// some mappings here for the most common case of "standard" encoding
|
||||||
|
case wxFONTENCODING_SYSTEM:
|
||||||
|
case wxFONTENCODING_ISO8859_1:
|
||||||
|
case wxFONTENCODING_ISO8859_15:
|
||||||
|
case wxFONTENCODING_CP1252:
|
||||||
|
info->charset = ANSI_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
#if !defined(__WIN16__)
|
||||||
|
case wxFONTENCODING_CP1250:
|
||||||
|
info->charset = EASTEUROPE_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1251:
|
||||||
|
info->charset = RUSSIAN_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1253:
|
||||||
|
info->charset = GREEK_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1254:
|
||||||
|
info->charset = TURKISH_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1255:
|
||||||
|
info->charset = HEBREW_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1256:
|
||||||
|
info->charset = ARABIC_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP1257:
|
||||||
|
info->charset = BALTIC_CHARSET;
|
||||||
|
break;
|
||||||
|
#endif // !Win16
|
||||||
|
|
||||||
|
case wxFONTENCODING_CP437:
|
||||||
|
info->charset = OEM_CHARSET;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// no way to translate this encoding into a Windows charset
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxTestFontEncoding(const wxNativeEncodingInfo& info)
|
||||||
|
{
|
||||||
|
// try to create such font
|
||||||
|
LOGFONT lf;
|
||||||
|
wxZeroMemory(lf); // all default values
|
||||||
|
|
||||||
|
lf.lfCharSet = info.charset;
|
||||||
|
strncpy(lf.lfFaceName, info.facename, sizeof(lf.lfFaceName));
|
||||||
|
|
||||||
|
HFONT hfont = ::CreateFontIndirect(&lf);
|
||||||
|
if ( !hfont )
|
||||||
|
{
|
||||||
|
// no such font
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
::DeleteObject((HGDIOBJ)hfont);
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxFont <-> LOGFONT conversion
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
|
||||||
|
{
|
||||||
|
int ff_family;
|
||||||
|
wxString ff_face;
|
||||||
|
|
||||||
|
switch ( font->GetFamily() )
|
||||||
|
{
|
||||||
|
case wxSCRIPT:
|
||||||
|
ff_family = FF_SCRIPT;
|
||||||
|
ff_face = _T("Script");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxDECORATIVE:
|
||||||
|
ff_family = FF_DECORATIVE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxROMAN:
|
||||||
|
ff_family = FF_ROMAN;
|
||||||
|
ff_face = _T("Times New Roman");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxTELETYPE:
|
||||||
|
case wxMODERN:
|
||||||
|
ff_family = FF_MODERN;
|
||||||
|
ff_face = _T("Courier New");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxSWISS:
|
||||||
|
ff_family = FF_SWISS;
|
||||||
|
ff_face = _T("Arial");
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxDEFAULT:
|
||||||
|
default:
|
||||||
|
ff_family = FF_SWISS;
|
||||||
|
ff_face = _T("MS Sans Serif");
|
||||||
|
}
|
||||||
|
|
||||||
|
BYTE ff_italic;
|
||||||
|
switch ( font->GetStyle() )
|
||||||
|
{
|
||||||
|
case wxITALIC:
|
||||||
|
case wxSLANT:
|
||||||
|
ff_italic = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("unknown font slant"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxNORMAL:
|
||||||
|
ff_italic = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ff_weight;
|
||||||
|
switch ( font->GetWeight() )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(_T("unknown font weight"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case wxNORMAL:
|
||||||
|
ff_weight = FW_NORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxLIGHT:
|
||||||
|
ff_weight = FW_LIGHT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case wxBOLD:
|
||||||
|
ff_weight = FW_BOLD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
HDC dc = ::GetDC(NULL);
|
||||||
|
int ppInch = ::GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
|
::ReleaseDC(NULL, dc);
|
||||||
|
#else
|
||||||
|
// New behaviour: apparently ppInch varies according to Large/Small Fonts
|
||||||
|
// setting in Windows. This messes up fonts. So, set ppInch to a constant
|
||||||
|
// 96 dpi.
|
||||||
|
static const int ppInch = 96;
|
||||||
|
#endif // 0/1
|
||||||
|
|
||||||
|
#if wxFONT_SIZE_COMPATIBILITY
|
||||||
|
// Incorrect, but compatible with old wxWindows behaviour
|
||||||
|
int nHeight = (font->GetPointSize()*ppInch/72);
|
||||||
|
#else
|
||||||
|
// Correct for Windows compatibility
|
||||||
|
int nHeight = - (font->GetPointSize()*ppInch/72);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
wxString facename = font->GetFaceName();
|
||||||
|
if ( !!facename )
|
||||||
|
{
|
||||||
|
ff_face = facename;
|
||||||
|
}
|
||||||
|
//else: ff_face is a reasonable default facename for this font family
|
||||||
|
|
||||||
|
// deal with encoding now
|
||||||
|
wxNativeEncodingInfo info;
|
||||||
|
wxFontEncoding encoding = font->GetEncoding();
|
||||||
|
if ( !wxGetNativeFontEncoding(encoding, &info) )
|
||||||
|
{
|
||||||
|
if ( !wxTheFontMapper->GetAltForEncoding(encoding, &info) )
|
||||||
|
{
|
||||||
|
// unsupported encoding, replace with the default
|
||||||
|
info.charset = ANSI_CHARSET;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( !info.facename.IsEmpty() )
|
||||||
|
{
|
||||||
|
// the facename determined by the encoding overrides everything else
|
||||||
|
ff_face = info.facename;
|
||||||
|
}
|
||||||
|
|
||||||
|
// transfer all the data to LOGFONT
|
||||||
|
logFont->lfHeight = nHeight;
|
||||||
|
logFont->lfWidth = 0;
|
||||||
|
logFont->lfEscapement = 0;
|
||||||
|
logFont->lfOrientation = 0;
|
||||||
|
logFont->lfWeight = ff_weight;
|
||||||
|
logFont->lfItalic = ff_italic;
|
||||||
|
logFont->lfUnderline = (BYTE)font->GetUnderlined();
|
||||||
|
logFont->lfStrikeOut = 0;
|
||||||
|
logFont->lfCharSet = info.charset;
|
||||||
|
logFont->lfOutPrecision = OUT_DEFAULT_PRECIS;
|
||||||
|
logFont->lfClipPrecision = CLIP_DEFAULT_PRECIS;
|
||||||
|
logFont->lfQuality = PROOF_QUALITY;
|
||||||
|
logFont->lfPitchAndFamily = DEFAULT_PITCH | ff_family;
|
||||||
|
wxStrncpy(logFont->lfFaceName, ff_face, WXSIZEOF(logFont->lfFaceName));
|
||||||
|
}
|
||||||
|
|
||||||
|
wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
|
||||||
|
{
|
||||||
|
// extract family from pitch-and-family
|
||||||
|
int lfFamily = logFont->lfPitchAndFamily;
|
||||||
|
if ( lfFamily & FIXED_PITCH )
|
||||||
|
lfFamily -= FIXED_PITCH;
|
||||||
|
if ( lfFamily & VARIABLE_PITCH )
|
||||||
|
lfFamily -= VARIABLE_PITCH;
|
||||||
|
|
||||||
|
int fontFamily;
|
||||||
|
switch ( lfFamily )
|
||||||
|
{
|
||||||
|
case FF_ROMAN:
|
||||||
|
fontFamily = wxROMAN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FF_SWISS:
|
||||||
|
fontFamily = wxSWISS;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FF_SCRIPT:
|
||||||
|
fontFamily = wxSCRIPT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FF_MODERN:
|
||||||
|
fontFamily = wxMODERN;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FF_DECORATIVE:
|
||||||
|
fontFamily = wxDECORATIVE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
fontFamily = wxSWISS;
|
||||||
|
}
|
||||||
|
|
||||||
|
// weight and style
|
||||||
|
int fontWeight = wxNORMAL;
|
||||||
|
switch ( logFont->lfWeight )
|
||||||
|
{
|
||||||
|
case FW_LIGHT:
|
||||||
|
fontWeight = wxLIGHT;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
case FW_NORMAL:
|
||||||
|
fontWeight = wxNORMAL;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case FW_BOLD:
|
||||||
|
fontWeight = wxBOLD;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
int fontStyle = logFont->lfItalic ? wxITALIC : wxNORMAL;
|
||||||
|
|
||||||
|
bool fontUnderline = logFont->lfUnderline != 0;
|
||||||
|
|
||||||
|
wxString fontFace = logFont->lfFaceName;
|
||||||
|
|
||||||
|
// font size
|
||||||
|
HDC dc = ::GetDC(NULL);
|
||||||
|
|
||||||
|
// remember that 1pt = 1/72inch
|
||||||
|
int height = abs(logFont->lfHeight);
|
||||||
|
int fontPoints = (72*height)/GetDeviceCaps(dc, LOGPIXELSY);
|
||||||
|
|
||||||
|
::ReleaseDC(NULL, dc);
|
||||||
|
|
||||||
|
wxFontEncoding fontEncoding;
|
||||||
|
switch ( logFont->lfCharSet )
|
||||||
|
{
|
||||||
|
default:
|
||||||
|
wxFAIL_MSG(wxT("unsupported charset"));
|
||||||
|
// fall through
|
||||||
|
|
||||||
|
case ANSI_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1252;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EASTEUROPE_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1250;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BALTIC_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1257;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RUSSIAN_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1251;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ARABIC_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1256;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case GREEK_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1253;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case HEBREW_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1255;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TURKISH_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP1254;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case OEM_CHARSET:
|
||||||
|
fontEncoding = wxFONTENCODING_CP437;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wxFont(fontPoints, fontFamily, fontStyle,
|
||||||
|
fontWeight, fontUnderline, fontFace,
|
||||||
|
fontEncoding);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@@ -497,11 +497,7 @@ wxTextCtrl* wxListCtrl::GetEditControl(void) const
|
|||||||
bool wxListCtrl::GetItem(wxListItem& info) const
|
bool wxListCtrl::GetItem(wxListItem& info) const
|
||||||
{
|
{
|
||||||
LV_ITEM lvItem;
|
LV_ITEM lvItem;
|
||||||
#ifdef __GNUWIN32__
|
wxZeroMemory(lvItem);
|
||||||
memset(&lvItem, 0, sizeof(lvItem));
|
|
||||||
#else
|
|
||||||
ZeroMemory(&lvItem, sizeof(lvItem)); // must set all fields to 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
lvItem.iItem = info.m_itemId;
|
lvItem.iItem = info.m_itemId;
|
||||||
lvItem.iSubItem = info.m_col;
|
lvItem.iSubItem = info.m_col;
|
||||||
@@ -1362,11 +1358,8 @@ bool wxListCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result)
|
|||||||
|
|
||||||
// else translate it into wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event
|
// else translate it into wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK event
|
||||||
LV_HITTESTINFO lvhti;
|
LV_HITTESTINFO lvhti;
|
||||||
#ifdef __GNUWIN32__
|
wxZeroMemory(lvhti);
|
||||||
memset(&lvhti,0,sizeof(LV_HITTESTINFO));
|
|
||||||
#else
|
|
||||||
ZeroMemory(&lvhti, sizeof(LV_HITTESTINFO)); // must set all fields to 0
|
|
||||||
#endif
|
|
||||||
::GetCursorPos(&(lvhti.pt));
|
::GetCursorPos(&(lvhti.pt));
|
||||||
::ScreenToClient(GetHwnd(),&(lvhti.pt));
|
::ScreenToClient(GetHwnd(),&(lvhti.pt));
|
||||||
if ( ListView_HitTest(GetHwnd(),&lvhti) != -1 )
|
if ( ListView_HitTest(GetHwnd(),&lvhti) != -1 )
|
||||||
|
@@ -47,10 +47,9 @@ WXHWND wxToolTip::hwndTT = (WXHWND)NULL;
|
|||||||
// private classes
|
// private classes
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
// a simple wrapper around TOOLINFO Win32 structure
|
// a simple wrapper around TOOLINFO Win32 structure
|
||||||
#ifdef __VISUALC__
|
#ifdef __VISUALC__
|
||||||
#pragma warning( disable : 4097 )
|
#pragma warning( disable : 4097 ) // we inherit from a typedef - so what?
|
||||||
#endif
|
#endif
|
||||||
class wxToolInfo : public TOOLINFO
|
class wxToolInfo : public TOOLINFO
|
||||||
{
|
{
|
||||||
@@ -58,11 +57,7 @@ public:
|
|||||||
wxToolInfo(wxWindow *win)
|
wxToolInfo(wxWindow *win)
|
||||||
{
|
{
|
||||||
// initialize all members
|
// initialize all members
|
||||||
#if __GNUWIN32__ && !defined(wxUSE_NORLANDER_HEADERS)
|
|
||||||
memset(this, 0, sizeof(TOOLINFO));
|
|
||||||
#else
|
|
||||||
::ZeroMemory(this, sizeof(TOOLINFO));
|
::ZeroMemory(this, sizeof(TOOLINFO));
|
||||||
#endif
|
|
||||||
|
|
||||||
cbSize = sizeof(TOOLINFO);
|
cbSize = sizeof(TOOLINFO);
|
||||||
uFlags = TTF_IDISHWND;
|
uFlags = TTF_IDISHWND;
|
||||||
|
@@ -214,11 +214,7 @@ long wxExecute(const wxString& command, bool sync, wxProcess *handler)
|
|||||||
#else // 1
|
#else // 1
|
||||||
// create the process
|
// create the process
|
||||||
STARTUPINFO si;
|
STARTUPINFO si;
|
||||||
#ifdef __GNUWIN32__
|
wxZeroMemory(si);
|
||||||
memset(&si, 0, sizeof(si));
|
|
||||||
#else
|
|
||||||
::ZeroMemory(&si, sizeof(si));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
si.cb = sizeof(si);
|
si.cb = sizeof(si);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user