예제 #1
0
파일: iupwin_list.c 프로젝트: LuaDist/iup
static void winListUpdateScrollWidthItem(Ihandle* ih, int item_width, int add)
{
  int max_w;

  if (ih->data->is_dropdown && iupAttribGetBoolean(ih, "DROPEXPAND"))
  {
    max_w = (int)SendMessage(ih->handle, CB_GETDROPPEDWIDTH, 0, 0);
    max_w = max_w -3 -3 -iupdrvGetScrollbarSize();
  }
  else
    max_w = (int)SendMessage(ih->handle, WIN_GETHORIZONTALEXTENT(ih), 0, 0);

  if (add)
  {
    if (item_width > max_w)
    {
      if (ih->data->is_dropdown && iupAttribGetBoolean(ih, "DROPEXPAND"))
      {
        int w = 3+item_width+iupdrvGetScrollbarSize()+3;
        SendMessage(ih->handle, CB_SETDROPPEDWIDTH, w, 0);
      }
      else
        SendMessage(ih->handle, WIN_SETHORIZONTALEXTENT(ih), item_width, 0);
    }
  }
  else
  {
    if (item_width >= max_w)
      winListUpdateScrollWidth(ih);
  }
}
예제 #2
0
static void gtkItemActivate(GtkWidget *widget, Ihandle* ih)
{
  Icallback cb;

  if (GTK_IS_CHECK_MENU_ITEM(ih->handle) && !iupAttribGetBoolean(ih, "AUTOTOGGLE") && !iupAttribGetBoolean(ih->parent, "RADIO"))
  {
    /* GTK by default will do autotoggle */
    g_signal_handlers_block_by_func(G_OBJECT(ih->handle), G_CALLBACK(gtkItemActivate), ih);
    gtk_check_menu_item_set_active((GtkCheckMenuItem*)ih->handle, !gtk_check_menu_item_get_active((GtkCheckMenuItem*)ih->handle));
    g_signal_handlers_unblock_by_func(G_OBJECT(ih->handle), G_CALLBACK(gtkItemActivate), ih);
  }

  if (GTK_IS_IMAGE_MENU_ITEM(ih->handle))
  {
    if (iupAttribGetBoolean(ih, "AUTOTOGGLE"))
    {
      if (iupAttribGetBoolean(ih, "VALUE"))
        iupAttribSetStr(ih, "VALUE", "OFF");
      else
        iupAttribSetStr(ih, "VALUE", "ON");

      gtkItemUpdateImage(ih, iupAttribGet(ih, "VALUE"), iupAttribGet(ih, "IMAGE"), iupAttribGet(ih, "IMPRESS"));
    }
  }

  cb = IupGetCallback(ih, "ACTION");
  if (cb && cb(ih)==IUP_CLOSE)
    IupExitLoop();

  (void)widget;
}
예제 #3
0
static int winDatePickMapMethod(Ihandle* ih)
{
  DWORD dwStyle = WS_CHILD | WS_CLIPSIBLINGS | DTS_SHORTDATECENTURYFORMAT;

  if (!ih->parent)
    return IUP_ERROR;

  if (iupAttribGetBoolean(ih, "CANFOCUS"))
    dwStyle |= WS_TABSTOP;

  if (!iupwinCreateWindow(ih, DATETIMEPICK_CLASS, 0, dwStyle, NULL))
    return IUP_ERROR;

  /* Process WM_NOTIFY */
  IupSetCallback(ih, "_IUPWIN_NOTIFY_CB", (Icallback)winDatePickWmNotify);

  if (iupwinIsVistaOrNew())
  {
    dwStyle = MCS_NOTODAY | MCS_NOSELCHANGEONNAV;

    if (iupAttribGetBoolean(ih, "CALENDARWEEKNUMBERS"))
      dwStyle |= MCS_WEEKNUMBERS;

    SendMessage(ih->handle, DTM_SETMCSTYLE, 0, (LPARAM)dwStyle);
  }

  if (iupAttribGet(ih, "SEPARATOR") || iupAttribGet(ih, "ZEROPRECED") || iupAttribGet(ih, "MONTHSHORTNAMES"))
    winDatePickSetOrderAttrib(ih, "DMY");

  return IUP_NOERROR;
}
예제 #4
0
static void winButtonDrawItem(Ihandle* ih, DRAWITEMSTRUCT *drawitem)
{ 
  HDC hDC;
  iupwinBitmapDC bmpDC;
  int border, draw_border;
  int width = drawitem->rcItem.right - drawitem->rcItem.left;
  int height = drawitem->rcItem.bottom - drawitem->rcItem.top;

  hDC = iupwinDrawCreateBitmapDC(&bmpDC, drawitem->hDC, width, height);

  iupwinDrawParentBackground(ih, hDC, &drawitem->rcItem);

  if ((drawitem->itemState & ODS_FOCUS) && !(drawitem->itemState & ODS_HOTLIGHT))
    drawitem->itemState |= ODS_DEFAULT;

  if (iupAttribGet(ih, "_IUPWINBUT_SELECTED"))
    drawitem->itemState |= ODS_SELECTED;

  border = winButtonGetBorder();

  if ((ih->data->type & IUP_BUTTON_IMAGE) && 
      iupAttribGet(ih, "IMPRESS") && 
      !iupAttribGetBoolean(ih, "IMPRESSBORDER"))
    draw_border = 0;
  else
  {
    if (iupAttribGetBoolean(ih, "FLAT"))
    {
      if (drawitem->itemState & ODS_HOTLIGHT || iupAttribGet(ih, "_IUPWINBUT_ENTERWIN"))
        draw_border = 1;
      else
        draw_border = 0;
    }
    else
      draw_border = 1;
  }

  if (draw_border)
    iupwinDrawButtonBorder(ih->handle, hDC, &drawitem->rcItem, drawitem->itemState);

  if (ih->data->type == IUP_BUTTON_IMAGE)
    winButtonDrawImage(ih, hDC, width, height, border, drawitem->itemState);
  else if (ih->data->type == IUP_BUTTON_TEXT)
    winButtonDrawText(ih, hDC, width, height, border, drawitem->itemState);
  else  /* both */
    winButtonDrawImageText(ih, hDC, width, height, border, drawitem->itemState);

  if (drawitem->itemState & ODS_FOCUS &&
      !(drawitem->itemState & ODS_NOFOCUSRECT) &&
      iupAttribGetBoolean(ih, "CANFOCUS"))
  {
    border--;
    iupdrvDrawFocusRect(ih, hDC, border, border, width-2*border, height-2*border);
  }

  iupwinDrawDestroyBitmapDC(&bmpDC);
}
예제 #5
0
static int winCanvasSetDYAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_VERT)
  {
    double posy, ymin, ymax;
    float dy;
    int iposy, ipagey;

    if (!iupStrToFloatDef(value, &dy, 0.1f))
      return 1;

    ymin = iupAttribGetFloat(ih, "YMIN");
    ymax = iupAttribGetFloat(ih, "YMAX");
    posy = ih->data->posy;

    iupCanvasCalcScrollIntPos(ymin, ymax, dy, posy, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagey, &iposy);

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagey, SB_VERT, iupAttribGetBoolean(ih, "YAUTOHIDE"));

    if (dy >= (ymax-ymin))
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        iupAttribSet(ih, "YHIDDEN", "YES");
        ShowScrollBar(ih->handle, SB_VERT, FALSE);
        SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, FALSE);
      }
      else
      {
        EnableScrollBar(ih->handle, SB_VERT, ESB_DISABLE_BOTH);
        SetScrollPos(ih->handle, SB_VERT, IUP_SB_MIN, TRUE);
      }

      ih->data->posy = (float)ymin;
      return 1;
    }
    else
    {
      if (iupAttribGetBoolean(ih, "YAUTOHIDE"))
      {
        iupAttribSet(ih, "YHIDDEN", "NO");
        ShowScrollBar(ih->handle, SB_VERT, TRUE);
      }
      else
        EnableScrollBar(ih->handle, SB_VERT, ESB_ENABLE_BOTH);

      /* also update position because it could have being changed */
      iupCanvasCalcScrollRealPos(ymin, ymax, &posy,
                                 IUP_SB_MIN, IUP_SB_MAX, ipagey, &iposy);
      SetScrollPos(ih->handle, SB_VERT, iposy, TRUE);
      ih->data->posy = (float)posy;
    }
  }
  return 1;
}
예제 #6
0
static int winCanvasSetDXAttrib(Ihandle* ih, const char *value)
{
  if (ih->data->sb & IUP_SB_HORIZ)
  {
    double posx, xmin, xmax;
    float dx;
    int iposx, ipagex;

    if (!iupStrToFloatDef(value, &dx, 0.1f))
      return 1;

    xmin = iupAttribGetFloat(ih, "XMIN");
    xmax = iupAttribGetFloat(ih, "XMAX");
    posx = ih->data->posx;

    iupCanvasCalcScrollIntPos(xmin, xmax, dx, posx, 
                              IUP_SB_MIN, IUP_SB_MAX, &ipagex, &iposx);

    winCanvasSetScrollInfo(ih->handle, IUP_SB_MIN, IUP_SB_MAX, ipagex, SB_HORZ, iupAttribGetBoolean(ih, "XAUTOHIDE"));

    if (dx >= (xmax-xmin))
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        iupAttribSet(ih, "XHIDDEN", "YES");
        ShowScrollBar(ih->handle, SB_HORZ, FALSE);
        SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, FALSE);
      }
      else
      {
        EnableScrollBar(ih->handle, SB_HORZ, ESB_DISABLE_BOTH);
        SetScrollPos(ih->handle, SB_HORZ, IUP_SB_MIN, TRUE);
      }

      ih->data->posx = (float)xmin;
    }
    else
    {
      if (iupAttribGetBoolean(ih, "XAUTOHIDE"))
      {
        iupAttribSet(ih, "XHIDDEN", "NO");
        ShowScrollBar(ih->handle, SB_HORZ, TRUE);
      }
      else
        EnableScrollBar(ih->handle, SB_HORZ, ESB_ENABLE_BOTH);

      /* also update position because it could have being changed */
      iupCanvasCalcScrollRealPos(xmin, xmax, &posx, 
                                 IUP_SB_MIN, IUP_SB_MAX, ipagex, &iposx);
      SetScrollPos(ih->handle, SB_HORZ, iposx, TRUE);
      ih->data->posx = (float)posx;
    }
  }
  return 1;
}
예제 #7
0
static int iFlatButtonSetValueAttrib(Ihandle* ih, const char* value)
{
  if (iupAttribGetBoolean(ih, "TOGGLE"))
  {
    Ihandle* radio = iupRadioFindToggleParent(ih);
    if (radio)
    {
      /* can only set Radio to ON */
      if (iupStrEqualNoCase(value, "TOGGLE") || iupStrBoolean(value))
      {
        Ihandle* last_tg = (Ihandle*)iupAttribGet(radio, "_IUP_FLATBUTTON_LASTRADIO");
        if (iupObjectCheck(last_tg) && last_tg != ih)
        {
          iupAttribSet(last_tg, "VALUE", "OFF");
          if (last_tg->handle)
            iupdrvRedrawNow(last_tg);
        }

        iupAttribSet(radio, "_IUP_FLATBUTTON_LASTRADIO", (char*)ih);
      }
      else
        return 0;
    }
    else
    {
      if (iupStrEqualNoCase(value, "TOGGLE"))
      {
        int oldcheck = iupAttribGetBoolean(ih, "VALUE");
        if (oldcheck)
          iupAttribSet(ih, "VALUE", "OFF");
        else
          iupAttribSet(ih, "VALUE", "ON");

        if (ih->handle)
          iupdrvRedrawNow(ih);

        return 0;
      }
    }

    if (ih->handle)
      iupdrvPostRedraw(ih);

    return 1;
  }
  else
    return 0;
}
예제 #8
0
void iupLayoutCompute(Ihandle* ih)
{
  /* usually called only for the dialog */

  int shrink = iupAttribGetBoolean(ih, "SHRINK");

  /* Compute the natural size for all elements in the dialog,   
     using the minimum visible size and the defined user size.
     The minimum visible size is the size where all the controls can display
     all their contents.
     The defined user size is used to increase the value of the minimum visible size for containers,
     for standard controls will replace the minimum visible size.
     So the native size will be the maximum value between 
     minimum visible size and defined user size.
     Also calculates the expand configuration for each element, but expand is used only in SetChildrenCurrentSize.
     SEQUENCE: will first calculate the native size for the children, then for the element. */
  iupBaseComputeNaturalSize(ih);

  /* Set the current size (not reflected in the native element yet) based on
     the natural size and the expand configuration. 
     If shrink is 0 (default) the current size of containers can be only larger than the natural size,
     the result will depend on the EXPAND attribute.
     If shrink is 1 the containers can be resized to sizes smaller than the natural size.
     SEQUENCE: will first calculate the current size of the element, then for the children. */
  iupBaseSetCurrentSize(ih, 0, 0, shrink);

  /* Now that the current size is known, set the position of the elements 
     relative to the parent.
     SEQUENCE: will first set the position of the element, then for the children. */
  iupBaseSetPosition(ih, 0, 0);
}
예제 #9
0
void iupDialogHide(Ihandle* ih)
{
  /* hidden at the system and marked hidden in IUP */
  if (!iupdrvDialogIsVisible(ih) && ih->data->show_state == IUP_HIDE) 
    return;

  /* marked hidden in IUP */
  ih->data->show_state = IUP_HIDE;

  /* if called IupHide for a Popup window */
  if (iupAttribGetBoolean(ih, "MODAL"))
  {
    iDialogUnSetModal(ih);
    IupExitLoop();
  }

  ih->data->ignore_resize = 1;

  /* actually hide the window */
  iupdrvDialogSetVisible(ih, 0);

  ih->data->ignore_resize = 0;

  /* decrement visible count */
  iupDlgListVisibleDec();
    
  /* process flush and process show_cb */
  iDialogAfterHide(ih);

  iDialogListCheckLastVisible();
}
예제 #10
0
/* Verify if the mouse is in the intersection between two of column titles,
   if so the resize is started */
