new uvs2 releases : uppsrc-2598 tutorial-38 examples-141 reference-113

git-svn-id: svn://ultimatepp.org/upp/trunk@300 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
mdelfede 2008-06-16 23:06:34 +00:00
parent b3e2a7145a
commit cb0ff92715
22 changed files with 225 additions and 238 deletions

View file

@ -897,7 +897,7 @@ struct StableSortLess_ {
template <class I, class Less, class T>
void StableSort_(I begin, I end, const Less& less, const T *)
{
int count = end - begin;
int count = (int)(uintptr_t)(end - begin);
Buffer<int> h(count);
for(int i = 0; i < count; i++)
h[i] = i;

View file

@ -24,7 +24,7 @@ zhCN("用户放弃")
T_("date\vSunday")
csCZ("Neděle")
deDE("Sonntag")
esES("date\vDomingo")
esES("Domingo")
fiFI("Sunnuntai")
frFR("Dimanche")
huHU("Vasárnap")
@ -39,7 +39,7 @@ zhCN("星期日")
T_("date\vMonday")
csCZ("Pondělí")
deDE("Montag")
esES("date\vLunes")
esES("Lunes")
fiFI("Maanantai")
frFR("Lundi")
huHU("Hétfő")
@ -54,7 +54,7 @@ zhCN("星期一")
T_("date\vTuesday")
csCZ("Úterý")
deDE("Dienstag")
esES("date\vMartes")
esES("Martes")
fiFI("Tiistai")
frFR("Mardi")
huHU("Kedd")
@ -69,7 +69,7 @@ zhCN("星期二")
T_("date\vWednesday")
csCZ("Středa")
deDE("Mittwoch")
esES("date\vMiercoles")
esES("Miercoles")
fiFI("Keskiviikko")
frFR("Mercredi")
huHU("Szerda")
@ -84,7 +84,7 @@ zhCN("星期三")
T_("date\vThursday")
csCZ("Čtvrtek")
deDE("Donnerstag")
esES("date\vJueves")
esES("Jueves")
fiFI("Torstai")
frFR("Jeudi")
huHU("Csütörtök")
@ -99,7 +99,7 @@ zhCN("星期四")
T_("date\vFriday")
csCZ("Pátek")
deDE("Freitag")
esES("date\vViernes")
esES("Viernes")
fiFI("Perjantai")
frFR("Vendredi")
huHU("Péntek")
@ -114,7 +114,7 @@ zhCN("星期五")
T_("date\vSaturday")
csCZ("Sobota")
deDE("Samstag")
esES("date\vSábado")
esES("Sábado")
fiFI("Lauantai")
frFR("Samedi")
huHU("Szombat")
@ -128,8 +128,8 @@ zhCN("星期六")
T_("date\vSu")
csCZ("Ne")
deDE("Sa")
esES("date\vDo")
deDE("So")
esES("Do")
fiFI("Su")
frFR("Sam")
huHU("Vas")
@ -144,7 +144,7 @@ zhCN("Fri")
T_("date\vMo")
csCZ("Po")
deDE("Mo")
esES("date\vLu")
esES("Lu")
fiFI("Ma")
frFR("Lun")
huHU("Hé")
@ -159,7 +159,7 @@ zhCN("Mon")
T_("date\vTu")
csCZ("Út")
deDE("Di")
esES("date\vMa")
esES("Ma")
fiFI("Ti")
frFR("Mar")
huHU("Ke")
@ -174,7 +174,7 @@ zhCN("Tue")
T_("date\vWe")
csCZ("St")
deDE("Mi")
esES("date\vMi")
esES("Mi")
fiFI("Ke")
frFR("Mer")
huHU("Sze")
@ -189,7 +189,7 @@ zhCN("Wed")
T_("date\vTh")
csCZ("Čt")
deDE("Do")
esES("date\vJu")
esES("Ju")
fiFI("To")
frFR("Jeu")
huHU("Csüt")
@ -204,7 +204,7 @@ zhCN("Thu")
T_("date\vFr")
csCZ("Pa")
deDE("Fr")
esES("date\vVi")
esES("Vi")
fiFI("Pe")
frFR("Ven")
huHU("Pé")
@ -218,8 +218,8 @@ zhCN("")
T_("date\vSa")
csCZ("So")
deDE("So")
esES("")
deDE("Sa")
esES("")
fiFI("La")
frFR("Dim")
huHU("Szo")
@ -234,7 +234,7 @@ zhCN("Sun")
T_("date\vJanuary")
csCZ("Leden")
deDE("Januar")
esES("date\vEnero")
esES("Enero")
fiFI("Tammikuu")
frFR("Janvier")
huHU("Január")
@ -249,7 +249,7 @@ zhCN("一月")
T_("date\vFebruary")
csCZ("Únor")
deDE("Februar")
esES("date\vFebrero")
esES("Febrero")
fiFI("Helmikuu")
frFR("Février")
huHU("Február")
@ -264,7 +264,7 @@ zhCN("二月")
T_("date\vMarch")
csCZ("Březen")
deDE("März")
esES("date\vMarzo")
esES("Marzo")
fiFI("Maaliskuu")
frFR("Mars")
huHU("Március")
@ -279,7 +279,7 @@ zhCN("三月")
T_("date\vApril")
csCZ("Duben")
deDE("April")
esES("date\vAbril")
esES("Abril")
fiFI("Huhtikuu")
frFR("Avril")
huHU("Április")
@ -294,7 +294,7 @@ zhCN("四月")
T_("date\vMay")
csCZ("Květen")
deDE("Mai")
esES("date\vMayo")
esES("Mayo")
fiFI("Toukokuu")
frFR("Mai")
huHU("Május")
@ -309,7 +309,7 @@ zhCN("五月")
T_("date\vJune")
csCZ("Červen")
deDE("Juni")
esES("date\vJunio")
esES("Junio")
fiFI("Kesäkuu")
frFR("Juin")
huHU("Június")
@ -324,7 +324,7 @@ zhCN("六月")
T_("date\vJuly")
csCZ("Červenec")
deDE("Juli")
esES("date\vJulio")
esES("Julio")
fiFI("Heinäkuu")
frFR("Juillet")
huHU("Július")
@ -339,7 +339,7 @@ zhCN("七月")
T_("date\vAugust")
csCZ("Srpen")
deDE("August")
esES("date\vAgosto")
esES("Agosto")
fiFI("Elokuu")
frFR("Août")
huHU("Augusztus")
@ -354,7 +354,7 @@ zhCN("八月")
T_("date\vSeptember")
csCZ("Září")
deDE("September")
esES("date\vSeptiembre")
esES("Septiembre")
fiFI("Syyskuu")
frFR("Septembre")
huHU("Szeptember")
@ -369,7 +369,7 @@ zhCN("九月")
T_("date\vOctober")
csCZ("Říjen")
deDE("Oktober")
esES("date\vOctubre")
esES("Octubre")
fiFI("Lokakuu")
frFR("Octobre")
huHU("Október")
@ -384,7 +384,7 @@ zhCN("十月")
T_("date\vNovember")
csCZ("Listopad")
deDE("November")
esES("date\vNoviembre")
esES("Noviembre")
fiFI("Marraskuu")
frFR("Novembre")
huHU("November")
@ -399,7 +399,7 @@ zhCN("十一月")
T_("date\vDecember")
csCZ("Prosinec")
deDE("Dezember")
esES("date\vDiciembre")
esES("Diciembre")
fiFI("Joulukuu")
frFR("Décembre")
huHU("December")
@ -414,7 +414,7 @@ zhCN("十二月")
T_("sdate\vJan")
csCZ("Led")
deDE("Jan")
esES("sdate\vEne")
esES("Ene")
fiFI("Tam")
frFR("Jan")
huHU("Jan")
@ -429,7 +429,7 @@ zhCN("Jan")
T_("sdate\vFeb")
csCZ("Úno")
deDE("Feb")
esES("")
esES("Feb")
fiFI("Hel")
frFR("Fév")
huHU("Feb")
@ -444,7 +444,7 @@ zhCN("Feb")
T_("sdate\vMar")
csCZ("Bře")
deDE("Mär")
esES("")
esES("Mar")
fiFI("Maa")
frFR("Mar")
huHU("Márc")
@ -459,7 +459,7 @@ zhCN("Mar")
T_("sdate\vApr")
csCZ("Dub")
deDE("Apr")
esES("sdate\vAbr")
esES("Abr")
fiFI("Huh")
frFR("Avr")
huHU("Ápr")
@ -474,7 +474,7 @@ zhCN("Apr")
T_("sdate\vMay")
csCZ("Kvě")
deDE("Mai")
esES("")
esES("May")
fiFI("Tou")
frFR("Mai")
huHU("Máj")
@ -489,7 +489,7 @@ zhCN("May")
T_("sdate\vJun")
csCZ("Čer")
deDE("Jun")
esES("")
esES("Jun")
fiFI("Kes")
frFR("Jun")
huHU("Jún")
@ -504,7 +504,7 @@ zhCN("Jun")
T_("sdate\vJul")
csCZ("Čec")
deDE("Jul")
esES("")
esES("Jul")
fiFI("Hei")
frFR("Jui")
huHU("Júl")
@ -519,7 +519,7 @@ zhCN("Jul")
T_("sdate\vAug")
csCZ("Srp")
deDE("Aug")
esES("sdate\vAgo")
esES("Ago")
fiFI("Elo")
frFR("Aou")
huHU("Aug")
@ -534,7 +534,7 @@ zhCN("Aug")
T_("sdate\vSep")
csCZ("Zář")
deDE("Sep")
esES("")
esES("Sep")
fiFI("Syy")
frFR("Sep")
huHU("Szept")
@ -549,7 +549,7 @@ zhCN("Sep")
T_("sdate\vOct")
csCZ("Říj")
deDE("Okt")
esES("")
esES("Oct")
fiFI("Lok")
frFR("Oct")
huHU("Okt")
@ -564,7 +564,7 @@ zhCN("Oct")
T_("sdate\vNov")
csCZ("Lis")
deDE("Nov")
esES("")
esES("Nov")
fiFI("Mar")
frFR("Nov")
huHU("Nov")
@ -579,7 +579,7 @@ zhCN("Nov")
T_("sdate\vDec")
csCZ("Pro")
deDE("Dez")
esES("sdate\vDic")
esES("Dic")
fiFI("Jou")
frFR("Déc")
huHU("Dec")

View file

@ -365,15 +365,15 @@ inline void MemoryCheckDebug() {}
#endif
struct MemoryProfile {
int allocated[1024];
int fragmented[1024];
int freepages;
int large_count;
int large_size[1024];
int large_total;
int large_free_count;
int large_free_size[1024];
int large_free_total;
int allocated[1024];
int fragmented[1024];
int freepages;
int large_count;
size_t large_size[1024];
size_t large_total;
int large_free_count;
size_t large_free_size[1024];
int large_free_total;
MemoryProfile();
};
@ -475,6 +475,8 @@ inline int SwapEndian32(int v) { __asm__("bswap %0" : "=r" (v) : "0" (v))
#endif
#ifdef COMPILER_MSC
#pragma intrinsic (_byteswap_ushort, _byteswap_ulong, _byteswap_uint64)
inline word SwapEndian16(word v) { return _byteswap_ushort(v); }
inline int16 SwapEndian16(int16 v) { return _byteswap_ushort(v); }
inline dword SwapEndian32(dword v) { return _byteswap_ulong(v); }

View file

@ -33,7 +33,7 @@ struct Heap {
byte *Begin() { return (byte *)this + sizeof(Page); }
byte *End() { return (byte *)this + 4096; }
int Count() { return (End() - Begin()) / Ksz(klass); }
int Count() { return (int)(uintptr_t)(End() - Begin()) / Ksz(klass); }
};
struct Header;
@ -82,7 +82,7 @@ struct Heap {
Page *empty[NKLASS];
FreeLink *cache[NKLASS];
int cachen[NKLASS];
bool initialized;
static word BinSz[LBINS];
@ -98,7 +98,7 @@ struct Heap {
static DLink big[1];
static Heap aux;
#ifdef HEAPDBG
static void DbgFreeFill(void *ptr, size_t size);
static void DbgFreeCheck(void *ptr, size_t size);
@ -143,7 +143,7 @@ struct Heap {
void LinkFree(DLink *b, int size);
DLink *AddChunk();
void *DivideBlock(DLink *b, int size, int ii);
void *TryLAlloc(int ii, int size);
void *TryLAlloc(int ii, size_t size);
void *LAlloc(size_t& size);
void LFree(void *ptr);
void Make(MemoryProfile& f);

View file

@ -242,20 +242,20 @@ bool LogStream::IsOpen() const
#endif
}
static void sLarge(String& text, int *large, int count, const char *txt)
static void sLarge(String& text, size_t *large, int count, const char *txt)
{
int n = min(1024, count);
Sort(large, large + n, StdLess<int>());
Sort(large, large + n, StdLess<size_t>());
int i = 0;
while(i < n) {
int q = large[i];
size_t q = large[i];
int nn = i++;
while(i < n && large[i] == q) i++;
nn = i - nn;
if(q < 10000)
text << Format("%4d B, %5d %s (%6d KB)\r\n", q, nn, txt, (nn * q) >> 10);
text << Format("%4d B, %5d %s (%6d KB)\r\n", (int)(uintptr_t)q, nn, txt, (int)(uintptr_t)((nn * q) >> 10));
else
text << Format("%4d`KB, %5d %s (%6d KB)\r\n", q >> 10, nn, txt, (nn * q) >> 10);
text << Format("%4d`KB, %5d %s (%6d KB)\r\n", (int)(uintptr_t)(q >> 10), nn, txt, (int)(uintptr_t)((nn * q) >> 10));
}
}

View file

@ -274,19 +274,19 @@ String Stream::GetLine() {
byte *q = ptr;
while(q < rdlim)
if(*q == '\n') {
String result((const char *)ptr, q - ptr - (q > ptr && q[-1] == '\r'));
String result((const char *)ptr, (int)(uintptr_t)(q - ptr - (q > ptr && q[-1] == '\r')));
ptr = q + 1;
return result;
}
else
q++;
String result((const char *)ptr, q - ptr);
String result((const char *)ptr, (int)(uintptr_t)(q - ptr));
ptr = q;
for(;;) {
byte *q = ptr;
while(q < rdlim && *q != '\n')
q++;
result.Cat(ptr, q - ptr);
result.Cat(ptr, (int)(uintptr_t)(q - ptr));
ptr = q;
int c = Get();
if(c == '\n')

View file

@ -310,7 +310,7 @@ WString String::ToWString() const
String::String(StringBuffer& b)
{
if(b.begin == b.buffer) {
String0::Set(b.begin, b.end - b.begin);
String0::Set(b.begin, (int)(uintptr_t)(b.end - b.begin));
return;
}
int l = b.GetLength();

View file

@ -48,7 +48,7 @@ static void DbgHeapPanic(const char *text, DbgBlkHeader *p)
char b[100];
strcpy(h, text);
strcat(h, DbgFormat(b, p));
HeapPanic(h, p + 1, p->size);
HeapPanic(h, p + 1, (int)(uintptr_t)p->size);
}
static DbgBlkHeader dbg_live = { 0, &dbg_live, &dbg_live, 0 };
@ -93,7 +93,7 @@ void *MemoryAlloc(size_t size)
#endif
static dword serial_number = 0;
DbgBlkHeader *p = (DbgBlkHeader *)MemoryAlloc_(sizeof(DbgBlkHeader) + size + sizeof(dword));
p->serial = s_ignoreleaks ? 0 : ~ ++serial_number ^ (uintptr_t) p;
p->serial = s_ignoreleaks ? 0 : ~ ++serial_number ^ (dword)(uintptr_t) p;
p->size = size;
if(s_allocbreakpoint && s_allocbreakpoint == serial_number)
__BREAK__;
@ -182,7 +182,7 @@ void MemoryDumpLeaks()
DbgFormat(b, p);
BugLog() << '\n' << b;
VppLog() << '\n' << b << ": ";
HexDump(VppLog(), p + 1, p->size, 64);
HexDump(VppLog(), p + 1, (int)(uintptr_t)p->size, 64);
}
p = p->next;
}

View file

@ -146,7 +146,7 @@ void Heap::DbgFreeCheck(void *p, size_t size)
dword *ptr = (dword *)p;
while(count--)
if(*ptr++ != 0x65657246)
HeapPanic("Writes to freed blocks detected", p, size);
HeapPanic("Writes to freed blocks detected", p, (int)(uintptr_t)size);
}
void *Heap::DbgFreeCheckK(void *p, int k)

View file

@ -134,7 +134,7 @@ void Heap::MoveToEmpty(DLink *l, Header *bh)
}
inline
void *Heap::TryLAlloc(int ii, int size)
void *Heap::TryLAlloc(int ii, size_t size)
{
while(ii < LBINS) {
if(freebin[ii] != freebin[ii]->next) {

View file

@ -96,7 +96,7 @@ String CParser::ReadId() throw(Error) {
p++;
term = p;
DoSpaces();
return String(b, p - b);
return String(b, (int)(uintptr_t)(p - b));
}
String CParser::ReadIdt() throw(Error) {

View file

@ -188,13 +188,13 @@ void Ctrl::InitWin32(HINSTANCE hInstance)
if(IsWinNT())
#endif
{
WNDCLASSW wc;
Zero(wc);
WNDCLASSW wc;
Zero(wc);
wc.style = CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW+1);
wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL;
wc.lpszClassName = L"UPP-CLASS-W";
RegisterClassW(&wc);
wc.style = 0x20000|CS_DBLCLKS|CS_HREDRAW|CS_VREDRAW;
@ -215,7 +215,7 @@ void Ctrl::InitWin32(HINSTANCE hInstance)
wc.lpfnWndProc = (WNDPROC)Ctrl::WndProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = NULL; //(HBRUSH)(COLOR_WINDOW+1);
wc.hbrBackground = IsWinVista() ? (HBRUSH)(COLOR_WINDOW+1) : (HBRUSH)NULL;
wc.lpszClassName = L_("UPP-CLASS-A");
RegisterClass(&wc);
if(IsWinXP()) {

View file

@ -202,51 +202,9 @@ void Get(ArrayCtrl& array, int ii, IdCtrls& m)
m[i] <<= array.Get(ii, m(i));
}
void sLarge(String& text, int *large, int count, const char *txt)
{
int n = min(1024, count);
Sort(large, large + n, StdLess<int>());
int i = 0;
while(i < n) {
int q = large[i];
int nn = i++;
while(i < n && large[i] == q) i++;
nn = i - nn;
if(q < 10000)
text << Format("%4d B, %5d %s (%6d KB)\r\n", q, nn, txt, (nn * q) >> 10);
else
text << Format("%4d`KB, %5d %s (%6d KB)\r\n", q >> 10, nn, txt, (nn * q) >> 10);
}
}
String sProfile(MemoryProfile& mem)
{
String text;
int acount = 0;
size_t asize = 0;
int fcount = 0;
size_t fsize = 0;
for(int i = 0; i < 1024; i++)
if(mem.allocated[i]) {
int sz = 4 * i;
text << Format("%4d B, %6d allocated (%5d KB), %6d fragmented (%5d KB)\r\n",
sz, mem.allocated[i], (mem.allocated[i] * sz) >> 10,
mem.fragmented[i], (mem.fragmented[i] * sz) >> 10);
acount += mem.allocated[i];
asize += mem.allocated[i] * sz;
fcount += mem.fragmented[i];
fsize += mem.fragmented[i] * sz;
}
text << Format(" TOTAL, %6d allocated (%5d KB), %6d fragmented (%5d KB)\r\n",
acount, int(asize >> 10), fcount, int(fsize >> 10));
text << "Free pages " << mem.freepages << " (" << mem.freepages * 4 << " KB)\r\n";
text << "Large block count " << mem.large_count
<< ", total size " << (mem.large_total >> 10) << " KB\r\n";
sLarge(text, mem.large_size, mem.large_count, "allocated");
text << "Large fragments count " << mem.large_free_count
<< ", total size " << (mem.large_free_total >> 10) << " KB\r\n";
sLarge(text, mem.large_free_size, mem.large_free_count, "fragments");
return text;
return AsString(mem);
}
void MemoryProfileInfo() {

View file

@ -70,6 +70,13 @@ MultiButton::SubButton& MultiButton::SubButton::SetStdImage()
return *this;
}
MultiButton::SubButton& MultiButton::SubButton::SetLabel(const char *text)
{
label = text;
Refresh();
return *this;
}
MultiButton::SubButton& MultiButton::SubButton::Left(bool b)
{
left = b;
@ -184,17 +191,9 @@ int MultiButton::FindButton(int px)
Metrics(border, lx, rx);
for(int i = 0; i < button.GetCount(); i++) {
SubButton& b = button[i];
int bcx = Nvl(b.cx, style->stdwidth);
if(b.left) {
lx += bcx;
if(px < lx)
return b.enabled ? i : Null;
}
else {
rx -= bcx;
if(px >= rx)
return b.enabled ? i : Null;
}
int x = 0, cx = 0;
if(GetPos(b, lx, rx, x, cx, px))
return b.enabled ? i : Null;
}
if(WhenPush || WhenClick)
return MAIN;
@ -205,21 +204,34 @@ int MultiButton::FindButton(int px)
return Null;
}
bool MultiButton::GetPos(SubButton& b, int& lx, int& rx, int& x, int& cx, int px)
{
Size tsz = GetTextSize(b.label, StdFont());
cx = Nvl(b.cx, style->stdwidth + tsz.cx);
if(IsNull(b.cx) && tsz.cx > 0 && !IsNull(b.img))
cx += LB_IMAGE + LB_MARGIN;
if(b.left) {
x = lx;
lx += cx;
if(px >= 0 && px < lx)
return true;
}
else {
rx -= cx;
x = rx;
if(px >= 0 && px >= rx)
return true;
}
return false;
}
void MultiButton::GetPos(int ii, int& x, int& cx)
{
int border, lx, rx;
Metrics(border, lx, rx);
for(int i = 0; i <= ii; i++) {
SubButton& b = button[i];
cx = Nvl(b.cx, style->stdwidth);
if(b.left) {
x = lx;
lx += cx;
}
else {
rx -= cx;
x = rx;
}
GetPos(b, lx, rx, x, cx);
}
}
@ -251,17 +263,9 @@ void MultiButton::Lay(Rect& r)
bool left = false;
bool right = false;
for(int i = 0; i < button.GetCount(); i++) {
const SubButton& b = button[i];
int cx = Nvl(b.cx, style->stdwidth);
int x;
if(b.left) {
x = lx;
lx += cx;
}
else {
rx -= cx;
x = rx;
}
SubButton& b = button[i];
int cx = 0; int x = 0;
GetPos(b, lx, rx, x, cx);
(b.left ? left : right) = true;
}
if(ComplexFrame()) {
@ -302,17 +306,9 @@ void MultiButton::Paint(Draw& w)
for(int i = 0; i < button.GetCount(); i++) {
SubButton& b = button[i];
int st = ChState(i);
int cx = Nvl(b.cx, style->stdwidth);
int x;
if(b.left) {
x = lx;
lx += cx;
}
else {
rx -= cx;
x = rx;
}
bool paintimg = true;
int x = 0, cx = 0;
GetPos(b, lx, rx, x, cx);
bool dopaint = true;
Value v = b.left ? left ? style->lmiddle[st] : style->left[st]
: right ? style->rmiddle[st] : style->right[st];
if(ComplexFrame())
@ -320,9 +316,9 @@ void MultiButton::Paint(Draw& w)
else
if(frm) {
if(IsTrivial() && style->usetrivial)
paintimg = false;
dopaint = false;
ChPaint(w, x, border, cx, sz.cy - 2 * border,
paintimg ? v : style->trivial[st]);
dopaint ? v : style->trivial[st]);
}
else {
w.Clip(x, 0, cx, sz.cy);
@ -345,11 +341,12 @@ void MultiButton::Paint(Draw& w)
ChPaint(w, x, 0, cx, sz.cy, v);
w.End();
}
if(paintimg) {
Image m = Nvl(b.img, CtrlsImg::DA());
if(dopaint) {
Size tsz = GetTextSize(b.label, StdFont());
Image m = tsz.cx > 0 ? b.img : (Image)Nvl(b.img, CtrlsImg::DA());
Size isz = m.GetSize();
Point p = (st == CTRL_PRESSED) * style->pressoffset;
p.x += x + (cx - isz.cx) / 2;
p.x += x + (cx - isz.cx - tsz.cx - (tsz.cx > 0 && isz.cx > 0 ? LB_IMAGE : 0)) / 2;
p.y += (sz.cy - isz.cy) / 2;
if(b.left) {
if(!left) p.x += style->loff;
@ -360,6 +357,12 @@ void MultiButton::Paint(Draw& w)
w.DrawImage(p.x, p.y, m, style->monocolor[st]);
else
w.DrawImage(p.x, p.y, m);
if(tsz.cx > 0) {
if(isz.cx > 0)
p.x += isz.cx + LB_IMAGE;
w.DrawText(p.x, (sz.cy - tsz.cy) / 2, b.label);
}
}
(b.left ? left : right) = true;
}

View file

@ -53,6 +53,8 @@ public:
bool monoimg;
bool enabled;
String label;
void Refresh();
public:
@ -62,6 +64,7 @@ public:
SubButton& SetImage(const Image& m);
SubButton& SetMonoImage(const Image& m);
SubButton& SetStdImage();
SubButton& SetLabel(const char *text);
SubButton& Left(bool b = true);
SubButton& Width(int w);
SubButton& Enable(bool b);
@ -74,7 +77,11 @@ public:
};
private:
enum { MAIN = -1 };
enum {
MAIN = -1,
LB_IMAGE = 5, // image <-> text space
LB_MARGIN = 10
};
virtual bool Frame();
@ -94,6 +101,7 @@ private:
int FindButton(int px);
void Margins(int& l, int& r);
Rect ContentRect();
bool GetPos(SubButton& b, int& lx, int& rx, int& x, int& cx, int px = -1);
void GetPos(int ii, int& x, int& cx);
int ChState(int i);
void Lay(Rect& r);

View file

@ -257,6 +257,21 @@ void AlphaBlendStraightOpaque(RGBA *t, const RGBA *s, int len)
}
}
void AlphaBlendStraightOpaque(RGBA *t, const RGBA *s, int len, int alpha)
{
const RGBA *e = s + len;
alpha *= 0x101;
while(s < e) {
int a = (s->a * alpha) >> 16;
t->r += a * (s->r - t->r) >> 8;
t->g += a * (s->g - t->g) >> 8;
t->b += a * (s->b - t->b) >> 8;
t->a = 255;
s++;
t++;
}
}
struct sBlends {
int16 m;
byte a;

View file

@ -101,8 +101,10 @@ void Sql::SetStatement(const String& s) {
bool Sql::Execute() {
SqlSession &session = GetSession();
if(session.traceslow < INT_MAX)
cn->starttime = GetTickCount();
session.SetStatement(cn->statement);
session.SetStatus(SqlSession::BEFORE_EXECUTING);
cn->starttime = GetTickCount();
if(session.usrlog)
UsrLogT(9, cn->statement);
Stream *s = session.GetTrace();
@ -113,23 +115,25 @@ bool Sql::Execute() {
#endif
*s << cn->statement << '\n';
}
session.GetStatus().Statement(cn->statement);
session.PassStatus(ActivityStatus::EXECUTING);
if(!session.IsOpen())
{
session.SetStatus(SqlSession::CONNECTION_ERROR);
return false;
}
session.SetStatus(SqlSession::START_EXECUTING);
bool b = cn->Execute();
session.GetStatus().Time(GetTickCount() - cn->starttime);
session.PassStatus(ActivityStatus::END_EXECUTING);
session.SetTime(GetTickCount() - cn->starttime);
session.SetStatus(SqlSession::END_EXECUTING);
if(!b) {
if(s) {
*s << "## ERROR: " << session.GetLastError() << '\n';
}
session.GetStatus()
.Error(session.GetLastError())
.ErrorCode(session.GetErrorCode())
.ErrorCode(session.GetErrorCodeString());
session.PassStatus(ActivityStatus::EXECUTING_ERROR);
session.SetStatus(SqlSession::EXECUTING_ERROR);
}
for(int i = 0; i < cn->info.GetCount(); i++)
cn->info[i].name = ToUpper(cn->info[i].name);
session.SetStatus(SqlSession::AFTER_EXECUTING);
return b;
}
@ -182,24 +186,30 @@ __Expand(E__ExecuteFX)
bool Sql::Fetch() {
SqlSession& session = GetSession();
session.PassStatus(ActivityStatus::FETCHING);
session.SetStatus(SqlSession::START_FETCHING);
int t0 = GetTickCount();
bool b = cn->Fetch();
int t = GetTickCount();
int total = t - cn->starttime;
int fetch = t - t0;
session.SetStatus(SqlSession::END_FETCHING);
if(!b) {
session.GetStatus().Time(t - cn->starttime);
session.PassStatus(ActivityStatus::END_FETCHING);
session.SetTime(total);
session.SetStatus(SqlSession::END_FETCHING_MANY);
}
if(t - session.traceslow - cn->starttime > 0)
BugLog() << t - cn->starttime << " ms: " << cn->statement << '\n';
else
if(t - t0 - session.traceslow > 0)
BugLog() << t - t0 << " ms further fetch: " << cn->statement << '\n';
if(total > session.traceslow)
BugLog() << total << " ms: " << cn->statement << '\n';
else if(fetch > session.traceslow)
BugLog() << fetch << " ms further fetch: " << cn->statement << '\n';
cn->starttime = INT_MAX;
return b;
}
#define E__GetColumn(I) cn->GetColumn(I - 1, p##I)
#define E__GetColumn(I) cn->GetColumn(I - 1, p##I)
#define E__FetchF(I) \
bool Sql::Fetch(__List##I(E__Ref)) { \

View file

@ -4,44 +4,6 @@ const String& BoolToSql(bool b);
class SqlSession;
/* TODO: it should be integrated more somehow with SqlSession to not duplicate error fields */
class ActivityStatus {
public:
enum {
NONE,
FETCHING,
END_FETCHING,
EXECUTING,
END_EXECUTING,
EXECUTING_ERROR
};
private:
String error;
int error_code_number;
String error_code_string;
String statement;
int status;
int time;
public:
ActivityStatus& Error(const String& s) { error = s; return *this; }
ActivityStatus& ErrorCode(const String& s) { error_code_string = s; return *this; }
ActivityStatus& ErrorCode(int n) { error_code_number = n; return *this; }
ActivityStatus& Statement(const String& s) { statement = s; return *this; }
ActivityStatus& SetStatus(int s) { status = s; return *this; } // Status does not work in Linux (a type or macro?)
ActivityStatus& Time(int n) { time = n; return *this; }
String GetStatement() const { return statement; }
String GetError() const { return error; }
int GetErrorCode() const { return error_code_number; }
String GetErrorCodeString() const { return error_code_string; }
int GetStatus() const { return status; }
int GetTime() const { return time; }
bool operator == (int s) const { return status == s; }
bool operator != (int s) const { return status != s; }
};
class SqlExc : public Exc {
public:
#ifndef NOAPPSQL
@ -280,6 +242,19 @@ struct StatementExecutor {
typedef bool (*RunScript)(const String& text, StatementExecutor& executor, Gate2<int, int> progress_canceled);
class SqlSession : public SqlSource {
public:
enum {
START_FETCHING,
END_FETCHING,
END_FETCHING_MANY,
START_EXECUTING,
END_EXECUTING,
EXECUTING_ERROR,
CONNECTION_ERROR,
BEFORE_EXECUTING,
AFTER_EXECUTING
};
protected:
virtual SqlConnection *CreateConnection();
@ -291,6 +266,9 @@ protected:
bool usrlog;
int traceslow;
int dialect;
int exectime;
String statement;
String lasterror;
String errorstatement;
@ -298,7 +276,7 @@ protected:
String errorcode_string;
Sql::ERRORCLASS errorclass;
ActivityStatus status;
int status;
public:
virtual void Begin();
@ -308,7 +286,7 @@ public:
virtual String Savepoint();
virtual void RollbackTo(const String& savepoint);
virtual bool IsOpen() const;
virtual RunScript GetRunScript() const;
@ -347,6 +325,12 @@ public:
Sql::ERRORCLASS GetErrorClass() const { return errorclass; }
void ClearError();
String GetStatement() const { return statement; }
void SetStatement(const String& s) { statement = s; }
void SetTime(int t) { exectime = t; }
int GetTime() const { return exectime; }
String GetUser() { return Sql(*this).GetUser(); }
operator bool() const { return IsOpen(); }
@ -354,10 +338,12 @@ public:
SqlSession();
virtual ~SqlSession();
ActivityStatus& GetStatus() { return status; }
void PassStatus(int s) { WhenDatabaseActivity(status.SetStatus(s)); }
int GetStatus() { return status; }
void SetStatus(int s) { status = s; WhenDatabaseActivity(*this); }
bool operator == (int s) const { return status == s; }
bool operator != (int s) const { return status != s; }
Callback1<const ActivityStatus&> WhenDatabaseActivity;
Callback1<const SqlSession&> WhenDatabaseActivity;
};
class OciConnection;

View file

@ -432,7 +432,7 @@ One<HttpRequest> HttpServer::GetRequest()
switch(request_state) {
case RS_FIRST:
if(first_line.GetLength() < 4) {
int left = min<int>(e - p, 4 - first_line.GetLength());
int left = min<int>((int)(uintptr_t)(e - p), 4 - first_line.GetLength());
first_line.Cat(p, left);
p += left;
break;
@ -440,7 +440,7 @@ One<HttpRequest> HttpServer::GetRequest()
int four = Peek32le(first_line);
if(four == FOURCHAR('S', 'A', 'P', 'I')) {
if(first_line.GetLength() < 8) {
int left = min<int>(e - p, 8 - first_line.GetLength());
int left = min<int>((int)(uintptr_t)(e - p), 8 - first_line.GetLength());
first_line.Cat(p, left);
p += left;
break;
@ -478,7 +478,7 @@ One<HttpRequest> HttpServer::GetRequest()
LogTime("HTTP request length limit reached, request trashed", 1);
return NULL;
}
first_line.Cat(b, p - b);
first_line.Cat(b, (int)(uintptr_t)(p - b));
if(p >= e)
break;
p++;
@ -543,7 +543,7 @@ One<HttpRequest> HttpServer::GetRequest()
case RS_SAPI:
if(sapi_request.GetLength() < sapi_length) {
int add = min<int>(e - p, sapi_length - sapi_request.GetLength());
int add = min<int>((int)(uintptr_t)(e - p), sapi_length - sapi_request.GetLength());
LogTime(NFormat("SAPI request length = %d, collected %d, adding %d",
sapi_length, sapi_request.GetLength(), add), 2);
sapi_request.Cat(p, add);
@ -571,7 +571,7 @@ One<HttpRequest> HttpServer::GetRequest()
LogTime("Header line too long, request trashed", 1);
return NULL;
}
header_line.Cat(b, p - b);
header_line.Cat(b, (int)(uintptr_t)(p - b));
LOG("b - b = " << (p - b) << ", header_line = " << header_line);
if(p >= e)
break;
@ -613,7 +613,7 @@ One<HttpRequest> HttpServer::GetRequest()
String v = request_query.GetString(var);
if(!v.IsEmpty())
v.Cat(", ");
v.Cat(s, r - s);
v.Cat(s, (int)(uintptr_t)(r - s));
request_query.Set(var, v);
headers_length += var.GetLength() + v.GetLength();
}
@ -630,13 +630,13 @@ One<HttpRequest> HttpServer::GetRequest()
LogTime("HTTP POST length exceeded, request trashed", 1);
return NULL;
}
post_data.Cat(b, p - b);
post_data.Cat(b, (int)(uintptr_t)(p - b));
if(p >= e)
break;
p++;
}
else if(post_data.GetLength() < post_length) {
int add = min<int>(post_length - post_data.GetLength(), e - p);
int add = min<int>(post_length - post_data.GetLength(), (int)(uintptr_t)(e - p));
post_data.Cat(p, add);
p += add;
if(post_data.GetLength() < post_length)

5
uppsrc/ide/Builders/init Normal file
View file

@ -0,0 +1,5 @@
#ifndef _ide_Builders_icpp_init_stub
#define _ide_Builders_icpp_init_stub
#include "ide\Common/init"
#include "coff\binobj/init"
#endif

View file

@ -44,7 +44,7 @@ String BZ2Decompress(String s, Gate2<int, int> progress)
out.Cat(output, buf_size - z.avail_out);
z.next_out = output;
z.avail_out = buf_size;
if(progress((const char *)z.next_in - ~s, s.GetLength()))
if(progress((int)(uintptr_t)((const char *)z.next_in - ~s), s.GetLength()))
{
BZ2_bzDecompressEnd(&z);
return String::GetVoid();
@ -90,7 +90,7 @@ String BZ2Compress(String s, Gate2<int, int> progress)
out.Cat(output, buf_size - z.avail_out);
z.next_out = output;
z.avail_out = buf_size;
if(progress((const char *)z.next_in - ~s, s.GetLength()))
if(progress((int)(uintptr_t)((const char *)z.next_in - ~s), s.GetLength()))
{
BZ2_bzCompressEnd(&z);
return String::GetVoid();

View file

@ -1285,7 +1285,7 @@ void GIFEncoder::Data::FlushDataBlock()
{
// TIMING("GifEncoder::FlushDataBlock");
int count = data_ptr - data_block;
int count = (int)(uintptr_t)(data_ptr - data_block);
if(count) {
ASSERT(count <= 255);
stream.Put(count);