Esempio n. 1
0
static char* motDialogGetYAttrib(Ihandle *ih)
{
  char* str = iupStrGetMemory(20);
 
  int y;
  iupdrvDialogGetPosition(ih->handle, &y, NULL);

  sprintf(str, "%d", y);
  return str;
}
Esempio n. 2
0
static gboolean gtkDialogConfigureEvent(GtkWidget *widget, GdkEventConfigure *evt, Ihandle *ih)
{
  int old_width, old_height, old_x, old_y;
  gint x, y;
  (void)widget;

#ifndef HILDON
  /* In hildon the menu is not a menubar */
  if (ih->data->menu && ih->data->menu->handle)
    gtk_widget_set_size_request(ih->data->menu->handle, evt->width, -1);
#endif

  if (ih->data->ignore_resize) return FALSE; 

  old_width = iupAttribGetInt(ih, "_IUPGTK_OLD_WIDTH");
  old_height = iupAttribGetInt(ih, "_IUPGTK_OLD_HEIGHT");

  /* Check the size change, because configure is called also for position changes */
  if (evt->width != old_width || evt->height != old_height)
  {
    IFnii cb;
    int border, caption, menu;
    iupAttribSetInt(ih, "_IUPGTK_OLD_WIDTH", evt->width);
    iupAttribSetInt(ih, "_IUPGTK_OLD_HEIGHT", evt->height);

    iupdrvDialogGetDecoration(ih, &border, &caption, &menu);

  /* update dialog size */
#ifdef HILDON
    /* In Hildon, the configure event contains the window size, not the client area size */
    ih->currentwidth = evt->width;
    ih->currentheight = evt->height;
#else
    ih->currentwidth = evt->width + 2*border;
    ih->currentheight = evt->height + 2*border + caption;  /* menu is inside the window client area */
#endif

    cb = (IFnii)IupGetCallback(ih, "RESIZE_CB");
    if (!cb || cb(ih, evt->width, evt->height - menu)!=IUP_IGNORE)  /* width and height here are for the client area */
    {
      ih->data->ignore_resize = 1;
      IupRefresh(ih);
      ih->data->ignore_resize = 0;
    }
  }

  old_x = iupAttribGetInt(ih, "_IUPGTK_OLD_X");
  old_y = iupAttribGetInt(ih, "_IUPGTK_OLD_Y");
  iupdrvDialogGetPosition(ih, NULL, &x, &y);  /* ignore evt->x and evt->y because they are the clientpos and not X/Y */

  /* Check the position change, because configure is called also for size changes */
  if (x != old_x || y != old_y)
  {
    IFnii cb;
    iupAttribSetInt(ih, "_IUPGTK_OLD_X", x);
    iupAttribSetInt(ih, "_IUPGTK_OLD_Y", y);

    cb = (IFnii)IupGetCallback(ih, "MOVE_CB");
    if (cb)
      cb(ih, x, y);
  }

  return FALSE;
}
Esempio n. 3
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;
}
Esempio n. 4
0
static char* iDialogGetScreenPositionAttrib(Ihandle *ih)
{
  int x = 0, y = 0;
  iupdrvDialogGetPosition(ih, NULL, &x, &y);
  return iupStrReturnIntInt(x, y, ',');
}
Esempio n. 5
0
static char* iDialogGetYAttrib(Ihandle *ih)
{
  int y = 0;
  iupdrvDialogGetPosition(ih, NULL, NULL, &y);
  return iupStrReturnInt(y);
}
Esempio n. 6
0
static char* iDialogGetXAttrib(Ihandle *ih)
{
  int x = 0;
  iupdrvDialogGetPosition(ih, NULL, &x, NULL);
  return iupStrReturnInt(x);
}
Esempio n. 7
0
static void iDialogAdjustPos(Ihandle *ih, int *x, int *y)
{
  int cursor_x = 0, cursor_y = 0;
  int screen_width = 0, screen_height = 0;
  int current_x = 0, current_y = 0;
  int parent_x = 0, parent_y = 0;

  /* the dialog is already mapped here */

  if (*x == IUP_CURRENT || *y == IUP_CURRENT)
  {
    /* if first time, there is no current position */
    if (!ih->data->first_show)
    {
      int center = IUP_CENTER;
      InativeHandle* parent = iupDialogGetNativeParent(ih);
      if (parent)
        center = IUP_CENTERPARENT;

      if (*x == IUP_CURRENT) *x = center;
      if (*y == IUP_CURRENT) *y = center;
    }
    else
      iupdrvDialogGetPosition(ih, NULL, &current_x, &current_y);
  }

  if (*x == IUP_CENTER || *y == IUP_CENTER ||
      *x == IUP_RIGHT  || *y == IUP_RIGHT ||
      *x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
    iupdrvGetScreenSize(&screen_width, &screen_height);

  if (*x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
  {
    InativeHandle* parent = iupDialogGetNativeParent(ih);
    if (parent)
    {
      Ihandle* ih_parent = IupGetAttributeHandle(ih, "PARENTDIALOG");

      iupdrvDialogGetPosition(ih_parent, parent, &parent_x, &parent_y);

      if (*x == IUP_CENTERPARENT && *y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, &screen_width, &screen_height);
      else if (*x == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, &screen_width, NULL);
      else if (*y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(ih_parent, parent, NULL, &screen_height);
    }
  }

  if (*x == IUP_MOUSEPOS || *y == IUP_MOUSEPOS)
    iupdrvGetCursorPos(&cursor_x, &cursor_y);

  if (iupAttribGetBoolean(ih, "MDICHILD"))
  {
    Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
    if (client)
    {
      /* position is relative to mdi client */
      parent_x = 0; 
      parent_y = 0;

      /* screen size is now the size of the mdi client */
      screen_width = client->currentwidth;
      screen_height = client->currentheight;

      iupdrvScreenToClient(client, &current_x, &current_y);
      iupdrvScreenToClient(client, &cursor_x, &cursor_y);
    }
  }

  switch (*x)
  {
  case IUP_CENTERPARENT:
    *x = (screen_width - ih->currentwidth)/2 + parent_x;
    break;
  case IUP_CENTER:
    *x = (screen_width - ih->currentwidth)/2;
    break;
  case IUP_LEFT:
    *x = 0;
    break;
  case IUP_RIGHT:
    *x = screen_width - ih->currentwidth;
    break;
  case IUP_MOUSEPOS:
    *x = cursor_x;
    break;
  case IUP_CURRENT:
    *x = current_x;
    break;
  }

  switch (*y)
  {
  case IUP_CENTERPARENT:
    *y = (screen_height - ih->currentheight)/2 + parent_y;
    break;
  case IUP_CENTER:
    *y = (screen_height - ih->currentheight)/2;
    break;
  case IUP_LEFT:
    *y = 0;
    break;
  case IUP_RIGHT:
    *y = screen_height - ih->currentheight;
    break;
  case IUP_MOUSEPOS:
    *y = cursor_y;
    break;
  case IUP_CURRENT:
    *y = current_y;
    break;
  }

  iupdrvAddScreenOffset(x, y, 1);
}
Esempio n. 8
0
void iupDialogAdjustPos(Ihandle *ih, int *x, int *y)
{
  int cursor_x = 0, cursor_y = 0;
  int screen_width = 0, screen_height = 0;
  int current_x = 0, current_y = 0;
  int parent_x = 0, parent_y = 0;

  if (*x == IUP_CURRENT || *y == IUP_CURRENT)
    iupdrvDialogGetPosition(ih->handle, &current_x, &current_y);

  if (*x == IUP_CENTER || *y == IUP_CENTER ||
      *x == IUP_RIGHT  || *y == IUP_RIGHT ||
      *x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
    iupdrvGetScreenSize(&screen_width, &screen_height);

  if (*x == IUP_CENTERPARENT || *y == IUP_CENTERPARENT)
  {
    InativeHandle* parent = iupDialogGetNativeParent(ih);
    if (parent)
    {
      iupdrvDialogGetPosition(parent, &parent_x, &parent_y);

      if (*x == IUP_CENTERPARENT && *y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, &screen_width, &screen_height);
      else if (*x == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, &screen_width, NULL);
      else if (*y == IUP_CENTERPARENT)
        iupdrvDialogGetSize(parent, NULL, &screen_height);
    }
  }

  if (*x == IUP_MOUSEPOS || *y == IUP_MOUSEPOS)
    iupdrvGetCursorPos(&cursor_x, &cursor_y);

  if (IupGetInt(ih, "MDICHILD"))
  {
    Ihandle* client = (Ihandle*)iupAttribGetStr(ih, "MDICLIENT_HANDLE");
    if (client)
    {
      /* position is relative to mdi client */
      parent_x = 0; 
      parent_y = 0;

      /* screen size is now the size of the mdi client */
      screen_width = client->currentwidth;
      screen_height = client->currentheight;

      iupdrvScreenToClient(client, &current_x, &current_y);
      iupdrvScreenToClient(client, &cursor_x, &cursor_y);
    }
  }

  switch (*x)
  {
  case IUP_CENTERPARENT:
    *x = (screen_width - ih->currentwidth)/2 + parent_x;
    break;
  case IUP_CENTER:
    *x = (screen_width - ih->currentwidth)/2;
    break;
  case IUP_LEFT:
    *x = 0;
    break;
  case IUP_RIGHT:
    *x = screen_width - ih->currentwidth;
    break;
  case IUP_MOUSEPOS:
    *x = cursor_x;
    break;
  case IUP_CURRENT:
    *x = current_x;
    break;
  }

  switch (*y)
  {
  case IUP_CENTERPARENT:
    *y = (screen_height - ih->currentheight)/2 + parent_y;
    break;
  case IUP_CENTER:
    *y = (screen_height - ih->currentheight)/2;
    break;
  case IUP_LEFT:
    *y = 0;
    break;
  case IUP_RIGHT:
    *y = screen_height - ih->currentheight;
    break;
  case IUP_MOUSEPOS:
    *y = cursor_y;
    break;
  case IUP_CURRENT:
    *y = current_y;
    break;
  }
}