mirror of
https://github.com/ultimatepp/ultimatepp.git
synced 2026-08-28 06:12:53 -06:00
changed svn layout
git-svn-id: svn://ultimatepp.org/upp/trunk@281 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
commit
263ff5f895
2665 changed files with 642923 additions and 0 deletions
53
reference/Convert/main.cpp
Normal file
53
reference/Convert/main.cpp
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
#include <CtrlLib/CtrlLib.h>
|
||||
|
||||
using namespace Upp;
|
||||
|
||||
struct ConvertBin : Convert {
|
||||
virtual Value Format(const Value& q) const
|
||||
{
|
||||
return FormatIntBase(q, 2, 0, 0, 0);
|
||||
}
|
||||
|
||||
virtual Value Scan(const Value& text) const
|
||||
{
|
||||
String txt = text;
|
||||
int r = 0;
|
||||
for(const char *s = txt; *s; s++)
|
||||
if(*s == '1')
|
||||
r = (r << 1) | 1;
|
||||
else
|
||||
if(*s == '0')
|
||||
r <<= 1;
|
||||
return r;
|
||||
}
|
||||
|
||||
virtual int Filter(int chr) const
|
||||
{
|
||||
return chr == '0' || chr == '1' ? chr : 0;
|
||||
}
|
||||
};
|
||||
|
||||
struct App : TopWindow {
|
||||
EditField bin;
|
||||
EditInt dec;
|
||||
|
||||
void BinChanged() { dec <<= ~bin; }
|
||||
void DecChanged() { bin <<= ~dec; }
|
||||
|
||||
typedef App CLASSNAME;
|
||||
|
||||
App()
|
||||
{
|
||||
SetRect(0, 0, 200, 50);
|
||||
bin.SetConvert(Single<ConvertBin>());
|
||||
Add(bin.HSizePos().TopPos(0, Ctrl::STDSIZE));
|
||||
Add(dec.HSizePos().BottomPos(0, Ctrl::STDSIZE));
|
||||
bin <<= THISBACK(BinChanged);
|
||||
dec <<= THISBACK(DecChanged);
|
||||
}
|
||||
};
|
||||
|
||||
GUI_APP_MAIN
|
||||
{
|
||||
App().Run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue