> How do I make a wxFrame behave modally?
Daniel,
Call the ShowModal() method.
Mark
ME> On Nov 14, 2009, at 1:07 PM, Daniel wrote:
ME>
ME> > How do I make a wxFrame behave modally?
ME>
ME> Daniel,
ME>
ME> Call the ShowModal() method.
wxFrame doesn't have this method and can't be modal.
A word of advice to Daniel: please look in the archives before posting.
Both your questions had been asked and answered many times in the past and
searching for the obvious keywords would have found the (right) answer much
faster.
Regards,
VZ
--
TT-Solutions: wxWidgets consultancy and technical support
http://www.tt-solutions.com/
Daniel,
What isn't wxDialog doing that you need?
Mark
Have a look at the MakeModal method of wxFrame.
Greg
..An empty string is returned by wxSWISS_FONT->GetFaceName().
This happens using the trunk, while in 2.8.x and 2.9.0 it still has the FaceName ("Arial" in my case).
wxNORMAL_FONT still has a FaceName in the trunk ("Segoe UI" in my case).
I'm using Vista.
Thank you,
Catalin
C> ..An empty string is returned by wxSWISS_FONT->GetFaceName().
Indeed. And also for wxITALIC_FONT and wxSMALL_FONT.
C> This happens using the trunk, while in 2.8.x and 2.9.0 it still has the
C> FaceName ("Arial" in my case).
This is due to the change of r60391 by Francesco, in particular this part:
--- a/src/msw/font.cpp
+++ b/src/msw/font.cpp
@@ -641,10 +641,9 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family)
lf.lfPitchAndFamily = (BYTE)(DEFAULT_PITCH) | ff_family;
- if ( !wxStrlen(lf.lfFaceName) )
- {
- SetFaceName(facename);
- }
+ // reset the facename so that CreateFontIndirect() will automatically choose a
+ // face name based only on the font family.
+ lf.lfFaceName[0] = '\0';
}
void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
I guess I understand why was this done -- to allow the system a fuller
liberty of choice when creating the font -- but it does mean that we lose
the information about the font face name.
However I just found that it is possible to retrieve the information about
the real face name being used from the system, it's just done using a not
very widely known GetOutlineTextMetrics() function. The following patch
should make it work for you:
--- a/src/msw/font.cpp
+++ b/src/msw/font.cpp
@@ -182,7 +182,15 @@ public:
wxString GetFaceName() const
{
- return m_nativeFontInfo.GetFaceName();
+ wxString facename = m_nativeFontInfo.GetFaceName();
+ if ( facename.empty() )
+ {
+ facename = GetMSWFaceName();
+ if ( !facename.empty() )
+ const_cast<wxFontRefData *>(this)->SetFaceName(facename);
+ }
+
+ return facename;
}
wxFontEncoding GetEncoding() const
@@ -291,6 +299,36 @@ protected:
void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
+ wxString GetMSWFaceName() const
+ {
+ ScreenHDC hdc;
+ SelectInHDC selectFont(hdc, m_hFont);
+
+ UINT otmSize = GetOutlineTextMetrics(hdc, 0, NULL);
+ if ( !otmSize )
+ {
+ wxLogLastError("GetOutlineTextMetrics(NULL)");
+ return wxString();
+ }
+
+ OUTLINETEXTMETRIC * const
+ otm = static_cast<OUTLINETEXTMETRIC *>(malloc(otmSize));
+ wxON_BLOCK_EXIT1( free, otm );
+
+ otm->otmSize = otmSize;
+ if ( !GetOutlineTextMetrics(hdc, otmSize, otm) )
+ {
+ wxLogLastError("GetOutlineTextMetrics()");
+ return wxString();
+ }
+
+ // in spit of its type, the otmpFaceName field of OUTLINETEXTMETRIC
+ // gives an offset in _bytes_ of the face name from the struct start
+ // while the name itself is an array of TCHARs
+ return reinterpret_cast<wxChar *>(otm) +
+ wxPtrToUInt(otm->otmpFaceName)/sizeof(wxChar);
+ }
+
// are we using m_nativeFontInfo.lf.lfHeight for point size or pixel size?
bool m_sizeUsingPixels;
Could you please test it?
C> wxNORMAL_FONT still has a FaceName in the trunk ("Segoe UI" in my case).
This is because we get this font from the system instead of constructing
it ourselves.
One question though: is it ok for GetFaceName() to internally call SetFaceName(facename)? I didn't check or anything but maybe the empty facename string is useful somewhere (? to indicate that the font was internally built in wxW and not explicitly...) so GetFaceName() should only return the newly found string?
Anyway, I've copied & regenerated your patch for rev 62673 (I couldn't apply the previous one...), added include "wx/scopeguard.h" for wxON_BLOCK_EXIT1 and fixed a small typo.
I'll attach the new patch here. Should I open a ticket for this, or will you, or no need for it?
Regards,
C
----- Original Message ----
> From: Vadim Zeitlin <va...@wxwidgets.org>
> To: wx-u...@googlegroups.com
> Sent: Tue, 17 November, 2009 17:56:57
> Subject: Re: Why wxSWISS_FONT does not have a FaceName in the trunk (2.9.1) ?
>
> On Sun, 15 Nov 2009 09:20:46 -0800 (PST) Catalin wrote:
>
> C> ..An empty string is returned by wxSWISS_FONT->GetFaceName().
>
> Indeed. And also for wxITALIC_FONT and wxSMALL_FONT.
>
> C> This happens using the trunk, while in 2.8.x and 2.9.0 it still has the
> C> FaceName ("Arial" in my case).
>
> This is due to the change of r60391 by Francesco, in particular this part:
>
> --- a/src/msw/font.cpp
> +++ b/src/msw/font.cpp
> @@ -641,10 +641,9 @@ void wxNativeFontInfo::SetFamily(wxFontFamily family)
>
> lf.lfPitchAndFamily = (BYTE)(DEFAULT_PITCH) | ff_family;
>
> - if ( !wxStrlen(lf.lfFaceName) )
> - {
> - SetFaceName(facename);
> - }
> + // reset the facename so that CreateFontIndirect() will automatically
> choose a
> + // face name based only on the font family..
> + lf.lfFaceName[0] = '\0';
> }
>
> void wxNativeFontInfo::SetEncoding(wxFontEncoding encoding)
>
>
> I guess I understand why was this done -- to allow the system a fuller
> liberty of choice when creating the font -- but it does mean that we lose
> the information about the font face name.
>
> However I just found that it is possible to retrieve the information about
> the real face name being used from the system, it's just done using a not
> very widely known GetOutlineTextMetrics() function. The following patch
> should make it work for you:
>
> --- a/src/msw/font.cpp
> +++ b/src/msw/font.cpp
> @@ -182,7 +182,15 @@ public:
>
> wxString GetFaceName() const
> {
> - return m_nativeFontInfo.GetFaceName();
> + wxString facename = m_nativeFontInfo.GetFaceName();
> + if ( facename.empty() )
> + {
> + facename = GetMSWFaceName();
> + if ( !facename.empty() )
> + const_cast(this)->SetFaceName(facename);
> + }
> +
> + return facename;
> }
>
> wxFontEncoding GetEncoding() const
> @@ -291,6 +299,36 @@ protected:
>
> void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
>
> + wxString GetMSWFaceName() const
> + {
> + ScreenHDC hdc;
> + SelectInHDC selectFont(hdc, m_hFont);
> +
> + UINT otmSize = GetOutlineTextMetrics(hdc, 0, NULL);
> + if ( !otmSize )
> + {
> + wxLogLastError("GetOutlineTextMetrics(NULL)");
> + return wxString();
> + }
> +
> + OUTLINETEXTMETRIC * const
> + otm = static_cast(malloc(otmSize));
> + wxON_BLOCK_EXIT1( free, otm );
> +
> + otm->otmSize = otmSize;
> + if ( !GetOutlineTextMetrics(hdc, otmSize, otm) )
> + {
> + wxLogLastError("GetOutlineTextMetrics()");
> + return wxString();
> + }
> +
> + // in spit of its type, the otmpFaceName field of OUTLINETEXTMETRIC
> + // gives an offset in _bytes_ of the face name from the struct start
> + // while the name itself is an array of TCHARs
> + return reinterpret_cast(otm) +
C> That looks good. Tested and working as expected. Thanks!
Thanks for testing, committed as r62675.
C> One question though: is it ok for GetFaceName() to internally call
C> SetFaceName(facename)? I didn't check or anything but maybe the empty
C> facename string is useful somewhere (? to indicate that the font was
C> internally built in wxW and not explicitly...) so GetFaceName() should
C> only return the newly found string?
I couldn't think about any scenario when it would be undesirable to store
the face name. If anybody sees when it could create a problem, please let
me know.