Esempio n. 1
0
static int winDialogMDICloseChildren(Ihandle* ih)
{
  Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
  if (iupObjectCheck(client))
  {
    HWND hWndChild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);

    /* As long as the MDI client has a child, close it */
    while (hWndChild)
    {
      Ihandle* child = iupwinHandleGet(hWndChild); 
      if (iupObjectCheck(child) && iupAttribGetBoolean(child, "MDICHILD"))
      {
        Icallback cb = IupGetCallback(child, "CLOSE_CB");
        if (cb)
        {
          int ret = cb(child);
          if (ret == IUP_IGNORE)
            return 0;
          if (ret == IUP_CLOSE)
            IupExitLoop();
        }

        IupDestroy(child);
      }

      hWndChild = (HWND)SendMessage(client->handle, WM_MDIGETACTIVE, 0, 0);
    }
  }
  return 1;
}
Esempio n. 2
0
void IupStoreAttribute(Ihandle *ih, const char* name, const char *value)
{
  int inherit;

  if (!name)
    return;

  if (!ih)
  {
    IupStoreGlobal(name, value);
    return;
  }

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (iupAttribIsInternal(name))
    iupAttribStoreStr(ih, name, value);
  else
  {
    if (iupClassObjectSetAttribute(ih, name, value, &inherit)==1) /* store only strings */
      iupAttribStoreStr(ih, name, value);

    if (inherit)
      iAttribNotifyChildren(ih, name, value);
  }
}
Esempio n. 3
0
int IupGetAllAttributes(Ihandle* ih, char** names, int n)
{
  char *name;
  int i = 0;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return 0;

  if (!names || !n)
    return iupTableCount(ih->attrib);

  name = iupTableFirst(ih->attrib);
  while (name)
  {
    names[i] = name;
    i++;
    if (i == n)
      break;

    name = iupTableNext(ih->attrib);
  }

  return i;
}
void IupGLUseFont(Ihandle* ih, int first, int count, int list_base)
{
  HFONT font;
  IGlControlData* gldata;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be an IupGLCanvas */
  if (ih->iclass->nativetype != IUP_TYPECANVAS || 
      !IupClassMatch(ih, "glcanvas"))
    return;

  /* must be mapped */
  gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");
  if (!gldata->window)
    return;

  font = (HFONT)IupGetAttribute(ih, "HFONT");
  if (font)
  {
    HFONT old_font = SelectObject(gldata->device, font);
    wglUseFontBitmaps(gldata->device, first, count, list_base);
    SelectObject(gldata->device, old_font);
  }
}
Esempio n. 5
0
void iupNamesDestroyHandles(void)
{
    char *name;
    Ihandle** ih_array, *ih;
    int count, i = 0;

    count = iupTableCount(inames_strtable);
    if (!count)
        return;

    ih_array = (Ihandle**)malloc(count * sizeof(Ihandle*));

    /* store the names before updating so we can remove elements in the loop */
    name = iupTableFirst(inames_strtable);
    while (name)
    {
        ih = (Ihandle*)iupTableGetCurr(inames_strtable);
        if (iupObjectCheck(ih))
        {
            ih_array[i] = ih;
            i++;
        }
        name = iupTableNext(inames_strtable);
    }

    count = i;
    for (i = 0; i < count; i++)
    {
        if (iupObjectCheck(ih_array[i]))
            IupDestroy(ih_array[i]);
    }

    free(ih_array);
}
Esempio n. 6
0
Ihandle* IupSetHandle(const char *name, Ihandle *ih)
{
  Ihandle *old_ih;

  iupASSERT(name!=NULL);
  if (!name)
    return NULL;

  old_ih = iupTableGet(inames_strtable, name);

  if (ih != NULL)
  {
    iupTableSet(inames_strtable, name, ih, IUPTABLE_POINTER);

    /* save the name in the cache if it is a valid handle */
    if (iupObjectCheck(ih))
      iupAttribStoreStr(ih, "_IUP_LASTHANDLENAME", name);
  }
  else
  {
    iupTableRemove(inames_strtable, name);

    /* clear the name from the cache if it is a valid handle */
    if (iupObjectCheck(old_ih))
      iupAttribSetStr(old_ih, "_IUP_LASTHANDLENAME", NULL);
  }

  return old_ih;
}
void IupGLSwapBuffers(Ihandle* ih)
{
  IGlControlData* gldata;
  Icallback cb;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be an IupGLCanvas */
  if (ih->iclass->nativetype != IUP_TYPECANVAS || 
      !IupClassMatch(ih, "glcanvas"))
    return;

  /* must be mapped */
  gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");
  if (!gldata->window)
    return;

  cb = IupGetCallback(ih, "SWAPBUFFERS_CB");
  if (cb)
    cb(ih);

  SwapBuffers(gldata->device);
}
Esempio n. 8
0
char* IupGetName(Ihandle* ih)
{
    iupASSERT(iupObjectCheck(ih));
    if (!iupObjectCheck(ih))
        return NULL;
    return iupTableGet(inames_ihtable, (char*)ih);
}
Esempio n. 9
0
void IupSetAttributeHandle(Ihandle *ih, const char* name, Ihandle *ih_named)
{
  int inherit;
  char* handle_name;

  iupASSERT(name!=NULL);
  if (!name)
    return;

  handle_name = IupGetName(ih_named);
  if (!handle_name)
  {
    iupAttribSetHandleName(ih_named);
    handle_name = IupGetName(ih_named);
  }

  if (ih)
  {
    iupASSERT(iupObjectCheck(ih));
    if (!iupObjectCheck(ih))
      return;

    iupClassObjectSetAttribute(ih, name, handle_name, &inherit);
    iupAttribStoreStr(ih, name, handle_name);
  }
  else
    IupStoreGlobal(name, handle_name);
}
Esempio n. 10
0
static int iZboxSetValueHandleAttrib(Ihandle* ih, const char* value)
{
  Ihandle* old_handle, *new_handle, *child;

  new_handle = (Ihandle*)value;
  if (!iupObjectCheck(new_handle))
    return 0;

  old_handle = (Ihandle*)iupAttribGetStr(ih, "VALUE_HANDLE");
  if (!iupObjectCheck(old_handle))
    old_handle = NULL;

  for (child = ih->firstchild; child; child = child->brother)
  {
    if (child == new_handle) /* found child */
    {
      if (old_handle && old_handle != new_handle)
        IupSetAttribute(old_handle, "VISIBLE", "NO");

      IupSetAttribute(new_handle, "VISIBLE", "YES");
      return 1;
    }
  }
 
  return 0;
}
Esempio n. 11
0
void IupSetAttribute(Ihandle *ih, const char* name, const char *value)
{
  int inherit;

  iupASSERT(name!=NULL);
  if (!name)
    return;

  if (!ih)
  {
    IupSetGlobal(name, value);
    return;
  }

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (iupAttribIsInternal(name))
    iupAttribSetStr(ih, name, value);
  else
  {
    if (iupClassObjectSetAttribute(ih, name, value, &inherit)!=0) /* store strings and pointers */
      iupAttribSetStr(ih, name, value);

    if (inherit)
      iAttribNotifyChildren(ih, name, value);
  }
}
Esempio n. 12
0
static int iZboxSetValueHandleAttrib(Ihandle* ih, const char* value)
{
  int visible;
  Ihandle* old_handle, *new_handle, *child;

  new_handle = (Ihandle*)value;
  if (!iupObjectCheck(new_handle))
    return 0;

  old_handle = ih->data->value_handle;
  if (!iupObjectCheck(old_handle))
    old_handle = NULL;

  if (old_handle == new_handle)
    return 0;

  visible = IupGetInt(ih, "VISIBLE");

  for (child = ih->firstchild; child; child = child->brother)
  {
    if (child == new_handle) /* found child */
    {
      if (old_handle && old_handle != new_handle)
        IupSetAttribute(old_handle, "VISIBLE", "NO");

      IupSetAttribute(new_handle, "VISIBLE", visible? "YES": "NO");
      ih->data->value_handle = new_handle;
      return 0;
    }
  }
 
  return 0;
}
void IupGLPalette(Ihandle* ih, int index, float r, float g, float b)
{
  IGlControlData* gldata;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be an IupGLCanvas */
  if (ih->iclass->nativetype != IUP_TYPECANVAS || 
      !IupClassMatch(ih, "glcanvas"))
    return;

  /* must be mapped */
  gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");
  if (!gldata->window)
    return;

  /* must have a palette */
  if (gldata->palette)
  {
    PALETTEENTRY entry;
    entry.peRed    = (BYTE)(r*255);
    entry.peGreen  = (BYTE)(g*255);
    entry.peBlue   = (BYTE)(b*255);
    entry.peFlags  = PC_NOCOLLAPSE;
    SetPaletteEntries(gldata->palette,index,1,&entry);
    UnrealizeObject(gldata->device);
    SelectPalette(gldata->device,gldata->palette,FALSE);
    RealizePalette(gldata->device);
  }
}
Esempio n. 14
0
Ihandle* IupGetDialogChild(Ihandle* ih, const char* name)
{
  Ihandle *child, *dialog;
  char attrib[1024] = "_IUP_DIALOG_CHILD_";

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  if (!name)
    return NULL;

  dialog = IupGetDialog(ih);
  if (dialog) ih = dialog;
 
  strcat(attrib, name);
  child = (Ihandle*)iupAttribGetStr(ih, attrib);
  if (child) return child;

  if (ih->firstchild)
  {
    child = iBaseFindChild(ih, name);
    if (child) return child;
  }
  return NULL;
}
void IupGLMakeCurrent(Ihandle* ih)
{
  IGlControlData* gldata;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be an IupGLCanvas */
  if (ih->iclass->nativetype != IUP_TYPECANVAS || 
      !IupClassMatch(ih, "glcanvas"))
    return;

  /* must be mapped */
  gldata = (IGlControlData*)iupAttribGet(ih, "_IUP_GLCONTROLDATA");
  if (!gldata->window)
    return;

  if (wglMakeCurrent(gldata->device, gldata->context)==FALSE)
  {
    iupAttribSet(ih, "ERROR", "Failed to set new current context.");
    iupAttribSetStr(ih, "LASTERROR", IupGetGlobal("LASTERROR"));
  }
  else
  {
    iupAttribSet(ih, "ERROR", NULL);
    iupAttribSet(ih, "LASTERROR", NULL);
  }
}
Esempio n. 16
0
void IupGLPalette(Ihandle* ih, int index, float r, float g, float b)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be a IupGLCanvas */
  if (!iupStrEqual(ih->iclass->name, "glcanvas"))
    return;

  /* must be mapped */
  if (!ih->handle)
    return;

  /* must have a palette */
  if (ih->data->palette)
  {
    PALETTEENTRY entry;
    entry.peRed    = (BYTE)(r*255);
    entry.peGreen  = (BYTE)(g*255);
    entry.peBlue   = (BYTE)(b*255);
    entry.peFlags  = PC_NOCOLLAPSE;
    SetPaletteEntries(ih->data->palette,index,1,&entry);
    UnrealizeObject(ih->data->device);
    SelectPalette(ih->data->device,ih->data->palette,FALSE);
    RealizePalette(ih->data->device);
  }
}
Esempio n. 17
0
int IupTreeGetId(Ihandle* ih, void *userdata)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return -1;

  return iTreeFindUserDataId(ih, userdata);
}
Esempio n. 18
0
int IupClassMatch(Ihandle* ih, const char* classname)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return 0;

  return iupClassMatch(ih->iclass, classname);
}
Esempio n. 19
0
char* IupGetClassName(Ihandle *ih)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  return (char*)ih->iclass->name;
}
Esempio n. 20
0
void IupUpdateChildren(Ihandle* ih)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  iLayoutDisplayUpdateChildren(ih);
}
Esempio n. 21
0
void IupUpdate(Ihandle* ih)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (ih->handle && ih->iclass->nativetype != IUP_TYPEVOID)
    iupdrvPostRedraw(ih);
}
Esempio n. 22
0
char* IupGetClassType(Ihandle *ih)
{
  static char* type2str[] = {"void", "control", "canvas", "dialog", "image", "menu"};
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  return type2str[ih->iclass->nativetype];
}
Esempio n. 23
0
Ihandle* IupSetAttributes(Ihandle *ih, const char* str)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return ih;
  if (str)
    iAttribParse(ih, str);
  return ih;
}
Esempio n. 24
0
void* IupTreeGetUserId(Ihandle* ih, int id)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return NULL;

  if (id >= 0 && id < ih->data->node_count)
    return ih->data->node_cache[id].userdata;

  return NULL;
}
Esempio n. 25
0
void IupRedraw(Ihandle* ih, int children)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (ih->handle && ih->iclass->nativetype != IUP_TYPEVOID)
    iupdrvRedrawNow(ih);

  if (children)
    iLayoutDisplayRedrawChildren(ih);
}
Esempio n. 26
0
Ihandle *IupSetFocus(Ihandle *ih)
{
  Ihandle* old_focus = iup_current_focus;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return old_focus;

  if (iupFocusCanAccept(ih))  
    iupdrvSetFocus(ih);

  return old_focus;
}
Esempio n. 27
0
void IupRefreshChildren(Ihandle* ih)
{
  int shrink;
  Ihandle *dialog, *child;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* must be mapped */
  if (!ih->handle)
    return;

  /* must have children */
  if (!ih->firstchild)
    return;

  /* must be inside a dialog */
  /* it can not be a dialog */
  dialog = IupGetDialog(ih);
  if (!dialog || dialog==ih)
    return;

  /****** local iupLayoutCompute,
     but ih will not be changed, only its children. */

  shrink = iupAttribGetBoolean(dialog, "SHRINK");

  /* children only iupBaseComputeNaturalSize */
  {
    int w=0, h=0, children_expand=ih->expand;
    iupClassObjectComputeNaturalSize(ih, &w, &h, &children_expand);

    /* If the container natural size changed from inside, simply ignore the change */
  }

  /* children only iupBaseSetCurrentSize */
  iupClassObjectSetChildrenCurrentSize(ih, shrink);

  /* children only iupBaseSetPosition */
  iupClassObjectSetChildrenPosition(ih, ih->x, ih->y);


  /****** local iupLayoutUpdate,
     but ih will not be changed, only its children. */
  for (child = ih->firstchild; child; child = child->brother)
  {
    if (child->handle)
      iupLayoutUpdate(child);
  }
}
Esempio n. 28
0
void IupListConvertXYToItem(Ihandle* ih, int x, int y, int *pos)
{
  *pos = 0;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  if (!ih->handle)
    return;
    
  if (iupStrEqual(ih->iclass->name, "list"))
    iupdrvListConvertXYToItem(ih, x, y, pos);
}
Esempio n. 29
0
int IupTreeSetUserId(Ihandle* ih, int id, void* userdata)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return 0;

  if (id >= 0 && id < ih->data->node_count)
  {
    ih->data->node_cache[id].userdata = userdata;
    return 1;
  }

  return 0;
}
Esempio n. 30
0
void IupResetAttribute(Ihandle *ih, const char* name)
{
  iupASSERT(name!=NULL);
  if (!name)
    return;

  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  iupAttribSetStr(ih, name, NULL);

  if (iAttribIsInherit(ih, name))
    iAttribResetChildren(ih, name);
}