lmi
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi] [PATCH] More XRC fixes, including wxDatePickerCtrl ones


From: Vadim Zeitlin
Subject: [lmi] [PATCH] More XRC fixes, including wxDatePickerCtrl ones
Date: Fri, 10 Apr 2015 20:26:58 +0200

 Hello,

 I wanted to wait until the XRC validation patch from
http://lists.nongnu.org/archive/html/lmi/2015-04/msg00002.html was applied
before submitting the subsequent ones, but maybe it's better to not wait
any longer, so here are 8 more XRC-related patches. I know that this number
can seem overwhelming, but there are so many of them mostly because I tried
to make each patch as simple to review as possible, so hopefully it
shouldn't be that difficult to review them. Notice that these patches are
supposed to be applied after the previously posted XRC validation patch.


 Before describing the patches in details, let me also describe the changes
in wxWidgets which were made in parallel with these patches. The first one
was adding the checks to detect incorrect uses of sizer flags in the code
and XRC. This doesn't change anything if correct sizer flags are used
(either from code or XRC), but will now give errors for the wrong flags
combinations. This is, of course, backwards incompatible, because loading
the previously silently working skin.xrc now results in the following error
messages:

---------------------------------- >8 --------------------------------------
XRC error: 2168: vertical alignment flag "wxALIGN_CENTER_VERTICAL" has no 
effect inside a vertical box sizer, remove it and consider setting the item 
proportion instead
XRC error: 2291: vertical alignment flag "wxALIGN_CENTER_VERTICAL" has no 
effect inside a vertical box sizer, remove it and consider setting the item 
proportion instead
XRC error: 2377: "wxGROW" flag has no effect when combined with both 
"wxALIGN_LEFT" and "wxALIGN_CENTER_VERTICAL" horizontal and vertical alignment 
flags
XRC error: 2413: "wxGROW" flag has no effect when combined with both 
"wxALIGN_LEFT" and "wxALIGN_CENTER_VERTICAL" horizontal and vertical alignment 
flags
XRC error: 2421: "wxGROW" flag has no effect when combined with both 
"wxALIGN_LEFT" and "wxALIGN_CENTER_VERTICAL" horizontal and vertical alignment 
flags
XRC error: 2436: "wxGROW" flag has no effect when combined with both 
"wxALIGN_LEFT" and "wxALIGN_CENTER_VERTICAL" horizontal and vertical alignment 
flags
XRC error: 2444: "wxGROW" flag has no effect when combined with both 
"wxALIGN_LEFT" and "wxALIGN_CENTER_VERTICAL" horizontal and vertical alignment 
flags
XRC error: 2349: "wxGROW" is incompatible with vertical alignment flag 
"wxALIGN_CENTER_VERTICAL" in a horizontal box sizer
XRC error: 2563: vertical alignment flag "wxALIGN_CENTER_VERTICAL" has no 
effect inside a vertical box sizer, remove it and consider setting the item 
proportion instead
XRC error: 2575: vertical alignment flag "wxALIGN_CENTER_VERTICAL" has no 
effect inside a vertical box sizer, remove it and consider setting the item 
proportion instead
---------------------------------- >8 --------------------------------------

for example. But I think these checks are very valuable because a lot of
people have trouble understanding how sizer flags work and hopefully they
will make it more difficult for them to get confused.

 The second change in wxWidgets allows to use wxGROW with alignment flags
such as wxALIGN_CENTER_VERTICAL in 2D grid sizers. Previously, the
alignment was just silently ignored, but now it works in the expected way,
i.e. using wxGROW|wxALIGN_CENTER_VERTICAL expands the item in the
horizontal direction but keeps it centered vertically. This is very useful
with single-line-text-like controls which it often makes sense to expand
horizontally but never vertically.

 While all the patches can and should be applied even if wxWidgets version
is not updated, they are especially useful and even required when using the
latest wxWidgets, i.e. 31d1644daaac3aeceeb2c112c06663f81d8f4e89, as of this
writing.


 Now let me describe the attached patches. As usual, their commit messages,
included in each patch, provide more details.

1. Consistently use wxGROW and not wxEXPAND in XRC files.

   This patch is trivial and just homogenizes the use of these flags.
   wxGROW was used in the vast majority of cases and so, even though I
   prefer wxEXPAND personally, I changed the few occurrences of the latter
   to wxGROW as well. This patch doesn't change any behaviour with any
   version of wxWidgets as wxGROW and wxEXPAND are exactly the same thing.

