/* public import "ecere" static class MsgLine : struct { MsgLine prev, next; char * string; int len; }; public class NotificationBox : Window { background = activeBorder; borderStyle = contour; //hasClose = true; //tabCycle = true; AutoDestroyThread autoDestroy { box = this }; public: property char * contents { set { FreeLines(); if(value) { int len = strlen(value); int start = 0; int c; for(c = 0; c <= len; c++) { if(c == len || value[c] == '\n') { MsgLine line { }; lines.Add(line); if(line) { line.len = c - start; line.string = new char[line.len+1]; CopyBytes(line.string, value + start, line.len); line.string[line.len] = '\0'; start = c+1; } } } } } }; Seconds delay; GuiApplication app; Window reactivate; private: OldList lines; int totalWidth, totalHeight, lineHeight; ~NotificationBox() { FreeLines(); } */ /* bool ButtonActivate(Window control, bool active, Window previous) { control.isDefault = true; return true; } */ /* bool OnPostCreate() { if(!delay) autoDestroy.delay = 1; else autoDestroy.delay = delay; autoDestroy.app = app; autoDestroy.Create(); return true; } */ /*bool OnActivate(bool active, Window previous, bool * goOnWithActivation, bool direct) { if(reactivate) reactivate.Activate(); return true; }*/ /* bool OnResizing(int *w, int *h) { *w = Max(*w, Max(totalWidth, 144) + 24); *h = Max(*h, Max(totalHeight, 33));// + 40); return true; } void OnRedraw(Surface surface) { MsgLine line; //int y = (clientSize.h - 33 - totalHeight) / 2; int y = (clientSize.h - totalHeight) / 2; for(line = lines.first; line; line = line.next) { surface.WriteText((clientSize.w - totalWidth) / 2, y, line.string, line.len); y += lineHeight; } } bool OnLoadGraphics() { MsgLine line; totalHeight = 0; for(line = lines.first; line; line = line.next) { Size size; if(!line.string[0]) display.FontExtent(fontObject, " ", 1, (int *)&size.w, (int *)&size.h); else display.FontExtent(fontObject, line.string, strlen(line.string), (int *)&size.w, (int *)&size.h); if(size.h) lineHeight = size.h; totalWidth = Max(totalWidth, size.w); totalHeight += size.h; } return true; } void FreeLines() { MsgLine line; for(line = lines.first; line; line = line.next) delete line.string; lines.Free(null); } }; class AutoDestroyThread : Thread { GuiApplication app; NotificationBox box; Seconds delay; unsigned int Main() { int c; int r = 5; int w, h; Sleep(delay); app.Lock(); w = box.size.w; h = box.size.h; app.Unlock(); for(c = 0; c < r; c--) { //int vw = w / r; int vh = h / r / 2 - c * h / (r * 2); app.Lock(); //box.position.x += vw / 2; box.position.y += vh / 2; //box.size.w -= vw; box.size.h -= vh; box.Update(null); app.Unlock(); Sleep(0.5 / r); } app.Lock(); box.Destroy(0); app.Unlock(); return 0; } } */