int iupMatrixColResStart(Ihandle* ih, int x, int y)
{
  if (ih->data->lines.sizes[0] && y < ih->data->lines.sizes[0] && iupAttribGetBoolean(ih, "RESIZEMATRIX"))
  {
    int size, col;
   
    /* Check if is the column of titles */
    size = ih->data->columns.sizes[0];
    if (abs(size-x) < IMAT_COLRES_TOL)
    {
      ih->data->colres_drag_col_start_x = 0;
      ih->data->colres_dragging =  1;
      ih->data->colres_drag_col_last_x = -1;
      ih->data->colres_drag_col = 0;
      return 1;
    }
    else
    {
      /* find the column */
      for(col = ih->data->columns.first; col <= ih->data->columns.last; col++)
      {
        ih->data->colres_drag_col_start_x = size;
        size += ih->data->columns.sizes[col];
        if (abs(size-x) < IMAT_COLRES_TOL)
        {
          ih->data->colres_dragging =  1;
          ih->data->colres_drag_col_last_x = -1;
          ih->data->colres_drag_col = col;
          return 1;
        }
      }
    }
  }
  return 0;
}
예제 #11
0
/* Change the cursor when it passes over a group of the column titles. */
void iupMatrixColResCheckChangeCursor(Ihandle* ih, int x, int y)
{
  if(ih->data->lines.sizes[0] && y < ih->data->lines.sizes[0] && iupAttribGetBoolean(ih, "RESIZEMATRIX"))
  {
    /* It is in the column titles area and the resize mode is on */
    int found = 0, size, col;

    size = ih->data->columns.sizes[0];
    if (abs(size - x) < IMAT_COLRES_TOL)
      found = 1;    /* line titles */
    else
    {
      for(col = ih->data->columns.first; col <= ih->data->columns.last && !found; col++)
      {
        size += ih->data->columns.sizes[col];
        if(abs(size - x) < IMAT_COLRES_TOL)
          found = 1;
      }
    }

    if (found)
    {
      if (!iupAttribGet(ih, "_IUPMAT_CURSOR"))
        iupAttribStoreStr(ih, "_IUPMAT_CURSOR", IupGetAttribute(ih, "CURSOR"));
      IupSetAttribute(ih, "CURSOR", "RESIZE_W");
    }
    else /* It is in the empty area after the last column */
      iMatrixColResResetMatrixCursor(ih); 
  }
  else
    iMatrixColResResetMatrixCursor(ih);
}
예제 #12
0
파일: iupmot_list.c 프로젝트: Vulcanior/IUP
void iupdrvListAppendItem(Ihandle* ih, const char* value)
{
  if (iupAttribGetBoolean(ih, "SORT"))
    motListAddSortedItem(ih, value);
  else
    motListAddItem(ih, -1, value);
}
예제 #13
0
static int winFileDlgGetSelectedFile(Ihandle* ih, HWND hWnd, char* filename)
{
  int ret = CommDlg_OpenSave_GetFilePath(GetParent(hWnd), filename, IUP_MAX_FILENAME_SIZE);
  if (ret < 0)
    return 0;

  if (iupAttribGetBoolean(ih, "MULTIPLEFILES"))
  {
    /* check if there are more than 1 files and return only the first one */
    int found = 0;
    while(*filename != 0)
    {            
      if (*filename == '"')
      {
        if (!found)
          found = 1;
        else
        {
          *(filename-1) = 0;
          return 1;
        }
      }
      if (found)
        *filename = *(filename+1);
      filename++;
    }
  }

  return 1;
}
예제 #14
0
static void winDialogUnMapMethod(Ihandle* ih)
{
    if (ih->data->menu)
    {
        ih->data->menu->handle = NULL; /* the dialog will destroy the native menu */
        IupDestroy(ih->data->menu);
    }

    if (iupAttribGet(ih, "_IUPDLG_HASTRAY"))
        winDialogSetTrayAttrib(ih, NULL);

    iupwinTipsDestroy(ih);
    iupwinDestroyDragDrop(ih);

    /* remove the association before destroying */
    iupwinHandleRemove(ih->handle);

    /* Destroys the window, so we can destroy the class */
    if (iupAttribGetBoolean(ih, "MDICHILD"))
    {
        /* for MDICHILDs must send WM_MDIDESTROY, instead of calling DestroyWindow */
        Ihandle* client = (Ihandle*)iupAttribGet(ih, "MDICLIENT_HANDLE");
        SendMessage(client->handle, WM_MDIDESTROY, (WPARAM)ih->handle, 0);

        winDialogMDIRefreshMenu(ih);
    }
    else
        DestroyWindow(ih->handle); /* this will destroy the Windows children also. */
    /* but IupDestroy already destroyed the IUP children */
    /* so it is safe to call DestroyWindow */
}
예제 #15
0
파일: iupmat_draw.c 프로젝트: sanikoyes/iup
static void iMatrixDrawFocus(Ihandle* ih)
{
  int x1, y1, x2, y2, dx, dy;

  if (iupAttribGetBoolean(ih, "HIDEFOCUS"))
    return;

  /* there are no cells that can get the focus */
  if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1)
    return;

  if (!iupMatrixAuxIsCellVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
    return;

  iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x1, &y1, &dx, &dy);

  x2 = x1 + dx - 1;
  y2 = y1 + dy - 1;

  if (ih->data->columns.focus_cell == 1 && ih->data->columns.dt[0].size == 0)
    x1++;
  if (ih->data->lines.focus_cell == 1 && ih->data->lines.dt[0].size == 0)
    y1++;

  {
    cdCanvas* cd_canvas_front = (cdCanvas*)IupGetAttribute(ih, "_CD_CANVAS");  /* front buffer canvas */
    IupCdDrawFocusRect(ih, cd_canvas_front, x1, iupMATRIX_INVERTYAXIS(ih, y1), x2, iupMATRIX_INVERTYAXIS(ih, y2));
  }
}
예제 #16
0
static void iGLCanvasBoxSetChildrenCurrentSizeMethod(Ihandle* ih, int shrink)
{
  Ihandle* child;
  for (child = ih->firstchild; child; child = child->brother)
  {
    /* update children to their own natural size */
    int width = child->naturalwidth;
    int height = child->naturalheight;
    if (iupAttribGetBoolean(child, "EXPANDHORIZONTAL"))
      width = ih->currentwidth;
    if (iupAttribGetBoolean(child, "EXPANDVERTICAL"))
      height = ih->currentheight;

    iupBaseSetCurrentSize(child, width, height, shrink);
  }
}
예제 #17
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;
}
예제 #18
0
static int iMatrixGetColResCheck(Ihandle* ih, int x, int y)
{
  if (ih->data->lines.dt[0].size && 
      y < ih->data->lines.dt[0].size && 
      iupAttribGetBoolean(ih, "RESIZEMATRIX"))
  {
    int x_col = 0, col;
   
    /* Check if it is in the non scrollable columns */
    for(col = 0; col < ih->data->columns.num_noscroll; col++)
    {
      x_col += ih->data->columns.dt[col].size;
      if (abs(x_col-x) < IMAT_COLRES_TOL)
        return col;
    }

    /* Check if it is in the visible columns */
    for(col = ih->data->columns.first; col <= ih->data->columns.last; col++)
    {
      x_col += ih->data->columns.dt[col].size;
      if (col == ih->data->columns.first)
        x_col -= ih->data->columns.first_offset;

      if (abs(x_col-x) < IMAT_COLRES_TOL)
        return col;
    }
  }

  return -1;
}
예제 #19
0
static int winFrameMapMethod(Ihandle* ih)
{
  char *title;
  DWORD dwStyle = WS_CHILD|WS_CLIPSIBLINGS|
                  BS_OWNERDRAW, /* owner draw necessary because BS_GROUPBOX does not work ok */
      dwExStyle = 0;

  if (!ih->parent)
    return IUP_ERROR;

  title = iupAttribGet(ih, "TITLE");
  if (title)
    iupAttribSetStr(ih, "_IUPFRAME_HAS_TITLE", "1");

  if (iupAttribGetBoolean(IupGetDialog(ih), "COMPOSITED"))
    dwExStyle |= WS_EX_COMPOSITED;
  else
    dwStyle |= WS_CLIPCHILDREN;

  if (!iupwinCreateWindowEx(ih, "BUTTON", dwExStyle, dwStyle))
    return IUP_ERROR;

  /* replace the WinProc to handle other messages */
  IupSetCallback(ih, "_IUPWIN_CTRLPROC_CB", (Icallback)winFrameProc);

  /* Process WM_DRAWITEM */
  IupSetCallback(ih, "_IUPWIN_DRAWITEM_CB", (Icallback)winFrameDrawItem);  

  return IUP_NOERROR;
}
예제 #20
0
파일: iupmat_draw.c 프로젝트: xushiwei/iup
static void iMatrixDrawFocus(Ihandle* ih)
{
    int x1, y1, x2, y2, dx, dy;

    if (iupAttribGetBoolean(ih, "HIDEFOCUS"))
        return;

    /* there are no cells that can get the focus */
    if (ih->data->columns.num <= 1 || ih->data->lines.num <= 1)
        return;

    if (!iupMatrixAuxIsCellVisible(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell))
        return;

    iupMatrixGetVisibleCellDim(ih, ih->data->lines.focus_cell, ih->data->columns.focus_cell, &x1, &y1, &dx, &dy);

    x2 = x1 + dx - 1;
    y2 = y1 + dy - 1;

    if (ih->data->columns.focus_cell == 1 && ih->data->columns.sizes[0] == 0)
        x1++;
    if (ih->data->lines.focus_cell == 1 && ih->data->lines.sizes[0] == 0)
        y1++;

    cdIupDrawFocusRect(ih, ih->data->cdcanvas, x1, iupMATRIX_INVERTYAXIS(ih, y1), x2, iupMATRIX_INVERTYAXIS(ih, y2));
}
예제 #21
0
static int gtkSetDragSourceAttrib(Ihandle* ih, const char* value)
{
  if (iupStrBoolean(value))
  {
    GtkTargetList *targetlist = (GtkTargetList*)iupAttribGet(ih, "_IUPGTK_DRAG_TARGETLIST");
    GtkTargetEntry *drag_types_entry;
    int targetlist_count;

    if(!targetlist)
      return 0;

    drag_types_entry = gtk_target_table_new_from_list(targetlist, &targetlist_count);

    gtk_drag_source_set(ih->handle, GDK_BUTTON1_MASK, drag_types_entry, targetlist_count, 
                        iupAttribGetBoolean(ih, "DRAGSOURCEMOVE")? GDK_ACTION_MOVE|GDK_ACTION_COPY: GDK_ACTION_COPY);

    g_signal_connect(ih->handle, "drag_begin", G_CALLBACK(gtkDragBegin), ih);
    g_signal_connect(ih->handle, "drag_data_get", G_CALLBACK(gtkDragDataGet), ih);
    g_signal_connect(ih->handle, "drag_end", G_CALLBACK(gtkDragEnd), ih);

    gtk_target_table_free(drag_types_entry, targetlist_count);
  }
  else
    gtk_drag_source_unset(ih->handle);

  return 1;
}
예제 #22
0
static void winCanvasUnMapMethod(Ihandle* ih)
{
  if (iupAttribGetBoolean(ih, "MDICLIENT")) 
  {
    /* hide the MDI client window to avoid multiple re-paints */
    ShowWindow(ih->handle, SW_HIDE);

    /* must destroy all MDI Children */
    winCanvasMDICloseChildren(ih);

    DestroyWindow(ih->handle);

    /* mdiclient class is not a IUP class, must return here */
    return;
  }

  iupwinTipsDestroy(ih);
  iupwinDestroyDragDrop(ih);

  /* remove the association before destroying */
  iupwinHandleRemove(ih->handle);

  /* remove from parent and destroys window */
  SetParent(ih->handle, NULL);
  DestroyWindow(ih->handle);
}
예제 #23
0
void iupwinGetNativeParentStyle(Ihandle* ih, DWORD *dwExStyle, DWORD *dwStyle)
{
  *dwStyle |= WS_CLIPCHILDREN;

  if (iupAttribGetBoolean(IupGetDialog(ih), "COMPOSITED"))
    *dwExStyle |= WS_EX_COMPOSITED;
}
예제 #24
0
파일: iupgtk_dialog.c 프로젝트: LuaDist/iup
static void gtkDialogLayoutUpdateMethod(Ihandle *ih)
{
  int border, caption, menu;
  int width, height;

  if (ih->data->ignore_resize ||
      iupAttribGet(ih, "_IUPGTK_FS_STYLE"))
    return;

  /* for dialogs the position is not updated here */
  ih->data->ignore_resize = 1;

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

  /* set size excluding the border */
  width = ih->currentwidth - 2*border;
  height = ih->currentheight - 2*border - caption;   /* menu is inside the client area. */
  gtk_window_resize((GtkWindow*)ih->handle, width, height);

  if (!iupAttribGetBoolean(ih, "RESIZE"))
  {
    GdkGeometry geometry;
    geometry.min_width = width;
    geometry.min_height = height;
    geometry.max_width = width;
    geometry.max_height = height;
    gtk_window_set_geometry_hints((GtkWindow*)ih->handle, ih->handle,
                                  &geometry, (GdkWindowHints)(GDK_HINT_MIN_SIZE | GDK_HINT_MAX_SIZE));
  }

  ih->data->ignore_resize = 0;
}
예제 #25
0
파일: iupgtk_font.c 프로젝트: Airr/iup_mac
int iupdrvFontGetStringWidth(Ihandle* ih, const char* str)
{
  IgtkFont* gtkfont;
  int len, w;
  char* line_end;

  if (!str || str[0]==0)
    return 0;

  gtkfont = gtkFontGet(ih);
  if (!gtkfont)
    return 0;

  line_end = strchr(str, '\n');
  if (line_end)
    len = line_end-str;
  else
    len = strlen(str);

  if (iupAttribGetBoolean(ih, "MARKUP"))
    pango_layout_set_markup(gtkfont->layout, iupgtkStrConvertToUTF8(str), len);
  else
    pango_layout_set_text(gtkfont->layout, iupgtkStrConvertToUTF8(str), len);

  pango_layout_get_pixel_size(gtkfont->layout, &w, NULL);
  return w;
}
예제 #26
0
void iupdrvListRemoveAllItems(Ihandle* ih)
{
  SendMessage(ih->handle, WIN_RESETCONTENT(ih), 0, 0L);
  if (ih->data->is_dropdown && iupAttribGetBoolean(ih, "DROPEXPAND"))
    SendMessage(ih->handle, CB_SETDROPPEDWIDTH, 0, 0);
  else
    SendMessage(ih->handle, WIN_SETHORIZONTALEXTENT(ih), 0, 0);
}
예제 #27
0
파일: iup_text.c 프로젝트: Airr/iup_mac
static void iTextComputeNaturalSizeMethod(Ihandle* ih, int *w, int *h, int *expand)
{
  int natural_w = 0, 
      natural_h = 0,
      visiblecolumns = iupAttribGetInt(ih, "VISIBLECOLUMNS"),
      visiblelines = iupAttribGetInt(ih, "VISIBLELINES");
  (void)expand; /* unset if not a container */

  /* Since the contents can be changed by the user, the size can not be dependent on it. */
  if (ih->data->is_multiline)
  {
    iupdrvFontGetCharSize(ih, NULL, &natural_h);  /* one line height */
    natural_w = iupdrvFontGetStringWidth(ih, "WWWWWWWWWW");
    natural_w = (visiblecolumns*natural_w)/10;
    natural_h = visiblelines*natural_h;
  }
  else
  {
    iupdrvFontGetCharSize(ih, NULL, &natural_h);  /* one line height */
    natural_w = iupdrvFontGetStringWidth(ih, "WWWWWWWWWW");
    natural_w = (visiblecolumns*natural_w)/10;
  }

  /* compute the borders space */
  if (iupAttribGetBoolean(ih, "BORDER"))
    iupdrvTextAddBorders(&natural_w, &natural_h);

  if (iupAttribGetBoolean(ih, "SPIN"))
    iupdrvTextAddSpin(&natural_w, natural_h);

  natural_w += 2*ih->data->horiz_padding;
  natural_h += 2*ih->data->vert_padding;

  /* add scrollbar */
  if (ih->data->is_multiline && ih->data->sb)
  {
    int sb_size = iupdrvGetScrollbarSize();
    if (ih->data->sb & IUP_SB_HORIZ)
      natural_w += sb_size;
    if (ih->data->sb & IUP_SB_VERT)
      natural_h += sb_size;
  }

  *w = natural_w;
  *h = natural_h;
}
예제 #28
0
static int iMatrixEditTextAction_CB(Ihandle* ih_text, int c, char* after)
{
    Ihandle* ih = ih_text->parent;
    IFniiiis cb = (IFniiiis) IupGetCallback(ih, "ACTION_CB");

    if (iupAttribGetBoolean(ih, "EDITFITVALUE"))
    {
        int value_w, value_h, resize = 0;

        value_w = iupdrvFontGetStringWidth(ih_text, after);
        iupdrvFontGetCharSize(ih_text, NULL, &value_h);

        if (iupAttribGetBoolean(ih_text, "BORDER"))
        {
            value_w += 2 * 4;
            value_h += 2 * 4;
        }

        if (value_w > ih_text->currentwidth)
        {
            ih_text->currentwidth = value_w;
            resize = 1;
        }
        if (value_h > ih_text->currentheight)
        {
            ih_text->currentheight = value_h;
            resize = 1;
        }

        if (resize)
            iupClassObjectLayoutUpdate(ih_text);
    }

    if (cb && iup_isprint(c)) /* only for keys that ARE ASCii characters */
    {
        int oldc = c;
        c = cb(ih, c, ih->data->edit_lin, ih->data->edit_col, 1, after);
        if (c == IUP_IGNORE || c == IUP_CLOSE || c == IUP_CONTINUE)
            return c;
        else if(c == IUP_DEFAULT)
            c = oldc;
        return c;
    }

    return IUP_DEFAULT;
}
예제 #29
0
static char* iColorDlgGetValueAttrib(Ihandle* ih)
{
  IcolorDlgData* colordlg_data = (IcolorDlgData*)iupAttribGetInherit(ih, "_IUP_GC_DATA");
  if (iupAttribGetBoolean(ih, "SHOWALPHA"))
    return iupStrReturnStrf("%d %d %d %d", (int)colordlg_data->red, (int)colordlg_data->green, (int)colordlg_data->blue, (int)colordlg_data->alpha);
  else
    return iupStrReturnRGB(colordlg_data->red, colordlg_data->green, colordlg_data->blue);
}
예제 #30
0
파일: iup_tree.c 프로젝트: LuaDist/iup
static int iTreeSetCtrlAttrib(Ihandle* ih, const char* value)
{
  if (iupStrBoolean(value) && iupAttribGetBoolean(ih, "SHIFT"))
    iTreeSetMarkModeAttrib(ih, "MULTIPLE");
  else
    iTreeSetMarkModeAttrib(ih, "SINGLE");
  return 1;
}