2. Remove invalid alignment flags from box sizers in XRC files.
3. Remove "option" element from wxFlexGridSizer items in XRC.
4. Remove all alignment flags combined with wxGROW from XRC files.

   All these patches don't change anything with the version of wxWidgets
   currently used by lmi as the XRC elements removed by them were ignored
   anyhow, but they would be needed to use the resources without errors
   with the latest wxWidgets version. They also fix many validation errors
   with the latest version of the XRC schema (see my earlier message at
   http://lists.nongnu.org/archive/html/lmi/2015-04/msg00002.html for how
   to validate them on your own).

5. Add missing border flags to XRC files.

   This patch is the first one to actually change anything but is still
   very simple: it just adds the obviously missing border flags which were
   just forgotten for some sizer items. As "border" element doesn't make
   sense without one of wxLEFT, wxRIGHT, wxTOP or wxBOTTOM (or their
   combination wxALL), previously the border was just unused, but it was
   used for the adjoining sizer elements, so I also added it here. If you
   have any doubts about this patch, please feel free to skip applying it
   but IMHO it's 100% safe.

6. Fix incorrect uses of wxGROW in XRC.

   This is the big, bad patch. Viewing it using some kind of diff program
   with intraline diffs support, e.g. "git diff --color-words" is strongly
   recommended as it becomes *much* more readable then and it's much
   simpler to see that mostly it just adds wxALIGN_CENTER_VERTICAL to the
   2D sizer items which previously used wxGROW. It also removes wxGROW from
   the windows that can't grow anyhow, mostly wxStaticText ones.

   I tested this patch extensively by manually visually comparing the 3
   layouts: (a) original XRC files with the currently used wxWidgets
   version, (b) new XRC files with the currently used wxWidgets version and
   (c) new XRC files with the latest wxWidgets. To the best of my vision,
   the changes don't result in any regressions or even any real changes as
   at most they can just shift some control by 1 pixel here or there. Their
   real effect is mostly seen under wxGTK where wxTextCtrl could be
   expanded vertically previously becoming horribly high, but where they
   keep their reasonable size now. So it would be great if you could apply
   this patch, even though I realize that it requires somewhat of a leap of
   faith as you probably won't have time to review all of the changes it
   makes. But, again, all the changes (325 of them AFAIR) were done
   manually and not by automatic search-and-replace and were tested
   carefully, so I really think they should be fine.

7. Remove explicit sizes from wxDatePickerCtrl in the resources.

   This is the patch previously posted here which removes the hard coded
   sizes from wxDatePickerCtrl. It is completely trivial and intentionally
   does nothing but what it says on the tin, and it does fix the truncation
   of wxDatePickerCtrl contents. However it also breaks visual alignment of
   the controls occupying the same column as wxDatePickerCtrl, so you might
   prefer to combine it with the next patch when applying it, I separated
   them mostly for ease of reviewing.

8. Fix controls alignment in XRC after wxDatePickerCtrl size change.

   This part finishes the job of the last patch and re-fixes the controls
   alignment broken by it. As it uses wxGROW|wxALIGN_CENTER_VERTICAL with
   2D sizer elements, it works best with the latest wxWidgets version, but
   in practice the difference is unnoticeable under MSW, so you can apply
   it even if you don't upgrade your wxWidgets version.

   This patch is not as bad as (6), but I still recommend using word diff
   for viewing it as it shows that it mostly replaces wxALIGN_LEFT with
   wxGROW, to ensure that all controls have the same size (with wxGROW they
   expand to the width of the widest one).

 As always, please let me know if you have any questions about these
patches and thanks in advance for applying them!
VZ

Attachment: 0001-Consistently-use-wxGROW-and-not-wxEXPAND-in-XRC-file.patch
Description: Text document

Attachment: 0002-Remove-invalid-alignment-flags-from-box-sizers-in-XR.patch
Description: Text document

Attachment: 0003-Remove-option-element-from-wxFlexGridSizer-items-in-.patch
Description: Text document

Attachment: 0004-Remove-all-alignment-flags-combined-with-wxGROW-from.patch
Description: Text document

Attachment: 0005-Add-missing-border-flags-to-XRC-files.patch
Description: Text document

Attachment: 0006-Fix-incorrect-uses-of-wxGROW-in-XRC.patch
Description: Text document

Attachment: 0007-Remove-explicit-sizes-from-wxDatePickerCtrl-in-the-r.patch
Description: Text document

Attachment: 0008-Fix-controls-alignment-in-XRC-after-wxDatePickerCtrl.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]