Home » Community » Newbie corner » Control with fixed rate Height/Width
|
|
|
|
Re: Control with fixed rate Height/Width [message #32587 is a reply to message #32519] |
Thu, 26 May 2011 10:19   |
 |
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 #32595 is a reply to message #32594] |
Thu, 26 May 2011 13:31   |
 |
koldo
Messages: 3432 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:

As you can see, Layout Designeer does not let you draw outside Control boundaries.
-
Attachment: dib.PNG
(Size: 2.73KB, Downloaded 655 times)
Best regards
Iñaki
|
|
|
|
|
Goto Forum:
Current Time: Sun Apr 27 00:19:50 CEST 2025
Total time taken to generate the page: 0.00679 seconds
|