Why is wxFontInfo incomplete ?

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
In need of some credit
In need of some credit
Posts: 4
Joined: Sat Oct 08, 2016 9:46 pm

Why is wxFontInfo incomplete ?

Postby richrobin » Thu Dec 01, 2016 5:42 pm

Why are the "m_pointSize" and "m_pixelSize" fields of wxFontInfo made inaccessible by being declared private and then not giving a public access function to set them? I am porting a windows program to Linux and wish to use wxFontInfo in place of the Windows LOGFONT structure. Both these classes are just storing information for creating fonts so why not allow alteration of point size after creation of the wxFontInfo class? The program I am porting stores LOGFONT structures in a database and updates the size of the font just before the structure is used to create the font to be used for drawing on the Device Context. Is there a reason for not allowing access to "m_pointSize" and "m_pixelSize" or is this just an oversight? Also "AllFlags" will set the flags register "m_flags" but there is no simple way of "Getting" the flags register. I am using version 3.02 of wxWidgets.

User avatar
Posts: 12889
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Why is wxFontInfo incomplete ?

Postby doublemax » Thu Dec 01, 2016 6:39 pm

wxFontInfo doesn't have reading access to any parameter, so how do you get the data out in order to put it into a database.

You could also try wxFont::GetNativeFontInfoDesc(). It's platform-specific but should serve your purpose. You just have to try out once where the font size is stored.
Use the source, Luke!

Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 223
Joined: Mon Jan 19, 2015 1:45 pm

Re: Why is wxFontInfo incomplete ?

Postby DenDev » Thu Dec 01, 2016 6:42 pm

wxFontInfo is just a helper class which can be used to more convenient (or read friendly) font creation, like this:

Code: Select all

wxFont f = new wxFont(wxFontInfo(18).Bold().Underlined().FaceName("Helvetica"));

You cannot access the private fields because they are only temporary storage for parameters. The functionality you need is available in wxFont: http://docs.wxwidgets.org/3.1/classwx_font.html

My suggestion is that you create your own wxFont* wxFontFromLOGFONT(LOGFONT *lf) method :)
I have a bad habbit of not testing the code I post :D

Return to “C++ Development”

Who is online

Users browsing this forum: Google [Bot] and 15 guests