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:
|
||||
String text;
|
||||
|
||||
void Animate() { Refresh(); }
|
||||
|
||||
public:
|
||||
typedef HelloWorld CLASSNAME;
|
||||
|
||||
HelloWorld& Text(const String& t) { text = t; Refresh(); return *this; }
|
||||
|
||||
HelloWorld();
|
||||
|
|
@ -25,31 +21,29 @@ public:
|
|||
|
||||
HelloWorld::HelloWorld()
|
||||
{
|
||||
SetTimeCallback(-40, THISBACK(Animate));
|
||||
SetTimeCallback(-40, [=] { Refresh(); });
|
||||
BackPaint();
|
||||
Zoomable().Sizeable();
|
||||
SetRect(0, 0, 260, 80);
|
||||
SetRect(0, 0, 1000, 300);
|
||||
}
|
||||
|
||||
void HelloWorld::LeftDown(Point, dword)
|
||||
{
|
||||
Close();
|
||||
EditText(text, "Text to display", "Text");
|
||||
}
|
||||
|
||||
void HelloWorld::Paint(Draw& w)
|
||||
{
|
||||
Font fnt = Roman(64);
|
||||
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);
|
||||
Size tsz = GetTextSize(text, Roman(32));
|
||||
Size tsz = GetTextSize(text, fnt);
|
||||
Point pos = (sz - tsz) / 2;
|
||||
for(int i = 0; i < text.GetLength(); i++) {
|
||||
int q = (i + GetTickCount() / 40) & 15;
|
||||
w.DrawText(pos.x, pos.y + sin_tbl[q] * (sz.cy - 32) / 200,
|
||||
~text + i, Roman(32), HsvColorf(q / 15.0, 1, 0.5), 1);
|
||||
pos.x += Roman(32).Info()[text[i]];
|
||||
w.DrawText(pos.x, pos.y + sin(GetTickCount() / 100.0 + i / 2.0) * (sz.cy - fnt.GetCy()) / 4,
|
||||
~text + i, fnt, HsvColorf(q / 15.0, 1, 0.5), 1);
|
||||
pos.x += fnt[text[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,10 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
|
||||
#define IMAGECLASS BombsImg
|
||||
#define IMAGEFILE <Bombs/bombs.iml>
|
||||
#include <Draw/iml.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
class Bombs : public TopWindow {
|
||||
|
|
@ -27,21 +32,13 @@ private:
|
|||
|
||||
int UNIT = 30;
|
||||
|
||||
void About();
|
||||
|
||||
void File(Bar& menu);
|
||||
void Game(Bar& menu);
|
||||
void Menu(Bar& menu);
|
||||
|
||||
void ShowStatus();
|
||||
void Level(Size sz);
|
||||
|
||||
void Uncover(int x, int y);
|
||||
void Generate();
|
||||
void UncoverAll();
|
||||
|
||||
public:
|
||||
typedef Bombs CLASSNAME;
|
||||
Bombs();
|
||||
};
|
||||
|
||||
|
|
@ -169,51 +166,29 @@ void Bombs::ShowStatus()
|
|||
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()
|
||||
{
|
||||
UNIT = DPI(30);
|
||||
level = Size(10, 10);
|
||||
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(InsetFrame());
|
||||
Title("uBombs");
|
||||
|
|
|
|||
|
|
@ -36,7 +36,6 @@ static String ExpandTabs(String line, int tabsize = 4)
|
|||
|
||||
class DlgCompareDir : public WithCompareDirLayout<TopWindow> {
|
||||
public:
|
||||
typedef DlgCompareDir CLASSNAME;
|
||||
DlgCompareDir();
|
||||
|
||||
void Run();
|
||||
|
|
@ -76,19 +75,19 @@ DlgCompareDir::DlgCompareDir()
|
|||
{
|
||||
CtrlLayout(*this, "Compare directories");
|
||||
Sizeable().Zoomable();
|
||||
refresh <<= THISBACK(CmdRefresh);
|
||||
refresh << [=] { CmdRefresh(); };
|
||||
splitter.Vert(tree, editor);
|
||||
editor << lineedit.SizePos() << qtf.SizePos();
|
||||
qtf.Background(White());
|
||||
qtf.SetFrame(InsetFrame());
|
||||
path_a.AddFrame(browse_a);
|
||||
browse_a.SetImage(CtrlImg::right_arrow());
|
||||
browse_a <<= THISBACK1(DoBrowse, &path_a);
|
||||
browse_a << [=] { DoBrowse(&path_a); };
|
||||
path_b.AddFrame(browse_b);
|
||||
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";
|
||||
tree.WhenCursor = THISBACK(DoTreeCursor);
|
||||
tree.WhenCursor = [=] { DoTreeCursor(); };
|
||||
lineedit.SetReadOnly();
|
||||
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
|
||||
CtrlLib;
|
||||
|
|
|
|||
|
|
@ -1,11 +1,7 @@
|
|||
#ifdef LAYOUTFILE
|
||||
|
||||
LAYOUT(ConverterPaneLayout, 244, 76)
|
||||
ITEM(LabelBox, title, LeftPosZ(8, 228).TopPosZ(4, 64))
|
||||
ITEM(EditDoubleSpin, value, LeftPosZ(16, 144).TopPosZ(20, 19))
|
||||
ITEM(SliderCtrl, slider, LeftPosZ(16, 144).TopPosZ(40, 20))
|
||||
ITEM(DropList, unit, LeftPosZ(164, 64).TopPosZ(20, 19))
|
||||
LAYOUT(ConverterPaneLayout, 280, 76)
|
||||
ITEM(Upp::LabelBox, title, LeftPosZ(8, 268).TopPosZ(4, 64))
|
||||
ITEM(Upp::EditDoubleSpin, value, LeftPosZ(16, 144).TopPosZ(20, 19))
|
||||
ITEM(Upp::SliderCtrl, slider, LeftPosZ(16, 252).TopPosZ(40, 20))
|
||||
ITEM(Upp::DropList, unit, LeftPosZ(164, 104).TopPosZ(20, 19))
|
||||
END_LAYOUT
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -8,33 +8,20 @@ using namespace Upp;
|
|||
#include <CtrlCore/lay.h>
|
||||
|
||||
struct ConverterPane : WithConverterPaneLayout<StaticRect> {
|
||||
ConverterPane *slave;
|
||||
void AdjustSlave()
|
||||
ConverterPane *other;
|
||||
void Sync()
|
||||
{
|
||||
slave->slider <<= slave->value <<=
|
||||
IsNull(value) ? 0.0 : (double)~unit * (double)~value / (double)~slave->unit;
|
||||
other->slider <<= other->value <<= (double)~unit * Nvl((double)~value) / (double)~other->unit;
|
||||
}
|
||||
void ValueChanged()
|
||||
{
|
||||
slider <<= ~value;
|
||||
AdjustSlave();
|
||||
}
|
||||
void SliderChanged()
|
||||
{
|
||||
value <<= ~slider;
|
||||
AdjustSlave();
|
||||
}
|
||||
|
||||
typedef ConverterPane CLASSNAME;
|
||||
|
||||
ConverterPane()
|
||||
{
|
||||
CtrlLayout(*this);
|
||||
slider.Range(10000);
|
||||
slider <<= value <<= 0;
|
||||
value <<= THISBACK(ValueChanged);
|
||||
slider <<= THISBACK(SliderChanged);
|
||||
unit <<= THISBACK(AdjustSlave);
|
||||
value << [=] { slider <<= ~value; Sync(); };
|
||||
slider << [=] { value <<= ~slider; Sync(); };
|
||||
unit << [=] { Sync(); };
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -65,10 +52,10 @@ struct Converter : TopWindow
|
|||
us.unit.Add(1613.0, "Miles");
|
||||
us.unit <<= 0.305;
|
||||
|
||||
us.slave = &metric;
|
||||
metric.slave = &us;
|
||||
us.other = &metric;
|
||||
metric.other = &us;
|
||||
|
||||
metric.AdjustSlave();
|
||||
metric.Sync();
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -139,10 +139,6 @@ struct FnGraph : public TopWindow {
|
|||
int zoom = 9;
|
||||
EditString expression; // function to display
|
||||
|
||||
void RefreshExpression() { Refresh(); }
|
||||
|
||||
typedef FnGraph CLASSNAME;
|
||||
|
||||
FnGraph();
|
||||
};
|
||||
|
||||
|
|
@ -150,7 +146,7 @@ FnGraph::FnGraph()
|
|||
{
|
||||
Title("Graph of a function");
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -19,8 +19,6 @@ private:
|
|||
void DirUp();
|
||||
|
||||
public:
|
||||
typedef ImageView CLASSNAME;
|
||||
|
||||
void Serialize(Stream& s);
|
||||
void LoadDir(const char *d);
|
||||
void LoadDir() { LoadDir(dir); }
|
||||
|
|
@ -115,12 +113,12 @@ ImageView::ImageView()
|
|||
splitter.SetPos(2700);
|
||||
Add(splitter.SizePos());
|
||||
|
||||
files.WhenEnterItem = THISBACK(Enter);
|
||||
files.WhenLeftDouble = THISBACK(DoDir);
|
||||
files.WhenEnterItem = [=] { Enter(); };
|
||||
files.WhenLeftDouble = [=] { DoDir(); };
|
||||
dirup.Height(max(CtrlImg::DirUp().GetSize().cy, Draw::GetStdFontCy() + 6));
|
||||
dirup.SetImage(CtrlImg::DirUp());
|
||||
dirup.NormalStyle();
|
||||
dirup <<= THISBACK(DirUp);
|
||||
dirup << [=] { DirUp(); };
|
||||
files.AddFrame(dirup);
|
||||
|
||||
Sizeable().Zoomable();
|
||||
|
|
|
|||
|
|
@ -132,6 +132,7 @@ Size TreeCtrl::Item::GetSize(const Display *treedisplay) const
|
|||
sz.cy = max(sz.cy, isz.cy);
|
||||
sz.cx += csz.cx;
|
||||
sz.cy = max(sz.cy, csz.cy);
|
||||
sz.cy = max(sz.cy, CtrlImg::treeminus().GetHeight(), CtrlImg::treeplus().GetHeight());
|
||||
sz += Size(2 * margin, 2 * margin);
|
||||
return sz;
|
||||
}
|
||||
|
|
@ -1126,7 +1127,7 @@ void TreeCtrl::Paint(Draw& w)
|
|||
dri.top++;
|
||||
}
|
||||
if(w.IsPainting(0, y, sz.cx, msz.cy) && msz.cy > 0) {
|
||||
if (multiroot) {
|
||||
if(multiroot) {
|
||||
if(m.canopen || m.child.GetCount()) {
|
||||
Image im = m.isopen ? CtrlImg::treeminus() : CtrlImg::treeplus();
|
||||
op -= im.GetSize() / 2;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue