mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-07-11 22:03:01 -06:00
.uppdev
git-svn-id: svn://ultimatepp.org/upp/trunk@6119 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
dc765a3537
commit
fdadae2c0b
4 changed files with 83 additions and 27 deletions
|
|
@ -1,8 +1,9 @@
|
|||
LAYOUT(AccessKeyLayout, 200, 100)
|
||||
ITEM(Base, ok, RightPosZ(90, 80).BottomPosZ(4, 22))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(4, 22))
|
||||
LAYOUT(AccessKeyLayout, 200, 308)
|
||||
ITEM(Base, ok, RightPosZ(90, 80).BottomPosZ(212, 22))
|
||||
ITEM(Button, cancel, SetLabel(t_("Cancel")).RightPosZ(4, 80).BottomPosZ(212, 22))
|
||||
ITEM(Label, dv___2, SetLabel(t_("asdfasdf\a\001[= Test")).SetFont(SansSerifZ(20)).LeftPosZ(8, 188).TopPosZ(28, 32))
|
||||
ITEM(EditDate, dv___3, LeftPosZ(56, 140).TopPosZ(4, 19))
|
||||
ITEM(Button, dv___4, SetLabel(t_("\001[= Test&asdflkajsdf&asdflkasldfjlkajsdf")).LeftPosZ(8, 184).TopPosZ(116, 188))
|
||||
END_LAYOUT
|
||||
|
||||
LAYOUT(asdfasdf, 400, 200)
|
||||
|
|
|
|||
|
|
@ -1,27 +1,64 @@
|
|||
#include "glyph.h"
|
||||
|
||||
void SImageDraw::PutImage(Point p, const Image& m, const Rect& src)
|
||||
void SImageDraw1::PutImage(Point p, const Image& m, const Rect& src)
|
||||
{
|
||||
Over(b, p, m, src);
|
||||
Over(ib, p, m, src);
|
||||
}
|
||||
|
||||
void SImageDraw::PutRect(const Rect& r, Color color)
|
||||
void SImageDraw1::PutRect(const Rect& r, Color color)
|
||||
{
|
||||
Upp::Fill(b, r, color);
|
||||
Upp::Fill(ib, r, color);
|
||||
}
|
||||
|
||||
void SImageDraw1::Create(Size sz)
|
||||
{
|
||||
ib.Create(sz);
|
||||
Init(sz);
|
||||
}
|
||||
|
||||
Draw& SImageDraw::Alpha()
|
||||
{
|
||||
if(!has_alpha) {
|
||||
Size sz = ib.GetSize();
|
||||
alpha.Create(sz);
|
||||
alpha.DrawRect(sz, GrayColor(0));
|
||||
has_alpha = true;
|
||||
}
|
||||
return alpha;
|
||||
}
|
||||
|
||||
SImageDraw::operator Image() const
|
||||
{
|
||||
ImageBuffer b(ib.GetSize());
|
||||
memcpy(b, ib.Begin(), sizeof(RGBA) * ib.GetLength());
|
||||
const RGBA *s = alpha.ib.Begin();
|
||||
RGBA *t = b;
|
||||
const RGBA *e = b.End();;
|
||||
if(has_alpha) {
|
||||
while(t < e) {
|
||||
t->a = s->r;
|
||||
t++;
|
||||
s++;
|
||||
}
|
||||
Premultiply(b);
|
||||
b.SetKind(IMAGE_ALPHA);
|
||||
}
|
||||
else {
|
||||
while(t < e) {
|
||||
t->a = 255;
|
||||
t++;
|
||||
}
|
||||
b.SetKind(IMAGE_OPAQUE);
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
SImageDraw::SImageDraw(Size sz)
|
||||
{
|
||||
Init(sz);
|
||||
b.Create(sz);
|
||||
SImageDraw1::Create(sz);
|
||||
}
|
||||
|
||||
SImageDraw::SImageDraw(int cx, int cy)
|
||||
{
|
||||
Init(Size(cx, cy));
|
||||
b.Create(cx, cy);
|
||||
}
|
||||
|
||||
SImageDraw::~SImageDraw()
|
||||
{
|
||||
SImageDraw1::Create(Size(cx, cy));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,17 +20,30 @@ struct TestDraw : SDraw {
|
|||
};
|
||||
|
||||
|
||||
struct SImageDraw : SDraw {
|
||||
ImageBuffer b;
|
||||
class SImageDraw1 : public SDraw {
|
||||
protected:
|
||||
ImageBuffer ib;
|
||||
friend class SImageDraw;
|
||||
|
||||
public:
|
||||
virtual void PutImage(Point p, const Image& m, const Rect& src);
|
||||
virtual void PutRect(const Rect& r, Color color);
|
||||
|
||||
Image PickResult() { return b; }
|
||||
|
||||
void Create(Size sz);
|
||||
};
|
||||
|
||||
class SImageDraw : public SImageDraw1 {
|
||||
SImageDraw1 alpha;
|
||||
|
||||
bool has_alpha;
|
||||
|
||||
public:
|
||||
Draw& Alpha();
|
||||
|
||||
operator Image() const;
|
||||
|
||||
SImageDraw(Size sz);
|
||||
SImageDraw(int cx, int cy);
|
||||
~SImageDraw();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -27,6 +27,17 @@ struct MyApp : TopWindow {
|
|||
|
||||
Image MyApp::CursorImage(Point p, dword keyflags)
|
||||
{
|
||||
static Image img;
|
||||
ONCELOCK {
|
||||
SImageDraw w(64, 64);
|
||||
w.DrawRect(0, 0, 64, 64, White());
|
||||
w.DrawText(2, 2, "A", Roman(60), Black());
|
||||
for(int x = -2; x <= 2; x++)
|
||||
for(int y = -2; y <= 2; y++)
|
||||
w.Alpha().DrawText(2 + x, 2 + y, "A", Roman(60), White());
|
||||
img = w;
|
||||
}
|
||||
return img;
|
||||
return GlyphImg::cursor1();
|
||||
}
|
||||
|
||||
|
|
@ -105,14 +116,9 @@ void MyApp::Paint(Draw& w)
|
|||
|
||||
// clip.Add(sz);
|
||||
|
||||
#if 0
|
||||
TestDraw fw;
|
||||
fw.draw = &w;
|
||||
fw.Init(sz);
|
||||
#else
|
||||
SImageDraw fw(sz);
|
||||
fw.DrawRect(sz, WhiteGray());
|
||||
#endif
|
||||
|
||||
// fw.DrawText(100, 100, "Ahoj!", Roman(400));
|
||||
|
||||
|
|
@ -134,6 +140,7 @@ void MyApp::Paint(Draw& w)
|
|||
sw.Clear(White());
|
||||
txt.Paint(Zoom(2, 10), sw, 0, 0, sz.cx);
|
||||
}
|
||||
|
||||
/*
|
||||
fw.cloff.Add();
|
||||
fw.cloff.Top().offset = Point(0, 0);
|
||||
|
|
@ -148,8 +155,6 @@ void MyApp::Paint(Draw& w)
|
|||
// fw.DrawText(sz.cx / 2, sz.cy / 2, -3600 * Bearing(p - sz / 2) / M_2PI,
|
||||
// "Hello world! abcdefghijklmnopqrstuv", Roman(40).Underline(), Red());
|
||||
fw.DrawImage(p.x, p.y, CtrlImg::reporticon(), RectC(0, 0, 20, 12), Blue());
|
||||
|
||||
w.DrawImage(0, 0, fw.PickResult());
|
||||
}
|
||||
|
||||
GUI_APP_MAIN
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue