Menu

#2 DropDown Size is wrong

open
nobody
None
5
2004-08-23
2004-08-23
No

When openening the drop down window of the
DatePickerCombo the size is not correctly calculated. It is
either to short (at the begining) or to large (with a green
background after a few selections).

Discussion

  • Matthias Becker

    Matthias Becker - 2004-08-23

    First click

     
  • hannesloehr

    hannesloehr - 2004-09-23

    Logged In: YES
    user_id=1126808

    Hi!

    I have the same problem. When I resize the window some times
    then the DatePlane becomes higher and higher after each
    resize. Could perhaps the author give me a hint where to
    look for the problem in the source code.

    Thanks

     
  • hannesloehr

    hannesloehr - 2004-09-23

    Logged In: YES
    user_id=1126808

    I made a small correction in DatePickerCombo.java, so it
    works for me at the moment. In the internalLayout() function
    I replaced the two lines

    Point listSize = dp.computeSize(SWT.DEFAULT, itemHeight);
    dp.setBounds(1, 1, Math.max(size.x - 2, listSize.x),
    listSize.y);

    by these one
    Point listSize = dp.computeSize(SWT.DEFAULT, SWT.DEFAULT);
    dp.setBounds(1, 1, Math.max(size.x - 2, listSize.x),
    listSize.y+10);

     
  • Daniel Dietrich

    Daniel Dietrich - 2005-06-30

    Logged In: YES
    user_id=1276492

    To compute the size correctly just replace the
    DatePicker#DatePanel.computeSize(int, int, boolean) method
    with this one:

    public Point computeSize(int wHint, int hHint, boolean
    changed) {

    Calendar cal_ = Calendar.getInstance();

    cal_.set(cal.get(Calendar.YEAR),
    cal.get(Calendar.MONTH), 1);

    int firstDay = cal_.get(Calendar.DAY_OF_WEEK);

    int max = cal_.getActualMaximum(Calendar.DAY_OF_MONTH);

    int factor = (firstDay == Calendar.SATURDAY && max == 31)
    || (firstDay == Calendar.SUNDAY && max >= 30) ? 8 : 7;

    return new Point(colSize * 7, rowSize * factor);

    }

    CAUTION -- There is one open task:
    The drop down menu of the combo box is not refreshed
    correctly (but the size is correct).

    The refresh should happen after each 'updateDate();' method
    in the constructor of the DatePicker. (But because I'm new
    to SWT I don't know at the moment how to refresh the drop
    down menu. (layout() and pack() doesn't worked for me...)

    - Daniel

     
  • Nobody/Anonymous

    Logged In: NO

    The solution is maybe in the computeSize of the Date Picker.

    Replace :
    int y = (pSize.y < (labelSize.y + 20) ? labelSize.y + 20 :
    pSize.y);
    By:
    int y = pSize.y + labelSize.y + 20;

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.