Void stopAnyPrinting() { /* terminate printing of expression,*/ if (printing) { /* after successful termination or */ printing = FALSE; /* runtime error (e.g. interrupt) */ Putchar('\n'); if (showStats) { #define plural(v) v, (v==1?"":"s") #if HUGS_FOR_WINDOWS { int svColor = SetForeColor(BLUE); #endif Printf("(%lu reduction%s, ",plural(numReductions)); Printf("%lu cell%s",plural(numCells)); if (numGcs>0) Printf(", %u garbage collection%s",plural(numGcs)); Printf(")\n"); #if HUGS_FOR_WINDOWS SetForeColor(svColor); } #endif #undef plural } #if OBSERVATIONS printObserve(ALLTAGS); if (obsCount) { ERRMSG(0) "Internal: observation sanity counter > 0\n" EEND; } if (showStats){ Int n = countObserve(); if (n > 0) Printf("%d observations recorded\n", n); } #endif FlushStdout(); garbageCollect(); } }
void ShowTempEntry(char *format,...) { char text[1024]; va_list v; va_start(v, format); vsprintf(text, format, v); SetBackColor(ANSI_BLUE); if (StatusLine > ScrnHeight - 2) { SetForeColor(ANSI_WHITE); ScrollText(); StatusLine--; } SetForeColor(ANSI_YELLOW); MoveCurs(4, StatusLine); CPrintf("%s", text); StatusLine++; TimeUpdate(); }
void ShowWarningEntry(char *format,...) { char text[1024]; va_list v; va_start(v, format); vsprintf(text, format, v); SetBackColor(ANSI_BLUE); if (StatusLine > ScrnHeight - 2) { SetForeColor(ANSI_WHITE); ScrollText(); StatusLine--; } SetForeColor(ANSI_RED); MoveCurs(2, StatusLine); CPrintf("$f1*** %s", text); if (logging) { LogFile = fopen("error.log", "a+"); if (LogFile != NULL) CfPrintf(LogFile, "*** %s", text); fclose(LogFile); } StatusLine++; TimeUpdate(); }
void ScrnInit(void) { InitText(); signal(SIGINT, SevereErrorSIGINT); signal(SIGSEGV, SevereErrorSIGSEGV); #ifdef SIGQUIT signal(SIGQUIT, SevereErrorSIGQUIT); #endif LastCheck = StartTime = (long)I_FloatTime(); SetForeColor(ANSI_WHITE); SetBackColor(ANSI_BLUE); DrawFilledBox(0, 0, ScrnWidth, ScrnHeight); StatusLine = 5; MoveCurs(2, 1); SetForeColor(ANSI_WHITE); SetBackColor(ANSI_BLUE); DrawVLine(45, 5, ScrnHeight - 6); DrawHLine(1, 4, ScrnWidth - 2); DrawHLine(1, 2, ScrnWidth - 2); MoveCurs(2, 3); CPrintf("$f3Elapsed time: $f200:00:00 $f7By Lee Smith <[email protected]$f7>$f3"); remove("error.log"); }
void CPrintf(char *format,...) { register char c; register char *ptr, *src; int x, y; char text[1024]; char text2[1024]; va_list v; va_start(v, format); vsprintf(text, format, v); GetCurs(&x, &y); for (ptr = text2, src = text; *src != '\0'; src++) { c = *src; if (c == '$') { switch (*++src) { case '$': *ptr++ = '$'; break; case 'a': *ptr = '\0'; cputs(ptr = text2); RingBell(); break; case 'n': *ptr = '\0'; cputs(ptr = text2); MoveCurs(x, ++y); break; case 'f': *ptr = '\0'; cputs(ptr = text2); SetForeColor(toupper(*++src) - '0'); break; case 'b': *ptr = '\0'; cputs(ptr = text2); SetBackColor(toupper(*++src) - '0'); break; case 'c': *ptr = '\0'; cputs(ptr = text2); SetForeColor(toupper(*++src) - '0'); SetBackColor(toupper(*++src) - '0'); break; } } else if (c >= 32 && c <= 126) *ptr++ = c; } *ptr = '\0'; cputs(ptr = text2); #ifdef UNIX refresh(); #endif }
/**************************************************************************** REMARKS: Draw the background image for the centering and refresh display ****************************************************************************/ static void drawBackground(void) { char buf[80]; int i,x,y,min,max; long range; GA_palette pal[256],*p; min = 32; max = 253; range = max - min; for (i = 0; i < 254; i++) { pal[i].Red = 0; pal[i].Blue = (((i*range)/254)+min); pal[i].Green = 0; } pal[254].Red = pal[254].Green = pal[254].Blue = 128; pal[255].Red = pal[255].Green = pal[255].Blue = 255; if (modeInfo.BitsPerPixel > 8) { for (i = 0; i < maxY; i++) { p = &pal[(i * 254L) / maxY]; SetForeColor(rgbColor(p->Red,p->Green,p->Blue)); draw2d.DrawLineInt(0,i,maxX,i,true); } } else { driver.SetPaletteData(pal,256,0,false); for (i = 0; i < maxY; i++) { SetForeColor((i * 254L) / maxY); draw2d.DrawLineInt(0,i,maxX,i,true); } defcolor = 255; } SetForeColor(defcolor); draw2d.DrawLineInt(0,0,maxX,0,true); draw2d.DrawLineInt(0,0,0,maxY,true); draw2d.DrawLineInt(maxX,0,maxX,maxY,true); draw2d.DrawLineInt(0,maxY,maxX,maxY,true); draw2d.DrawLineInt(maxX/2,0,maxX/2,maxY,true); draw2d.DrawLineInt(0,maxY/2,maxX,maxY/2,true); x = maxX/2 - 240; y = maxY/2 - 146; sprintf(buf,"Video mode: %d x %d %d bits per pixel",maxX+1,maxY+1,modeInfo.BitsPerPixel); WriteText(x,y,buf,defcolor); y += 32; WriteText(x,y,"Adjust mode parameters with the following keys:",defcolor); y += 32; WriteText(x,y," \x1B Move image left",defcolor); y += 16; WriteText(x,y," \x1A Move image right",defcolor); y += 16; WriteText(x,y," \x18 Move image up",defcolor); y += 16; WriteText(x,y," \x19 Move image down",defcolor); y += 16; WriteText(x,y," + Increase brightness",defcolor); y += 16; WriteText(x,y," - Decrease brightness",defcolor); y += 16; WriteText(x,y," r Restore original values",defcolor); y += 16; y += 16; WriteText(x,y,"Press <Enter> to accept changes, ESC to quit without saving",defcolor); }
PanelControl::PanelControl(ContainerControl &parent, int x, int y, unsigned width, unsigned height, const WindowStyle style) { SetForeColor(parent.GetForeColor()); SetBackColor(parent.GetBackColor()); set(parent.GetClientAreaWindow(), x, y, width, height, style); }
WndOwnerDrawFrame::WndOwnerDrawFrame(ContainerControl &parent, int X, int Y, int Width, int Height, const WindowStyle style, OnPaintCallback_t OnPaintCallback) :mOnPaintCallback(OnPaintCallback), mOnMouseDownCallback(NULL) { SetForeColor(parent.GetForeColor()); SetBackColor(parent.GetBackColor()); set(parent.GetClientAreaWindow(), X, Y, Width, Height, style); }
/**************************************************************************** REMARKS: Draw a simple moire pattern of lines on the display ****************************************************************************/ void DrawMoire(void) { int i,value; if (maxcolor >= 0x7FFFL) { for (i = 0; i < maxX; i++) { SetForeColor(rgbColor((uchar)((i*255L)/maxX),0,0)); draw2d.DrawLineInt(maxX/2,maxY/2,i,0,rgbColor((uchar)((i*255L)/maxX),0,0)); SetForeColor(rgbColor(0,(uchar)((i*255L)/maxX),0)); draw2d.DrawLineInt(maxX/2,maxY/2,i,maxY,rgbColor(0,(uchar)((i*255L)/maxX),0)); } for (i = 0; i < maxY; i++) { value = (int)((i*255L)/maxY); SetForeColor(rgbColor((uchar)value,0,(uchar)(255 - value))); draw2d.DrawLineInt(maxX/2,maxY/2,0,i,rgbColor((uchar)value,0,(uchar)(255 - value))); SetForeColor(rgbColor(0,(uchar)(255 - value),(uchar)value)); draw2d.DrawLineInt(maxX/2,maxY/2,maxX,i,rgbColor(0,(uchar)(255 - value),(uchar)value)); } } else { for (i = 0; i < maxX; i += 5) { SetForeColor(i % maxcolor); draw2d.DrawLineInt(maxX/2,maxY/2,i,0,true); SetForeColor((i+1) % maxcolor); draw2d.DrawLineInt(maxX/2,maxY/2,i,maxY,true); } for (i = 0; i < maxY; i += 5) { SetForeColor((i+2) % maxcolor); draw2d.DrawLineInt(maxX/2,maxY/2,0,i,true); SetForeColor((i+3) % maxcolor); draw2d.DrawLineInt(maxX/2,maxY/2,maxX,i,true); } } SetForeColor(defcolor); draw2d.DrawLineInt(0,0,maxX,0,true); draw2d.DrawLineInt(0,0,0,maxY,true); draw2d.DrawLineInt(maxX,0,maxX,maxY,true); draw2d.DrawLineInt(0,maxY,maxX,maxY,true); }
void FormWindow::Init(const FormDef& def) { if (def.GetRect().w > 0 && def.GetRect().h > 0) { // if form size is specified in def, and it is // smaller than the current screen size, // center the form on the display: Rect r = def.GetRect(); if (r.w < screen->Width()) { r.x = (screen->Width() - r.w) / 2; } else { r.x = 0; r.w = screen->Width(); } if (r.h < screen->Height()) { r.y = (screen->Height() - r.h) / 2; } else { r.y = 0; r.h = screen->Height(); } MoveTo(r); } SetMargins(def.GetMargins()); SetTextInsets(def.GetTextInsets()); SetCellInsets(def.GetCellInsets()); SetCells(def.GetCells()); SetFixedWidth(def.GetFixedWidth()); SetFixedHeight(def.GetFixedHeight()); UseLayout(def.GetLayout().x_mins, def.GetLayout().y_mins, def.GetLayout().x_weights, def.GetLayout().y_weights); if (def.GetTexture().length() > 0) { DataLoader* loader = DataLoader::GetLoader(); loader->SetDataPath("Screens/"); loader->LoadTexture(def.GetTexture(), texture); loader->SetDataPath(""); } SetBackColor(def.GetBackColor()); SetForeColor(def.GetForeColor()); Font* f = FontMgr::Find(def.GetFont()); if (f) SetFont(f); SetTransparent(def.GetTransparent()); ListIter<CtrlDef> ctrl = def.GetControls(); while (++ctrl) { switch (ctrl->GetType()) { case WIN_DEF_FORM: case WIN_DEF_LABEL: default: CreateDefLabel(*ctrl); break; case WIN_DEF_BUTTON: CreateDefButton(*ctrl); break; case WIN_DEF_COMBO: CreateDefCombo(*ctrl); break; case WIN_DEF_IMAGE: CreateDefImage(*ctrl); break; case WIN_DEF_EDIT: CreateDefEdit(*ctrl); break; case WIN_DEF_LIST: CreateDefList(*ctrl); break; case WIN_DEF_SLIDER: CreateDefSlider(*ctrl); break; case WIN_DEF_RICH: CreateDefRichText(*ctrl); break; } } RegisterControls(); DoLayout(); CalcGrid(); }
void CControlUI::SetAttribute(LPCTSTR pstrName, LPCTSTR pstrValue) { // ÊÇ·ñÑùʽ±í if(m_pManager != NULL) { LPCTSTR pStyle = m_pManager->GetStyle(pstrValue); if( pStyle != NULL) { ApplyAttributeList(pStyle); return; } } if( _tcsicmp(pstrName, _T("pos")) == 0 ) { RECT rcPos = { 0 }; LPTSTR pstr = NULL; rcPos.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPos.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPos.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SIZE szXY = {rcPos.left >= 0 ? rcPos.left : rcPos.right, rcPos.top >= 0 ? rcPos.top : rcPos.bottom}; SetFixedXY(szXY); SetFixedWidth(rcPos.right - rcPos.left); SetFixedHeight(rcPos.bottom - rcPos.top); } else if( _tcsicmp(pstrName, _T("float")) == 0 ) { CDuiString nValue = pstrValue; // ¶¯Ì¬¼ÆËãÏà¶Ô±ÈÀý if(nValue.Find(',') < 0) { SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); } else { TPercentInfo piFloatPercent = { 0 }; LPTSTR pstr = NULL; piFloatPercent.left = _tcstod(pstrValue, &pstr); ASSERT(pstr); piFloatPercent.top = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.right = _tcstod(pstr + 1, &pstr); ASSERT(pstr); piFloatPercent.bottom = _tcstod(pstr + 1, &pstr); ASSERT(pstr); SetFloatPercent(piFloatPercent); SetFloat(true); } } else if( _tcsicmp(pstrName, _T("padding")) == 0 ) { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetPadding(rcPadding); } else if( _tcsicmp(pstrName, _T("bkcolor")) == 0 || _tcsicmp(pstrName, _T("bkcolor1")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor2")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor2(clrColor); } else if( _tcsicmp(pstrName, _T("bkcolor3")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBkColor3(clrColor); } else if( _tcsicmp(pstrName, _T("forecolor")) == 0 ) { while( *pstrValue > _T('\0') && *pstrValue <= _T(' ') ) pstrValue = ::CharNext(pstrValue); if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetForeColor(clrColor); } else if( _tcsicmp(pstrName, _T("bordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("focusbordercolor")) == 0 ) { if( *pstrValue == _T('#')) pstrValue = ::CharNext(pstrValue); LPTSTR pstr = NULL; DWORD clrColor = _tcstoul(pstrValue, &pstr, 16); SetFocusBorderColor(clrColor); } else if( _tcsicmp(pstrName, _T("colorhsl")) == 0 ) SetColorHSL(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("bordersize")) == 0 ) { CDuiString nValue = pstrValue; if(nValue.Find(',') < 0) { SetBorderSize(_ttoi(pstrValue)); RECT rcPadding = {0}; SetBorderSize(rcPadding); } else { RECT rcPadding = { 0 }; LPTSTR pstr = NULL; rcPadding.left = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); rcPadding.top = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.right = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); rcPadding.bottom = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderSize(rcPadding); } } else if( _tcsicmp(pstrName, _T("leftbordersize")) == 0 ) SetLeftBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("topbordersize")) == 0 ) SetTopBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("rightbordersize")) == 0 ) SetRightBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("bottombordersize")) == 0 ) SetBottomBorderSize(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderstyle")) == 0 ) SetBorderStyle(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("borderround")) == 0 ) { SIZE cxyRound = { 0 }; LPTSTR pstr = NULL; cxyRound.cx = _tcstol(pstrValue, &pstr, 10); ASSERT(pstr); cxyRound.cy = _tcstol(pstr + 1, &pstr, 10); ASSERT(pstr); SetBorderRound(cxyRound); } else if( _tcsicmp(pstrName, _T("bkimage")) == 0 ) SetBkImage(pstrValue); else if( _tcsicmp(pstrName, _T("foreimage")) == 0 ) SetForeImage(pstrValue); else if( _tcsicmp(pstrName, _T("width")) == 0 ) SetFixedWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("height")) == 0 ) SetFixedHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minwidth")) == 0 ) SetMinWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("minheight")) == 0 ) SetMinHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxwidth")) == 0 ) SetMaxWidth(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("maxheight")) == 0 ) SetMaxHeight(_ttoi(pstrValue)); else if( _tcsicmp(pstrName, _T("name")) == 0 ) SetName(pstrValue); else if( _tcsicmp(pstrName, _T("drag")) == 0 ) SetDragEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("drop")) == 0 ) SetDropEnable(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("resourcetext")) == 0 ) SetResourceText(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("text")) == 0 ) SetText(pstrValue); else if( _tcsicmp(pstrName, _T("tooltip")) == 0 ) SetToolTip(pstrValue); else if( _tcsicmp(pstrName, _T("userdata")) == 0 ) SetUserData(pstrValue); else if( _tcsicmp(pstrName, _T("enabled")) == 0 ) SetEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("mouse")) == 0 ) SetMouseEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("keyboard")) == 0 ) SetKeyboardEnabled(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("visible")) == 0 ) SetVisible(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("float")) == 0 ) SetFloat(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("shortcut")) == 0 ) SetShortcut(pstrValue[0]); else if( _tcsicmp(pstrName, _T("menu")) == 0 ) SetContextMenuUsed(_tcsicmp(pstrValue, _T("true")) == 0); else if( _tcsicmp(pstrName, _T("cursor")) == 0 && pstrValue) { if( _tcsicmp(pstrValue, _T("arrow")) == 0 ) SetCursor(DUI_ARROW); else if( _tcsicmp(pstrValue, _T("ibeam")) == 0 ) SetCursor(DUI_IBEAM); else if( _tcsicmp(pstrValue, _T("wait")) == 0 ) SetCursor(DUI_WAIT); else if( _tcsicmp(pstrValue, _T("cross")) == 0 ) SetCursor(DUI_CROSS); else if( _tcsicmp(pstrValue, _T("uparrow")) == 0 ) SetCursor(DUI_UPARROW); else if( _tcsicmp(pstrValue, _T("size")) == 0 ) SetCursor(DUI_SIZE); else if( _tcsicmp(pstrValue, _T("icon")) == 0 ) SetCursor(DUI_ICON); else if( _tcsicmp(pstrValue, _T("sizenwse")) == 0 ) SetCursor(DUI_SIZENWSE); else if( _tcsicmp(pstrValue, _T("sizenesw")) == 0 ) SetCursor(DUI_SIZENESW); else if( _tcsicmp(pstrValue, _T("sizewe")) == 0 ) SetCursor(DUI_SIZEWE); else if( _tcsicmp(pstrValue, _T("sizens")) == 0 ) SetCursor(DUI_SIZENS); else if( _tcsicmp(pstrValue, _T("sizeall")) == 0 ) SetCursor(DUI_SIZEALL); else if( _tcsicmp(pstrValue, _T("no")) == 0 ) SetCursor(DUI_NO); else if( _tcsicmp(pstrValue, _T("hand")) == 0 ) SetCursor(DUI_HAND); } else if( _tcsicmp(pstrName, _T("virtualwnd")) == 0 ) SetVirtualWnd(pstrValue); else if( _tcsicmp(pstrName, _T("innerstyle")) == 0 ) { CDuiString sXmlData = pstrValue; sXmlData.Replace(_T("""), _T("\"")); LPCTSTR pstrList = sXmlData.GetData(); CDuiString sItem; CDuiString sValue; while( *pstrList != _T('\0') ) { sItem.Empty(); sValue.Empty(); while( *pstrList != _T('\0') && *pstrList != _T('=') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sItem += *pstrList++; } } ASSERT( *pstrList == _T('=') ); if( *pstrList++ != _T('=') ) return; ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; while( *pstrList != _T('\0') && *pstrList != _T('\"') ) { LPTSTR pstrTemp = ::CharNext(pstrList); while( pstrList < pstrTemp) { sValue += *pstrList++; } } ASSERT( *pstrList == _T('\"') ); if( *pstrList++ != _T('\"') ) return; SetAttribute(sItem, sValue); if( *pstrList++ != _T(' ') && *pstrList++ != _T(',') ) return; } } }