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 » Community » Newbie corner » Control with fixed rate Height/Width
Control with fixed rate Height/Width [message #32400] Mon, 16 May 2011 10:04 Go to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

I want a fixed rate Height/Width for a control, in any condition (resizing it in layout designer, resizing the window, zoomed window or not etc.). Is there a simple way to obtain this ? I get comfused studying Ctrl.cpp code... So many ways to change the size !

Re: Control with fixed rate Height/Width [message #32402 is a reply to message #32400] Mon, 16 May 2011 11:30 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Jibe

The brute force way could be overloading Layout() method.
However this would not serve in the Layout Designer.


Best regards
Iñaki
Re: Control with fixed rate Height/Width [message #32506 is a reply to message #32400] Mon, 23 May 2011 09:44 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

Thanks Smile

I'll make some tries and see...

For the layout designer, is the right place to do this in the .usc file ?
Re: Control with fixed rate Height/Width [message #32519 is a reply to message #32506] Mon, 23 May 2011 16:02 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
jibe wrote on Mon, 23 May 2011 09:44

Hi,

Thanks Smile

I'll make some tries and see...

For the layout designer, is the right place to do this in the .usc file ?

Sorry, I do not understand Rolling Eyes


Best regards
Iñaki
Re: Control with fixed rate Height/Width [message #32587 is a reply to message #32519] Thu, 26 May 2011 10:19 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
*.usc files are the U++ own ESC language files (go to manual for it), they serve TheIDE as a description how to show custom (or builtin) Ctrl's in Layout editor.

to achieve your goal, you need to derive the desired class overriding the Layout() function from Ctrl and specifying new size of the control based on lets say the x size.

maybe sth like that.
class MyEdit : public EditString
{
    virtual void Layout()
    {
         Rect r = GetRect();
         r.y = 0.5*x;
         SetRect(r);         
    }
};


what kolde meant is, that Layout editor wont be aware of your custom Layout function, in case you place your widget as a user class Ctrl on a layout. so it will be arbitrary resizeable in Layout Editor but will behave accordingly at runtime.

BTW: SetRect always Sets your Ctrl LogPos as to be LeftPos().TopPos() aligned. if you want sth more specific, you need to dig the LogPos facilities. see my LogPosCtrl package, there you will find some ressources on how to handle LogPos properly recalculating it based on alignment and Rect position.

[Updated on: Thu, 26 May 2011 10:22]

Report message to a moderator

Re: Control with fixed rate Height/Width [message #32589 is a reply to message #32400] Thu, 26 May 2011 11:23 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
Hi,

Thanks for those explanations, kohait00 Smile

I'll try that soon...

BTW : I was unable to find the doc about .usc files... Could you point me to the right manual page ? Thanks.
Re: Control with fixed rate Height/Width [message #32594 is a reply to message #32589] Thu, 26 May 2011 13:15 Go to previous messageGo to next message
kohait00 is currently offline  kohait00
Messages: 939
Registered: July 2009
Location: Germany
Experienced Contributor
http://www.ultimatepp.org/srcdoc$Esc$Esc$en-us.html

unfortunately there is not more doc available on that. upp is work in progress Smile

for more usc examples just search the upp folder for that type of files. i remember bazaar also having some of them, i.e. Controls4U

[Updated on: Thu, 26 May 2011 13:16]

Report message to a moderator

Re: Control with fixed rate Height/Width [message #32595 is a reply to message #32594] Thu, 26 May 2011 13:31 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Jibe

As far as I know there are no .usc document.

However I was not completely right about Layout Designer. See this code. It is a little bit overcomplex for this example, but it is rather easy

ctrl StaticRectangle {
	group "Static";

	GetMinSize() { return Size(0, 0); }
	GetStdSize() { return Size(64, 24); }
	
	bool IsSquare = false;
	int SetWidth = 1;
	Color SetColor = :SBlack;	
	Color SetBackground = Null;
	
	Paint(w) {
		r = GetRect();
		width = r.right - r.left;
		if (.IsSquare) 
			height = r.right - r.left;
		else
			height = r.bottom - r.top;
		w.DrawRect(r.left, r.top, width, height, .SetBackground);
		w.DrawRect(r.left, r.top, width, .SetWidth, .SetColor);
		w.DrawRect(r.right - .SetWidth, r.top, .SetWidth, height, .SetColor);
		w.DrawRect(r.left, r.top + height - .SetWidth, width, .SetWidth, .SetColor);
		w.DrawRect(r.left, r.top, .SetWidth, height, .SetColor);
	}
}


If the programmer chooses IsSquare = true in Layout Designer, s/he will obtain these possibilities:

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


As you can see, Layout Designeer does not let you draw outside Control boundaries.
  • Attachment: dib.PNG
    (Size: 2.73KB, Downloaded 561 times)


Best regards
Iñaki
Re: Control with fixed rate Height/Width [message #32597 is a reply to message #32594] Thu, 26 May 2011 19:19 Go to previous messageGo to next message
jibe is currently offline  jibe
Messages: 294
Registered: February 2007
Location: France
Experienced Member
kohait00 wrote on Thu, 26 May 2011 13:15

http://www.ultimatepp.org/srcdoc$Esc$Esc$en-us.html

unfortunately there is not more doc available on that. upp is work in progress Smile

Thanks for the link. Koldo already told me that there is no doc for usc files, but as you seemed to know one... Well, the doc about esc is usefull, and probably will help me to understand .usc samples Smile

koldo wrote on Thu, 26 May 2011 13:31

However I was not completely right about Layout Designer. See this code. It is a little bit overcomplex for this example, but it is rather easy

Thanks for this code. I'll study and try that tomorrow (late today, and I'm not yet finish...) I already did something, not perfect but not too bad. See in Slider/Progress forum.
Re: Control with fixed rate Height/Width [message #32599 is a reply to message #32597] Thu, 26 May 2011 22:08 Go to previous message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Jibe

Now it is added in Controls4U StaticRectangle class, as a new IsSquare() method.

See the results in LayoutDesigner and in program:

index.php?t=getfile&id=3265&private=0
  • Attachment: dib.PNG
    (Size: 30.12KB, Downloaded 329 times)


Best regards
Iñaki
Previous Topic: [SOLVED] I have a problem linking a LIB
Next Topic: How to internet enable a serial device
Goto Forum:
  


Current Time: Thu Apr 18 23:38:30 CEST 2024

Total time taken to generate the page: 0.03044 seconds