Added wxBITMAP_TYPE_TIFF and wxBITMAP_TYPE_TIFF_RESOURCE.
Having wxBITMAP_TYPE_TIFF and wxBITMAP_TYPE_TIFF_RESOURCE is more consistent with already using the complete short name of an image format elsewhere (e.g. wxBITMAP_TYPE_JPEG, not wxBTMAP_TYPE_JPG, and wxTIFFHandler as opposed to wxTIFHandler). Renamed all existing occurrences and kept the old enum values for backwards compatibility.
Also renamed occurrences of wxBITMAP_TYPE_RESOURCE to the already existing wxBITMAP_TYPE_BMP_RESOURCE.
Fixed linking errors related to wxAnyButton in wxUniv.
Native wxAnyButton headers were being included but the sources aren't used in wxUniv. Fixed this by not including any native header in wxUniv and instead made wxAnyButton a typedef of wxAnyButtonBase.
Make use of HasImageList() and GetImageList() instead of accessing the now private m_imageList directly. Fixed for wxUniv, wxGTK1, and wxOS2 (the latter 2 blindly). Changes are similar to r68856 and should have been a part of that.
Vadim Zeitlin [Mon, 22 Aug 2011 15:31:38 +0000 (15:31 +0000)]
Don't refresh not yet realized widget in wxGTK wxDataViewCtrl.
If the text of any of wxDataViewCtrl cells was set before the control was
realized (e.g. during its creation), the code tried to refresh the not yet
shown widget resulting in GTK+ errors.
Avoid this by only refreshing the tree if it's realized.
Vadim Zeitlin [Mon, 22 Aug 2011 15:31:36 +0000 (15:31 +0000)]
Return non-const pointer from wxDataViewRendererBase::GetView().
Non-const wxWindow pointers are unfortunately needed quite often in wx API so
return a non-const pointer here to allow using it with e.g. wxRendererNative
(whose methods all take non-const wxWindow pointers) in the derived classes.
Vadim Zeitlin [Mon, 22 Aug 2011 15:31:33 +0000 (15:31 +0000)]
Add wxDataViewIconText::IsSameAs() and make comparison operators members.
Add IsSameAs() to make it simpler to call from the derived class operator==()
implementation.
Also make comparison operators themselves members instead of global functions
to avoid considering them as matches for all operator==() uses in the program,
there is really no need for this as we do _not_ want to allow implicitly
converting something to wxDataViewIconText when comparing.
Vadim Zeitlin [Mon, 22 Aug 2011 12:18:33 +0000 (12:18 +0000)]
Add @genericAppearance Doxygen macro.
This allows to provide just a single image (in "generic" subdirectory) for the
generic controls that look the same in all ports instead of having to create
three identical ones (in "wxmsw", "wxgtk" and "wxmac" subdirectories) that are
required by @appearance.
Vadim Zeitlin [Mon, 22 Aug 2011 12:13:39 +0000 (12:13 +0000)]
Fix the coordinates in wxDataViewCustomRenderer::LeftClick() in generic wxDVC.
The code in generic wxDataViewCtrl implementation didn't take the space taken
by tree expander button nor the indentation of child nodes into account, so
the coordinates passed to LeftClick() could be completely wrong.
Fix this by offsetting them to ensure that click coordinates are always
relative to the cell client area.
Vadim Zeitlin [Sun, 21 Aug 2011 14:08:56 +0000 (14:08 +0000)]
Refactor: replace wxTreeItemId and wxDataViewItem with new wxItemId<>.
Add wxItemId<> template which can be used to identify items in different
{tree,list}-like controls, including wxDataViewCtrl (where it replaces, in
backwards compatible way, wxDataViewItem), wxTreeCtrl (where it replaces
wxTreeItemId) and the upcoming wxTreeListCtrl.
Vadim Zeitlin [Sun, 21 Aug 2011 14:08:49 +0000 (14:08 +0000)]
No changes, just use symbolic NO_IMAGE constant instead of -1 or wxNOT_FOUND.
Existing declarations used -1 in several places to indicate the absence of the
image which wasn't especially clear and was also inconsistent with other
places that used wxNOT_FOUND which didn't make much sense in this context.
Add a new symbolic constant NO_IMAGE in wxWithImages and use it in the classes
deriving from it. This still doesn't help with wx{Tree,List}Ctrl but improves
clarity for the other classes.
Vadim Zeitlin [Sun, 21 Aug 2011 14:08:43 +0000 (14:08 +0000)]
Add wxWithImages helper mix-in with {Set,Get,Assign}ImageList() methods.
Avoid defining SetImageList() in several different places in wx API as not
only this resulted in (trivial) code duplication but this method also had
different semantics before: it didn't take ownership of the pointer passed to
it in wxTreeCtrl, wxListCtrl and wxBookCtrl and derived classes but did take
its ownership in wxDataViewTreeCtrl and wxRichTextFormattingDialog.
Harmonize this for all the classes now: SetImageList() never takes ownership
while AssignImageList() (which is now available in all classes having
SetImageList()) always does.
Also add convenience wxWithImages::GetImage() helper to avoid (more) code
duplication in wxDataViewTreeCtrl code.
Vadim Zeitlin [Sun, 21 Aug 2011 12:06:16 +0000 (12:06 +0000)]
Replace wxComboBox::IsEmpty() with Is{List,Text}Empty().
IsEmpty() didn't exist in all ports (notably not wxMSW) and its meaning was
unclear anyhow, so remove it even from the ports where it did exist and add
clear Is{List,Text}Empty() replacements instead.
Václav Slavík [Sun, 21 Aug 2011 09:07:02 +0000 (09:07 +0000)]
Fix autosize columns width calculation in generic wxDataViewCtrl.
Column widths were recomputed too soon -- after the model changed, but
before the control's own data structures were updated to reflect the
change. This could lead to incorrect calculations or worse, crashes.
Added option to TIFF handler for specifying the photometric interpretation.
Added option wxIMAGE_OPTION_TIFF_PHOTOMETRIC for reading and writing TIFF images. This is mostly for being able to distinguish between PHOTOMETRIC_MINISBLACK (chocolate flavour) and PHOTOMETRIC_MINISWHITE (vanilla) as currently the flavour used was fixed. It applies to greyscale as well as black and white images. Added unit tests to verify the written photometric value.
When saving with a samples per pixel value of 1 the TIFF handler still treated the image as RGB, resulting in corrupted images. Handle the greyscale case and added a unit test for it.
Changed TIFF handler's monochrome conversion to look at the green channel instead of red.
It's common when reducing a coloured image to greyscale or black and white to give the green channel more significance. Since we're only looking at a single channel use the green one instead of red.
Fixed crash when saving as a monochrome TIFF image with incomplete options set.
When setting only wxIMAGE_OPTION_TIFF_BITSPERSAMPLE to 1 the used samples per pixel (wxIMAGE_OPTION_TIFF_SAMPLESPERPIXEL) would still be set to 3. This is invalid and confuses libtiff, resulting in a crash ("possible heap corruption" during _TIFFfree using WinXP+MSVC8). Set the used samples per pixel to 1 explicitly in cases where only bits per sample is set to 1. Added a unit test to check for this problem (and verify the bits per sample from the saved image is indeed 1).
The loading/saving options that are specific for TIFF were in the form of wxIMAGE_OPTION_<name> while all other non-generic options use the form wxIMAGE_OPTION_<imagetype>_<name>. Renamed the TIFF options to the form wxIMAGE_OPTION_TIFF_<name> and kept the old names for backwards compatibility.
moved description of wxIMAGE_OPTION_GIF_COMMENT from wxImage::GetOptionInt documentation to wxImage::GetOption because the value of the GIF option is a string, not int.
When reducing an RGB image to black and white any non-black pixel was treated as white resulting in mostly white images. Set the threshold to 127 instead to improve the looks of saved monochrome TIFF images.
Libtiff attempts to seek past the end of a stream and the behaviour for this can vary per stream implementation. Fixed failure to seek by filling the gap between the end of stream and new seek position with zeroes. Enabled a unit test which so far was disabled due to wxMemoryOutputStream failing to save a TIFF because of the seeking problem.
The BMP decoder did not handle images that are not stored upside down but straight up (in which case the height is negative). Also with RLE4 or RLE8 compressed images the 'end of scanline' RLE marker was not handled correctly. Fixed the issues and added a unit test for them.
Paul Cornett [Tue, 16 Aug 2011 07:02:37 +0000 (07:02 +0000)]
Avoid creating rect with negative size while clipping to DC size.
Also, don't convert result of wxDC::GetSize() to device coords, it's already device coords.
Vadim Zeitlin [Sun, 14 Aug 2011 19:39:31 +0000 (19:39 +0000)]
Fix return value of wxMBConvUTF8::ToWChar() when not using MAP_INVALID_UTF8_NOT.
wxMBConvUTF8::ToWChar() was off by 1 when the input length was explicitly
specified, the extra NUL should only be added in the implicit length case.
This bug didn't occur for the default wxMBConvUTF8 object as it simply
forwarded to the base class wxMBConvStrictUTF8 implementation but it happened
when MAP_INVALID_UTF8_TO_OCTAL or MAP_INVALID_UTF8_TO_PUA was used.
Vadim Zeitlin [Sat, 13 Aug 2011 13:54:26 +0000 (13:54 +0000)]
Fix bitmap position attribute name in XRC handler.
Bitmap position attribute was called "bitmapposition" in the documentation and
in the code that generated an error message for a wrong value in it but was
inexplicably called "direction" in the code that really looked it up.
This seems to be just a straight typo from the original r61065. Surprising as
it is that it wasn't noticed before, do correct it now.
Vadim Zeitlin [Fri, 12 Aug 2011 14:09:41 +0000 (14:09 +0000)]
No changes, just remove gratuitous inefficiency from generic wxDVC.
Don't return wxDataViewMainWindow::m_selection array by value, returning a
const reference to it is enough and avoids completely unnecessary memory
allocations and copying of potentially large amounts of data.
Also make wxDataViewMainWindow::GetSelections() const.
Vadim Zeitlin [Fri, 12 Aug 2011 14:09:37 +0000 (14:09 +0000)]
Fix compilation of generic wxDVC code when not using STL containers.
wx sorted containers don't implement iterators so use indices to iterate over
wxDataViewMainWindow::m_selection, just as r68613 already did in another place.
Vadim Zeitlin [Thu, 11 Aug 2011 10:56:05 +0000 (10:56 +0000)]
Use separate strings for stock labels with and without mnemonics.
Obtaining the string without mnemonics by simply removing "&" characters from
the string containing mnemonics doesn't work for some languages, notably
Chinese where the convention is to use "Chinese Text (&M)" for the labels with
"M" being the ASCII mnemonic and just "Chinese Text" and not "Chinese Text (M)"
should be used if wxSTOCK_WITH_MNEMONIC flag is not specified.
Fix the fundamental problem by using separate strings for the two cases.
Translations still need to be updated to really correct the labels appearance.
Since r68621 dataview.cpp didn't compile anymore (at least with wxOSX-Carbon). Fixed by explicitly using wxDataViewItem's void * constructor in a few cases.
The code to update m_selection was too aggressive in the virtual list
case, when it simply cleared it, and broken for single-item selection in
the general case.
Fixed to recompute selection properly.
Václav Slavík [Wed, 10 Aug 2011 15:21:22 +0000 (15:21 +0000)]
Make the wxDataViewItem(void*) constructor explicit.
Not having this as an implicit one made it possible to create
wxDataViewItem from any pointer without realizing it, leading to hard to
debug crashes later.
Added NSApplicationDelegate's openFiles for wxOSX-Cocoa.
openFiles (available since OS X 10.3) replaces using the openFile method. It allows for more convenient handling of multiple drops and knowing in advance how much files/folders are dropped instead of openFile with which you only get to respond to a single file/folder drop at a time. By default openFiles calls the newly added MacOpenFiles which calls MacOpenFile multiple times, so ordinarily the behaviour is backwards compatible (both on wxOSX Cocoa and Carbon).
The openFile instance method has been removed because it doesn't seem to be called anymore: neither when dropping a single file on the application in the dock or Finder nor when passed as a command-line argument.
Vadim Zeitlin [Mon, 8 Aug 2011 15:15:50 +0000 (15:15 +0000)]
Don't manually centre dialogs created with default position in wxMSW.
We always centered the dialogs on the main display which was wrong if the
parent window was on another one. Instead of fixing it, simply don't centre
them at all and let Windows position them, there is no reason to change the
default behaviour.
Václav Slavík [Mon, 8 Aug 2011 10:11:04 +0000 (10:11 +0000)]
Remove selection methods taking int from generic wxDataViewCtrl.
Current public API uses wxDataViewItem, this code dated back to 2.8.
They were now protected instead of public, the code wasn't used
anywhere and wasn't portable, it existed only in the generic version.
Vadim Zeitlin [Mon, 8 Aug 2011 09:32:39 +0000 (09:32 +0000)]
Added private wxMenu::MSWNewFromHMENU() method.
Add a method allowing creation of a wxMenu object from a native menu handle.
This will be used to implement access to the system menu in an upcoming commit
but could also be useful for other purposes.
Vadim Zeitlin [Mon, 8 Aug 2011 08:33:19 +0000 (08:33 +0000)]
Fix compilation with g++ 4.7 (prerelease).
The workaround for a bug in g++ 3.5 breaks compilation with 4.7 which
implements two-phase lookup correctly, so disable this workaround for 4.7 and
later. We could probably even only enable it for 3.x but this doesn't really
matter as previous 4.x releases don't have problems with this anyhow.
Vadim Zeitlin [Thu, 4 Aug 2011 22:53:42 +0000 (22:53 +0000)]
Add support for wxHELP button to wxMessageDialog.
Implement support for wxHELP for wxMSW, wxGTK and wxOSX/Cocoa (at least when
showing the message box from the main thread, there doesn't seem to be any way
to show more than three buttons with CFUserNotificationDisplayAlert() so
"Help" button is not supported when using it).
This is useful not only on its own, i.e. to allow the user to ask for help,
but also because it brings the total number of buttons supported by the
message dialog to 4, meaning that more choices can be offered to the user
(which is rarely, but not quite never, useful).
Vadim Zeitlin [Thu, 4 Aug 2011 16:12:41 +0000 (16:12 +0000)]
Add missing header for minimalistic builds not using PCH.
wxWindow might not be fully declared in dcbase.cpp but we need its full
declaration for wxDCImpl::InheritAttributes() so explicitly include
wx/window.h -- while this is usually already included from somewhere else it
might not be in minimal builds with a lot of features disabled.
Vadim Zeitlin [Thu, 4 Aug 2011 16:12:31 +0000 (16:12 +0000)]
Use wxWindowMSW instead of wxWindow to fix wxUniv/MSW compilation.
wxFindWindowAtPoint() only returns wxWindowMSW, not the derived wxWindow, in
wxUniv build so assign its return value to wxWindowMSW to avoid compilation
problems in it.
Vadim Zeitlin [Thu, 4 Aug 2011 13:19:57 +0000 (13:19 +0000)]
Avoid unwanted line break in wxDataViewListModel::GetCount() docs.
Using "i.e." in the brief Doxygen comment makes it end it after the second
period and results in truncated brief description and an unwanted line break
in the full description.
Just avoid using periods for now inside the brief description. Maybe a better
solution could be found in the future.