예제 #1
0
파일: KW_widget.c 프로젝트: ckeen/KiWi
void KW_DestroyWidget(KW_Widget * widget, int freechildren) {
  /* Reparent every child of widget to widget->parent */
  if (!freechildren) {
    while (widget->childrencount > 0) {
      KW_ReparentWidget(widget->children[0], widget->parent);
    }
  }
  FreeWidget(widget, freechildren);
}
예제 #2
0
파일: KW_widget.c 프로젝트: ckeen/KiWi
void FreeWidget(KW_Widget * widget, int freechildren) {
  KW_Widget * tofree;
  
  /* recursively delete children */
  if (freechildren) {
    while (widget->childrencount > 0) {
      tofree = widget->children[0];
      Reparent(tofree, NULL);
      FreeWidget(tofree, freechildren);
    }
  }
  
  free(widget->children);
  if (widget->destroy != NULL) {
    widget->destroy(widget);
  }
  free(widget);
}
예제 #3
0
파일: edit.c 프로젝트: navoj/xlisp
/* MakeEditText - make an edit text or rich edit text control */
static xlValue MakeEditText(xlValue obj,int type)
{
    xlValue hscrollp,vscrollp,autohscrollp,autovscrollp;
    xlValue label,multilinep,justify,borderp;
    WidgetPosition pos;
    FrameWidget *parent;
    Widget *widget;
    DWORD style;
    HWND wnd;
    
    /* parse the arguments */
    parent = GetArgFrameWidget();
    xlGetKeyArg(k_label,xlNil,&label);
    xlGetKeyArg(k_hscrollp,xlFalse,&hscrollp);
    xlGetKeyArg(k_vscrollp,xlFalse,&vscrollp);
    xlGetKeyArg(k_autohscrollp,xlFalse,&autohscrollp);
    xlGetKeyArg(k_autovscrollp,xlFalse,&autovscrollp);
    xlGetKeyArg(k_multilinep,xlFalse,&multilinep);
    xlGetKeyArg(k_justify,s_left,&justify);
    xlGetKeyArg(k_borderp,xlTrue,&borderp);
    GetWidgetPosition(&pos);

    /* setup the style */
    style = WS_CHILD | WS_VISIBLE | ES_NOHIDESEL;
    if (type == wtEditText)
        style |= DS_LOCALEDIT;
    if (hscrollp != xlFalse)
        style |= WS_HSCROLL;
    if (vscrollp != xlFalse)
        style |= WS_VSCROLL;
    if (autohscrollp != xlFalse)
        style |= ES_AUTOHSCROLL;
    if (autovscrollp != xlFalse)
        style |= ES_AUTOVSCROLL;
    if (multilinep != xlFalse)
        style |= ES_MULTILINE;
    if (justify == s_left)
        style |= ES_LEFT;
    else if (justify == s_right)
        style |= ES_RIGHT;
    else if (justify == s_center)
        style |= ES_CENTER;
    else
        xlError("expecting 'left, 'right or 'center",justify);
    if (borderp != xlFalse)
        style |= WS_BORDER;

    /* allocate the widget data structure */
    if (!(widget = MakeWidget(parent,type,sizeof(Widget))))
        return xlNil;
    widget->position = pos;

    /* make the button */
    wnd = CreateWindow(type == wtEditText ? "edit" : "RichEdit",
                       xlStringP(label) ? xlGetString(label) : "Edit Text",
                       style,
                       pos.x,               /* horizontal position */
                       pos.y,               /* vertical position */
                       pos.width,           /* width */
                       pos.height,          /* height */
                       GetParentWnd(parent),
                       (HMENU)widget->childID,
                       hInstance,
                       NULL);

    /* make sure the widget was created */
    if ((widget->wnd = wnd) == NULL) {
        FreeWidget(widget);
        return xlNil;
    }

    /* store the widget data structure pointer */
    SetWindowLong(wnd,GWL_USERDATA,(long)widget);

    /* setup to filter messages */
    widget->wndProc = (WNDPROC)SetWindowLong(widget->wnd,GWL_WNDPROC,(LONG)TextFilter);

    /* set the font */
    SendMessage(wnd,WM_SETFONT,(WPARAM)GetStockObject(ANSI_FIXED_FONT),0);
    
    /* return the widget object */
    SetWidget(obj,widget);
    return obj;
}