|
|
Home » U++ Library support » RichText,QTF,RTF... » Zooming font of RichText to the size of StdFont
Zooming font of RichText to the size of StdFont [message #19666] |
Sat, 03 January 2009 06:45  |
Novo
Messages: 1430 Registered: December 2006
|
Ultimate Contributor |
|
|
Do I understand correctly that zoom below will make size of the font of RichText equal to the size of StdFont?
Zoom zoom(StdFont().GetHeight(), ScreenDraw(false).GetPixelsPerInch().cy);
Regards,
Novo
|
|
|
|
|
|
|
|
Re: Zooming font of RichText to the size of StdFont [message #20006 is a reply to message #20001] |
Mon, 09 February 2009 09:39   |
Zeth
Messages: 2 Registered: February 2009 Location: Estonia
|
Junior Member |
|
|
I've read about it and it seems to be a Windows XP specific problem with GetDeviceCaps always returning 96. I ended up checking my main window size (it isn't resizable):
if(this->GetSize().cx > 690){ //Assume Large font
DPI = 120;
}
float Multiplier = DPI / 96;
I've attached a small testcase which shows my problem. If you load it with 96 dpi all is ok, but when you change it to use 120dpi then you can see the scrollArea StaticText control is not automatically resized and the buttons are no longer of the same size. Basically all the manually added controls are not resized according to the current dpi. How do you guys handle this?
-
Attachment: Testcase.zip
(Size: 2.31KB, Downloaded 412 times)
[Updated on: Mon, 09 February 2009 09:51] Report message to a moderator
|
|
|
Re: Zooming font of RichText to the size of StdFont [message #20049 is a reply to message #20006] |
Fri, 13 February 2009 15:11   |
 |
mirek
Messages: 14255 Registered: November 2005
|
Ultimate Member |
|
|
Zeth wrote on Mon, 09 February 2009 03:39 | I've read about it and it seems to be a Windows XP specific problem with GetDeviceCaps always returning 96. I ended up checking my main window size (it isn't resizable):
if(this->GetSize().cx > 690){ //Assume Large font
DPI = 120;
}
float Multiplier = DPI / 96;
I've attached a small testcase which shows my problem. If you load it with 96 dpi all is ok, but when you change it to use 120dpi then you can see the scrollArea StaticText control is not automatically resized and the buttons are no longer of the same size. Basically all the manually added controls are not resized according to the current dpi. How do you guys handle this?
|
FontZoom.
Check Ctrl::
static int HorzLayoutZoom(int cx);
static int VertLayoutZoom(int cy);
The basic idea is to query the size of specific text with current default GUI font. Knowing its "default size" (as defined by its size in WinXP with small fonts, but that is hardly relevant) you compute zooming ratio.
Mirek
[Updated on: Fri, 13 February 2009 15:11] Report message to a moderator
|
|
|
|
Re: Prompt with non-system dpi for text at first [message #23863 is a reply to message #23855] |
Fri, 27 November 2009 15:13   |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
I found the following solution for my problem:
int Prompt(Callback1<const String&> WhenLink,
const char *title, const Image& iconbmp, const char *qtf, bool okcancel,
const char *button1, const char *button2, const char *button3,
int cx,
Image im1, Image im2, Image im3)
{
+ int bcy = Ctrl::VertLayoutZoom(24);
+ int bcx = Ctrl::HorzLayoutZoom(72);
int fcy = Draw::GetStdFontCy();
PromptDlgWnd__ dlg;
RichTextCtrl qtfctrl;
Icon icon;
qtfctrl.WhenLink = WhenLink;
icon.SetImage(iconbmp);
Button b1, b2, b3;
qtfctrl.SetQTF(String("[G1 ") + qtf, GetRichTextStdScreenZoom());
- int bcy = Ctrl::VertLayoutZoom(24);
- int bcx = Ctrl::HorzLayoutZoom(72);
if(button1)
bcx = max(2 * fcy + GetTextSize(button1, Draw::GetStdFont()).cx, bcx);
if(button2)
bcx = max(2 * fcy + GetTextSize(button2, Draw::GetStdFont()).cx, bcx);
if(button3)
bcx = max(2 * fcy + GetTextSize(button3, Draw::GetStdFont()).cx, bcx);
Its just reordering of control flow. So, Ctrl::Csizeinit() can be initialized before GetRichTextStdScreenZoom().
|
|
|
|
Re: Prompt with non-system dpi for text at first [message #23959 is a reply to message #23870] |
Thu, 10 December 2009 15:52   |
Sender Ghost
Messages: 301 Registered: November 2008
|
Senior Member |
|
|
luzr wrote on Sun, 29 November 2009 23:31 | Thank you for reporting the problem.
I believe even better solution is to put Csizeinit call to GUI_APP_MAIN.
|
Thank you for your solution.
Considering new topic I propose following modified solution:
- Make public static SizeInit function to call inlined Csizeinit function.
- Use created SizeInit function in the CtrlCore/Win32Wnd.cpp::InitWin32, CtrlCore/X11App.cpp::InitX11 functions.
Normal diff for 1796 revision:
File: CtrlCore\Ctrl.cpp
770a771,775
> void Ctrl::SizeInit()
> {
> Csizeinit();
> }
>
File: CtrlCore\CtrlCore.h
1328a1329,1330
>
> static void SizeInit();
File: CtrlCore\Win32Wnd.cpp
288c288
< Csizeinit();
---
> SizeInit();
File: CtrlCore\X11App.cpp
429c429
< Csizeinit();
---
> SizeInit();
[Updated on: Thu, 10 December 2009 16:13] Report message to a moderator
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 21:49:28 CEST 2025
Total time taken to generate the page: 0.03413 seconds
|
|
|