mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 14:16:07 -06:00
Tutorial: Draw tutorial code modernization.
git-svn-id: svn://ultimatepp.org/upp/trunk@15464 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
parent
530fd101b8
commit
233b0fd047
5 changed files with 16 additions and 16 deletions
|
|
@ -3,7 +3,7 @@
|
|||
using namespace Upp;
|
||||
|
||||
struct MyApp : TopWindow {
|
||||
virtual void Paint(Draw& w) {
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), White());
|
||||
|
||||
w.DrawRect(10, 10, 60, 80, Green());
|
||||
|
|
|
|||
|
|
@ -7,7 +7,8 @@ struct MyApp : TopWindow {
|
|||
w.DrawEllipse(0, 0, 100, 30, WhiteGray(), 1, Cyan);
|
||||
w.DrawText(0, 0, "Hello world", Roman(30).Bold());
|
||||
}
|
||||
virtual void Paint(Draw& w) {
|
||||
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), White());
|
||||
DoPainting(w);
|
||||
w.Offset(30, 50);
|
||||
|
|
|
|||
|
|
@ -3,17 +3,18 @@
|
|||
using namespace Upp;
|
||||
|
||||
struct MyApp : TopWindow {
|
||||
DropList fontlist;
|
||||
DropList font_list;
|
||||
|
||||
void Paint(Draw& w) {
|
||||
virtual void Paint(Draw& w) override {
|
||||
const String text = "Programming is fun";
|
||||
Font fnt(~font_list, 60);
|
||||
|
||||
w.DrawRect(GetSize(), White);
|
||||
w.Offset(50, 50);
|
||||
const char *text = "Programming is fun";
|
||||
Font fnt(~fontlist, 60);
|
||||
int x = 0;
|
||||
Vector<int> dx;
|
||||
for(const char *s = text; *s; s++) {
|
||||
int width = fnt[*s];
|
||||
for(char letter : text) {
|
||||
int width = fnt[letter];
|
||||
w.DrawRect(x, 0, width - 1, fnt.GetAscent(), Color(255, 255, 200));
|
||||
w.DrawRect(x, fnt.GetAscent(), width - 1, fnt.GetDescent(), Color(255, 200, 255));
|
||||
w.DrawRect(x + width - 1, 0, 1, fnt.GetHeight(), Black());
|
||||
|
|
@ -30,14 +31,12 @@ struct MyApp : TopWindow {
|
|||
Refresh();
|
||||
}
|
||||
|
||||
typedef MyApp CLASSNAME;
|
||||
|
||||
MyApp() {
|
||||
for(int i = 0; i < Font::GetFaceCount(); i++)
|
||||
fontlist.Add(i, Font::GetFaceName(i));
|
||||
Add(fontlist.TopPos(0, MINSIZE).LeftPosZ(0, 200));
|
||||
fontlist <<= 0;
|
||||
fontlist <<= THISBACK(NewFont);
|
||||
font_list.Add(i, Font::GetFaceName(i));
|
||||
Add(font_list.TopPos(0, MINSIZE).LeftPosZ(0, 200));
|
||||
font_list <<= 0;
|
||||
font_list << [=] { NewFont(); };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
struct MyApp : TopWindow {
|
||||
Drawing drawing;
|
||||
|
||||
void Paint(Draw& w) {
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), White());
|
||||
w.DrawDrawing(10, 10, 50, 60, drawing);
|
||||
w.DrawDrawing(100, 10, 150, 100, drawing);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using namespace Upp;
|
|||
struct MyApp : TopWindow {
|
||||
Image image;
|
||||
|
||||
void Paint(Draw& w) {
|
||||
virtual void Paint(Draw& w) override {
|
||||
w.DrawRect(GetSize(), Cyan());
|
||||
w.DrawImage(10, 10, image);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue