Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » RichText,QTF,RTF... » Constant font size in resizeable RichEdit?
Re: Constant font size in resizeable RichEdit? [message #40945 is a reply to message #40933] Fri, 11 October 2013 11:02 Go to previous messageGo to previous message
iST1 is currently offline  iST1
Messages: 107
Registered: August 2013
Experienced Member
Both solutions do not come:
class ExtRichEdit : public RichEdit {
public:
	typedef AppRichEdit 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();
#if 0
		//Mirek's solution: to big font
		SetPage(Size(minmax(GetSize().cx, 50, 10000), INT_MAX));
#else
		//Alendar's solution: to small font
		long editor_cx = GetSize().cx;
		long adaptive_cx = (editor_cx * zoomlevel); // Smaller the number, the bigger the text
		SetPage(Size(adaptive_cx, INT_MAX));
#endif
	}
};

GUI_APP_MAIN
{	
	ExtRichEdit edit;	
	TopWindow r;
	r.Add(edit.SizePos());

	TopWindow wnd;	
	SplitterFrame sp;
	wnd.AddFrame(sp.Right(r, 300));
	wnd.AddFrame(NullFrame());	
	
    wnd.Run();
}
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: EncodeRTF bullet bug
Next Topic: RichText over an image background - weird scroll (on windows)
Goto Forum:
  


Current Time: Sat May 18 10:35:54 CEST 2024

Total time taken to generate the page: 0.00866 seconds