Ejemplo n.º 1
0
/*********************************************************************
*
*       Exported routines:  Various methods
*
**********************************************************************
*/
void PROGBAR_SetValue(PROGBAR_Handle hObj, int v) {
  PROGBAR_Obj* pObj;
  GUI_RECT r;
  if (hObj) {
    WM_LOCK();
    pObj= PROGBAR_H2P(hObj);
    /* Put v into legal range */
    if (v < pObj->Min)
	    v = pObj->Min;
    if (v > pObj->Max)
	    v = pObj->Max;
    if (pObj->v != v) {
      /* Invalidate */
      if (pObj->hpText) {
        /* Calculate invalid area */
        r.x0 = _Value2X(hObj, pObj->v);
        r.x1 = _Value2X(hObj, v);
        /* Make sure x0 <= x1 */
		    if (r.x0 > r.x1) {
			    int t = r.x0;
			    r.x0 = r.x1;
			    r.x1 = t;
		    }
		    r.y0 =0;
		    r.y1 =4095;
        WM_InvalidateRect(hObj,&r);
	    } else {
        Invalidate(hObj);
	    }
      pObj->v = v;                         /* Update stored value */
    }
    WM_UNLOCK();
  }
}
Ejemplo n.º 2
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(PROGBAR_Handle hObj) {
  PROGBAR_Obj* pObj;
  GUI_RECT r, rInside, rClient, rText;
  const char* pText;
  char ac[5];
  int tm, xPos;
  pObj = PROGBAR_H2P(hObj);
  WM_GetClientRect(&rClient);
  GUI__ReduceRect(&rInside, &rClient, pObj->Widget.pEffect->EffectSize);
  xPos  = _Value2X(pObj, pObj->v);
  pText = _GetText(pObj, ac);
  GUI_SetFont(pObj->pFont);
  _GetTextRect(pObj, &rText, pText);
  tm = GUI_SetTextMode(GUI_TM_TRANS);
  /* Draw left bar */
  r    = rInside;
  r.x1 = xPos - 1;
  WM_SetUserClipArea(&r);
  _DrawPart(pObj, 0, rText.x0, rText.y0, pText);
  /* Draw right bar */
  r    = rInside;
  r.x0 = xPos;
  WM_SetUserClipArea(&r);
  _DrawPart(pObj, 1, rText.x0, rText.y0, pText);
  WM_SetUserClipArea(NULL);
  GUI_SetTextMode(tm);
  WIDGET__EFFECT_DrawDownRect(&pObj->Widget, &rClient);
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       PROGBAR_SetValue
*/
void PROGBAR_SetValue(PROGBAR_Handle hObj, int v) {
  if (hObj) {
    PROGBAR_Obj* pObj;
    WM_LOCK();
    pObj= PROGBAR_H2P(hObj);
    /* Put v into legal range */
    if (v < pObj->Min) {
	    v = pObj->Min;
    }
    if (v > pObj->Max) {
	    v = pObj->Max;
    }
    if (pObj->v != v) {
      GUI_RECT r;
      /* Get x values */
      if (v < pObj->v) {
        r.x0 = _Value2X(pObj, v);
        r.x1 = _Value2X(pObj, pObj->v);
      } else {
        r.x0 = _Value2X(pObj, pObj->v);
        r.x1 = _Value2X(pObj, v);
      }
		  r.y0    = 0;
		  r.y1    = 4095;
      if (pObj->hpText == 0) {
        const GUI_FONT GUI_UNI_PTR * pOldFont;
        char acBuffer[5];
        GUI_RECT rText;
        pOldFont = GUI_SetFont(pObj->pFont);
        _GetTextRect(pObj, &rText, _GetText(pObj, acBuffer));
        GUI_MergeRect(&r, &r, &rText);
        pObj->v = v;
        _GetTextRect(pObj, &rText, _GetText(pObj, acBuffer));
        GUI_MergeRect(&r, &r, &rText);
        GUI_SetFont(pOldFont);
      } else {
        pObj->v = v;
      }
      WM_InvalidateRect(hObj, &r);
    }
    WM_UNLOCK();
  }
}
Ejemplo n.º 4
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);
}