|
|
Home » U++ Library support » RichText,QTF,RTF... » RichEdit questions
|
|
|
|
|
Re: RichEdit questions [message #25489 is a reply to message #25488] |
Thu, 25 February 2010 17:29   |
 |
koldo
Messages: 3432 Registered: August 2008
|
Senior Veteran |
|
|
Hello Fudadmin
Thank you but now Zoom has only one int argument.
SetZoom changes font size but ViewBorder just do the opposite.
Reading RichEdit code it seems like font size is forced by control size, so to get fixed font size seems impossible now. It is a pity 
Best regards
Iñaki
[Updated on: Thu, 25 February 2010 17:30] Report message to a moderator
|
|
|
|
|
|
|
|
|
|
|
|
Re: RichEdit questions [message #30230 is a reply to message #25472] |
Thu, 16 December 2010 22:55   |
alendar
Messages: 47 Registered: January 2010 Location: Idaho, USA
|
Member |
|
|
I hope this saves someone an hour or two:
void Layout() {
RichEdit::Layout();
long editor_cx = GetSize().cx;
long adaptive_cx = (editor_cx * 8); // Smaller the total, the bigger the text. Increase the constant to decrease the font.
SetPage(Size(adaptive_cx, INT_MAX));
}
This inverts the size of the editor rectangle to the font logical size, i.e., the bigger the editor, the bigger the page, the smaller the font, which is then zoomed to look the same as it did. Make sense?
I gave up on SetZoom, which has some relation to this function, but mostly it just seems to increase the unusable margins or indent on the page, and it can't be regained. The Zoom must be left as default or set to 100 (100%) if you want a 0 margin.
cd7651feeb698f6ac6cec1f6deda5e5b
|
|
|
Re: RichEdit questions [message #30231 is a reply to message #25472] |
Thu, 16 December 2010 23:37   |
alendar
Messages: 47 Registered: January 2010 Location: Idaho, USA
|
Member |
|
|
Here's a fun trick, I don't think I've seen it anywhere in the examples. Zooming with the mouse wheel whilest holding the control key down:
struct MyRichEdit : public RichEdit {
typedef MyRichEdit CLASSNAME;
float zoomlevel;
//==========================================================================================
virtual void MouseWheel(Point p, int zdelta, dword keyflags) {
if (keyflags == K_CTRL) {
// Zooms font
float fzdelta = zdelta;
zoomlevel+= (fzdelta / 240.0); // One bump on the mouse wheel is 120 on my machine
RefreshLayoutDeep();
} else {
// Scrolls down
RichEdit::MouseWheel(p, zdelta, keyflags);
}
}
//==========================================================================================
void Layout() {
RichEdit::Layout();
long editor_cx = GetSize().cx;
long adaptive_cx = (editor_cx * zoomlevel); // Smaller the number, the bigger the text
SetPage(Size(adaptive_cx, INT_MAX));
}
The RefreshLayoutDeep is required to redraw the text with the new font size.
cd7651feeb698f6ac6cec1f6deda5e5b
|
|
|
|
Goto Forum:
Current Time: Sat Apr 26 14:48:22 CEST 2025
Total time taken to generate the page: 0.01067 seconds
|
|
|