Example #1
0
File: wm.c Project: byxob/calendar
/*
  ********************************************************************
  *                                                                  *
  *                 Show / hide window                               *
  *                                                                  *
  ********************************************************************
*/
void WM_ShowWindow   (WM_HWIN hWin) {
  WM_Obj *pWin;
  WM_LOCK();
  pWin = WM_H2P(hWin);  
  /* First check if this is necessary at all */
  if ((pWin->Status&WM_SF_ISVIS)) {
    WM_UNLOCK();
    return;
  }
  /* Set Visibility flag */
  pWin->Status |= WM_SF_ISVIS;
  /* Mark content as invalid */
  WM_InvalidateWindow(hWin);
  WM_UNLOCK();
}
Example #2
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();
  }
}
Example #3
0
/*********************************************************************
*
*       WM_GetWindowOrgY
*/
int WM_GetWindowOrgY(WM_HWIN hWin) {
  int r;
  WM_LOCK();
  r = WM_HANDLE2PTR(hWin)->Rect.y0;
  WM_UNLOCK();
  return r;
}
/*********************************************************************
*
*       LISTVIEW_SetSort
*
* Purpose:
*   Enables sorting for the given listview object. The function returns,
*   if the object is 0, the column index is >= number of columns or if
*   no compare function has been set for the desired column
*
* Return value:
*   0 if succeed
*   1 if not succeed
*/
unsigned LISTVIEW_SetSort(LISTVIEW_Handle hObj, unsigned Column, unsigned Reverse) {
    LISTVIEW_Obj    * pObj;
    LISTVIEW_SORT   * pSort;
    LISTVIEW_COLUMN * pColumn;
    unsigned NumColumns, Error = 0;
    if (!hObj) {
        return 1;
    }
    NumColumns = LISTVIEW_GetNumColumns(hObj);
    if (Column >= NumColumns) {
        return 1;
    }
    WM_LOCK();
    pObj    = LISTVIEW_H2P(hObj);
    pColumn = (LISTVIEW_COLUMN *)GUI_ARRAY_GetpItem(&pObj->ColumnArray, Column);
    if (pColumn->fpCompare) {
        pSort = _CreateSortObject(hObj, pObj);
        pObj  = LISTVIEW_H2P(hObj); /* Restore after allocating memory */
        if (pSort) {
            pObj->SortIndex = Column;
            pSort->Reverse  = Reverse;
            LISTVIEW__InvalidateInsideArea(hObj, pObj);
        } else {
            Error = 1;
        }
    } else {
        Error = 1;
    }
    WM_UNLOCK();
    return Error;
}
Example #5
0
/*********************************************************************
*
*       GUI_EditString
*/
void GUI_EditString(char * pString, int Len, int xsize) {
  int Key, x, y, ysize, Id;
  EDIT_Handle hEdit;
  EDIT_Obj* pObj;
  const GUI_FONT GUI_UNI_PTR * pOldFont;
  WM_LOCK();
  pOldFont = GUI_SetFont(EDIT_GetDefaultFont());
  x = GUI_GetDispPosX();
  y = GUI_GetDispPosY();
  if (xsize == 0) {
    xsize = GUI_GetCharDistX('X') * Len + 6;
  }
  ysize = GUI_GetFontSizeY();
  Id = 0x1234;
  hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0);
  EDIT_SetText(hEdit, pString);
  pObj = EDIT_H2P(hEdit);
  WM_SetFocus(hEdit);
  do {
    Key = GUI_WaitKey();
  } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0));
  if (Key == GUI_KEY_ENTER) {
    EDIT_GetText(hEdit, pString, pObj->MaxLen);
  }
  GUI_SetFont(pOldFont);
  EDIT_Delete(hEdit);
  WM_UNLOCK();
}
Example #6
0
/*********************************************************************
*
*       TEXT_CreateEx
*/
TEXT_Handle TEXT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
                          int WinFlags, int ExFlags, int Id, const char* pText)
{
  TEXT_Handle hObj;
  /* Create the window */
  #if TEXT_SUPPORT_TRANSPARENCY
    WinFlags |= WM_CF_HASTRANS;
  #endif
  WM_LOCK();
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, TEXT_Callback,
                                sizeof(TEXT_Obj) - sizeof(WM_Obj));
  if (hObj) {
    TEXT_Obj* pObj;
    WM_HMEM hMem = 0;
    pObj = (TEXT_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
    /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, 0);
    /* init member variables */
    TEXT_INIT_ID(pObj);
    if (pText) {
      hMem = GUI_ALLOC_AllocZero(strlen(pText) + 1);
      if (hMem) {
        strcpy((char*) GUI_ALLOC_h2p(hMem), pText);
      }
    }
    pObj->hpText = hMem;
    pObj->Align  = ExFlags;
    pObj->Props  = TEXT__DefaultProps;
  } else {
    GUI_DEBUG_ERROROUT_IF(hObj==0, "TEXT_Create failed")
  }
  WM_UNLOCK();
  return hObj;
}
/*********************************************************************
*
*       LISTBOX_SetItemDisabled
*/
void LISTBOX_SetItemDisabled(LISTBOX_Handle hObj, unsigned Index, int OnOff) {
  if (hObj) {
    unsigned NumItems;
    LISTBOX_Obj* pObj;
    WM_LOCK();
    pObj = LISTBOX_H2P(hObj);
    NumItems = LISTBOX__GetNumItems(pObj);
    if (Index < NumItems) {
      WM_HMEM hItem = GUI_ARRAY_GethItem(&pObj->ItemArray, Index);
      if (hItem) {
        LISTBOX_ITEM * pItem = (LISTBOX_ITEM *)GUI_ALLOC_h2p(hItem);
        if (OnOff) {
          if (!(pItem->Status & LISTBOX_ITEM_DISABLED)) {
            pItem->Status |= LISTBOX_ITEM_DISABLED;
            LISTBOX__InvalidateItem(hObj, pObj, Index);
          }
        } else {
          if (pItem->Status & LISTBOX_ITEM_DISABLED) {
            pItem->Status &= ~LISTBOX_ITEM_DISABLED;
            LISTBOX__InvalidateItem(hObj, pObj, Index);
          }
        }
      }
    }
    WM_UNLOCK();
  }
}
Example #8
0
/*********************************************************************
*
*       PROGBAR_CreateEx
*/
PROGBAR_Handle PROGBAR_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
                                int WinFlags, int ExFlags, int Id)
{
  PROGBAR_Handle hObj;
  GUI_USE_PARA(ExFlags);
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, _PROGBAR_Callback,
                                sizeof(PROGBAR_Obj) - sizeof(WM_Obj));
  if (hObj) {
    PROGBAR_Obj* pObj;
    WM_LOCK();
    pObj = (PROGBAR_Obj*) GUI_ALLOC_h2p(hObj);
    /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, 0);
    WIDGET_SetEffect(hObj, &WIDGET_Effect_None); /* Standard effect for progbar: None */
    INIT_ID(pObj);
    /* init member variables */
    pObj->pFont        = GUI_DEFAULT_FONT;
    pObj->BarColor[0]  = PROGBAR_DEFAULT_BARCOLOR0;
    pObj->BarColor[1]  = PROGBAR_DEFAULT_BARCOLOR1;
    pObj->TextColor[0] = PROGBAR_DEFAULT_TEXTCOLOR0;
    pObj->TextColor[1] = PROGBAR_DEFAULT_TEXTCOLOR1;
    pObj->TextAlign    = GUI_TA_CENTER;
    pObj->Max          = 100;
    pObj->Min          = 0;
    WM_UNLOCK();
  }
  return hObj;
}
Example #9
0
/*********************************************************************
*
*       GUI_EditDec
*/
I32 GUI_EditDec(I32 Value, I32 Min, I32 Max, int Len, int xsize, int Shift, U8 Flags) {
  I32 Ret = Value;
  int Key, x, y, ysize, Id;
  EDIT_Handle hEdit;
  EDIT_Obj* pObj;
  const GUI_FONT GUI_UNI_PTR * pOldFont;
  WM_LOCK();
  pOldFont = GUI_SetFont(EDIT_GetDefaultFont());
  x = GUI_GetDispPosX();
  y = GUI_GetDispPosY();
  if (xsize == 0)
    xsize = GUI_GetCharDistX('X') * Len + 6;
  ysize = GUI_GetFontSizeY();
  Id = 0x1234;
  hEdit = EDIT_Create(x, y, xsize, ysize, Id, Len, 0);
  pObj = EDIT_H2P(hEdit);
  EDIT_SetDecMode(hEdit, Value, Min, Max, Shift, Flags);
  WM_SetFocus(hEdit);
  do {
    Key = GUI_WaitKey();
  } while ((Key != GUI_KEY_ESCAPE) && (Key != GUI_KEY_ENTER) && (Key != 0));
  GUI_SetFont(pOldFont);
  if (Key == GUI_KEY_ENTER)
    Ret = pObj->CurrentValue;
  EDIT_Delete(hEdit);
  WM_UNLOCK();
  return Ret;
}
Example #10
0
/**********************************************************
 *                 HSD_SLIDER_CreateEx
 *
 */
