Ejemplo n.º 1
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(PROGBAR_Handle hObj) {
  PROGBAR_Obj* pObj = PROGBAR_H2P(hObj);
  WM_HWIN hWin = hObj;
  int xsize = WM_GetWindowSizeX(hWin);
  int ysize = WM_GetWindowSizeY(hWin);
  int tm;
  GUI_SetFont(pObj->pFont);
  {
    int x1;
    int FontSizeY = GUI_GetFontSizeY();
    int xText = 0;
    int yText = (ysize-FontSizeY)/2;
    GUI_RECT r;
    int XSizeChar;
    char ac[5];   /* Just enough for the percentage */
    char*s = ac;
    const char* pText;
    if (pObj->hpText != WM_HMEM_NULL) {
      pText = (const char*) WM_HMEM2Ptr(pObj->hpText);
    } else {
      GUI_AddDecMin((100*(I32)(pObj->v-pObj->Min))/(pObj->Max-pObj->Min), &s);
      *s = '%';
			*(s+1) =0;
			pText = &ac[0];
		}
/* Calculate text positions */
    XSizeChar = GUI_GetStringDistX(pText);
    x1 = _Value2X(hObj, pObj->v);
    switch (pObj->TextAlign &GUI_TA_HORIZONTAL) {
    case GUI_TA_CENTER:
      xText  = (xsize-XSizeChar)/2;
			break;
    case GUI_TA_LEFT:
      xText  = 0;
			break;
    case GUI_TA_RIGHT:
      xText  = xsize-XSizeChar-1;
			break;
		}
    xText += pObj->XOff;
    yText += pObj->YOff;
    tm = GUI_SetTextMode(GUI_TM_TRANS);
/* Draw left bar */
    r.x0=0; r.x1=x1-1; r.y0=0; r.y1 = GUI_YMAX;
    WM_SetUserClipArea(&r);
    _DrawPart(pObj, 0, xText, yText, pText);
/* Draw right bar */
    r.x0=r.x1+1; r.x1=GUI_XMAX;
    WM_SetUserClipArea(&r);
    _DrawPart(pObj, 1, xText, yText, pText);
  }
  WM_SetUserClipArea(NULL);
  GUI_SetTextMode(tm);
}
Ejemplo n.º 2
0
/*********************************************************************
*
*       _GetText
*/
static const char* _GetText(const PROGBAR_Obj* pObj, char* pBuffer) {
  char* pText;
  if (pObj->hpText) {
    pText = (char*) GUI_ALLOC_h2p(pObj->hpText);
  } else {
    pText = pBuffer;
    GUI_AddDecMin((100 * (I32)(pObj->v - pObj->Min)) / (pObj->Max - pObj->Min), &pBuffer);
    *pBuffer++ = '%';
		*pBuffer   = 0;
	}
  return (const char*)pText;
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       GUI_DispDecSpace
*/
void GUI_DispDecSpace(I32 v, U8 MaxDigits) {
	char ac[12];
	char* s = ac;
  U8 Len;
  if (v < 0) {
    v = GUI_AddSign(v, &s);
    MaxDigits--;
  }
  Len = GUI_Long2Len(v);
  while (Len++ < MaxDigits) {
    *s++ = ' ';
  }
  GUI_AddDecMin(v, &s);
  GUI_DispString(ac);
}
Ejemplo n.º 4
0
/*********************************************************************
*
*       GUI_DispDecMin
*/
void GUI_DispDecMin(I32 v) {
	char ac[12];
	char* s = ac;
  GUI_AddDecMin(v, &s);
  GUI_DispString(ac);
}