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... » RichEdit questions
RichEdit questions [message #25472] Thu, 25 February 2010 09:42 Go to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello all

I have some questions about RichEdit. I would like to know how to:

- Remove upper ruler

- Remove blue marks on text like spaces and carriage returns

- Have fixed font: Avoid automatic text resize when control is resized

index.php?t=getfile&id=2345&private=0
  • Attachment: drw.PNG
    (Size: 16.74KB, Downloaded 1270 times)


Best regards
Iñaki
Re: RichEdit questions [message #25484 is a reply to message #25472] Thu, 25 February 2010 14:37 Go to previous messageGo to next message
andrei_natanael is currently offline  andrei_natanael
Messages: 262
Registered: January 2009
Experienced Member
NoRuler();
ShowCodes(Null);

I don't know about the fixed font but SetZoom may be related to it.
Re: RichEdit questions [message #25486 is a reply to message #25484] Thu, 25 February 2010 14:42 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
andrei_natanael wrote on Thu, 25 February 2010 14:37

NoRuler();
ShowCodes(Null);

I don't know about the fixed font but SetZoom may be related to it.

Thank you Andrei Smile

About font size I have tried it testing with different values with SetZoom and ViewBorder like proposed by Mirek here: http://www.ultimatepp.org/forum/index.php?t=msg&th=4818& amp;start=0& , but unsuccessfully Sad


Best regards
Iñaki
Re: RichEdit questions [message #25487 is a reply to message #25486] Thu, 25 February 2010 15:01 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
koldo wrote on Thu, 25 February 2010 08:42



- Remove blue marks on text like spaces and carriage returns




As a user: Use a spanner Smile on the left of the ruler.

programatically... someone above was faster... Smile

for fonts - I achieved this by sending as a param Zoom(1,1) somewhere, but no guarantee that this would help you because my versions of RichText and RichEdit are modified. (Sorry, writing from my car)
Re: RichEdit questions [message #25488 is a reply to message #25487] Thu, 25 February 2010 15:24 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
correction for fonts: you can try yourrichtextview.SetZoom(Zoom(-1, -8));
Re: RichEdit questions [message #25489 is a reply to message #25488] Thu, 25 February 2010 17:29 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
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 Sad


Best regards
Iñaki

[Updated on: Thu, 25 February 2010 17:30]

Report message to a moderator

Re: RichEdit questions [message #25490 is a reply to message #25489] Thu, 25 February 2010 18:49 Go to previous messageGo to next message
fudadmin is currently offline  fudadmin
Messages: 1321
Registered: November 2005
Location: Kaunas, Lithuania
Ultimate Contributor
Administrator
Yeh, you're right koldo. my advice was for RichTextView. Sorry.
Re: RichEdit questions [message #25509 is a reply to message #25490] Fri, 26 February 2010 15:26 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
I am using this to keep the size of font fixed:

void MyEdit::Layout()
{
	RichEdit::Layout();
	SetPage(Size(minmax(GetSize().cx, 50, 10000), INT_MAX));
}


Mirek
Re: RichEdit questions [message #25538 is a reply to message #25509] Sun, 28 February 2010 17:58 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you Mirek

It almost work now:

struct MyRichEdit : public RichEdit {
	MyRichEdit() {
		NoRuler();
		ShowCodes(Null);
		ViewBorder(0);
		SetZoom(20);
	}	
	void Layout() {
		RichEdit::Layout();
		SetPage(Size(minmax(GetSize().cx, 20, 10000), INT_MAX));
	}
};


index.php?t=getfile&id=2365&private=0

The white left and right margins resize when resizing control.
  • Attachment: Dib.PNG
    (Size: 14.69KB, Downloaded 1112 times)


Best regards
Iñaki
Re: RichEdit questions [message #25550 is a reply to message #25538] Mon, 01 March 2010 10:47 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
ViewBorder(0);
Re: RichEdit questions [message #25559 is a reply to message #25550] Mon, 01 March 2010 12:08 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
luzr wrote on Mon, 01 March 2010 10:47

ViewBorder(0);


Sorry Mirek

I do not understand.


Best regards
Iñaki
Re: RichEdit questions [message #25560 is a reply to message #25559] Mon, 01 March 2010 12:10 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 01 March 2010 06:08

luzr wrote on Mon, 01 March 2010 10:47

ViewBorder(0);


Sorry Mirek

I do not understand.


Sorry, I thought you do not have it there.

Mirek
Re: RichEdit questions [message #25561 is a reply to message #25560] Mon, 01 March 2010 12:20 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
It is because SetZoom(20) - that makes the whole issue with changing page size ineffective.

Remove that and it works fine...

Of course, "physical font size" will be quite big then, so you should alter the format as well:

#include <RichEdit/RichEdit.h>

using namespace Upp;

struct MyRichEdit : public RichEdit {
	MyRichEdit() {
		NoRuler();
		ShowCodes(Null);
		ViewBorder(0);

		RichPara::Format f;
		(Font&)f = StdFont();
		RichText::FormatInfo fi;
		fi.Set(f);
		ApplyFormatInfo(fi);	
	}	
	void Layout() {
		RichEdit::Layout();
		SetPage(Size(minmax(GetSize().cx, 20, 10000), INT_MAX));
	}
};

GUI_APP_MAIN {
	MyRichEdit edit;
	
	TopWindow win;
	win.Add(edit.SizePos());
	win.Sizeable().Zoomable().Run();
};
Re: RichEdit questions [message #25565 is a reply to message #25561] Mon, 01 March 2010 13:07 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Thank you Mirek

Changing StdFont() with Arial(16) I have got the desired font size Smile.

However is it possible to use SetZoom instead of changing font size ?.

Now it seems like SetZoom() and ViewBorder() fight between themselves.


Best regards
Iñaki
Re: RichEdit questions [message #25566 is a reply to message #25565] Mon, 01 March 2010 13:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 01 March 2010 07:07

Thank you Mirek

Changing StdFont() with Arial(16) I have got the desired font size Smile.

However is it possible to use SetZoom instead of changing font size ?.

Now it seems like SetZoom() and ViewBorder() fight between themselves.



No, I believe it is SetPage and SetZoom that fight Smile

My SetPage variant sets the width so that one font pixel is equal to one screen pixel.

Mire
Re: RichEdit questions [message #30230 is a reply to message #25472] Thu, 16 December 2010 22:55 Go to previous messageGo to next message
alendar is currently offline  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 Go to previous messageGo to next message
alendar is currently offline  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
Re: RichEdit questions [message #40773 is a reply to message #30231] Sat, 14 September 2013 23:43 Go to previous message
koldo is currently offline  koldo
Messages: 3355
Registered: August 2008
Senior Veteran
Hello alendar

Thank you for this trick. It works very well!

It will be proposed in RM.


Best regards
Iñaki
Previous Topic: [RTF format] - change tables and pictures
Next Topic: Get String from RichText
Goto Forum:
  


Current Time: Thu Mar 28 14:16:37 CET 2024

Total time taken to generate the page: 0.01195 seconds