mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-05-15 06:05:58 -06:00
CtrlLib: Fixed appearance of empty TreeCtrl, .examples
This commit is contained in:
parent
91b7c7e709
commit
d9a58cecfd
9 changed files with 56 additions and 110 deletions
|
|
@ -13,11 +13,7 @@ public:
|
||||||
private:
|
private:
|
||||||
String text;
|
String text;
|
||||||
|
|
||||||
void Animate() { Refresh(); }
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef HelloWorld CLASSNAME;
|
|
||||||
|
|
||||||
HelloWorld& Text(const String& t) { text = t; Refresh(); return *this; }
|
HelloWorld& Text(const String& t) { text = t; Refresh(); return *this; }
|
||||||
|
|
||||||
HelloWorld();
|
HelloWorld();
|
||||||
|
|
@ -25,31 +21,29 @@ public:
|
||||||
|
|
||||||
HelloWorld::HelloWorld()
|
HelloWorld::HelloWorld()
|
||||||
{
|
{
|
||||||
SetTimeCallback(-40, THISBACK(Animate));
|
SetTimeCallback(-40, [=] { Refresh(); });
|
||||||
BackPaint();
|
BackPaint();
|
||||||
Zoomable().Sizeable();
|
Zoomable().Sizeable();
|
||||||
SetRect(0, 0, 260, 80);
|
SetRect(0, 0, 1000, 300);
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloWorld::LeftDown(Point, dword)
|
void HelloWorld::LeftDown(Point, dword)
|
||||||
{
|
{
|
||||||
Close();
|
EditText(text, "Text to display", "Text");
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelloWorld::Paint(Draw& w)
|
void HelloWorld::Paint(Draw& w)
|
||||||
{
|
{
|
||||||
|
Font fnt = Roman(64);
|
||||||
Size sz = GetSize();
|
Size sz = GetSize();
|
||||||
static int sin_tbl[16] = {
|
|
||||||
0, 38, 71, 92, 100, 92, 71, 38, 0, -38, -71, -92, -100, -92, -71, -38
|
|
||||||
};
|
|
||||||
w.DrawRect(sz, White);
|
w.DrawRect(sz, White);
|
||||||
Size tsz = GetTextSize(text, Roman(32));
|
Size tsz = GetTextSize(text, fnt);
|
||||||
Point pos = (sz - tsz) / 2;
|
Point pos = (sz - tsz) / 2;
|
||||||
for(int i = 0; i < text.GetLength(); i++) {
|
for(int i = 0; i < text.GetLength(); i++) {
|
||||||
int q = (i + GetTickCount() / 40) & 15;
|
int q = (i + GetTickCount() / 40) & 15;
|
||||||
w.DrawText(pos.x, pos.y + sin_tbl[q] * (sz.cy - 32) / 200,
|
w.DrawText(pos.x, pos.y + sin(GetTickCount() / 100.0 + i / 2.0) * (sz.cy - fnt.GetCy()) / 4,
|
||||||
~text + i, Roman(32), HsvColorf(q / 15.0, 1, 0.5), 1);
|
~text + i, fnt, HsvColorf(q / 15.0, 1, 0.5), 1);
|
||||||
pos.x += Roman(32).Info()[text[i]];
|
pos.x += fnt[text[i]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
#include <CtrlLib/CtrlLib.h>
|
#include <CtrlLib/CtrlLib.h>
|
||||||
|
|
||||||
|
|
||||||
|
#define IMAGECLASS BombsImg
|
||||||
|
#define IMAGEFILE <Bombs/bombs.iml>
|
||||||
|
#include <Draw/iml.h>
|
||||||
|
|
||||||
using namespace Upp;
|
using namespace Upp;
|
||||||
|
|
||||||
class Bombs : public TopWindow {
|
class Bombs : public TopWindow {
|
||||||
|
|
@ -27,21 +32,13 @@ private:
|
||||||
|
|
||||||
int UNIT = 30;
|
int UNIT = 30;
|
||||||
|
|
||||||
void About();
|
|
||||||
|
|
||||||
void File(Bar& menu);
|
|
||||||
void Game(Bar& menu);
|
|
||||||
void Menu(Bar& menu);
|
|
||||||
|
|
||||||
void ShowStatus();
|
void ShowStatus();
|
||||||
void Level(Size sz);
|
|
||||||
|
|
||||||
void Uncover(int x, int y);
|
void Uncover(int x, int y);
|
||||||
void Generate();
|
void Generate();
|
||||||
void UncoverAll();
|
void UncoverAll();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef Bombs CLASSNAME;
|
|
||||||
Bombs();
|
Bombs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -169,51 +166,29 @@ void Bombs::ShowStatus()
|
||||||
status = Format("%d bombs, %d cells remaining", bombs, normal_cells);
|
status = Format("%d bombs, %d cells remaining", bombs, normal_cells);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bombs::Level(Size sz)
|
|
||||||
{
|
|
||||||
level = sz;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bombs::About()
|
|
||||||
{
|
|
||||||
PromptOK("[*A9/ uBombs]&[A5 Ultimate`+`+ example]");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bombs::File(Bar& menu)
|
|
||||||
{
|
|
||||||
menu.Add("Exit", Breaker(IDOK));
|
|
||||||
menu.Separator();
|
|
||||||
menu.Add("About..", THISBACK(About));
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bombs::Game(Bar& menu)
|
|
||||||
{
|
|
||||||
menu.Add("Restart", THISBACK(Generate));
|
|
||||||
menu.Separator();
|
|
||||||
menu.Add("Easy", THISBACK1(Level, Size(10, 10)))
|
|
||||||
.Check(level.cx == 10);
|
|
||||||
menu.Add("Medium", THISBACK1(Level, Size(15, 15)))
|
|
||||||
.Check(level.cx == 15);
|
|
||||||
menu.Add("Difficult", THISBACK1(Level, Size(25, 20)))
|
|
||||||
.Check(level.cx == 25);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Bombs::Menu(Bar& menu)
|
|
||||||
{
|
|
||||||
menu.Add("File", THISBACK(File));
|
|
||||||
menu.Add("Game", THISBACK(Game));
|
|
||||||
}
|
|
||||||
|
|
||||||
#define IMAGECLASS BombsImg
|
|
||||||
#define IMAGEFILE <Bombs/bombs.iml>
|
|
||||||
#include <Draw/iml.h>
|
|
||||||
|
|
||||||
Bombs::Bombs()
|
Bombs::Bombs()
|
||||||
{
|
{
|
||||||
UNIT = DPI(30);
|
UNIT = DPI(30);
|
||||||
level = Size(10, 10);
|
level = Size(10, 10);
|
||||||
AddFrame(menu);
|
AddFrame(menu);
|
||||||
menu.Set(THISBACK(Menu));
|
menu.Set([=](Bar& bar) {
|
||||||
|
menu.Sub("File", [=](Bar& bar) {
|
||||||
|
bar.Add("Exit", Breaker(IDOK));
|
||||||
|
bar.Separator();
|
||||||
|
bar.Add("About..", [] { PromptOK("[*A9/ uBombs]&[A5 Ultimate`+`+ example]"); });
|
||||||
|
});
|
||||||
|
menu.Sub("Game", [=](Bar& bar) {
|
||||||
|
bar.Add("Restart", [=] { Generate(); });
|
||||||
|
bar.Separator();
|
||||||
|
auto Lvl = [&](const char *txt, int cx, int cy) {
|
||||||
|
bar.Add(txt, [=] { level = Size(cx, cy); })
|
||||||
|
.Check(level == Size(cx, cy));
|
||||||
|
};
|
||||||
|
Lvl("Easy", 10, 10);
|
||||||
|
Lvl("Medium", 15, 15);
|
||||||
|
Lvl("Difficult", 25, 20);
|
||||||
|
});
|
||||||
|
});
|
||||||
AddFrame(status);
|
AddFrame(status);
|
||||||
AddFrame(InsetFrame());
|
AddFrame(InsetFrame());
|
||||||
Title("uBombs");
|
Title("uBombs");
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,6 @@ static String ExpandTabs(String line, int tabsize = 4)
|
||||||
|
|
||||||
class DlgCompareDir : public WithCompareDirLayout<TopWindow> {
|
class DlgCompareDir : public WithCompareDirLayout<TopWindow> {
|
||||||
public:
|
public:
|
||||||
typedef DlgCompareDir CLASSNAME;
|
|
||||||
DlgCompareDir();
|
DlgCompareDir();
|
||||||
|
|
||||||
void Run();
|
void Run();
|
||||||
|
|
@ -76,19 +75,19 @@ DlgCompareDir::DlgCompareDir()
|
||||||
{
|
{
|
||||||
CtrlLayout(*this, "Compare directories");
|
CtrlLayout(*this, "Compare directories");
|
||||||
Sizeable().Zoomable();
|
Sizeable().Zoomable();
|
||||||
refresh <<= THISBACK(CmdRefresh);
|
refresh << [=] { CmdRefresh(); };
|
||||||
splitter.Vert(tree, editor);
|
splitter.Vert(tree, editor);
|
||||||
editor << lineedit.SizePos() << qtf.SizePos();
|
editor << lineedit.SizePos() << qtf.SizePos();
|
||||||
qtf.Background(White());
|
qtf.Background(White());
|
||||||
qtf.SetFrame(InsetFrame());
|
qtf.SetFrame(InsetFrame());
|
||||||
path_a.AddFrame(browse_a);
|
path_a.AddFrame(browse_a);
|
||||||
browse_a.SetImage(CtrlImg::right_arrow());
|
browse_a.SetImage(CtrlImg::right_arrow());
|
||||||
browse_a <<= THISBACK1(DoBrowse, &path_a);
|
browse_a << [=] { DoBrowse(&path_a); };
|
||||||
path_b.AddFrame(browse_b);
|
path_b.AddFrame(browse_b);
|
||||||
browse_b.SetImage(CtrlImg::right_arrow());
|
browse_b.SetImage(CtrlImg::right_arrow());
|
||||||
browse_b <<= THISBACK1(DoBrowse, &path_b);
|
browse_b << [=] { DoBrowse(&path_b); };
|
||||||
file_mask <<= "*.cpp *.h *.hpp *.c *.C *.cxx *.cc *.lay *.iml *.upp *.sch *.dph";
|
file_mask <<= "*.cpp *.h *.hpp *.c *.C *.cxx *.cc *.lay *.iml *.upp *.sch *.dph";
|
||||||
tree.WhenCursor = THISBACK(DoTreeCursor);
|
tree.WhenCursor = [=] { DoTreeCursor(); };
|
||||||
lineedit.SetReadOnly();
|
lineedit.SetReadOnly();
|
||||||
lineedit.SetFont(Courier(14));
|
lineedit.SetFont(Courier(14));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
description "Converts metric units and U.S. units (meters / feets etc..)";
|
description "Converts metric units and U.S. units (meters / feets etc..)\377";
|
||||||
|
|
||||||
uses
|
uses
|
||||||
CtrlLib;
|
CtrlLib;
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,7 @@
|
||||||
#ifdef LAYOUTFILE
|
LAYOUT(ConverterPaneLayout, 280, 76)
|
||||||
|
ITEM(Upp::LabelBox, title, LeftPosZ(8, 268).TopPosZ(4, 64))
|
||||||
LAYOUT(ConverterPaneLayout, 244, 76)
|
ITEM(Upp::EditDoubleSpin, value, LeftPosZ(16, 144).TopPosZ(20, 19))
|
||||||
ITEM(LabelBox, title, LeftPosZ(8, 228).TopPosZ(4, 64))
|
ITEM(Upp::SliderCtrl, slider, LeftPosZ(16, 252).TopPosZ(40, 20))
|
||||||
ITEM(EditDoubleSpin, value, LeftPosZ(16, 144).TopPosZ(20, 19))
|
ITEM(Upp::DropList, unit, LeftPosZ(164, 104).TopPosZ(20, 19))
|
||||||
ITEM(SliderCtrl, slider, LeftPosZ(16, 144).TopPosZ(40, 20))
|
|
||||||
ITEM(DropList, unit, LeftPosZ(164, 64).TopPosZ(20, 19))
|
|
||||||
END_LAYOUT
|
END_LAYOUT
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,33 +8,20 @@ using namespace Upp;
|
||||||
#include <CtrlCore/lay.h>
|
#include <CtrlCore/lay.h>
|
||||||
|
|
||||||
struct ConverterPane : WithConverterPaneLayout<StaticRect> {
|
struct ConverterPane : WithConverterPaneLayout<StaticRect> {
|
||||||
ConverterPane *slave;
|
ConverterPane *other;
|
||||||
void AdjustSlave()
|
void Sync()
|
||||||
{
|
{
|
||||||
slave->slider <<= slave->value <<=
|
other->slider <<= other->value <<= (double)~unit * Nvl((double)~value) / (double)~other->unit;
|
||||||
IsNull(value) ? 0.0 : (double)~unit * (double)~value / (double)~slave->unit;
|
|
||||||
}
|
}
|
||||||
void ValueChanged()
|
|
||||||
{
|
|
||||||
slider <<= ~value;
|
|
||||||
AdjustSlave();
|
|
||||||
}
|
|
||||||
void SliderChanged()
|
|
||||||
{
|
|
||||||
value <<= ~slider;
|
|
||||||
AdjustSlave();
|
|
||||||
}
|
|
||||||
|
|
||||||
typedef ConverterPane CLASSNAME;
|
|
||||||
|
|
||||||
ConverterPane()
|
ConverterPane()
|
||||||
{
|
{
|
||||||
CtrlLayout(*this);
|
CtrlLayout(*this);
|
||||||
slider.Range(10000);
|
slider.Range(10000);
|
||||||
slider <<= value <<= 0;
|
slider <<= value <<= 0;
|
||||||
value <<= THISBACK(ValueChanged);
|
value << [=] { slider <<= ~value; Sync(); };
|
||||||
slider <<= THISBACK(SliderChanged);
|
slider << [=] { value <<= ~slider; Sync(); };
|
||||||
unit <<= THISBACK(AdjustSlave);
|
unit << [=] { Sync(); };
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -65,10 +52,10 @@ struct Converter : TopWindow
|
||||||
us.unit.Add(1613.0, "Miles");
|
us.unit.Add(1613.0, "Miles");
|
||||||
us.unit <<= 0.305;
|
us.unit <<= 0.305;
|
||||||
|
|
||||||
us.slave = &metric;
|
us.other = &metric;
|
||||||
metric.slave = &us;
|
metric.other = &us;
|
||||||
|
|
||||||
metric.AdjustSlave();
|
metric.Sync();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -139,10 +139,6 @@ struct FnGraph : public TopWindow {
|
||||||
int zoom = 9;
|
int zoom = 9;
|
||||||
EditString expression; // function to display
|
EditString expression; // function to display
|
||||||
|
|
||||||
void RefreshExpression() { Refresh(); }
|
|
||||||
|
|
||||||
typedef FnGraph CLASSNAME;
|
|
||||||
|
|
||||||
FnGraph();
|
FnGraph();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -150,7 +146,7 @@ FnGraph::FnGraph()
|
||||||
{
|
{
|
||||||
Title("Graph of a function");
|
Title("Graph of a function");
|
||||||
Add(expression.TopPos(0).HSizePos()); // place widget to the top, horizontally fill the window
|
Add(expression.TopPos(0).HSizePos()); // place widget to the top, horizontally fill the window
|
||||||
expression << THISBACK(RefreshExpression); // when expression changes, repaint the graph
|
expression << [=] { Refresh(); }; // when expression changes, repaint the graph
|
||||||
Sizeable().Zoomable(); // make the window resizable
|
Sizeable().Zoomable(); // make the window resizable
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,8 +19,6 @@ private:
|
||||||
void DirUp();
|
void DirUp();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef ImageView CLASSNAME;
|
|
||||||
|
|
||||||
void Serialize(Stream& s);
|
void Serialize(Stream& s);
|
||||||
void LoadDir(const char *d);
|
void LoadDir(const char *d);
|
||||||
void LoadDir() { LoadDir(dir); }
|
void LoadDir() { LoadDir(dir); }
|
||||||
|
|
@ -115,12 +113,12 @@ ImageView::ImageView()
|
||||||
splitter.SetPos(2700);
|
splitter.SetPos(2700);
|
||||||
Add(splitter.SizePos());
|
Add(splitter.SizePos());
|
||||||
|
|
||||||
files.WhenEnterItem = THISBACK(Enter);
|
files.WhenEnterItem = [=] { Enter(); };
|
||||||
files.WhenLeftDouble = THISBACK(DoDir);
|
files.WhenLeftDouble = [=] { DoDir(); };
|
||||||
dirup.Height(max(CtrlImg::DirUp().GetSize().cy, Draw::GetStdFontCy() + 6));
|
dirup.Height(max(CtrlImg::DirUp().GetSize().cy, Draw::GetStdFontCy() + 6));
|
||||||
dirup.SetImage(CtrlImg::DirUp());
|
dirup.SetImage(CtrlImg::DirUp());
|
||||||
dirup.NormalStyle();
|
dirup.NormalStyle();
|
||||||
dirup <<= THISBACK(DirUp);
|
dirup << [=] { DirUp(); };
|
||||||
files.AddFrame(dirup);
|
files.AddFrame(dirup);
|
||||||
|
|
||||||
Sizeable().Zoomable();
|
Sizeable().Zoomable();
|
||||||
|
|
|
||||||
|
|
@ -132,6 +132,7 @@ Size TreeCtrl::Item::GetSize(const Display *treedisplay) const
|
||||||
sz.cy = max(sz.cy, isz.cy);
|
sz.cy = max(sz.cy, isz.cy);
|
||||||
sz.cx += csz.cx;
|
sz.cx += csz.cx;
|
||||||
sz.cy = max(sz.cy, csz.cy);
|
sz.cy = max(sz.cy, csz.cy);
|
||||||
|
sz.cy = max(sz.cy, CtrlImg::treeminus().GetHeight(), CtrlImg::treeplus().GetHeight());
|
||||||
sz += Size(2 * margin, 2 * margin);
|
sz += Size(2 * margin, 2 * margin);
|
||||||
return sz;
|
return sz;
|
||||||
}
|
}
|
||||||
|
|
@ -1126,7 +1127,7 @@ void TreeCtrl::Paint(Draw& w)
|
||||||
dri.top++;
|
dri.top++;
|
||||||
}
|
}
|
||||||
if(w.IsPainting(0, y, sz.cx, msz.cy) && msz.cy > 0) {
|
if(w.IsPainting(0, y, sz.cx, msz.cy) && msz.cy > 0) {
|
||||||
if (multiroot) {
|
if(multiroot) {
|
||||||
if(m.canopen || m.child.GetCount()) {
|
if(m.canopen || m.child.GetCount()) {
|
||||||
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
|
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
|
||||||
op -= im.GetSize() / 2;
|
op -= im.GetSize() / 2;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue