mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
ide, CtrlLib: Vertical labels support in Laydes and .usc
This commit is contained in:
parent
0ea89ac598
commit
609167ede2
8 changed files with 116 additions and 11 deletions
|
|
@ -22,6 +22,18 @@ enum_property Align {
|
||||||
"ALIGN_RIGHT"
|
"ALIGN_RIGHT"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum_property VAlign {
|
||||||
|
"ALIGN_TOP",
|
||||||
|
"ALIGN_CENTER",
|
||||||
|
"ALIGN_BOTTOM"
|
||||||
|
};
|
||||||
|
|
||||||
|
enum_property Orientation {
|
||||||
|
"ORIENTATION_NORMAL",
|
||||||
|
"ORIENTATION_CLOCKWISE",
|
||||||
|
"ORIENTATION_ANTICLOCKWISE"
|
||||||
|
};
|
||||||
|
|
||||||
fn IsUHD()
|
fn IsUHD()
|
||||||
{
|
{
|
||||||
return GetTextSize("X", StdFont()).cy > 24;
|
return GetTextSize("X", StdFont()).cy > 24;
|
||||||
|
|
@ -261,6 +273,8 @@ ctrl Label {
|
||||||
|
|
||||||
Doc SetLabel @0 ? "Label of control";
|
Doc SetLabel @0 ? "Label of control";
|
||||||
Align SetAlign = ALIGN_LEFT @2;
|
Align SetAlign = ALIGN_LEFT @2;
|
||||||
|
VAlign SetVAlign = ALIGN_CENTER @2;
|
||||||
|
Orientation SetOrientation = ORIENTATION_NORMAL @2;
|
||||||
Font SetFont = StdFont() @2;
|
Font SetFont = StdFont() @2;
|
||||||
Color SetInk = :SBlack @2;
|
Color SetInk = :SBlack @2;
|
||||||
Frame SetFrame @3;
|
Frame SetFrame @3;
|
||||||
|
|
@ -268,13 +282,30 @@ ctrl Label {
|
||||||
|
|
||||||
Paint(w) {
|
Paint(w) {
|
||||||
sz = ViewSize(w);
|
sz = ViewSize(w);
|
||||||
textsize = GetSmartTextSize(.SetLabel, .SetFont);
|
/* textsize = GetSmartTextSize(.SetLabel, .SetFont);
|
||||||
px = 0;
|
px = 0;
|
||||||
if(.SetAlign == "ALIGN_CENTER")
|
if(.SetAlign == "ALIGN_CENTER")
|
||||||
px = (sz.cx - textsize.cx) / 2;
|
px = (sz.cx - textsize.cx) / 2;
|
||||||
if(.SetAlign == "ALIGN_RIGHT")
|
if(.SetAlign == "ALIGN_RIGHT")
|
||||||
px = sz.cx - textsize.cx;
|
px = sz.cx - textsize.cx;
|
||||||
w.DrawSmartText(px, (sz.cy - textsize.cy) / 2, .SetLabel, .SetFont, .SetInk, sz.cx);
|
w.DrawSmartText(px, (sz.cy - textsize.cy) / 2, .SetLabel, .SetFont, .SetInk, sz.cx);
|
||||||
|
*/
|
||||||
|
align = 1;
|
||||||
|
if(.SetAlign == "ALIGN_CENTER")
|
||||||
|
align = 3;
|
||||||
|
if(.SetAlign == "ALIGN_RIGHT")
|
||||||
|
align = 2;
|
||||||
|
valign = 3;
|
||||||
|
if(.SetVAlign == "ALIGN_TOP")
|
||||||
|
valign = 1;
|
||||||
|
if(.SetVAlign == "ALIGN_BOTTOM")
|
||||||
|
valign = 2;
|
||||||
|
orientation = 0;
|
||||||
|
if(.SetOrientation == "ORIENTATION_CLOCKWISE")
|
||||||
|
orientation = 1;
|
||||||
|
if(.SetOrientation == "ORIENTATION_ANTICLOCKWISE")
|
||||||
|
orientation = 2;
|
||||||
|
w.DrawLabel(0, 0, sz.cx, sz.cy, .SetLabel, .SetFont, .SetInk, align, valign, orientation);
|
||||||
}
|
}
|
||||||
Sample() {
|
Sample() {
|
||||||
.SetLabel = "Label";
|
.SetLabel = "Label";
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ void DrawSmartText(Draw& w, int x, int y, int cx, const char *text,
|
||||||
Font font = StdFont(), Color ink = SBlack(), int accesskey = 0,
|
Font font = StdFont(), Color ink = SBlack(), int accesskey = 0,
|
||||||
Color qtf_ink = Null, int dark_theme = Null);
|
Color qtf_ink = Null, int dark_theme = Null);
|
||||||
|
|
||||||
enum { ORIENTATION_NORMAL, ORIENTATION_ANTICLOCKWISE, ORIENTATION_CLOCKWISE };
|
enum { ORIENTATION_NORMAL, ORIENTATION_CLOCKWISE, ORIENTATION_ANTICLOCKWISE };
|
||||||
|
|
||||||
void DrawSmartText(Draw& w, int x, int y, int cx, const char *text, int orientation,
|
void DrawSmartText(Draw& w, int x, int y, int cx, const char *text, int orientation,
|
||||||
Font font = StdFont(), Color ink = SBlack(), int accesskey = 0,
|
Font font = StdFont(), Color ink = SBlack(), int accesskey = 0,
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,7 @@ struct EscDraw : public EscHandle {
|
||||||
void DrawLine(EscEscape& e);
|
void DrawLine(EscEscape& e);
|
||||||
void DrawText(EscEscape& e);
|
void DrawText(EscEscape& e);
|
||||||
void DrawSmartText(EscEscape& e);
|
void DrawSmartText(EscEscape& e);
|
||||||
|
void DrawLabel(EscEscape& e);
|
||||||
void DrawQtf(EscEscape& e);
|
void DrawQtf(EscEscape& e);
|
||||||
void GetTextSize(EscEscape& e);
|
void GetTextSize(EscEscape& e);
|
||||||
void DrawImage(EscEscape& e);
|
void DrawImage(EscEscape& e);
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,47 @@ void EscDraw::DrawSmartText(EscEscape& e)
|
||||||
::DrawSmartText(w, x, y, cx, text, font, color, accesskey);
|
::DrawSmartText(w, x, y, cx, text, font, color, accesskey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void EscDraw::DrawLabel(EscEscape& e)
|
||||||
|
{ // DrawLabel(x, y, cx, cy, text, font, ink, align, valign, orientation)
|
||||||
|
if(e.GetCount() < 5 || e.GetCount() > 10)
|
||||||
|
e.ThrowError("wrong number of arguments in call to 'DrawLabel'");
|
||||||
|
int x = e.Int(0);
|
||||||
|
int y = e.Int(1);
|
||||||
|
int cx = e.Int(2);
|
||||||
|
int cy = e.Int(3);
|
||||||
|
|
||||||
|
Upp::DrawLabel dl;
|
||||||
|
int ii = 4;
|
||||||
|
String text;
|
||||||
|
if(ii < e.GetCount() && e[ii].IsArray())
|
||||||
|
dl.text = ToUtf8((WString)e[ii++]);
|
||||||
|
|
||||||
|
dl.font = StdFont().Height(11);
|
||||||
|
if(ii < e.GetCount())
|
||||||
|
dl.font = FontEsc(e[ii++]);
|
||||||
|
if(dl.font.GetHeight() == 0)
|
||||||
|
#ifdef GUI_X11
|
||||||
|
dl.font.Height(12);
|
||||||
|
#else
|
||||||
|
dl.font.Height(11);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(ii < e.GetCount())
|
||||||
|
dl.ink = ColorEsc(e[ii++]);
|
||||||
|
|
||||||
|
if(ii < e.GetCount() && e[ii].IsInt())
|
||||||
|
dl.align = clamp(e.Int(ii++), 1, 3);
|
||||||
|
|
||||||
|
if(ii < e.GetCount() && e[ii].IsInt())
|
||||||
|
dl.valign = clamp(e.Int(ii++), 1, 3);
|
||||||
|
|
||||||
|
if(ii < e.GetCount() && e[ii].IsInt())
|
||||||
|
dl.orientation = clamp(e.Int(ii++), 0, 2);
|
||||||
|
|
||||||
|
dl.Paint(w, e.Int(0), e.Int(1), e.Int(2), e.Int(3));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void EscDraw::DrawQtf(EscEscape& e)
|
void EscDraw::DrawQtf(EscEscape& e)
|
||||||
{
|
{
|
||||||
if(e.GetCount() < 5 || e.GetCount() > 6)
|
if(e.GetCount() < 5 || e.GetCount() > 6)
|
||||||
|
|
@ -467,6 +508,7 @@ EscDraw::EscDraw(EscValue& v, Draw& w)
|
||||||
v.Escape("DrawLine(...)", this, THISBACK(DrawLine));
|
v.Escape("DrawLine(...)", this, THISBACK(DrawLine));
|
||||||
v.Escape("DrawText(...)", this, THISBACK(DrawText));
|
v.Escape("DrawText(...)", this, THISBACK(DrawText));
|
||||||
v.Escape("DrawSmartText(...)", this, THISBACK(DrawSmartText));
|
v.Escape("DrawSmartText(...)", this, THISBACK(DrawSmartText));
|
||||||
|
v.Escape("DrawLabel(...)", this, THISBACK(DrawLabel));
|
||||||
v.Escape("DrawQtf(...)", this, THISBACK(DrawQtf));
|
v.Escape("DrawQtf(...)", this, THISBACK(DrawQtf));
|
||||||
v.Escape("GetTextSize(...)", this, THISBACK(GetTextSize));
|
v.Escape("GetTextSize(...)", this, THISBACK(GetTextSize));
|
||||||
v.Escape("DrawImage(...)", this, THISBACK(DrawImage));
|
v.Escape("DrawImage(...)", this, THISBACK(DrawImage));
|
||||||
|
|
|
||||||
16
upptst/VerticalLabel/VerticalLabel.h
Normal file
16
upptst/VerticalLabel/VerticalLabel.h
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
#ifndef _VerticalLabel_VerticalLabel_h
|
||||||
|
#define _VerticalLabel_VerticalLabel_h
|
||||||
|
|
||||||
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
|
||||||
|
using namespace Upp;
|
||||||
|
|
||||||
|
#define LAYOUTFILE <VerticalLabel/VerticalLabel.lay>
|
||||||
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
|
class VerticalLabel : public WithVerticalLabelLayout<TopWindow> {
|
||||||
|
public:
|
||||||
|
VerticalLabel();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
15
upptst/VerticalLabel/VerticalLabel.lay
Normal file
15
upptst/VerticalLabel/VerticalLabel.lay
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
LAYOUT(VerticalLabelLayout, 804, 248)
|
||||||
|
ITEM(Upp::Label, dv___0, SetLabel(t_("Label!")).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(8, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___1, SetLabel(t_("Label!")).SetAlign(Upp::ALIGN_RIGHT).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(140, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___2, SetLabel(t_("Label!")).SetAlign(Upp::ALIGN_CENTER).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(272, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___3, SetLabel(t_("Label!")).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(8, 128).TopPosZ(128, 116))
|
||||||
|
ITEM(Upp::Label, dv___4, SetLabel(t_("Label!")).SetAlign(Upp::ALIGN_RIGHT).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(140, 128).TopPosZ(128, 116))
|
||||||
|
ITEM(Upp::Label, dv___5, SetLabel(t_("Label!")).SetAlign(Upp::ALIGN_CENTER).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(272, 128).TopPosZ(128, 116))
|
||||||
|
ITEM(Upp::Label, dv___6, SetLabel(t_("Label!")).SetAlign(Upp::ALIGN_CENTER).SetVAlign(Upp::ALIGN_TOP).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(404, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___7, SetLabel(t_("\001[/ Label!")).SetAlign(Upp::ALIGN_CENTER).SetVAlign(Upp::ALIGN_BOTTOM).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(536, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___8, SetLabel(t_("\001[/ Label!")).SetAlign(Upp::ALIGN_CENTER).SetVAlign(Upp::ALIGN_TOP).SetOrientation(Upp::ORIENTATION_CLOCKWISE).LeftPosZ(668, 128).TopPosZ(8, 116))
|
||||||
|
ITEM(Upp::Label, dv___9, SetLabel(t_("Label!")).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(404, 128).TopPosZ(128, 116))
|
||||||
|
ITEM(Upp::Label, dv___10, SetLabel(t_("\001[/ Label!")).SetAlign(Upp::ALIGN_CENTER).SetVAlign(Upp::ALIGN_TOP).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(536, 128).TopPosZ(128, 116))
|
||||||
|
ITEM(Upp::Label, dv___11, SetLabel(t_("\001[/ Label!")).SetAlign(Upp::ALIGN_CENTER).SetVAlign(Upp::ALIGN_BOTTOM).SetOrientation(Upp::ORIENTATION_ANTICLOCKWISE).LeftPosZ(668, 128).TopPosZ(128, 116))
|
||||||
|
END_LAYOUT
|
||||||
|
|
||||||
|
|
@ -2,7 +2,9 @@ uses
|
||||||
CtrlLib;
|
CtrlLib;
|
||||||
|
|
||||||
file
|
file
|
||||||
main.cpp;
|
VerticalLabel.h,
|
||||||
|
main.cpp,
|
||||||
|
VerticalLabel.lay;
|
||||||
|
|
||||||
mainconfig
|
mainconfig
|
||||||
"" = "GUI";
|
"" = "GUI";
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
#include <CtrlLib/CtrlLib.h>
|
#include "VerticalLabel.h"
|
||||||
|
|
||||||
using namespace Upp;
|
VerticalLabel::VerticalLabel()
|
||||||
|
{
|
||||||
|
CtrlLayout(*this, "Window title");
|
||||||
|
}
|
||||||
|
|
||||||
GUI_APP_MAIN
|
GUI_APP_MAIN
|
||||||
{
|
{
|
||||||
TopWindow win;
|
VerticalLabel().Run();
|
||||||
Label l;
|
|
||||||
l = "This is a label";
|
|
||||||
win << l.SizePos();
|
|
||||||
l.SetOrientation(ORIENTATION_VERTICAL_LEFT);
|
|
||||||
win.Run();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue