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 » U++ Widgets - General questions or Mixed problems » Paint outside Ctrl Rect
Paint outside Ctrl Rect [message #23788] Sun, 22 November 2009 11:11 Go to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello all

I have derived a class from Ctrl and I would like to paint outside its Rect, but Ctrl painting clips the painting area to the Ctrl Rect.

Is it a way to disable the Rect clipping in Rect ?

Best regards
Koldo


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23795 is a reply to message #23788] Sun, 22 November 2009 23:09 Go to previous messageGo to next message
mirek is currently online  mirek
Messages: 11827
Registered: November 2005
Ultimate Member
Sort of.

There is an "overpaint" parameter that allows Frames to paint outside of widget (OverPaint is number of widgets "outside").

Mirek
Re: Paint outside Ctrl Rect [message #23804 is a reply to message #23795] Mon, 23 November 2009 11:05 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
luzr wrote on Sun, 22 November 2009 23:09

Sort of.

There is an "overpaint" parameter that allows Frames to paint outside of widget (OverPaint is number of widgets "outside").

Mirek


Sorry Mirek

I have added this method to the class:

int  OverPaint() const {return 1;};


But nothing happens. I have seen too that it is called in the window constructor but not in the Ctrl Paint function.

Best regards
Koldo


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23806 is a reply to message #23804] Mon, 23 November 2009 11:09 Go to previous messageGo to next message
mrjt is currently offline  mrjt
Messages: 705
Registered: March 2007
Location: London
Contributor
shouldn't that be
virtual int  OverPaint() const {return 1;};


?
Re: Paint outside Ctrl Rect [message #23809 is a reply to message #23806] Mon, 23 November 2009 17:36 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello mrjt

Unfortunately the control is clipped too with OverPaint().

Best regards
Koldo


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23819 is a reply to message #23809] Tue, 24 November 2009 15:01 Go to previous messageGo to next message
mirek is currently online  mirek
Messages: 11827
Registered: November 2005
Ultimate Member
koldo wrote on Mon, 23 November 2009 11:36

Hello mrjt

Unfortunately the control is clipped too with OverPaint().

Best regards
Koldo


Ctrl view is. Its Frames are not.

Frankly, your request is quite specific, it makes the whole paradigm upside-down. Anyway, we had similar problem in the past as X11 input fields paint outside too. But that is just frame...

In practice, I do no undestand why you would want something like that... It is like requiring regular host platform windows to paint one over another.

But I guess you should be able to reuse frame overpaint to this:

#include <CtrlLib/CtrlLib.h>

using namespace Upp;

struct OverCtrl : public Ctrl, public CtrlFrame {
	virtual void FrameAddSize(Size& sz) {}
	virtual void FrameLayout(Rect& r) {}
	virtual void FramePaint(Draw& w, const Rect& r) {
		w.DrawRect(r.left - 10, r.top - 10, r.GetWidth() + 20, r.GetHeight() + 20, Blue());
		w.DrawRect(r, Red());
	}

	virtual int OverPaint() const { return 10; }
	
	OverCtrl() {
		SetFrame(*this);
	}
};

GUI_APP_MAIN
{
	OverCtrl ctrl;
	TopWindow win;
	
	win.Add(ctrl.LeftPos(40, 40).TopPos(40, 10));
	
	win.Run();
}




Mirek
Re: Paint outside Ctrl Rect [message #23835 is a reply to message #23819] Wed, 25 November 2009 14:18 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello Mirek

Excellent: It works !

Quote:

In practice, I do no understand why you would want something like that...


It is easy. Just a sample. Black rectangles are Ctrl ends:

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

If the Ctrl itself is a line or something derived from it (like an arrow) it is nice to see the ends not clipped, mainly with a big width.

Best regards
Koldo


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23836 is a reply to message #23835] Wed, 25 November 2009 14:50 Go to previous messageGo to next message
mirek is currently online  mirek
Messages: 11827
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 25 November 2009 08:18

Hello Mirek

Excellent: It works !

Quote:

In practice, I do no understand why you would want something like that...


It is easy. Just a sample. Black rectangles are Ctrl ends:

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

If the Ctrl itself is a line or something derived from it (like an arrow) it is nice to see the ends not clipped, mainly with a big width.

Best regards
Koldo


Still not undestanding Smile For me, the "BAD" is correct one.... Smile
Re: Paint outside Ctrl Rect [message #23837 is a reply to message #23836] Wed, 25 November 2009 15:33 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello Mirek

If the Arrow is a Ctrl Smile, I see this better like this instead of clipped.

Best regards
Koldo

index.php?t=getfile&id=2006&private=0
  • Attachment: Arrow.png
    (Size: 2.50KB, Downloaded 551 times)


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23838 is a reply to message #23837] Wed, 25 November 2009 19:30 Go to previous messageGo to next message
mirek is currently online  mirek
Messages: 11827
Registered: November 2005
Ultimate Member
koldo wrote on Wed, 25 November 2009 09:33

Hello Mirek

If the Arrow is a Ctrl Smile, I see this better like this instead of clipped.

Best regards
Koldo

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


In that case, why do not you just make it bigger? I mean, include 'overpaint' into its size.

Mirek
Re: Paint outside Ctrl Rect [message #23840 is a reply to message #23838] Wed, 25 November 2009 21:49 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello Mirek

Sorry. I do not know what it is exactly OverPaint for.

In this case as this arrow can be entered in the layout designer, it is expected that the shape of the Ctrl both in the layout designer and in the final program has to be the same.

Best regards
Koldo


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23843 is a reply to message #23788] Thu, 26 November 2009 08:52 Go to previous messageGo to next message
mr_ped is currently offline  mr_ped
Messages: 793
Registered: November 2005
Location: Czech Republic - Praha
Contributor

The control should adapt to arrow's width, and draw it a tad smaller, so it will end inside rectangle and no clipping will happen. That's the correct way how it should work, but I can see it may be a bit tricky to code that size adjustment by width.

edit: I would probably end with calculating new boundary rectangle as 1/2 of line width inside of the clip rectangle. This way the drawn arrow would be inside the clipping, and like 99+% of available space would be used (but under certain arrow's angles like the one you posted it would not use 100% of available space). But I think visually it would work very well even in this simple way.

[Updated on: Thu, 26 November 2009 08:55]

Report message to a moderator

Re: Paint outside Ctrl Rect [message #23844 is a reply to message #23843] Thu, 26 November 2009 10:20 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Hello mr_ped and Mirek

Just another example:

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

Left is from layout designer and right is from the program.

If when painting I move and resize the arrows, they will not match as in the designer view.

Best regards
Koldo
  • Attachment: Draw.png
    (Size: 7.08KB, Downloaded 498 times)


Best regards
Iñaki
Re: Paint outside Ctrl Rect [message #23849 is a reply to message #23844] Thu, 26 November 2009 13:20 Go to previous message
koldo is currently offline  koldo
Messages: 2944
Registered: August 2008
Veteran
Well, now arrow painting in layout designer is improved Smile

This is also another opportunity to compare Draw with Painter quality.

index.php?t=getfile&id=2012&private=0
  • Attachment: Draw.png
    (Size: 7.06KB, Downloaded 527 times)


Best regards
Iñaki
Previous Topic: Calling windows not in main.cpp
Next Topic: up & down within ColumnList moves focus out
Goto Forum:
  


Current Time: Fri Apr 19 13:11:53 CEST 2019

Total time taken to generate the page: 0.00754 seconds