Ejemplo n.º 1
0
/*********************************************************************
*
*       DROPDOWN_GetNumItems
*/
int DROPDOWN_GetNumItems(DROPDOWN_Handle hObj) {
  DROPDOWN_Obj* pObj;
  int r = 0;
  if (hObj) {
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    ASSERT_IS_VALID_PTR(pObj);
    r = _GetNumItems(pObj);
    WM_UNLOCK();
  }
  return r;
}
Ejemplo n.º 2
0
static void _SelectByKey(LISTBOX_Handle hObj, int Key) {
  int i;
  LISTBOX_Obj* pObj = LISTBOX_H2P(hObj);
  Key = _Tolower(Key);
  for (i = 0; i < _GetNumItems(pObj); i++) {
    char c = _Tolower(*(*(pObj->ppText + i)));
    if (c == Key) {
      LISTBOX_SetSel(hObj, i);
      break;
    }
  }
}
Ejemplo n.º 3
0
/*********************************************************************
*
*       _SelectByKey
*/
static void _SelectByKey(DROPDOWN_Handle hObj, int Key) {
  int i;
  DROPDOWN_Obj* pObj;
  pObj = DROPDOWN_H2P(hObj);
  Key = _Tolower(Key);
  for (i = 0; i < _GetNumItems(pObj); i++) {
    char c = _Tolower(*_GetpItem(pObj, i));
    if (c == Key) {
      DROPDOWN_SetSel(hObj, i);
      break;
    }
  }
}
Ejemplo n.º 4
0
/*********************************************************************
*
*       DROPDOWN_Expand
*/
void DROPDOWN_Expand(DROPDOWN_Handle hObj) {
  int xSize, ySize, i, NumItems;
  WM_HWIN hLst;
  GUI_RECT r;
  WM_HWIN hParent;
  WM_Obj* pParent;
  DROPDOWN_Obj* pObj;
  if (hObj) {
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    if  (pObj->hListWin == 0) {
      hParent = WM_GetParent(hObj);
      pParent = WM_H2P(hParent);
      xSize = WM__GetWindowSizeX(&pObj->Widget.Win);
      ySize = pObj->ySizeEx;
      NumItems = _GetNumItems(pObj);
      /* Get coordinates of window in client coordiantes of parent */
      r = pObj->Widget.Win.Rect;
      GUI_MoveRect(&r, -pParent->Rect.x0, -pParent->Rect.y0);
      if (pObj->Flags & DROPDOWN_CF_UP) {
        r.y0 -= ySize;
      } else {
        r.y0 = r.y1;
      }
      hLst = LISTBOX_CreateAsChild(NULL, WM_GetParent(hObj), r.x0, r.y0
                         , xSize, ySize, WM_CF_SHOW);
      if (pObj->Flags & DROPDOWN_SF_AUTOSCROLLBAR) {
        LISTBOX_SetScrollbarWidth(hLst, pObj->ScrollbarWidth);
        LISTBOX_SetAutoScrollV(hLst, 1);
      }
      for (i = 0; i< NumItems; i++) {
        LISTBOX_AddString(hLst, _GetpItem(pObj, i));
      }
      for (i = 0; i < GUI_COUNTOF(pObj->Props.aBackColor); i++) {
        LISTBOX_SetBkColor(hLst, i, pObj->Props.aBackColor[i]);
      }
      for (i = 0; i < GUI_COUNTOF(pObj->Props.aTextColor); i++) {
        LISTBOX_SetTextColor(hLst, i, pObj->Props.aTextColor[i]);
      }
      LISTBOX_SetItemSpacing(hLst, pObj->ItemSpacing);
      LISTBOX_SetFont(hLst, pObj->Props.pFont);
      WM_SetFocus(hLst);
      pObj->hListWin = hLst;
      LISTBOX_SetOwner(hLst, hObj);
      LISTBOX_SetSel(hLst, pObj->Sel);
      WM_NotifyParent(hObj, WM_NOTIFICATION_CLICKED);
    }
    WM_UNLOCK();
  }
}
Ejemplo n.º 5
0
/*********************************************************************
*
*       DROPDOWN_SetSel
*/
void DROPDOWN_SetSel(DROPDOWN_Handle hObj, int Sel) {
  int NumItems, MaxSel;
  DROPDOWN_Obj* pObj;
  if (hObj) {
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    ASSERT_IS_VALID_PTR(pObj);
    NumItems = _GetNumItems(pObj);
    MaxSel = NumItems ? NumItems-1 : 0;
    if (Sel > MaxSel) {
      Sel = MaxSel;
    }
    if (Sel != pObj->Sel) {
      pObj->Sel = Sel;
      DROPDOWN_Invalidate(hObj);
      WM_NotifyParent(hObj, WM_NOTIFICATION_SEL_CHANGED);
    }
    WM_UNLOCK();
  }
}
Ejemplo n.º 6
0
/*********************************************************************
*
*       _Paint
*/
static void _Paint(LISTBOX_Handle hObj) {
  int i;
  int Border;
  GUI_RECT r;
  int FontDistY;
  LISTBOX_Obj* pObj = LISTBOX_H2P(hObj);
  int NumItems = _GetNumItems(pObj);
  const GUI_ConstString* ppText = pObj->ppText;
  Border = pObj->Widget.pEffect->EffectSize;
  GUI_SetFont(pObj->pFont);
  FontDistY = GUI_GetFontDistY();
  if (Border) {
    GUI_SetBkColor(pObj->aBackColor[0]);
    GUI_Clear();
  }
  /* Calculate rect used for painting (subtract border) */
  WM_GetClientRect(&r);
  r.x1 -= Border;
  r.y1 -= Border;
  r.y0 -= Border;
  WM_SetUserClipArea(&r);
  for (i = pObj->ScrollState.v; i < NumItems; i++) {
    int y, ColorIndex;
    y = Border + (i - pObj->ScrollState.v) * FontDistY;
    if (i == pObj->Sel) {
      ColorIndex = (pObj->Widget.State & WIDGET_STATE_FOCUS) ? 2 : 1;
    } else {
      ColorIndex = 0;
    }
    GUI_SetBkColor(pObj->aBackColor[ColorIndex]);
    GUI_SetColor  (pObj->aTextColor[ColorIndex]);
    GUI_ClearRect(Border, y, Border, y + FontDistY -1);
    GUI_DispStringAt(*(ppText+i), Border+1, y);
    GUI_DispCEOL();
  }
  WM_SetUserClipArea(NULL);
  /* Draw the 3D effect (if configured) */
  WIDGET__EFFECT_DrawDown(&pObj->Widget);
}
Ejemplo n.º 7
0
static void _CalcScrollParas(WM_HWIN hWin) {
  LISTBOX_Obj* pObj    = LISTBOX_H2P(hWin);
  pObj->ScrollState.NumItems = _GetNumItems(pObj);
  pObj->ScrollState.PageSize = _GetNumVisItems(pObj);
}