SLIDER_Handle HSD_SLIDER_CreateEx(int x0, int y0, int xSize, int ySize, WM_HWIN hParent,
                                  int WinFlags, int ExFlags, int Id)
{
   SLIDER_Handle hObj;
   
   WM_LOCK();
   hObj  = WM_CreateWindowAsChild(x0, y0, xSize, ySize, hParent, WinFlags, HSD_SLIDER_Callback, sizeof(SLIDER_Obj)-sizeof(WM_Obj));
   if(hObj)
   {
      SLIDER_Obj* pObj  = SLIDER_H2P(hObj);
      U16 InitState;
      InitState  = WIDGET_STATE_FOCUSSABLE;
      if(ExFlags & SLIDER_CF_VERTICAL)
      {
         InitState  |= WIDGET_CF_VERTICAL;
      }
      
      WIDGET__Init(&pObj->Widget, Id, InitState);
      
      pObj->aBkColor[0]  = GUI_GRAY;
      pObj->aBkColor[1]  = GUI_DARKCYAN;
      pObj->aColor[0]  = GUI_BLACK;
      pObj->aColor[1]  = GUI_ORANGE;
      pObj->Width  = 16;
      pObj->Max  = 6;
      pObj->Min  = 0;
      pObj->NumTicks  = -1;
   }
   else
   {
//INFO("Slider create failed!");   
   }
   WM_UNLOCK();
   return hObj;
}     
Example #11
0
/*********************************************************************
*
*       EDIT_SetMaxLen
*/
void EDIT_SetMaxLen(EDIT_Handle  hObj, int MaxLen) {
  if (hObj) {
    EDIT_Obj* pObj;
    WM_LOCK();
    pObj = EDIT_H2P(hObj);
    if (MaxLen != pObj->MaxLen) {
      if (MaxLen < pObj->MaxLen) {
        if (pObj->hpText) {
          char* pText;
          int   NumChars;
          pText    = (char*) GUI_ALLOC_h2p(pObj->hpText);
          NumChars = GUI__GetNumChars(pText);
          if (NumChars > MaxLen) {
            int NumBytes;
            NumBytes = GUI_UC__NumChars2NumBytes(pText, MaxLen);
            *(pText + NumBytes) = 0;
          }
        }
      }
      _IncrementBuffer(pObj, MaxLen - pObj->BufferSize + 1);
      pObj->MaxLen = MaxLen;
      EDIT_Invalidate(hObj);
    }
    WM_UNLOCK();
  }
}
Example #12
0
/*********************************************************************
*
*       EDIT_CreateEx
*/
EDIT_Handle EDIT_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int WinFlags, int ExFlags,
                          int Id, int MaxLen)
{
  EDIT_Handle hObj;
  GUI_USE_PARA(ExFlags);
  WM_LOCK();
  /* Alloc memory for obj */
  WinFlags |= WM_CF_LATE_CLIP;    /* Always use late clipping since widget is optimized for it. */
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WM_CF_SHOW | WinFlags, EDIT_Callback,
                                sizeof(EDIT_Obj) - sizeof(WM_Obj));
  if (hObj) {
    EDIT_Obj* pObj;
    pObj = (EDIT_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
    /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE);
    /* init member variables */
    EDIT_INIT_ID(pObj);
    pObj->Props         = EDIT__DefaultProps;
    pObj->XSizeCursor   = 1;
    pObj->MaxLen        = (MaxLen == 0) ? 8 : MaxLen;
    pObj->BufferSize    = 0;
    pObj->hpText        = 0;
    if (_IncrementBuffer(pObj, pObj->MaxLen + 1) == 0) {
      GUI_DEBUG_ERROROUT("EDIT_Create failed to alloc buffer");
      EDIT_Delete(hObj);
      hObj = 0;
    }
  }
  WM_UNLOCK();
  return hObj;
}
Example #13
0
/*********************************************************************
*
*       _SetValue
*/
static void _SetValue(EDIT_Handle hObj, I32 Value, int Unsigned) {
  EDIT_Obj* pObj;
  if (hObj) {
    WM_LOCK();
    pObj = EDIT_H2P(hObj);
    /* Put in min/max range */
    if (Unsigned) {
      if ((unsigned)Value < (unsigned)pObj->Min) {
        Value = pObj->Min;
      }
      if ((unsigned)Value > (unsigned)pObj->Max) {
        Value = pObj->Max;
      }
    } else {
      if (Value < pObj->Min) {
        Value = pObj->Min;
      }
      if (Value > pObj->Max) {
        Value = pObj->Max;
      }
    }
    if (pObj->CurrentValue != (U32)Value) {
      pObj->CurrentValue = Value;
      if (pObj->pfUpdateBuffer) {
        pObj->pfUpdateBuffer(hObj);
      }
      WM_InvalidateWindow(hObj);
      WM_NotifyParent(hObj, WM_NOTIFICATION_VALUE_CHANGED);
    }
    WM_UNLOCK();
  }
}
Example #14
0
WM_HWIN WM_Screen2hWin(int x, int y) {
  WM_HWIN r;
  WM_LOCK();
  r = _Screen2hWin(WM__FirstWin, x, y);
  WM_UNLOCK();
  return r;
}
Example #15
0
/*********************************************************************
*
*       WM_CreateTimer
*
*  Returns:    0 if failed, else != 0
*  Parameters:
*                hWin        Window handle of the window to receive the WM_TIMER message
*                UserId      User defined Id. If not needed, use 0.
*                Period      Number of time units (ticks)
*                Mode        0: one-shot
*
*/
int WM_CreateTimer               (WM_HWIN hWin, int UserId, int Period, int Mode) {
  int r = 0;
  int TimerId;
  GUI_HMEM hTimerLink;
  TIMER_LINK* pLink;
  WM_LOCK();
  TimerId = GUI_X_CREATE_TIMER(Period, _OnTimer);
  if (TimerId) {
    hTimerLink = GUI_ALLOC_AllocZero(sizeof(TIMER_LINK));
    if (hTimerLink) {
      pLink = (TIMER_LINK*) GUI_ALLOC_h2p(hTimerLink);
      /* Put new timer at beginning of the linked list */
      pLink->hNext = _hFirst;
      if (_hFirst) {
        TIMER_LINK* pNext;
        pNext = (TIMER_LINK*) GUI_ALLOC_h2p(_hFirst);
      }
      _hFirst = hTimerLink;
      /* Fill in link data */
      pLink->hWin    = hWin;
      pLink->TimerId = TimerId;
      pLink->UserId  = UserId;
      r = 1;            /* All right, we have successfully created a new timer */
    }
  }
  /* Cleanup in case of problem */
  if (r == 0) {
    if (TimerId) {
      GUI_X_DELETE_TIMER(TimerId);
    }
  }
  WM_UNLOCK();
  return r;
}
Example #16
0
WM_HWIN WM_SetFocusOnNextChild(WM_HWIN hParent) {     /* Set the focus to the first child */
  WM_HWIN r;
  WM_LOCK();
    r = _SetFocusOnNextChild(hParent);
  WM_UNLOCK();
  return r;
}
Example #17
0
/*********************************************************************
*
*       WM_IsWindow
*/
int WM_IsWindow(WM_HWIN hWin) {
  int r;
  WM_LOCK();
  r = WM__IsWindow(hWin);
  WM_UNLOCK();
  return r;
}
Example #18
0
/*********************************************************************
*
*       LISTVIEW_AddColumn
*/
int LISTVIEW_AddColumn(LISTVIEW_Handle hObj, int Width, const char * s, int Align) {
  int r = 0;
  if (hObj) {
    LISTVIEW_Obj* pObj;
    LISTVIEW_COLUMN Column = {0};
    unsigned NumRows;
    WM_LOCK();
    pObj = LISTVIEW_H2P(hObj);
    HEADER_AddItem(pObj->hHeader, Width, s, Align);
    Column.Align = Align;
    GUI_ARRAY_AddItem(&pObj->ColumnArray, &Column, sizeof(LISTVIEW_COLUMN));
    pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */
    NumRows = LISTVIEW__GetNumRows(pObj);
    if (NumRows) {
      LISTVIEW_ROW* pRow;
      unsigned i;
      for (i = 0; i < NumRows; i++) {
        pRow = (LISTVIEW_ROW*) GUI_ARRAY_GetpItem(&pObj->RowArray, i);
        if (GUI_ARRAY_AddItem(&pRow->CellArray, NULL, sizeof(LISTVIEW_CELL))) {
          r = 1;
          break;
        }
        pObj = LISTVIEW_H2P(hObj); /* Restore after allocating memory */
      }
    }
    LISTVIEW__UpdateScrollParas(hObj, pObj);
    LISTVIEW__InvalidateInsideArea(hObj, pObj);
    WM_UNLOCK();
  }
  return r;
}
/*********************************************************************
*
*       DROPDOWN_InsertString
*/
void DROPDOWN_InsertString(DROPDOWN_Handle hObj, const char * s, unsigned int Index) {
  if (hObj && s) {
    DROPDOWN_Obj* pObj;
    unsigned int NumItems;
    WM_LOCK();
    pObj = DROPDOWN_H2P(hObj);
    NumItems = DROPDOWN_GetNumItems(hObj);
    if (Index < NumItems) {
      WM_HMEM hItem;
      hItem = GUI_ARRAY_InsertItem(&pObj->Handles, Index, strlen(s) + 1);
      if (hItem) {
        char * pBuffer = (char *)GUI_ALLOC_h2p(hItem);
        strcpy(pBuffer, s);
      }
      WM_InvalidateWindow(hObj);
      if (pObj->hListWin) {
        LISTBOX_InsertString(pObj->hListWin, s, Index);
      }
    } else {
      DROPDOWN_AddString(hObj, s);
      if (pObj->hListWin) {
        LISTBOX_AddString(pObj->hListWin, s);
      }
    }
    WM_UNLOCK();
  }
}
Example #20
0
/*********************************************************************
*
*       _UpdateChildPositions
*/
static void _UpdateChildPostions(WM_HWIN hObj, int Diff) {
  WM_Obj* pObj;
  WM_LOCK();
  pObj = (WM_Obj*)WM_H2P(hObj);
  WM__UpdateChildPositions(pObj, -Diff, -Diff, Diff, Diff);
  WM_UNLOCK();
}
/*********************************************************************
*
*       LISTVIEW_DeleteColumn
*/
void LISTVIEW_DeleteColumn(LISTVIEW_Handle hObj, unsigned Index) {
  if (hObj) {
    LISTVIEW_Obj* pObj;
    WM_LOCK();
    pObj = LISTVIEW_H2P(hObj);
    if (Index < GUI_ARRAY_GetNumItems(&pObj->AlignArray)) {
      unsigned NumRows, i;
      GUI_ARRAY* pRow;
      HEADER_DeleteItem(pObj->hHeader, Index);
      GUI_ARRAY_DeleteItem(&pObj->AlignArray, Index);
      NumRows = GUI_ARRAY_GetNumItems(&pObj->RowArray);
      for (i = 0; i < NumRows; i++) {
        LISTVIEW_ITEM * pItem;
        pRow = (GUI_ARRAY*)GUI_ARRAY_GetpItem(&pObj->RowArray, i);
        /* Delete attached info items */
        pItem = (LISTVIEW_ITEM *)GUI_ARRAY_GetpItem(pRow, Index);
        if (pItem->hItemInfo) {
          GUI_ALLOC_Free(pItem->hItemInfo);
        }
        /* Delete cell */
        GUI_ARRAY_DeleteItem(pRow, Index);
      }
      LISTVIEW__UpdateScrollParas(hObj, pObj);
      LISTVIEW__InvalidateInsideArea(hObj, pObj);
    }
    WM_UNLOCK();
  }
}
Example #22
0
/*********************************************************************
*
*       LISTBOX_DecSel
*/
void LISTBOX_DecSel      (LISTBOX_Handle hObj) {
  if (hObj) {
    WM_LOCK();
    _MoveSel(hObj, -1);
    WM_UNLOCK();
  }
}
Example #23
0
EDIT_Handle EDIT_CreateAsChild     (int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags, int MaxLen) {
    EDIT_Handle hObj;
    if (MaxLen == 0) {
        MaxLen = 8;
    }
    /* Alloc memory for obj */
    WM_LOCK();
    hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent,
                                  WM_CF_SHOW | Flags, EDIT__Callback,
                                  sizeof(EDIT_Obj)-sizeof(WM_Obj));
    if (hObj) {
        EDIT_Obj* pObj = (EDIT_Obj*)WM_HMEM2Ptr(hObj);
        /* init widget specific variables */
        WIDGET__Init(&pObj->Widget, WIDGET_STATE_FOCUSSABLE  | WIDGET_STATE_ENABLED);
        pObj->Widget.Id     = Id;
        /* init member variables */
        INIT_ID(pObj);
        pObj->pFont         = _pDefaultFont;
        pObj->aBkColor[0]   = EDIT_BKCOLOR0_DEFAULT;
        pObj->aBkColor[1]   = EDIT_BKCOLOR1_DEFAULT;
        pObj->aTextColor[0] = EDIT_TEXTCOLOR0_DEFAULT;
        pObj->aTextColor[1] = EDIT_TEXTCOLOR1_DEFAULT;
        pObj->Align         = _DefaultAlign;
        pObj->Border        = _DefaultBorder;
        pObj->XSizeCursor   = 1;
        pObj->MaxLen        = MaxLen;
        if ((pObj->hpText = WM_ALLOC(MaxLen+1)) ==0) {
            GUI_DEBUG_ERROROUT("EDIT_Create failed to alloc buffer");
            EDIT_Delete(hObj);
            hObj =0;
        }
    }
    WM_UNLOCK();
    return hObj;
}
Example #24
0
/*********************************************************************
*
*       LISTBOX_CreateEx
*/
LISTBOX_Handle LISTBOX_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
                                int WinFlags, int ExFlags, int Id, const GUI_ConstString* ppText)
{
  LISTBOX_Handle hObj;
  GUI_USE_PARA(ExFlags);
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, _LISTBOX_Callback,
                                sizeof(LISTBOX_Obj) - sizeof(WM_Obj));
  if (hObj) {
    LISTBOX_Obj* pObj;
    WM_LOCK();
    pObj = LISTBOX_H2P(hObj);
     /* Init sub-classes */
    GUI_ARRAY_CREATE(&pObj->ItemArray);
   /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, WIDGET_STATE_FOCUSSABLE);
    pObj->Props = LISTBOX_DefaultProps;
    if (ppText) {
      /* init member variables */
      /* Set non-zero attributes */
      LISTBOX_SetText(hObj, ppText);
    }
    INIT_ID(pObj);
    LISTBOX_UpdateScrollers(hObj);
    WM_UNLOCK();
  }
  return hObj;
}
/*********************************************************************
*
*                Pull window in foreground (top of stack)
*
**********************************************************************
*/
void WM_BringToTop(WM_HWIN hWin) {
  WM_HWIN hPrev, hLast;
  WM_Obj* pWin;
  WM_Obj* pLast;
  if (hWin) {
    WM_LOCK();
    pWin = WM_H2P(hWin);
  /* First of all check if window is already top of stack */
    if (pWin->hNext && pWin->hParent) {
      /* unlink hWin */
      if ((hPrev = WM__GetPrevSibling(hWin)) != 0) {
        WM_Obj* pPrev;
        pPrev = WM_H2P(hPrev);
        pPrev->hNext = pWin->hNext;
      } else {
        WM_Obj* pParent;
        pParent= WM_H2P(pWin->hParent);
        pParent->hFirstChild = pWin->hNext;
      }
      /* Link last sibling */
      hLast = WM__GetLastSibling(hWin);
      pLast = WM_H2P(hLast);
      pLast->hNext = hWin;
      pWin->hNext = 0;
      /* Send message in order to make sure top window will be drawn */
      WM_InvalidateArea(&pWin->Rect);     /* Invalidate new area */
    }
    WM_UNLOCK();
  }
}
/*********************************************************************
*
*       FRAMEWIN_AddMenu
*/
void FRAMEWIN_AddMenu(FRAMEWIN_Handle hObj, WM_HWIN hMenu) {
    if (hObj) {
        FRAMEWIN_Obj* pObj;
        WM_LOCK();
        pObj = FRAMEWIN_H2P(hObj);
        if (pObj) {
            int TitleHeight, BorderSize, IBorderSize = 0;
            int x0, y0, xSize;
            TitleHeight = FRAMEWIN__CalcTitleHeight(pObj);
            BorderSize = pObj->Props.BorderSize;
            if (pObj->Widget.State & FRAMEWIN_SF_TITLEVIS) {
                IBorderSize = pObj->Props.IBorderSize;
            }
            x0     = BorderSize;
            y0     = BorderSize + TitleHeight + IBorderSize;
            xSize  = WM__GetWindowSizeX(&pObj->Widget.Win);
            xSize -= BorderSize * 2;
            pObj->hMenu = hMenu;
            if (pObj->cb) {
                MENU_SetOwner(hMenu, pObj->hClient);
            }
            MENU_Attach(hMenu, hObj, x0, y0, xSize, 0, 0);
            WM_SetAnchor(hMenu, WM_CF_ANCHOR_LEFT | WM_CF_ANCHOR_RIGHT);
            FRAMEWIN__UpdatePositions(pObj);
            FRAMEWIN_Invalidate(hObj);
        }
        WM_UNLOCK();
    }
}
Example #27
0
void EDIT_SetBinMode(EDIT_Handle hEdit, U32 Value, U32 Min, U32 Max) {
  EDIT_Obj* pObj;
  int MaxLen;
  WM_LOCK();
  pObj = EDIT_H2P(hEdit);
  pObj->pfAddKeyEx    = _AddKeyBin;
  pObj->pfUpdateBufer = _UpdateBuffer;
  pObj->CurrentValue = Value;
  pObj->CursorPos = 0;
  MaxLen = pObj->MaxLen;
  if (MaxLen <= 0 ) {
    MaxLen = _GetNumDigits(Max);
  }
  if (MaxLen > 32) {
    MaxLen = 32;
  }
  if (MaxLen != pObj->MaxLen) {
    EDIT_SetMaxLen(hEdit, MaxLen);
  }
  pObj->Min = Min;
  pObj->Max = Max;
  pObj->EditMode = GUI_EDIT_MODE_OVERWRITE;
  _UpdateBuffer(pObj);
  WM_UNLOCK();
}
Example #28
0
/*********************************************************************
*
*       SLIDER_CreateEx
*/
SLIDER_Handle SLIDER_CreateEx(int x0, int y0, int xsize, int ysize, WM_HWIN hParent,
                              int WinFlags, int ExFlags, int Id)
{
  SLIDER_Handle hObj;
  /* Create the window */
  WM_LOCK();
  #if SLIDER_SUPPORT_TRANSPARENCY
    WinFlags |= WM_CF_HASTRANS;
  #endif
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent, WinFlags, SLIDER_Callback, sizeof(SLIDER_Obj) - sizeof(WM_Obj));
  if (hObj) {
    SLIDER_Obj * pObj;
    U16 InitState;
    pObj = (SLIDER_Obj *)GUI_ALLOC_h2p(hObj); /* Don't use use WIDGET_H2P because WIDGET_INIT_ID() has not be called at this point */
    /* Handle SpecialFlags */
    InitState = WIDGET_STATE_FOCUSSABLE;
    if (ExFlags & SLIDER_CF_VERTICAL) {
      InitState |= WIDGET_CF_VERTICAL;
    }
    /* init widget specific variables */
    WIDGET__Init(&pObj->Widget, Id, InitState);
    /* init member variables */
    SLIDER_INIT_ID(pObj);
    pObj->Props = SLIDER__DefaultProps;
    pObj->Width       = 8;
    pObj->Max         = 100;
    pObj->Min         = 0;
    pObj->NumTicks    = -1;
  } else {
    GUI_DEBUG_ERROROUT_IF(hObj==0, "SLIDER_Create failed")
  }
  WM_UNLOCK();
  return hObj;
}
Example #29
0
BUTTON_Handle BUTTON_CreateAsChild (int x0, int y0, int xsize, int ysize, WM_HWIN hParent, int Id, int Flags) {
  BUTTON_Handle hObj;
  /* Create the window */
  WM_LOCK();
  hObj = WM_CreateWindowAsChild(x0, y0, xsize, ysize, hParent,
                       Flags, _BUTTON_Callback,
                       sizeof(BUTTON_Obj)-sizeof(WM_Obj));
  if (hObj) {
    BUTTON_Obj* pObj = BUTTON_H2P(hObj);
    /* init widget specific variables */
    /* init member variables */
    BUTTON_INIT_ID(pObj);
    pObj->Widget.Id     = Id;
    pObj->pFont         = BUTTON_FONT_DEFAULT;
    pObj->aBkColor[0]   = BUTTON_BKCOLOR0_DEFAULT;
    pObj->aBkColor[1]   = BUTTON_BKCOLOR1_DEFAULT;
    pObj->aTextColor[0] = BUTTON_TEXTCOLOR0_DEFAULT;
    pObj->aTextColor[1] = BUTTON_TEXTCOLOR1_DEFAULT;
    pObj->Widget.State  = BUTTON_STATE_INACTIVE;
  } else {
    GUI_DEBUG_ERROROUT_IF(hObj==0, "BUTTON_Create failed")
  }
  WM_UNLOCK();
  return hObj;
}
Example #30
0
/* Invalidate, using desktop coordinates */
void WM_InvalidateBWinAbs(WM_HWIN hWin, const GUI_RECT*pRect) {
  GUI_RECT r = *pRect;
  WM_LOCK();
  GUI_MoveRect(&r, -WM_H2P(hWin)->Rect.x0, -WM_H2P(hWin)->Rect.y0);
  WM_InvalidateRect(hWin, &r);
  WM_UNLOCK();
}