Ah, yes. I should have caught that in needed to set RASTERWIDTH values from your last reply. For the benefit of others that might run into the same issues, I will mention the other changes I made to get this to work. I added dlg.shrink="YES" so that the dialog would attempt to shrink the components it contains when it get smaller. This didn't work because I was using an hbox layout and the component is expanding in the horizontal direction. hbox in this case only allows expansion, so I switched to vbox. (This is discussed on the iup documentation in the Layout guide.) Below is the code that is working for me:

When the columns resize, each is set to the same width. It would be nice if they maintained the same proportion. Is there a way to make this happen automatically?

function OpenTimestepDialog()
  require("iuplua")
  require("iupluacontrols")

mat = iup.matrix {border="Yes", resizematrix = "Yes", scrollbar="Yes", REDRAW="ALL", numcol=7, numlin=3,numcol_visible=7, numlin_visible=3, widthdef=34}
  mat:setcell(0,1,"End\nTime")
  mat:setcell(0,2,"Minimum\nStep")
  mat:setcell(0,3,"Maximum\nStep")
  mat:setcell(0,4,"Control\nOption")
  mat:setcell(0,5,"Plot\nFreq.")
  mat:setcell(0,6,"Edit\nFreq.")
  mat:setcell(0,7,"Restart\nFreq.")

  dlg = iup.dialog{ iup.vbox{mat, margin="5x5"}, title="Time Step Data",}

  -- Need so that the control will shrink with the dialog
  dlg.shrink="yes"

  -- use the dlg resize callback rather than the matrix resize callback
  -- Otherwise the matrix will not redraw
  function dlg:resize_cb(w, h)
        -- Call refresh before adjusting size
        iup.Refresh(dlg)
        -- Set the columns you would like to auto resize to nil
        -- then set the FITTOSIZE flag to columns to resize columns
        mat.RASTERWIDTH1 = nil
        mat.RASTERWIDTH2 = nil
        mat.RASTERWIDTH3 = nil
        mat.RASTERWIDTH4 = nil
        mat.RASTERWIDTH5 = nil
        mat.RASTERWIDTH6 = nil
        mat.RASTERWIDTH7 = nil
        mat.FITTOSIZE = "Columns"
    return iup.DEFAULT
  end

  dlg:show()
end

On 4/5/2013 1:13 PM, Antonio Scuri wrote:

 Hi,

FITTOSIZE will set RASTERWIDTH1,... for all columns. So when you set it again, you must first reset them to NULL or nil in Lua

mat.RASTERWIDTH1 = nil

mat.RASTERWIDTH2 = nil

mat.RASTERWIDTH3 = nil

mat.RASTERWIDTH4 = nil

mat.RASTERWIDTH5 = nil

mat.RASTERWIDTH6 = nil

mat.RASTERWIDTH7 = nil

Best,

Scuri

*From:*Lance Larsen [mailto:gaffer...@gmail.com]
*Sent:* sexta-feira, 5 de abril de 2013 15:02
*To:* IUP discussion list.
*Subject:* Re: [Iup-users] Auto-resizing the Matrix component

Scuri,

I implemented the resize callback on the dialog instead. This did fix the problem with the matrix view not being drawn, but the matrix columns are not being resized when I expand the dialog bounds. I turned on the matrix view border, so I can see that the matrix view is resizing, just not the table itself. Am I setting FITTOSIZE correctly, or is there something else I am missing?

function OpenTimeStepDialog()

local mat = iup.matrix {border="Yes", resizematrix = "Yes", scrollbar="Yes",

REDRAW="ALL", numcol=7, numlin=3,numcol_visible=7, numlin_visible=3, widthdef=34}

  mat:setcell(0,1,"End\nTime")

  ...

tsd = iup.dialog{ iup.hbox{mat; margin="5x5";expand="Yes"}, title="Time Step Data", }

  function tsd:resize_cb(w, h)

    iup.Refresh(tsd)

    mat.FITTOSIZE = "Columns"

    return iup.DEFAULT

  end

end

~Lance

On Fri, Apr 5, 2013 at 11:25 AM, Antonio Scuri <antonio.sc...@gmail.com <mailto:antonio.sc...@gmail.com>> wrote:

Hi Lance,

The resize_cb callback in Lua can not be replaced, you must do it in C. But I suggest you to use the resize_cb of the dialog instead, but you will have to call the iup.Refresh(dlg) function before setting FITTOSIZE.

When setting FITTOSIZE all columns that don't have RASTERWIDTH set to a given value will be resized, in other words all columns that RASTERWIDTH is set to NULL will be resized.

Best Regards,

Antonio Scuri

*From:*Lance Larsen [mailto:gaffer...@gmail.com <mailto:gaffer...@gmail.com>]
*Sent:* sexta-feira, 5 de abril de 2013 13:08
*To:* iup-users@lists.sourceforge.net <mailto:iup-users@lists.sourceforge.net>
*Subject:* [Iup-users] Auto-resizing the Matrix component

I am evaluating iup for a project where I am combining the SciTE text editor for popup dialogs that help with adding or editing content. I need to use Lua to access iup. One thing I wanted to do was set up a dialog that included a spreadsheet view that expands with the dialog. I saw that there is a FITTOSIZE option that should allow you to do this, but I am having trouble figuring out how to set it up correctly.

I did see an incomplete c example in the archive where a RESIZE_CB was defined and RASTERWIDTH2 was set (does this control which columns are expanded) and FITTOSIZE was set to "COLUMNS". When I created a Lua resize_cb callback, it stopped drawing the matrix view. I saw another archived item indicating that the original callback needed to be called inside the resize_cb that I create, but I am not sure how to do this in Lua. I tried to get a reference to the original resize_cb, but the value is 'nil'. Below is one of my attempts to get this right followed by some specific questions. Any help is appreciated.

mat = iup.matrix {border="Yes", resizematrix = "Yes", scrollbar="Yes", redraw="All", \

     numcol=7, numlin=3, numcol_visible=7, numlin_visible=3, widthdef=34}

  mat:setcell(0,1,"End\nTime")

  mat:setcell(0,2,"Minimum\nStep")

  mat:setcell(0,3,"Maximum\nStep")

  mat:setcell(0,4,"Control\nOption")

  mat:setcell(0,5,"Plot\nFreq.")

  mat:setcell(0,6,"Edit\nFreq.")

  mat:setcell(0,7,"Restart\nFreq.")

  old_resize = mat.resize_cb

  function mat:resize_cb(w, h)

    mat.RASTERWIDTH2 = nil

    mat.FITTOSIZE = "Columns"

    -- The following line fails since old_resize is nil

    --mat:old_resize(w,h)

    return iup.DEFAULT

  end

dlg = iup.dialog{ iup.hbox{mat; margin="5x5";expand="Yes"}, title="Time Step Data", }

  dlg:show()

How do I set FITTOSIZE, and is resize_cb the right place to do this?

How do I indicate which columns expand (RASTERWIDTH? - if so what do I set this to?)

How do I call the original resize_cb function for the matrix view (if there is one)? If there isn't why does the view not redraw correctly?

-Lance Larsen


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net <mailto:Iup-users@lists.sourceforge.net>
https://lists.sourceforge.net/lists/listinfo/iup-users


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire
the most talented Cisco Certified professionals. Visit the
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html


_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users


CONFIDENTIALITY NOTICE: This e-mail message, including any attachments, is for 
the sole use of the intended recipient(s) and may contain confidential and 
privileged information. Any unauthorized review, use, disclosure or 
distribution is prohibited. If you are not the intended recipient, please 
contact the sender by reply e-mail and destroy all copies of the original 
message.
------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to