Ejemplo n.º 1
0
static void motMessageDlgOkCb(Widget w,
                             void* client_data,
                             XmAnyCallbackStruct* call_data)
{
  Ihandle* h = (Ihandle*)client_data;
  IupHide(h);
}
Ejemplo n.º 2
0
static int iDialogSetVisibleAttrib(Ihandle* ih, const char* value)
{
  if (iupStrBoolean(value))
    IupShow(ih);
  else
    IupHide(ih);
  return 0;
}
Ejemplo n.º 3
0
static int cancel_cb(Ihandle* ih)
{
  int ret = IupAlarm("Warning!", "Interrupt Processing?", "Yes", "No", NULL);
  if (ret == 1) /* Yes Interrupt */
  {
    IupSetAttribute(ih, "SIMULATEMODAL", "No");
    IupHide(ih);
    return IUP_DEFAULT;
  }

  return IUP_CONTINUE;
}
Ejemplo n.º 4
0
static void counter_stop(void)
{
  // force one last update
  IupSetInt(counter_dlg, "COUNT", IupGetInt(counter_dlg, "TOTALCOUNT"));

  IupSetAttribute(counter_dlg, "SIMULATEMODAL", "No");

  IupHide(counter_dlg);

//  Ihandle* main_window = IupGetHandle("MainWindow");
//  IupSetAttribute(main_window, "TASKBARPROGRESSVALUE", "100");
//  IupSetAttribute(main_window, "TASKBARPROGRESSSTATE", "NOPROGRESS");

  printf("Stop\n");
}
Ejemplo n.º 5
0
int iupDialogPopup(Ihandle* ih, int x, int y)
{
  int ret = iupClassObjectDlgPopup(ih, x, y);
  if (ret != IUP_INVALID) /* IUP_INVALID means it is not implemented */
    return ret;

  ih->data->show_state = IUP_SHOW;

  /* Update only the position */
  iupDialogAdjustPos(ih, &x, &y);
  iupdrvDialogSetPosition(ih, x, y);

  if (iupdrvDialogIsVisible(ih)) /* already visible */
  {
    /* only re-show to raise the window */
    iupdrvDialogSetVisible(ih, 1);
    
    iDialogCallShowCb(ih);
    return IUP_NOERROR; 
  }

  if (iupAttribGetInt(ih, "MODAL")) /* already a popup */
    return IUP_NOERROR; 

  iDialogSetModal(ih);

  /* actually show the window */
  iupdrvDialogSetVisible(ih, 1);

  /* increment visible count */
  iupDlgListVisibleInc();
    
  iDialogCallShowCb(ih);

  /* interrupt processing here */
  IupMainLoop();

  /* if window is still valid (IupDestroy not called), 
     hide the dialog if still visible. */
  if (iupObjectCheck(ih))
  {
    iDialogUnSetModal(ih);

    IupHide(ih); 
  }

  return IUP_NOERROR;
}
Ejemplo n.º 6
0
static int winPopupDialog(Ihandle* n, int x, int y)
{
  HWND last_hwnd;
  HWND popup_hwnd;

  Ihandle* parent = IupGetAttributeHandle(n, IUP_PARENTDIALOG);
  if (parent && handle(parent))
    last_hwnd = handle(parent);
  else
    last_hwnd = GetActiveWindow();

  winShowXY(n, x, y);

  if (iupGetEnv(n, "_IUPWIN_POPUP"))
    return IUP_ERROR;

  popup_hwnd = (HWND)handle(n);

  /* disable all visible dialogs, and mark popup level */
  /* will be enable by IupHide */
  winDisableVisible(n);

  iupSetEnv(n, "_IUPWIN_POPUP", "1");  /* mark window as popup so IupHide can also detect it */

  /* interrupt processing here */
  IupMainLoop();

  /* if window is still valid (IupDestroy not called) */
  if (IsWindow(popup_hwnd))
  {
    iupSetEnv(n, "_IUPWIN_POPUP", "2"); 
    IupHide(n); /* hide the popup to update the disabled windows */
                /* but do not call IupExitLoop again */

    iupSetEnv(n, "_IUPWIN_POPUP", NULL); /* unmark the window */
  }

  /* activate the previous active window */
  if (last_hwnd) 
    SetActiveWindow(last_hwnd);

  return IUP_NOERROR;
}
Ejemplo n.º 7
0
static int iDetachBoxSetDetachAttrib(Ihandle* ih, const char* value)
{
  IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");

  /* Create new dialog */
  Ihandle *new_parent = IupDialog(NULL);
  Ihandle *old_dialog = IupGetDialog(ih);

  /* Set new dialog as child of the current application */
  IupSetAttributeHandle(new_parent, "PARENTDIALOG", old_dialog);

  if (detachedCB)
    detachedCB(ih, new_parent, 0, 0);

  /* Save current parent and reference child */
  ih->data->old_parent = ih->parent;
  ih->data->old_brother = ih->brother;

  IupMap(new_parent);

  /* Sets the new parent */
  IupReparent(ih, new_parent, NULL);

  /* Hide canvas bar */
  ih->data->barsize = 0;
  IupHide(ih->firstchild);

  /* Restores the cursor */
  IupSetAttribute(ih->firstchild, "CURSOR", "MOVE");

  /* Updates/redraws the layout of the dialog application */
  IupRefresh(old_dialog);

  IupSetAttribute(new_parent, "RASTERSIZE", NULL);
  IupRefresh(new_parent);

  /* Maps and shows the new dialog */
  IupShow(new_parent);

  (void)value;
  return 0;
}
Ejemplo n.º 8
0
void IupDestroy(Ihandle *ih)
{
  Icallback cb;

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

  /* Hide before destroy to avoid children redraw */
  if (ih->iclass->nativetype == IUP_TYPEDIALOG)
    IupHide(ih);

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

  cb = IupGetCallback(ih, "LDESTROY_CB");  /* for language bindings */
  if (cb) cb(ih);

  /* Destroy all its children.
     Just need to remove the first child,
     IupDetach will update firstchild. */
  while (ih->firstchild)
    IupDestroy(ih->firstchild);

  /* unmap if mapped and remove from its parent child list */
  IupDetach(ih);

  /* removes names associated with the element */
  iupRemoveNames(ih);

  /* destroy the element */
  iupClassObjectDestroy(ih);

  /* destroy the private data */
  if (ih->data)
    free(ih->data);

  /* destroy the base handle structure */
  iHandleDestroy(ih);
}
Ejemplo n.º 9
0
gboolean iupgtkDialogDeleteEvent(GtkWidget *widget, GdkEvent *evt, Ihandle *ih)
{
  Icallback cb;
  (void)widget;
  (void)evt;

  /* even when ACTIVE=NO the dialog gets this evt */
  if (!iupdrvIsActive(ih))
    return TRUE;

  cb = IupGetCallback(ih, "CLOSE_CB");
  if (cb)
  {
    int ret = cb(ih);
    if (ret == IUP_IGNORE)
      return TRUE;
    if (ret == IUP_CLOSE)
      IupExitLoop();
  }

  IupHide(ih); /* default: close the window */

  return TRUE; /* do not propagate */
}
Ejemplo n.º 10
0
static void motDialogCBclose(Widget w, XtPointer client_data, XtPointer call_data)
{
  Icallback cb;
  Ihandle *ih = (Ihandle*)client_data;
  if (!ih) return;
  (void)call_data;
  (void)w;

  /* even when ACTIVE=NO the dialog gets this event */
  if (!iupdrvIsActive(ih))
    return;

  cb = IupGetCallback(ih, "CLOSE_CB");
  if (cb)
  {
    int ret = cb(ih);
    if (ret == IUP_IGNORE)
      return;
    if (ret == IUP_CLOSE)
      IupExitLoop();
  }

  IupHide(ih); /* default: close the window */
}
Ejemplo n.º 11
0
void IupDestroy(Ihandle *ih)
{
  iupASSERT(iupObjectCheck(ih));
  if (!iupObjectCheck(ih))
    return;

  /* Hide before destroy to avoid children redraw */
  if (ih->iclass->nativetype == IUP_TYPEDIALOG)
    IupHide(ih);

  /* Destroy all its children.
     Just need to remove the first child,
     IupDetach will update firstchild. */
  while (ih->firstchild)
    IupDestroy(ih->firstchild);

  /* unmap if mapped and remove from its parent child list */
  IupDetach(ih);

  /* destroy the element */
  iupClassObjectDestroy(ih);

  /* destroy the private data */
  if (ih->data)
    free(ih->data);

  { 
    /* removes all the names associated with the element */
    char *name;
    while ((name=IupGetName(ih)) != NULL)
      IupSetHandle(name, NULL);
  }

  /* destroy the base handle structure */
  iHandleDestroy(ih);
}
Ejemplo n.º 12
0
int  guiMenu_OnValueChanged ( Ihandle *ih )
{
  Ihandle *kid = IupGetChild ( ih, 0 ), *fset[] =
  {
#ifndef EMULATOR
    guiOrg.main.fset,
    guiPfm.main.fset,
    guiTar.main.fset,
#endif
    guiPro.main.fset,
    guiQry.main.fset,
    guiRes.main.fset,
    NULL,
    guiHacks.main.fset,
    guiHack.main.fset,
    guiCodes->main.fset,
    guiCode->main.fset,
    NULL
  };
  Icallback cb[] =
  {
#ifndef EMULATOR
    guiOrg_OnShow,
    guiPfm_OnShow,
    guiTar_OnShow,
#endif
    guiPro_OnShow,
    guiQry_OnShow,
    guiRes_OnShow,
    NULL,
    guiHacks_OnShow,
    guiHack_OnShow,
    guiCodes_OnShow,
    guiCode_OnShow,
    NULL
  };
  //char  *title = IupGetAttribute ( kid, IUP_TITLE );
  int i = 1, c = IupGetChildCount ( guiDlg.vb );

  // Hide all groups first
  for ( ; i < c; ++i )
  {
    kid = IupGetChild ( guiDlg.vb, i );
    IupSetAttribute ( kid, "FLOATING", IUP_YES );
    IupHide ( kid );
  }

  for ( i = 0, c = IupGetChildCount ( guiOrg.main.vb ); i < c; ++i )
  {
    kid = IupGetChild ( guiOrg.main.vb, i );
    IupSetAttribute ( kid, "FLOATING", IUP_YES );
    IupHide ( kid );
  }

  // Find and show appropriate group
  i = IupGetInt ( ih, IUP_VALUE );
  IupSetInt( ih, "MEDIT_I", i );

  if ( ( --i ) >= 0 && fset[i] && cb[i] )
  {
    IupShow ( fset[i] );
    cb[i] ( fset[i] );
  }

  guiMenu_OnLang();
  // Force Update GUI
  IupRefresh ( guiDlg.vb );
  IupRedraw ( guiDlg.vb, 1 );
  IupFlush();
  return IUP_DEFAULT;
}
Ejemplo n.º 13
0
static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
  if (iupwinBaseContainerProc(ih, msg, wp, lp, result))
    return 1;

  iupwinMenuDialogProc(ih, msg, wp, lp);

  switch (msg)
  {
  case WM_GETDLGCODE:
    *result = DLGC_WANTALLKEYS;
    return 1;
  case WM_GETMINMAXINFO:
    {
      if (winDialogCheckMinMaxInfo(ih, (MINMAXINFO*)lp))
      {
        *result = 0;
        return 1;
      }
      break;
    }
  case WM_SIZE:
    {
      if (ih->data->ignore_resize)
        break;

      switch(wp)
      {
      case SIZE_MINIMIZED:
        {
          if (ih->data->show_state != IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_MINIMIZE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_MINIMIZE;
          }
          break;
        }
      case SIZE_MAXIMIZED:
        {
          if (ih->data->show_state != IUP_MAXIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_MAXIMIZE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_MAXIMIZE;
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));
          break;
        }
      case SIZE_RESTORED:
        {
          if (ih->data->show_state == IUP_MAXIMIZE || ih->data->show_state == IUP_MINIMIZE)
          {
            IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
            if (show_cb && show_cb(ih, IUP_RESTORE) == IUP_CLOSE)
              IupExitLoop();
            ih->data->show_state = IUP_RESTORE;
          }

          winDialogResize(ih, LOWORD(lp), HIWORD(lp));
          break;
        }
      }

      break;
    }
  case WM_USER+IWIN_TRAY_NOTIFICATION:
    {
      int dclick  = 0;
      int button  = 0;
      int pressed = 0;

      switch (lp)
      {
      case WM_LBUTTONDOWN:
        pressed = 1;
        button  = 1;
        break;
      case WM_MBUTTONDOWN:
        pressed = 1;
        button  = 2;
        break;
      case WM_RBUTTONDOWN:
        pressed = 1;
        button  = 3;
        break;
      case WM_LBUTTONDBLCLK:
        dclick = 1;
        button = 1;
        break;
      case WM_MBUTTONDBLCLK:
        dclick = 1;
        button = 2;
        break;
      case WM_RBUTTONDBLCLK:
        dclick = 1;
        button = 3;
        break;
      case WM_LBUTTONUP:
        button = 1;
        break;
      case WM_MBUTTONUP:
        button = 2;
        break;
      case WM_RBUTTONUP:
        button = 3;
        break;
      }

      if (button != 0)
      {
        IFniii cb = (IFniii)IupGetCallback(ih, "TRAYCLICK_CB");
        if (cb && cb(ih, button, pressed, dclick) == IUP_CLOSE)
          IupExitLoop();
      }

      break;
    }
  case WM_CLOSE:
    {
      Icallback cb = IupGetCallback(ih, "CLOSE_CB");
      if (cb)
      {
        int ret = cb(ih);
        if (ret == IUP_IGNORE)
        {
          *result = 0;
          return 1;
        }
        if (ret == IUP_CLOSE)
          IupExitLoop();
      }

      /* child mdi is automatically destroyed */
      if (iupAttribGetInt(ih, "MDICHILD"))
        IupDestroy(ih);
      else
      {
        if (!winDialogMDICloseChildren(ih))
        {
          *result = 0;
          return 1;
        }

        IupHide(ih); /* IUP default processing */
      }

      *result = 0;
      return 1;
    }
  case WM_SETCURSOR: 
    { 
      if (ih->handle == (HWND)wp && LOWORD(lp)==HTCLIENT)
      {
        HCURSOR hCur = (HCURSOR)iupAttribGet(ih, "_IUPWIN_HCURSOR");
        if (hCur)
        {
          SetCursor(hCur); 
          *result = 1;
          return 1;
        }
        else if (iupAttribGet(ih, "CURSOR"))
        {
          SetCursor(NULL); 
          *result = 1;
          return 1;
        }
      }
      break; 
    } 
  case WM_ERASEBKGND:
    {
      HBITMAP hBitmap = (HBITMAP)iupAttribGet(ih, "_IUPWIN_BACKGROUND_BITMAP");
      if (hBitmap) 
      {
        RECT rect;
        HDC hdc = (HDC)wp;

        HBRUSH hBrush = CreatePatternBrush(hBitmap);
        GetClientRect(ih->handle, &rect); 
        FillRect(hdc, &rect, hBrush); 
        DeleteObject(hBrush);

        /* return non zero value */
        *result = 1;
        return 1; 
      }
      else
      {
        unsigned char r, g, b;
        char* color = iupAttribGet(ih, "_IUPWIN_BACKGROUND_COLOR");
        if (iupStrToRGB(color, &r, &g, &b))
        {
          RECT rect;
          HDC hdc = (HDC)wp;

          SetDCBrushColor(hdc, RGB(r,g,b));
          GetClientRect(ih->handle, &rect); 
          FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH)); 

          /* return non zero value */
          *result = 1;
          return 1;
        }
      }
      break;
    }
  case WM_DESTROY:
    {
      /* Since WM_CLOSE changed the Windows default processing                            */
      /* WM_DESTROY is NOT received by IupDialogs                                         */
      /* Except when they are children of other IupDialogs and the parent is destroyed.   */
      /* So we have to destroy the child dialog.                                          */
      /* The application is responsable for destroying the children before this happen.   */
      IupDestroy(ih);
      break;
    }
  }

  if (msg == (UINT)WM_HELPMSG)
  {
    Ihandle* child = NULL;
    DWORD* struct_ptr = (DWORD*)lp;
    if (*struct_ptr == sizeof(CHOOSECOLOR))
    {
      CHOOSECOLOR* choosecolor = (CHOOSECOLOR*)lp;
      child = (Ihandle*)choosecolor->lCustData;
    }
    if (*struct_ptr == sizeof(CHOOSEFONT))
    {
      CHOOSEFONT* choosefont = (CHOOSEFONT*)lp;
      child = (Ihandle*)choosefont->lCustData;
    }

    if (child)
    {
      Icallback cb = IupGetCallback(child, "HELP_CB");
      if (cb && cb(child) == IUP_CLOSE)
        EndDialog((HWND)iupAttribGet(child, "HWND"), IDCANCEL);
    }
  }

  return 0;
}
Ejemplo n.º 14
0
static int winDialogBaseProc(Ihandle* ih, UINT msg, WPARAM wp, LPARAM lp, LRESULT *result)
{
    if (iupwinBaseContainerProc(ih, msg, wp, lp, result))
        return 1;

    iupwinMenuDialogProc(ih, msg, wp, lp);

    switch (msg)
    {
    case WM_GETMINMAXINFO:
    {
        if (winDialogCheckMinMaxInfo(ih, (MINMAXINFO*)lp))
        {
            *result = 0;
            return 1;
        }
        break;
    }
    case WM_MOVE:
    {
        IFnii cb = (IFnii)IupGetCallback(ih, "MOVE_CB");
        int x, y;
        /* ignore LPARAM because they are the clientpos */
        iupdrvDialogGetPosition(ih, NULL, &x, &y);
        if (cb) cb(ih, x, y);
        break;
    }
    case WM_SIZE:
    {
        if (ih->data->ignore_resize)
            break;

        switch(wp)
        {
        case SIZE_MINIMIZED:
        {
            if (ih->data->show_state != IUP_MINIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_MINIMIZE;
                if (show_cb && show_cb(ih, IUP_MINIMIZE) == IUP_CLOSE)
                    IupExitLoop();
            }
            break;
        }
        case SIZE_MAXIMIZED:
        {
            if (ih->data->show_state != IUP_MAXIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_MAXIMIZE;
                if (show_cb && show_cb(ih, IUP_MAXIMIZE) == IUP_CLOSE)
                    IupExitLoop();
            }

            winDialogResize(ih, LOWORD(lp), HIWORD(lp));

            if (iupAttribGetBoolean(ih, "MDICHILD"))
            {
                /* WORKAROUND: when a child MDI dialog is maximized,
                   its title is displayed inside the MDI client area.
                   So we force a MDI client size update */
                RECT rect;
                Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
                GetClientRect(client->handle, &rect);
                PostMessage(client->handle, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(rect.right-rect.left, rect.bottom-rect.top));
            }
            break;
        }
        case SIZE_RESTORED:
        {
            if (ih->data->show_state == IUP_MAXIMIZE || ih->data->show_state == IUP_MINIMIZE)
            {
                IFni show_cb = (IFni)IupGetCallback(ih, "SHOW_CB");
                ih->data->show_state = IUP_RESTORE;
                if (show_cb && show_cb(ih, IUP_RESTORE) == IUP_CLOSE)
                    IupExitLoop();
            }

            winDialogResize(ih, LOWORD(lp), HIWORD(lp));
            break;
        }
        }

        if (iupAttribGetBoolean(ih, "MDIFRAME"))
        {
            /* We are going to manually position the MDI client,
               so abort MDI frame processing. */
            *result = 0;
            return 1;
        }
        else
            break;
    }
    case WM_USER+IUPWIN_TRAY_NOTIFICATION:
    {
        int dclick  = 0;
        int button  = 0;
        int pressed = 0;

        switch (lp)
        {
        case WM_LBUTTONDOWN:
            pressed = 1;
            button  = 1;
            break;
        case WM_MBUTTONDOWN:
            pressed = 1;
            button  = 2;
            break;
        case WM_RBUTTONDOWN:
            pressed = 1;
            button  = 3;
            break;
        case WM_LBUTTONDBLCLK:
            dclick = 1;
            button = 1;
            break;
        case WM_MBUTTONDBLCLK:
            dclick = 1;
            button = 2;
            break;
        case WM_RBUTTONDBLCLK:
            dclick = 1;
            button = 3;
            break;
        case WM_LBUTTONUP:
            button = 1;
            break;
        case WM_MBUTTONUP:
            button = 2;
            break;
        case WM_RBUTTONUP:
            button = 3;
            break;
        }

        if (button != 0)
        {
            IFniii cb = (IFniii)IupGetCallback(ih, "TRAYCLICK_CB");
            if (cb && cb(ih, button, pressed, dclick) == IUP_CLOSE)
                IupExitLoop();
        }

        break;
    }
    case WM_CLOSE:
    {
        Icallback cb = IupGetCallback(ih, "CLOSE_CB");
        if (cb)
        {
            int ret = cb(ih);
            if (ret == IUP_IGNORE)
            {
                *result = 0;
                return 1;
            }
            if (ret == IUP_CLOSE)
                IupExitLoop();
        }

        /* child mdi is automatically destroyed */
        if (iupAttribGetBoolean(ih, "MDICHILD"))
            IupDestroy(ih);
        else
        {
            if (!winDialogMDICloseChildren(ih))
            {
                *result = 0;
                return 1;
            }

            IupHide(ih); /* IUP default processing */
        }

        *result = 0;
        return 1;
    }
    case WM_COPYDATA:  /* usually from SetGlobal("SINGLEINSTANCE") */
    {
        COPYDATASTRUCT* cds = (COPYDATASTRUCT*)lp;
        IFnsi cb = (IFnsi)IupGetCallback(ih, "COPYDATA_CB");
        if (cb) cb(ih, cds->lpData, cds->cbData);
        break;
    }
    case WM_SETCURSOR:
    {
        if (ih->handle == (HWND)wp && LOWORD(lp)==HTCLIENT)
        {
            HCURSOR hCur = (HCURSOR)iupAttribGet(ih, "_IUPWIN_HCURSOR");
            if (hCur)
            {
                SetCursor(hCur);
                *result = 1;
                return 1;
            }
            else if (iupAttribGet(ih, "CURSOR"))
            {
                SetCursor(NULL);
                *result = 1;
                return 1;
            }
        }
        break;
    }
    case WM_ERASEBKGND:
    {
        HBITMAP hBitmap = (HBITMAP)iupAttribGet(ih, "_IUPWIN_BACKGROUND_BITMAP");
        if (hBitmap)
        {
            RECT rect;
            HDC hdc = (HDC)wp;

            HBRUSH hBrush = CreatePatternBrush(hBitmap);
            GetClientRect(ih->handle, &rect);
            FillRect(hdc, &rect, hBrush);
            DeleteObject(hBrush);

            /* return non zero value */
            *result = 1;
            return 1;
        }
        else
        {
            unsigned char r, g, b;
            char* color = iupAttribGet(ih, "_IUPWIN_BACKGROUND_COLOR");
            if (iupStrToRGB(color, &r, &g, &b))
            {
                RECT rect;
                HDC hdc = (HDC)wp;

                SetDCBrushColor(hdc, RGB(r,g,b));
                GetClientRect(ih->handle, &rect);
                FillRect(hdc, &rect, (HBRUSH)GetStockObject(DC_BRUSH));

                /* return non zero value */
                *result = 1;
                return 1;
            }
        }
        break;
    }
    case WM_DESTROY:
    {
        /* Since WM_CLOSE changed the Windows default processing                            */
        /* WM_DESTROY is NOT received by IupDialogs                                         */
        /* Except when they are children of other IupDialogs and the parent is destroyed.   */
        /* So we have to destroy the child dialog.                                          */
        /* The application is responsable for destroying the children before this happen.   */
        IupDestroy(ih);
        break;
    }
    }

    if (msg == (UINT)WM_HELPMSG)
    {
        Ihandle* child = NULL;
        DWORD* struct_ptr = (DWORD*)lp;
        if (*struct_ptr == sizeof(CHOOSECOLOR))
        {
            CHOOSECOLOR* choosecolor = (CHOOSECOLOR*)lp;
            child = (Ihandle*)choosecolor->lCustData;
        }
        if (*struct_ptr == sizeof(CHOOSEFONT))
        {
            CHOOSEFONT* choosefont = (CHOOSEFONT*)lp;
            child = (Ihandle*)choosefont->lCustData;
        }

        if (child)
        {
            Icallback cb = IupGetCallback(child, "HELP_CB");
            if (cb && cb(child) == IUP_CLOSE)
                EndDialog((HWND)iupAttribGet(child, "HWND"), IDCANCEL);
        }
    }

    return 0;
}
Ejemplo n.º 15
0
int find_close_action_cb(Ihandle* bt_close)
{
  IupHide(IupGetDialog(bt_close));
  return IUP_DEFAULT;
}
Ejemplo n.º 16
0
static int iDetachBoxButton_CB(Ihandle* bar, int button, int pressed, int x, int y, char* status)
{
  Ihandle* ih = bar->parent;
  Ihandle* mainDlg = IupGetDialog(ih);

  if (button != IUP_BUTTON1)
    return IUP_DEFAULT;

  if (!ih->data->is_holding && pressed)  /* DRAG BEGIN */
  {
    ih->data->is_holding = 1;
    
    /* Change cursor */
    IupSetAttribute(bar, "CURSOR", "IupDetachBoxCursor");
  }
  else if (ih->data->is_holding && !pressed)  /* DRAG END */
  {
    Ihandle *new_parent;
    IFnnii detachedCB = (IFnnii)IupGetCallback(ih, "DETACHED_CB");
    int cur_x, cur_y;

    ih->data->is_holding = 0;

    iupStrToIntInt(IupGetGlobal("CURSORPOS"), &cur_x, &cur_y, 'x');

    /* Create new dialog */
    new_parent = IupDialog(NULL);

    /* Set new dialog as child of the current application */
    IupSetAttributeHandle(new_parent, "PARENTDIALOG", mainDlg);

    if (detachedCB)
    {
      int ret = detachedCB(ih, new_parent, cur_x, cur_y);
      if (ret == IUP_IGNORE)
      {
        IupDestroy(new_parent);
        return IUP_DEFAULT;
      }
    }

    /* Save current parent and reference child */
    ih->data->old_parent = ih->parent;
    ih->data->old_brother = ih->brother;

    IupMap(new_parent);

    /* Sets the new parent */
    IupReparent(ih, new_parent, NULL);

    /* Restores the cursor */
    IupSetAttribute(bar, "CURSOR", "MOVE");

    /* Hide canvas bar */
    ih->data->barsize = 0;
    IupHide(bar);

    /* Updates/redraws the layout of the dialog application */
    IupRefresh(mainDlg);

    IupSetAttribute(new_parent, "RASTERSIZE", NULL);
    IupRefresh(new_parent);

    /* Maps and shows the new dialog */
    IupShowXY(new_parent, cur_x, cur_y);
  }

  (void)x;
  (void)y;
  (void)status;
  return IUP_DEFAULT;
}
// -------------------------------------------------------------------------------------------------
// -------------------------------------------------------------------------------------------------
void cCanvasDetailHandler::close_detail_windows(void)
{
    for(int i = 0; i < (int) m_vec_dialog.size(); i++)
        IupHide(m_vec_dialog[i]);
}
Ejemplo n.º 18
0
static int Hide(lua_State *L)
{
  Ihandle *ih = iuplua_checkihandle(L,1);
  lua_pushinteger(L, IupHide(ih));
  return 1;
}
Ejemplo n.º 19
0
static int k_any(Ihandle *ih, int c)
{
  if (iup_isprint(c))
    printf("K_ANY(%s, %d = %s \'%c\')", IupGetAttribute(ih, "TESTTITLE"), c, iupKeyCodeToName(c), (char)c);
  else
    printf("K_ANY(%s, %d = %s)", IupGetAttribute(ih, "TESTTITLE"), c, iupKeyCodeToName(c));
  printf("  MODKEYSTATE(%s)\n", IupGetGlobal("MODKEYSTATE"));

  switch(c)
  {
  case K_r:
    IupSetAttribute(ih, "RASTERSIZE", "300x300");
    IupRefresh(ih);
    break;
  case K_1:
    new_dialog(1, "SIZE=FULLxFULL + IupShow.\n"
                  "Check also F1 = RASTERSIZE+IupRefresh.\n"
                  "close_cb returns IGNORE.");
    break;
  case K_2:
    new_dialog(2, "Only common dlg decorations.\n"
                  "ShowXY.\n"
                  "min/max size.");
    break;
  case K_3:
    new_dialog(3, "NO decorations");
    break;
  case K_4:
    new_dialog(4, "PLACEMENT.\n"
                  "Repeat key to test variations.");
    break;
  case K_5:
    new_dialog(5, "IupPopup");
    break;
  case K_6:
    new_dialog(6, "FULLSCREEN");
    break;
  case K_p:
    {
      static int count = 0;
      if (count == 0)
        IupSetAttribute(ih, "PLACEMENT", "MAXIMIZED");
      else if (count == 1)
        IupSetAttribute(ih, "PLACEMENT", "MINIMIZED");
      else if (count == 2)
        IupSetAttribute(ih, "PLACEMENT", "NORMAL");
      else 
        IupSetAttribute(ih, "PLACEMENT", "FULL");

      count++;
      if (count == 4) // cicle from 0 to 3
        count = 0;

      IupShow(ih);
    }
    break;
  case K_s:
    IupShow(IupGetHandle("_MAIN_DIALOG_TEST_"));
    break;
  case K_f:
    if (IupGetInt(ih, "FULLSCREEN"))
      IupSetAttribute(ih, "FULLSCREEN", "NO");
    else 
      IupSetAttribute(ih, "FULLSCREEN", "YES");
    break;
  case K_ESC:
    IupDestroy(ih);
    return IUP_IGNORE;
  case K_c:
    return IUP_CLOSE;
  case K_h:
    IupHide(ih);
    break;
  }
  return IUP_DEFAULT;
}
Ejemplo n.º 20
0
static void winDestroyWindow(Ihandle *n)
{
  assert(n);
  if(!n)
    return;

  if(type(n) == DIALOG_)
  {
    Ihandle *menu = IupGetAttributeHandle(n, IUP_MENU);
    if (menu) 
    {
      handle(menu) = NULL; /* the dialog will destroy the menu */
      IupDestroy(menu);  
    }

    /* if this is a popup window, this will also end the message loop */
    IupHide(n); 
    
    /* Deletes window and associated window class */
    winDestroyFreeWindowClass(n);
  }
  else if(type(n) == CANVAS_)
  {
    winDestroyFreeWindowClass(n);
  }
  else if(type(n) == MULTILINE_ || type(n) == TEXT_)
  {
    winDestroyRemoveProc(n, handle(n), "_IUPWIN_TEXTOLDPROC__");
    iupwinHandleRemove(n);
    DestroyWindow(handle(n));
  }
  else if(type(n) == LABEL_ || type(n) == LIST_ || type(n) == TOGGLE_)
  {
    if (type(n) == TOGGLE_)
      winDestroyRemoveProc(n, handle(n), "_IUPWIN_TOGGLEOLDPROC__");
    else if (type(n) == LIST_)
    {
      winDestroyRemoveProc(n, (HWND)IupGetAttribute(n, "_IUPWIN_EDITBOX"), "_IUPWIN_TEXTOLDPROC__");
      winDestroyRemoveProc(n, (HWND)IupGetAttribute(n, "_IUPWIN_COMBOBOX"), "_IUPWIN_COMBOLISTOLDPROC__");
    }
    else if (type(n) == LABEL_)
    {
      winDestroyRemoveProc(n, handle(n), "_IUPWIN_BUTTONOLDPROC__");
    }
    iupwinHandleRemove(n);
    DestroyWindow(handle(n));
  }
  else if(type(n) == BUTTON_)
  {
    winDestroyRemoveProc(n, handle(n), "_IUPWIN_BUTTONOLDPROC__");
    iupwinHandleRemove(n);
    DestroyWindow(handle(n));
  }
  else if(type(n) == IMAGE_)
  {
    winDestroyImage(n);
  }
  else if(type(n) == FRAME_)
  {
    winDestroyRemoveProc(n, handle(n), "_IUPWIN_FRAMEOLDPROC__");
    iupwinHandleRemove(n);
    DestroyWindow(handle(n));
  }
  else if(type(n) == MENU_)
  {
    assert(number(n)!=-1); 
    iupwinCleanidIhandle(number(n));
    if (handle(n)) DestroyMenu(handle(n));  /* Destroy Menu is recursive */
  }
  else if(type(n) == SUBMENU_)
  {
    assert(number(n)!=-1); 
    iupwinCleanidIhandle(number(n));
    /* DestroyWindows is automatically called by the system */
  }
  else if(type(n) == ITEM_ || type(n) == SEPARATOR_)
  {
    assert(number(n)!=-1); 
    iupwinCleanidIhandle(number(n));
    /* DestroyWindows is automatically called by the system */
  }
}
Ejemplo n.º 21
0
static void Hide(void)
{
  lua_pushnumber(IupHide(iuplua_checkihandle(1)));
}
Ejemplo n.º 22
0
int iupDialogPopup(Ihandle* ih, int x, int y)
{
  int was_visible;

  int ret = iupClassObjectDlgPopup(ih, x, y);
  if (ret != IUP_INVALID) /* IUP_INVALID means it is not implemented */
    return ret;

  ih->data->show_state = IUP_SHOW;

  /* save visible state before iupdrvDialogSetPlacement */
  /* because it can also show the window when changing placement. */
  was_visible = iupdrvDialogIsVisible(ih); 

  /* Update the position and placement */
  if (!iupdrvDialogSetPlacement(ih))
  {
    iDialogAdjustPos(ih, &x, &y);
    iupdrvDialogSetPosition(ih, x, y);
  }

  if (was_visible) /* already visible */
  {
    /* only re-show to raise the window */
    iupdrvDialogSetVisible(ih, 1);
    
    /* flush, then process show_cb and startfocus */
    iDialogAfterShow(ih);
    return IUP_NOERROR; 
  }

  if (iupAttribGetBoolean(ih, "MODAL")) /* already a popup */
    return IUP_NOERROR; 

  iDialogSetModal(ih);

  ih->data->first_show = 1;

  /* actually show the window */
  /* test if placement turn the dialog visible */
  if (!iupdrvDialogIsVisible(ih))
    iupdrvDialogSetVisible(ih, 1);

  /* increment visible count */
  iupDlgListVisibleInc();
    
  /* flush, then process show_cb and startfocus */
  iDialogAfterShow(ih);

  /* interrupt processing here */
  IupMainLoop();

  /* if window is still valid (IupDestroy not called), 
     hide the dialog if still visible. */
  if (iupObjectCheck(ih))
  {
    iDialogUnSetModal(ih);
    IupHide(ih); 
  }

  return IUP_NOERROR;
}