Merge pull request #1591 from turtleli/update-wx

3rdparty: Update wxWidgets to latest 3.0.x git branch
This commit is contained in:
Jonathan Li 2016-10-01 02:34:45 +01:00 committed by GitHub
commit e8ab0f6e85
125 changed files with 1714 additions and 878 deletions

View File

@ -164,13 +164,17 @@ private:
public: \ public: \
static bool IsSameClass(const wxAnyValueType* otherType) \ static bool IsSameClass(const wxAnyValueType* otherType) \
{ \ { \
return wxTypeId(*sm_instance.get()) == wxTypeId(*otherType); \ return AreSameClasses(*sm_instance.get(), *otherType); \
} \ } \
virtual bool IsSameType(const wxAnyValueType* otherType) const \ virtual bool IsSameType(const wxAnyValueType* otherType) const \
{ \ { \
return IsSameClass(otherType); \ return IsSameClass(otherType); \
} \ } \
private: \ private: \
static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b) \
{ \
return wxTypeId(a) == wxTypeId(b); \
} \
static wxAnyValueTypeScopedPtr sm_instance; \ static wxAnyValueTypeScopedPtr sm_instance; \
public: \ public: \
static wxAnyValueType* GetInstance() \ static wxAnyValueType* GetInstance() \

View File

@ -51,9 +51,11 @@ public:
if ( !m_argsA ) if ( !m_argsA )
{ {
const size_t count = m_args.size(); const size_t count = m_args.size();
m_argsA = new char *[count]; m_argsA = new char *[count + 1];
for ( size_t n = 0; n < count; n++ ) for ( size_t n = 0; n < count; n++ )
m_argsA[n] = wxStrdup(m_args[n].ToAscii()); m_argsA[n] = wxStrdup(m_args[n].ToAscii());
m_argsA[count] = NULL;
} }
return m_argsA; return m_argsA;
@ -64,9 +66,11 @@ public:
if ( !m_argsW ) if ( !m_argsW )
{ {
const size_t count = m_args.size(); const size_t count = m_args.size();
m_argsW = new wchar_t *[count]; m_argsW = new wchar_t *[count + 1];
for ( size_t n = 0; n < count; n++ ) for ( size_t n = 0; n < count; n++ )
m_argsW[n] = wxStrdup(m_args[n].wc_str()); m_argsW[n] = wxStrdup(m_args[n].wc_str());
m_argsW[count] = NULL;
} }
return m_argsW; return m_argsW;

View File

@ -357,7 +357,21 @@ typedef short int WXTYPE;
#endif #endif
#endif #endif
#if defined(__has_include) /*
Check for C++11 compilers, it is important to do it before the
__has_include() checks because of g++ 4.9.2+ complications below.
*/
#if (defined(__cplusplus) && __cplusplus >= 201103L) || wxCHECK_VISUALC_VERSION(10)
#ifndef HAVE_TYPE_TRAITS
#define HAVE_TYPE_TRAITS
#endif
#ifndef HAVE_STD_UNORDERED_MAP
#define HAVE_STD_UNORDERED_MAP
#endif
#ifndef HAVE_STD_UNORDERED_SET
#define HAVE_STD_UNORDERED_SET
#endif
#elif defined(__has_include)
/* /*
Notice that we trust our configure tests more than __has_include(), Notice that we trust our configure tests more than __has_include(),
notably the latter can return true even if the header exists but isn't notably the latter can return true even if the header exists but isn't
@ -365,8 +379,20 @@ typedef short int WXTYPE;
So if configure already detected at least one working alternative, So if configure already detected at least one working alternative,
just use it. just use it.
*/ */
/*
Since 4.9.2, g++ provides __has_include() but, unlike clang, refuses to
compile the C++11 headers in C++98 mode (and we are sure we use the
latter because we explicitly checked for C++11 above).
*/
#if defined(__GNUC__) && !defined(__clang__)
#define wx_has_cpp11_include(h) 0
#else
#define wx_has_cpp11_include(h) __has_include(h)
#endif
#if !defined(HAVE_TYPE_TRAITS) && !defined(HAVE_TR1_TYPE_TRAITS) #if !defined(HAVE_TYPE_TRAITS) && !defined(HAVE_TR1_TYPE_TRAITS)
#if __has_include(<type_traits>) #if wx_has_cpp11_include(<type_traits>)
#define HAVE_TYPE_TRAITS #define HAVE_TYPE_TRAITS
#elif __has_include(<tr1/type_traits>) #elif __has_include(<tr1/type_traits>)
#define HAVE_TR1_TYPE_TRAITS #define HAVE_TR1_TYPE_TRAITS
@ -374,7 +400,7 @@ typedef short int WXTYPE;
#endif #endif
#if !defined(HAVE_STD_UNORDERED_MAP) && !defined(HAVE_TR1_UNORDERED_MAP) #if !defined(HAVE_STD_UNORDERED_MAP) && !defined(HAVE_TR1_UNORDERED_MAP)
#if __has_include(<unordered_map>) #if wx_has_cpp11_include(<unordered_map>)
#define HAVE_STD_UNORDERED_MAP #define HAVE_STD_UNORDERED_MAP
#elif __has_include(<tr1/unordered_map>) #elif __has_include(<tr1/unordered_map>)
#define HAVE_TR1_UNORDERED_MAP #define HAVE_TR1_UNORDERED_MAP
@ -382,7 +408,7 @@ typedef short int WXTYPE;
#endif #endif
#if !defined(HAVE_STD_UNORDERED_SET) && !defined(HAVE_TR1_UNORDERED_SET) #if !defined(HAVE_STD_UNORDERED_SET) && !defined(HAVE_TR1_UNORDERED_SET)
#if __has_include(<unordered_set>) #if wx_has_cpp11_include(<unordered_set>)
#define HAVE_STD_UNORDERED_SET #define HAVE_STD_UNORDERED_SET
#elif __has_include(<tr1/unordered_set>) #elif __has_include(<tr1/unordered_set>)
#define HAVE_TR1_UNORDERED_SET #define HAVE_TR1_UNORDERED_SET
@ -1787,7 +1813,12 @@ enum wxBorder
/* /*
* Window (Frame/dialog/subwindow/panel item) style flags * Window (Frame/dialog/subwindow/panel item) style flags
*/ */
#define wxVSCROLL 0x80000000
/* The cast is needed to avoid g++ -Wnarrowing warnings when initializing
* values of int type with wxVSCROLL on 32 bit platforms, where its value is
* greater than INT_MAX.
*/
#define wxVSCROLL ((int)0x80000000)
#define wxHSCROLL 0x40000000 #define wxHSCROLL 0x40000000
#define wxCAPTION 0x20000000 #define wxCAPTION 0x20000000
@ -3169,14 +3200,22 @@ DECLARE_WXCOCOA_OBJC_CLASS(UIImage);
DECLARE_WXCOCOA_OBJC_CLASS(UIEvent); DECLARE_WXCOCOA_OBJC_CLASS(UIEvent);
DECLARE_WXCOCOA_OBJC_CLASS(NSSet); DECLARE_WXCOCOA_OBJC_CLASS(NSSet);
DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext); DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext);
DECLARE_WXCOCOA_OBJC_CLASS(UIWebView);
typedef WX_UIWindow WXWindow; typedef WX_UIWindow WXWindow;
typedef WX_UIView WXWidget; typedef WX_UIView WXWidget;
typedef WX_EAGLContext WXGLContext; typedef WX_EAGLContext WXGLContext;
typedef WX_NSString* WXGLPixelFormat; typedef WX_NSString* WXGLPixelFormat;
typedef WX_UIWebView OSXWebViewPtr;
#endif #endif
#if wxOSX_USE_COCOA_OR_CARBON
DECLARE_WXCOCOA_OBJC_CLASS(WebView);
typedef WX_WebView OSXWebViewPtr;
#endif
#endif /* __WXMAC__ */ #endif /* __WXMAC__ */
/* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */ /* ABX: check __WIN32__ instead of __WXMSW__ for the same MSWBase in any Win32 port */

View File

@ -11,6 +11,8 @@
#ifndef _WX_DIRDLG_H_BASE_ #ifndef _WX_DIRDLG_H_BASE_
#define _WX_DIRDLG_H_BASE_ #define _WX_DIRDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_DIRDLG #if wxUSE_DIRDLG
#include "wx/dialog.h" #include "wx/dialog.h"

View File

@ -216,9 +216,23 @@ enum wxPosixPermissions
#define wxFtell _ftelli64 #define wxFtell _ftelli64
#elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc) #elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
#define wxHAS_HUGE_STDIO_FILES #define wxHAS_HUGE_STDIO_FILES
wxDECL_FOR_STRICT_MINGW32(int, fseeko64, (FILE*, long long, int));
#define wxFseek fseeko64 #define wxFseek fseeko64
#ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
// Unfortunately ftello64() is not defined in the library for
// whatever reason but as an inline function, so define wxFtell()
// here similarly.
inline long long wxFtell(FILE* fp)
{
fpos_t pos;
return fgetpos(fp, &pos) == 0 ? pos : -1LL;
}
#else
#define wxFtell ftello64 #define wxFtell ftello64
#endif #endif
#endif
// other Windows compilers (DMC, Watcom, and Borland) don't have huge file // other Windows compilers (DMC, Watcom, and Borland) don't have huge file
// support (or at least not all functions needed for it by wx) currently // support (or at least not all functions needed for it by wx) currently
@ -376,7 +390,7 @@ enum wxPosixPermissions
// finally the default char-type versions // finally the default char-type versions
#if wxUSE_UNICODE #if wxUSE_UNICODE
#if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__) #if wxUSE_UNICODE_MSLU
// implement the missing file functions in Win9x ourselves // implement the missing file functions in Win9x ourselves
WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name, WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name,
int flags, int mode); int flags, int mode);
@ -404,6 +418,9 @@ enum wxPosixPermissions
#define wxCRT_MkDir wxCRT_MkDirW #define wxCRT_MkDir wxCRT_MkDirW
#define wxCRT_RmDir wxCRT_RmDirW #define wxCRT_RmDir wxCRT_RmDirW
#define wxCRT_Stat wxCRT_StatW #define wxCRT_Stat wxCRT_StatW
wxDECL_FOR_STRICT_MINGW32(int, _wmkdir, (const wchar_t*))
wxDECL_FOR_STRICT_MINGW32(int, _wrmdir, (const wchar_t*))
#endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU #endif // wxUSE_UNICODE_MSLU/!wxUSE_UNICODE_MSLU
#else // !wxUSE_UNICODE #else // !wxUSE_UNICODE
#define wxCRT_Open wxCRT_OpenA #define wxCRT_Open wxCRT_OpenA

View File

@ -227,6 +227,9 @@ public:
// init with the parameters of the given font // init with the parameters of the given font
void InitFromFont(const wxFont& font) void InitFromFont(const wxFont& font)
{ {
#if wxUSE_PANGO
Init(*font.GetNativeFontInfo());
#else
// translate all font parameters // translate all font parameters
SetStyle((wxFontStyle)font.GetStyle()); SetStyle((wxFontStyle)font.GetStyle());
SetWeight((wxFontWeight)font.GetWeight()); SetWeight((wxFontWeight)font.GetWeight());
@ -252,6 +255,7 @@ public:
// deal with encoding now (it may override the font family and facename // deal with encoding now (it may override the font family and facename
// so do it after setting them) // so do it after setting them)
SetEncoding(font.GetEncoding()); SetEncoding(font.GetEncoding());
#endif // !wxUSE_PANGO
} }
// accessors and modifiers for the font elements // accessors and modifiers for the font elements

View File

@ -179,6 +179,7 @@ private:
void OnPaint(wxPaintEvent& event); void OnPaint(wxPaintEvent& event);
void OnClick(wxMouseEvent& event); void OnClick(wxMouseEvent& event);
void OnDClick(wxMouseEvent& event); void OnDClick(wxMouseEvent& event);
void OnWheel(wxMouseEvent& event);
void OnChar(wxKeyEvent& event); void OnChar(wxKeyEvent& event);
void OnMonthChange(wxCommandEvent& event); void OnMonthChange(wxCommandEvent& event);

View File

@ -863,6 +863,7 @@ private:
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
friend class wxGenericListCtrl; friend class wxGenericListCtrl;
friend class wxListCtrlMaxWidthCalculator;
}; };
#endif // wxUSE_LISTCTRL #endif // wxUSE_LISTCTRL

View File

@ -0,0 +1,123 @@
/////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/private/widthcalc.h
// Purpose: wxMaxWidthCalculatorBase helper class.
// Author: Václav Slavík, Kinaou Hervé
// Copyright: (c) 2015 wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifndef _WX_GENERIC_PRIVATE_WIDTHCALC_H_
#define _WX_GENERIC_PRIVATE_WIDTHCALC_H_
#include "wx/defs.h"
#if wxUSE_DATAVIEWCTRL || wxUSE_LISTCTRL
#include "wx/log.h"
#include "wx/timer.h"
// ----------------------------------------------------------------------------
// wxMaxWidthCalculatorBase: base class for calculating max column width
// ----------------------------------------------------------------------------
class wxMaxWidthCalculatorBase
{
public:
// column of which calculate the width
explicit wxMaxWidthCalculatorBase(size_t column)
: m_column(column),
m_width(0)
{
}
void UpdateWithWidth(int width)
{
m_width = wxMax(m_width, width);
}
// Update the max with for the expected row
virtual void UpdateWithRow(int row) = 0;
int GetMaxWidth() const { return m_width; }
size_t GetColumn() const { return m_column; }
void
ComputeBestColumnWidth(size_t count,
size_t first_visible,
size_t last_visible)
{
// The code below deserves some explanation. For very large controls, we
// simply can't afford to calculate sizes for all items, it takes too
// long. So the best we can do is to check the first and the last N/2
// items in the control for some sufficiently large N and calculate best
// sizes from that. That can result in the calculated best width being too
// small for some outliers, but it's better to get slightly imperfect
// result than to wait several seconds after every update. To avoid highly
// visible miscalculations, we also include all currently visible items
// no matter what. Finally, the value of N is determined dynamically by
// measuring how much time we spent on the determining item widths so far.
#if wxUSE_STOPWATCH
size_t top_part_end = count;
static const long CALC_TIMEOUT = 20/*ms*/;
// don't call wxStopWatch::Time() too often
static const unsigned CALC_CHECK_FREQ = 100;
wxStopWatch timer;
#else
// use some hard-coded limit, that's the best we can do without timer
size_t top_part_end = wxMin(500, count);
#endif // wxUSE_STOPWATCH/!wxUSE_STOPWATCH
size_t row = 0;
for ( row = 0; row < top_part_end; row++ )
{
#if wxUSE_STOPWATCH
if ( row % CALC_CHECK_FREQ == CALC_CHECK_FREQ-1 &&
timer.Time() > CALC_TIMEOUT )
break;
#endif // wxUSE_STOPWATCH
UpdateWithRow(row);
}
// row is the first unmeasured item now; that's our value of N/2
if ( row < count )
{
top_part_end = row;
// add bottom N/2 items now:
const size_t bottom_part_start = wxMax(row, count - row);
for ( row = bottom_part_start; row < count; row++ )
{
UpdateWithRow(row);
}
// finally, include currently visible items in the calculation:
first_visible = wxMax(first_visible, top_part_end);
last_visible = wxMin(bottom_part_start, last_visible);
for ( row = first_visible; row < last_visible; row++ )
{
UpdateWithRow(row);
}
wxLogTrace("items container",
"determined best size from %zu top, %zu bottom "
"plus %zu more visible items out of %zu total",
top_part_end,
count - bottom_part_start,
wxMax(0, last_visible - first_visible),
count);
}
}
private:
const size_t m_column;
int m_width;
wxDECLARE_NO_COPY_CLASS(wxMaxWidthCalculatorBase);
};
#endif // wxUSE_DATAVIEWCTRL || wxUSE_LISTCTRL
#endif // _WX_GENERIC_PRIVATE_WIDTHCALC_H_

View File

@ -48,7 +48,10 @@ enum
WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits) WX_GL_MIN_ACCUM_BLUE, // use blue buffer with most bits (> MIN_ACCUM_BLUE bits)
WX_GL_MIN_ACCUM_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits) WX_GL_MIN_ACCUM_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
WX_GL_SAMPLE_BUFFERS, // 1 for multisampling support (antialiasing) WX_GL_SAMPLE_BUFFERS, // 1 for multisampling support (antialiasing)
WX_GL_SAMPLES // 4 for 2x2 antialiasing supersampling on most graphics cards WX_GL_SAMPLES, // 4 for 2x2 antialiasing supersampling on most graphics cards
WX_GL_CORE_PROFILE, // use an OpenGL core profile
WX_GL_MAJOR_VERSION, // major OpenGL version of the core profile
WX_GL_MINOR_VERSION // minor OpenGL version of the core profile
}; };
#define wxGLCanvasName wxT("GLCanvas") #define wxGLCanvasName wxT("GLCanvas")

View File

@ -1487,7 +1487,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
#define wxDEFINE_EMPTY_LOG_FUNCTION2(level, argclass) \ #define wxDEFINE_EMPTY_LOG_FUNCTION2(level, argclass) \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxFormatString&)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxFormatString&)) \
WX_WATCOM_OR_MINGW_ONLY_CODE( \ WX_WATCOM_ONLY_CODE( \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const char*)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const char*)) \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wchar_t*)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wchar_t*)) \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \ WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \

View File

@ -15,6 +15,17 @@
#include "wx/defs.h" #include "wx/defs.h"
#ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
/*
In addition to declaring _finite() ourselves below, we also must work
around a compilation error in MinGW standard header itself, see
https://sourceforge.net/p/mingw/bugs/2250/
*/
#ifndef __NO_INLINE__
#define __NO_INLINE__
#endif
#endif
#include <math.h> #include <math.h>
#ifndef M_PI #ifndef M_PI
@ -53,11 +64,18 @@
#ifdef __cplusplus #ifdef __cplusplus
/* Any C++11 compiler should provide isfinite() */ /*
Things are simple with C++11: we have everything we need in std.
Eventually we will only have this section and not the legacy stuff below.
*/
#if __cplusplus >= 201103 #if __cplusplus >= 201103
#include <cmath> #include <cmath>
#define wxFinite(x) std::isfinite(x) #define wxFinite(x) std::isfinite(x)
#elif defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__) #define wxIsNaN(x) std::isnan(x)
#else /* C++98 */
#if defined(__VISUALC__) || defined(__BORLANDC__) || defined(__WATCOMC__)
#include <float.h> #include <float.h>
#define wxFinite(x) _finite(x) #define wxFinite(x) _finite(x)
#elif defined(__MINGW64_TOOLCHAIN__) || defined(__clang__) #elif defined(__MINGW64_TOOLCHAIN__) || defined(__clang__)
@ -71,6 +89,10 @@
#else #else
#define wxFinite(x) isfinite(x) #define wxFinite(x) isfinite(x)
#endif #endif
#elif defined(wxNEEDS_STRICT_ANSI_WORKAROUNDS)
wxDECL_FOR_STRICT_MINGW32(int, _finite, (double));
#define wxFinite(x) _finite(x)
#elif ( defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \ #elif ( defined(__GNUG__)||defined(__GNUWIN32__)||defined(__DJGPP__)|| \
defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \ defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \
defined(__HPUX__) ) && ( !defined(wxOSX_USE_IPHONE) || wxOSX_USE_IPHONE == 0 ) defined(__HPUX__) ) && ( !defined(wxOSX_USE_IPHONE) || wxOSX_USE_IPHONE == 0 )
@ -93,6 +115,8 @@
#define wxIsNaN(x) ((x) != (x)) #define wxIsNaN(x) ((x) != (x))
#endif #endif
#endif /* C++11/C++98 */
#ifdef __INTELC__ #ifdef __INTELC__
inline bool wxIsSameDouble(double x, double y) inline bool wxIsSameDouble(double x, double y)

View File

@ -101,6 +101,11 @@ public:
wxString GetCaption() const { return m_caption; } wxString GetCaption() const { return m_caption; }
// Title and caption are the same thing, GetCaption() mostly exists just
// for compatibility.
virtual void SetTitle(const wxString& title) { m_caption = title; }
virtual wxString GetTitle() const { return m_caption; }
virtual void SetMessage(const wxString& message) virtual void SetMessage(const wxString& message)
{ {
m_message = message; m_message = message;

View File

@ -15,7 +15,20 @@
#include "wx/msw/wrapwin.h" #include "wx/msw/wrapwin.h"
#ifndef __WXWINCE__ #ifndef __WXWINCE__
#ifdef __VISUALC__
// Disable a warning that we can do nothing about: we get it at least for
// imagehlp.h from 8.1 Windows kit when using VC14.
#pragma warning(push)
// 'typedef ': ignored on left of '' when no variable is declared
#pragma warning(disable:4091)
#endif
#include <imagehlp.h> #include <imagehlp.h>
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#endif // __WXWINCE__ #endif // __WXWINCE__
#include "wx/msw/private.h" #include "wx/msw/private.h"

View File

@ -156,5 +156,28 @@
#endif #endif
#endif #endif
/*
Traditional MinGW (but not MinGW-w64 nor TDM-GCC) omits many POSIX
functions from their headers when compiled with __STRICT_ANSI__ defined.
Unfortunately this means that they are not available when using -std=c++98
(not very common) or -std=c++11 (much more so), but we still need them even
in this case. As the intention behind using -std=c++11 is probably to get
the new C++11 features and not disable the use of POSIX functions, we just
manually declare the functions we need in this case if necessary.
*/
#if defined(__MINGW32_TOOLCHAIN__) && defined(__STRICT_ANSI__)
#define wxNEEDS_STRICT_ANSI_WORKAROUNDS
/*
This macro is somewhat unusual as it takes the list of parameters
inside parentheses and includes semicolon inside it as putting the
semicolon outside wouldn't do the right thing when this macro is empty.
*/
#define wxDECL_FOR_STRICT_MINGW32(rettype, func, params) \
extern "C" _CRTIMP rettype __cdecl __MINGW_NOTHROW func params ;
#else
#define wxDECL_FOR_STRICT_MINGW32(rettype, func, params)
#endif
#endif #endif
/* _WX_MSW_GCCPRIV_H_ */ /* _WX_MSW_GCCPRIV_H_ */

View File

@ -30,6 +30,10 @@
typedef char *wxCmdLineArgType; typedef char *wxCmdLineArgType;
#endif #endif
// Call this function to prevent wxMSW from calling SetProcessDPIAware().
// Must be called before wxEntry().
extern WXDLLIMPEXP_CORE void wxMSWDisableSettingHighDPIAware();
// Windows-only overloads of wxEntry() and wxEntryStart() which take the // Windows-only overloads of wxEntry() and wxEntryStart() which take the
// parameters passed to WinMain() instead of those passed to main() // parameters passed to WinMain() instead of those passed to main()
extern WXDLLIMPEXP_CORE bool extern WXDLLIMPEXP_CORE bool

View File

@ -183,6 +183,8 @@ extern LONG APIENTRY _EXPORT
|| defined(__MINGW32__) || defined(__MINGW32__)
#define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd)) #define wxGetOSFHandle(fd) ((HANDLE)_get_osfhandle(fd))
#define wxOpenOSFHandle(h, flags) (_open_osfhandle(wxPtrToUInt(h), flags)) #define wxOpenOSFHandle(h, flags) (_open_osfhandle(wxPtrToUInt(h), flags))
wxDECL_FOR_STRICT_MINGW32(FILE*, _fdopen, (int, const char*))
#define wx_fdopen _fdopen #define wx_fdopen _fdopen
#endif #endif

View File

@ -312,7 +312,7 @@ protected:
virtual ExitCode Entry(); virtual ExitCode Entry();
// wait for events to occur, read them and send to interested parties // wait for events to occur, read them and send to interested parties
// returns false it empty status was read, which means we whould exit // returns false it empty status was read, which means we would exit
// true otherwise // true otherwise
bool ReadEvents(); bool ReadEvents();

View File

@ -123,7 +123,7 @@ public:
// hKey should be opened and will be closed in wxRegKey dtor // hKey should be opened and will be closed in wxRegKey dtor
void SetHkey(WXHKEY hKey); void SetHkey(WXHKEY hKey);
// get infomation about the key // get information about the key
// get the (full) key name. Abbreviate std root keys if bShortPrefix. // get the (full) key name. Abbreviate std root keys if bShortPrefix.
wxString GetName(bool bShortPrefix = true) const; wxString GetName(bool bShortPrefix = true) const;
// Retrieves the registry view used by this key. // Retrieves the registry view used by this key.
@ -132,7 +132,7 @@ public:
bool Exists() const; bool Exists() const;
// get the info about key (any number of these pointers may be NULL) // get the info about key (any number of these pointers may be NULL)
bool GetKeyInfo(size_t *pnSubKeys, // number of subkeys bool GetKeyInfo(size_t *pnSubKeys, // number of subkeys
size_t *pnMaxKeyLen, // max len of subkey name size_t *pnMaxKeyLen, // max length of subkey name
size_t *pnValues, // number of values size_t *pnValues, // number of values
size_t *pnMaxValueLen) const; size_t *pnMaxValueLen) const;
// return true if the key is opened // return true if the key is opened

View File

@ -152,6 +152,7 @@ private:
{ {
m_count = 0; m_count = 0;
m_hwnds = NULL; m_hwnds = NULL;
m_ids = NULL;
} }
// number of elements in m_hwnds array // number of elements in m_hwnds array

View File

@ -39,7 +39,7 @@ public:
// here, so explicitly preserve the last error here. // here, so explicitly preserve the last error here.
const DWORD dwLastError = ::GetLastError(); const DWORD dwLastError = ::GetLastError();
void* const value = ::TlsGetValue(m_slot); void* const value = ::TlsGetValue(m_slot);
if (dwLastError) if ( dwLastError )
::SetLastError(dwLastError); ::SetLastError(dwLastError);
return value; return value;
} }

View File

@ -692,7 +692,7 @@ public:
virtual HRESULT wxSTDCALL get_onpropertychange(VARIANT *p) = 0; virtual HRESULT wxSTDCALL get_onpropertychange(VARIANT *p) = 0;
virtual HRESULT wxSTDCALL getClientRects(wxIHTMLRectCollection **pRectCol) = 0; virtual HRESULT wxSTDCALL getClientRects(wxIHTMLRectCollection **pRectCol) = 0;
virtual HRESULT wxSTDCALL getBoundingClientRect(wxIHTMLRect **pRect) = 0; virtual HRESULT wxSTDCALL getBoundingClientRect(wxIHTMLRect **pRect) = 0;
virtual HRESULT wxSTDCALL setExpression(BSTR propname, BSTR expression, BSTR language = L"") = 0; virtual HRESULT wxSTDCALL setExpression(BSTR propname, BSTR expression, BSTR language) = 0;
virtual HRESULT wxSTDCALL getExpression(BSTR propname, VARIANT *expression) = 0; virtual HRESULT wxSTDCALL getExpression(BSTR propname, VARIANT *expression) = 0;
virtual HRESULT wxSTDCALL removeExpression(BSTR propname, VARIANT_BOOL *pfSuccess) = 0; virtual HRESULT wxSTDCALL removeExpression(BSTR propname, VARIANT_BOOL *pfSuccess) = 0;
virtual HRESULT wxSTDCALL put_tabIndex(short v) = 0; virtual HRESULT wxSTDCALL put_tabIndex(short v) = 0;

View File

@ -24,8 +24,21 @@
#define min(a,b) (((a) < (b)) ? (a) : (b)) #define min(a,b) (((a) < (b)) ? (a) : (b))
#endif #endif
// There are many clashes between the names of the member fields and parameters
// in the standard gdiplus.h header and each of them results in C4458 with
// VC14, so disable this warning for this file as there is no other way to
// avoid it.
#ifdef __VISUALC__
#pragma warning(push)
#pragma warning(disable:4458) // declaration of 'xxx' hides class member
#endif
#include <gdiplus.h> #include <gdiplus.h>
using namespace Gdiplus; using namespace Gdiplus;
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#endif // _WX_MSW_WRAPGDIP_H_ #endif // _WX_MSW_WRAPGDIP_H_

View File

@ -20,8 +20,21 @@
#include <shellapi.h> #include <shellapi.h>
#endif #endif
#ifdef __VISUALC__
// Disable a warning that we can do nothing about: we get it for
// shlobj.h at least from 7.1a Windows kit when using VC14.
#pragma warning(push)
// 'typedef ': ignored on left of '' when no variable is declared
#pragma warning(disable:4091)
#endif
#include <shlobj.h> #include <shlobj.h>
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#include "wx/msw/winundef.h" #include "wx/msw/winundef.h"
#include "wx/log.h" #include "wx/log.h"

View File

@ -310,7 +310,7 @@
*/ */
#elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \ #elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \
defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || \ defined(____SVR4____) || defined(__LINUX__) || defined(__sgi) || \
defined(__hpux) || defined(sun) || defined(__SUN__) || defined(_AIX) || \ defined(__hpux) || defined(__sun) || defined(__SUN__) || defined(_AIX) || \
defined(__EMX__) || defined(__VMS) || defined(__BEOS__) || defined(__MACH__) defined(__EMX__) || defined(__VMS) || defined(__BEOS__) || defined(__MACH__)
# define __UNIX_LIKE__ # define __UNIX_LIKE__
@ -459,6 +459,7 @@
# define wxCHECK_W32API_VERSION(maj, min) (0) # define wxCHECK_W32API_VERSION(maj, min) (0)
# undef wxCHECK_MINGW32_VERSION # undef wxCHECK_MINGW32_VERSION
# define wxCHECK_MINGW32_VERSION( major, minor ) (0) # define wxCHECK_MINGW32_VERSION( major, minor ) (0)
# define wxDECL_FOR_STRICT_MINGW32(rettype, func, params)
#endif #endif

View File

@ -308,6 +308,9 @@ public:
protected: protected:
wxSocketImpl(wxSocketBase& wxsocket); wxSocketImpl(wxSocketBase& wxsocket);
// get the associated socket flags
wxSocketFlags GetSocketFlags() const { return m_wxsocket->GetFlags(); }
// true if we're a listening stream socket // true if we're a listening stream socket
bool m_server; bool m_server;

View File

@ -381,7 +381,7 @@ struct wxPixelDataOut<wxImage>
{ {
m_pRGB += data.GetRowStride()*y + PixelFormat::SizePixel*x; m_pRGB += data.GetRowStride()*y + PixelFormat::SizePixel*x;
if ( m_pAlpha ) if ( m_pAlpha )
m_pAlpha += data.GetWidth() + x; m_pAlpha += data.GetWidth()*y + x;
} }
// move x pixels to the right (again, no row wrapping) // move x pixels to the right (again, no row wrapping)
@ -397,7 +397,7 @@ struct wxPixelDataOut<wxImage>
{ {
m_pRGB += data.GetRowStride()*y; m_pRGB += data.GetRowStride()*y;
if ( m_pAlpha ) if ( m_pAlpha )
m_pAlpha += data.GetWidth(); m_pAlpha += data.GetWidth()*y;
} }
// go to the given position // go to the given position

View File

@ -27,9 +27,9 @@
/* NB: this file is parsed by automatic tools so don't change its format! */ /* NB: this file is parsed by automatic tools so don't change its format! */
#define wxMAJOR_VERSION 3 #define wxMAJOR_VERSION 3
#define wxMINOR_VERSION 0 #define wxMINOR_VERSION 0
#define wxRELEASE_NUMBER 2 #define wxRELEASE_NUMBER 3
#define wxSUBRELEASE_NUMBER 0 #define wxSUBRELEASE_NUMBER 0
#define wxVERSION_STRING wxT("wxWidgets 3.0.2") #define wxVERSION_STRING wxT("wxWidgets 3.0.3")
/* nothing to update below this line when updating the version */ /* nothing to update below this line when updating the version */
/* ---------------------------------------------------------------------------- */ /* ---------------------------------------------------------------------------- */

View File

@ -73,6 +73,9 @@
#ifdef wxNEED_ISASCII #ifdef wxNEED_ISASCII
inline int isascii(int c) { return (unsigned)c < 0x80; } inline int isascii(int c) { return (unsigned)c < 0x80; }
// Avoid further (re)definitions of it.
#define isascii isascii
#endif #endif
#ifdef _WIN32_WCE #ifdef _WIN32_WCE
@ -445,7 +448,7 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
#else /* Unicode filenames */ #else /* Unicode filenames */
/* special case: these functions are missing under Win9x with Unicows so we /* special case: these functions are missing under Win9x with Unicows so we
have to implement them ourselves */ have to implement them ourselves */
#if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__) #if wxUSE_UNICODE_MSLU
WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name, const wchar_t *mode); WXDLLIMPEXP_BASE FILE* wxMSLU__wfopen(const wchar_t *name, const wchar_t *mode);
WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream); WXDLLIMPEXP_BASE FILE* wxMSLU__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream);
WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname, const wchar_t *newname); WXDLLIMPEXP_BASE int wxMSLU__wrename(const wchar_t *oldname, const wchar_t *newname);
@ -455,6 +458,11 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
#define wxCRT_Remove wxMSLU__wremove #define wxCRT_Remove wxMSLU__wremove
#define wxCRT_Rename wxMSLU__wrename #define wxCRT_Rename wxMSLU__wrename
#else #else
wxDECL_FOR_STRICT_MINGW32(FILE*, _wfopen, (const wchar_t*, const wchar_t*))
wxDECL_FOR_STRICT_MINGW32(FILE*, _wfreopen, (const wchar_t*, const wchar_t*, FILE*))
wxDECL_FOR_STRICT_MINGW32(int, _wrename, (const wchar_t*, const wchar_t*))
wxDECL_FOR_STRICT_MINGW32(int, _wremove, (const wchar_t*))
/* WinCE CRT doesn't provide these functions so use our own */ /* WinCE CRT doesn't provide these functions so use our own */
#ifdef __WXWINCE__ #ifdef __WXWINCE__
WXDLLIMPEXP_BASE int wxCRT_Rename(const wchar_t *src, WXDLLIMPEXP_BASE int wxCRT_Rename(const wchar_t *src,

View File

@ -38,79 +38,84 @@ wxAcceleratorTable wxNullAcceleratorTable;
// wxAcceleratorEntry implementation // wxAcceleratorEntry implementation
// ============================================================================ // ============================================================================
wxGCC_WARNING_SUPPRESS(missing-field-initializers)
static const struct wxKeyName static const struct wxKeyName
{ {
wxKeyCode code; wxKeyCode code;
const char *name; const char *name;
const char *display_name;
} wxKeyNames[] = } wxKeyNames[] =
{ {
{ WXK_DELETE, wxTRANSLATE("DEL") }, { WXK_DELETE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Delete") },
{ WXK_DELETE, wxTRANSLATE("DELETE") }, { WXK_DELETE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Del") },
{ WXK_BACK, wxTRANSLATE("BACK") }, { WXK_BACK, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Back"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Backspace") },
{ WXK_INSERT, wxTRANSLATE("INS") }, { WXK_INSERT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Insert") },
{ WXK_INSERT, wxTRANSLATE("INSERT") }, { WXK_INSERT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Ins") },
{ WXK_RETURN, wxTRANSLATE("ENTER") }, { WXK_RETURN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Enter") },
{ WXK_RETURN, wxTRANSLATE("RETURN") }, { WXK_RETURN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Return") },
{ WXK_PAGEUP, wxTRANSLATE("PGUP") }, { WXK_PAGEUP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("PageUp"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Page Up") },
{ WXK_PAGEDOWN, wxTRANSLATE("PGDN") }, { WXK_PAGEDOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("PageDown"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Page Down") },
{ WXK_LEFT, wxTRANSLATE("LEFT") }, { WXK_PAGEUP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("PgUp") },
{ WXK_RIGHT, wxTRANSLATE("RIGHT") }, { WXK_PAGEDOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("PgDn") },
{ WXK_UP, wxTRANSLATE("UP") }, { WXK_LEFT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Left"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Left") },
{ WXK_DOWN, wxTRANSLATE("DOWN") }, { WXK_RIGHT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Right"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Right") },
{ WXK_HOME, wxTRANSLATE("HOME") }, { WXK_UP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Up"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Up") },
{ WXK_END, wxTRANSLATE("END") }, { WXK_DOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Down"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Down") },
{ WXK_SPACE, wxTRANSLATE("SPACE") }, { WXK_HOME, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Home") },
{ WXK_TAB, wxTRANSLATE("TAB") }, { WXK_END, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("End") },
{ WXK_ESCAPE, wxTRANSLATE("ESC") }, { WXK_SPACE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Space") },
{ WXK_ESCAPE, wxTRANSLATE("ESCAPE") }, { WXK_TAB, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Tab") },
{ WXK_CANCEL, wxTRANSLATE("CANCEL") }, { WXK_ESCAPE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Esc") },
{ WXK_CLEAR, wxTRANSLATE("CLEAR") }, { WXK_ESCAPE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Escape") },
{ WXK_MENU, wxTRANSLATE("MENU") }, { WXK_CANCEL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Cancel") },
{ WXK_PAUSE, wxTRANSLATE("PAUSE") }, { WXK_CLEAR, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Clear") },
{ WXK_CAPITAL, wxTRANSLATE("CAPITAL") }, { WXK_MENU, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Menu") },
{ WXK_SELECT, wxTRANSLATE("SELECT") }, { WXK_PAUSE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Pause") },
{ WXK_PRINT, wxTRANSLATE("PRINT") }, { WXK_CAPITAL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Capital") },
{ WXK_EXECUTE, wxTRANSLATE("EXECUTE") }, { WXK_SELECT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Select") },
{ WXK_SNAPSHOT, wxTRANSLATE("SNAPSHOT") }, { WXK_PRINT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Print") },
{ WXK_HELP, wxTRANSLATE("HELP") }, { WXK_EXECUTE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Execute") },
{ WXK_ADD, wxTRANSLATE("ADD") }, { WXK_SNAPSHOT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Snapshot") },
{ WXK_SEPARATOR, wxTRANSLATE("SEPARATOR") }, { WXK_HELP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Help") },
{ WXK_SUBTRACT, wxTRANSLATE("SUBTRACT") }, { WXK_ADD, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Add") },
{ WXK_DECIMAL, wxTRANSLATE("DECIMAL") }, { WXK_SEPARATOR, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Separator") },
{ WXK_DIVIDE, wxTRANSLATE("DIVIDE") }, { WXK_SUBTRACT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Subtract") },
{ WXK_NUMLOCK, wxTRANSLATE("NUM_LOCK") }, { WXK_DECIMAL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Decimal") },
{ WXK_SCROLL, wxTRANSLATE("SCROLL_LOCK") }, { WXK_DIVIDE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Divide") },
{ WXK_PAGEUP, wxTRANSLATE("PAGEUP") }, { WXK_NUMLOCK, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num_lock"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Lock") },
{ WXK_PAGEDOWN, wxTRANSLATE("PAGEDOWN") }, { WXK_SCROLL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Scroll_lock"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Scroll Lock") },
{ WXK_NUMPAD_SPACE, wxTRANSLATE("KP_SPACE") }, { WXK_NUMPAD_SPACE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Space"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Space") },
{ WXK_NUMPAD_TAB, wxTRANSLATE("KP_TAB") }, { WXK_NUMPAD_TAB, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Tab"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Tab") },
{ WXK_NUMPAD_ENTER, wxTRANSLATE("KP_ENTER") }, { WXK_NUMPAD_ENTER, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Enter"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Enter") },
{ WXK_NUMPAD_HOME, wxTRANSLATE("KP_HOME") }, { WXK_NUMPAD_HOME, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Home"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Home") },
{ WXK_NUMPAD_LEFT, wxTRANSLATE("KP_LEFT") }, { WXK_NUMPAD_LEFT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Left"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num left") },
{ WXK_NUMPAD_UP, wxTRANSLATE("KP_UP") }, { WXK_NUMPAD_UP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Up"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Up") },
{ WXK_NUMPAD_RIGHT, wxTRANSLATE("KP_RIGHT") }, { WXK_NUMPAD_RIGHT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Right"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Right") },
{ WXK_NUMPAD_DOWN, wxTRANSLATE("KP_DOWN") }, { WXK_NUMPAD_DOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Down"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Down") },
{ WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PRIOR") }, { WXK_NUMPAD_PAGEUP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_PageUp"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Page Up") },
{ WXK_NUMPAD_PAGEUP, wxTRANSLATE("KP_PAGEUP") }, { WXK_NUMPAD_PAGEDOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_PageDown"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Page Down") },
{ WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_NEXT") }, { WXK_NUMPAD_PAGEUP, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Prior") },
{ WXK_NUMPAD_PAGEDOWN, wxTRANSLATE("KP_PAGEDOWN") }, { WXK_NUMPAD_PAGEDOWN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Next") },
{ WXK_NUMPAD_END, wxTRANSLATE("KP_END") }, { WXK_NUMPAD_END, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_End"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num End") },
{ WXK_NUMPAD_BEGIN, wxTRANSLATE("KP_BEGIN") }, { WXK_NUMPAD_BEGIN, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Begin"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Begin") },
{ WXK_NUMPAD_INSERT, wxTRANSLATE("KP_INSERT") }, { WXK_NUMPAD_INSERT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Insert"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Insert") },
{ WXK_NUMPAD_DELETE, wxTRANSLATE("KP_DELETE") }, { WXK_NUMPAD_DELETE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Delete"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num Delete") },
{ WXK_NUMPAD_EQUAL, wxTRANSLATE("KP_EQUAL") }, { WXK_NUMPAD_EQUAL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Equal"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num =") },
{ WXK_NUMPAD_MULTIPLY, wxTRANSLATE("KP_MULTIPLY") }, { WXK_NUMPAD_MULTIPLY, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Multiply"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num *") },
{ WXK_NUMPAD_ADD, wxTRANSLATE("KP_ADD") }, { WXK_NUMPAD_ADD, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Add"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num +") },
{ WXK_NUMPAD_SEPARATOR, wxTRANSLATE("KP_SEPARATOR") }, { WXK_NUMPAD_SEPARATOR, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Separator"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num ,") },
{ WXK_NUMPAD_SUBTRACT, wxTRANSLATE("KP_SUBTRACT") }, { WXK_NUMPAD_SUBTRACT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Subtract"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num -") },
{ WXK_NUMPAD_DECIMAL, wxTRANSLATE("KP_DECIMAL") }, { WXK_NUMPAD_DECIMAL, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Decimal"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num .") },
{ WXK_NUMPAD_DIVIDE, wxTRANSLATE("KP_DIVIDE") }, { WXK_NUMPAD_DIVIDE, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("KP_Divide"), /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Num /") },
{ WXK_WINDOWS_LEFT, wxTRANSLATE("WINDOWS_LEFT") }, { WXK_WINDOWS_LEFT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Windows_Left") },
{ WXK_WINDOWS_RIGHT, wxTRANSLATE("WINDOWS_RIGHT") }, { WXK_WINDOWS_RIGHT, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Windows_Right") },
{ WXK_WINDOWS_MENU, wxTRANSLATE("WINDOWS_MENU") }, { WXK_WINDOWS_MENU, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Windows_Menu") },
{ WXK_COMMAND, wxTRANSLATE("COMMAND") }, { WXK_COMMAND, /*TRANSLATORS: Name of keyboard key*/ wxTRANSLATE("Command") },
}; };
wxGCC_WARNING_RESTORE(missing-field-initializers)
// return true if the 2 strings refer to the same accel // return true if the 2 strings refer to the same accel
// //
// as accels can be either translated or not, check for both possibilities and // as accels can be either translated or not, check for both possibilities and
@ -346,7 +351,7 @@ wxString wxAcceleratorEntry::AsPossiblyLocalizedString(bool localized) const
const wxKeyName& kn = wxKeyNames[n]; const wxKeyName& kn = wxKeyNames[n];
if ( code == kn.code ) if ( code == kn.code )
{ {
text << PossiblyLocalize(kn.name, localized); text << PossiblyLocalize(kn.display_name ? kn.display_name : kn.name, localized);
break; break;
} }
} }

View File

@ -315,9 +315,9 @@ wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
wxAppTraits& wxAppConsoleBase::GetValidTraits() wxAppTraits& wxAppConsoleBase::GetValidTraits()
{ {
static wxConsoleAppTraits s_traitsConsole; static wxConsoleAppTraits s_traitsConsole;
wxAppTraits* const traits = wxTheApp ? wxTheApp->GetTraits() : NULL; wxAppTraits* const traits = (wxTheApp ? wxTheApp->GetTraits() : NULL);
return traits ? *traits : s_traitsConsole; return *(traits ? traits : &s_traitsConsole);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -690,9 +690,13 @@ int wxCmdLineParser::Parse(bool showUsage)
continue; continue;
} }
#ifdef __WXOSX__ #ifdef __WXOSX__
if ( arg == wxT("-ApplePersistenceIgnoreState") ) if ( arg == wxS("-ApplePersistenceIgnoreState") ||
arg == wxS("-AppleTextDirection") ||
arg == wxS("-AppleLocale") ||
arg == wxS("-AppleLanguages") )
{ {
maybeOption = false; maybeOption = false;
n++;
continue; continue;
} }

View File

@ -333,7 +333,10 @@ bool wxCommandProcessor::IsDirty() const
{ {
// We have never been saved, so we are dirty if and only if we have any // We have never been saved, so we are dirty if and only if we have any
// commands at all. // commands at all.
return m_currentCommand; //
// NB: The ugly "!!" test is needed to avoid warnings both from MSVC in
// non-STL build and g++ in STL build.
return !!m_currentCommand;
} }
if ( !m_currentCommand ) if ( !m_currentCommand )

View File

@ -343,9 +343,12 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
wxString format = formatp; wxString format = formatp;
#ifdef __WXOSX__ #ifdef __WXOSX__
format.Replace("%c",wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT)); if ( format.Contains("%c") )
format.Replace("%x",wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT)); format.Replace("%c", wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT));
format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT)); if ( format.Contains("%x") )
format.Replace("%x", wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT));
if ( format.Contains("%X") )
format.Replace("%X", wxLocale::GetInfo(wxLOCALE_TIME_FMT));
#endif #endif
// we have to use our own implementation if the date is out of range of // we have to use our own implementation if the date is out of range of
// strftime() // strftime()
@ -993,7 +996,14 @@ wxDateTime::ParseRfc822Date(const wxString& date, wxString::const_iterator *end)
// the spec was correct, construct the date from the values we found // the spec was correct, construct the date from the values we found
Set(day, mon, year, hour, min, sec); Set(day, mon, year, hour, min, sec);
MakeFromTimezone(TimeZone::Make(offset*SEC_PER_MIN));
// As always, dealing with the time zone is the most interesting part: we
// can't just use MakeFromTimeZone() here because it wouldn't handle the
// DST correctly because the TZ specified in the string is DST-invariant
// and so we have to manually shift to the UTC first and then convert to
// the local TZ.
*this -= wxTimeSpan::Minutes(offset);
MakeFromUTC();
if ( end ) if ( end )
*end = p; *end = p;

View File

@ -646,13 +646,12 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
m_graphicContext->PushState(); m_graphicContext->PushState();
m_graphicContext->Translate(dx, dy); m_graphicContext->Translate(dx, dy);
m_graphicContext->Scale(factor, 1.0); m_graphicContext->Scale(factor, 1.0);
wxGraphicsPath path; wxGraphicsPath path = m_graphicContext->CreatePath();
// since these angles (ea,sa) are measured counter-clockwise, we invert them to // since these angles (ea,sa) are measured counter-clockwise, we invert them to
// get clockwise angles // get clockwise angles
if ( m_brush.GetStyle() != wxTRANSPARENT ) if ( m_brush.GetStyle() != wxTRANSPARENT )
{ {
path = m_graphicContext->CreatePath();
path.MoveToPoint( 0, 0 ); path.MoveToPoint( 0, 0 );
path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea ); path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
path.AddLineToPoint( 0, 0 ); path.AddLineToPoint( 0, 0 );
@ -664,7 +663,6 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
} }
else else
{ {
wxGraphicsPath path = m_graphicContext->CreatePath();
path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea ); path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
m_graphicContext->DrawPath( path ); m_graphicContext->DrawPath( path );
} }
@ -878,10 +876,9 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
CalcBoundingBox(x, y); CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h); CalcBoundingBox(x + w, y + h);
if ( m_graphicContext->ShouldOffset() ) if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
{ {
// if we are offsetting the entire rectangle is moved 0.5, so the // outline is one pixel larger than what raster-based wxDC implementations draw
// border line gets off by 1
w -= 1; w -= 1;
h -= 1; h -= 1;
} }
@ -907,10 +904,9 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
CalcBoundingBox(x, y); CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h); CalcBoundingBox(x + w, y + h);
if ( m_graphicContext->ShouldOffset() ) if (m_pen.IsOk() && m_pen.GetStyle() != wxPENSTYLE_TRANSPARENT && m_pen.GetWidth() > 0)
{ {
// if we are offsetting the entire rectangle is moved 0.5, so the // outline is one pixel larger than what raster-based wxDC implementations draw
// border line gets off by 1
w -= 1; w -= 1;
h -= 1; h -= 1;
} }
@ -927,13 +923,6 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
CalcBoundingBox(x, y); CalcBoundingBox(x, y);
CalcBoundingBox(x + w, y + h); CalcBoundingBox(x + w, y + h);
if ( m_graphicContext->ShouldOffset() )
{
// if we are offsetting the entire rectangle is moved 0.5, so the
// border line gets off by 1
w -= 1;
h -= 1;
}
m_graphicContext->DrawEllipse(x,y,w,h); m_graphicContext->DrawEllipse(x,y,w,h);
} }
@ -1213,9 +1202,10 @@ void wxGCDCImpl::Clear(void)
wxCompositionMode formerMode = m_graphicContext->GetCompositionMode(); wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE); m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE);
// maximum positive coordinate Cairo can handle is 2^23 - 1 // maximum positive coordinate Cairo can handle is 2^23 - 1
// Use a value slightly less than this to be sure we avoid the limit
DoDrawRectangle( DoDrawRectangle(
DeviceToLogicalX(0), DeviceToLogicalY(0), DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(0x007fffff), DeviceToLogicalYRel(0x007fffff)); DeviceToLogicalXRel(0x800000 - 64), DeviceToLogicalYRel(0x800000 - 64));
m_graphicContext->SetCompositionMode(formerMode); m_graphicContext->SetCompositionMode(formerMode);
m_graphicContext->SetPen( m_pen ); m_graphicContext->SetPen( m_pen );
m_graphicContext->SetBrush( m_brush ); m_graphicContext->SetBrush( m_brush );

View File

@ -284,12 +284,12 @@ bool wxTextDataObject::GetDataHere(const wxDataFormat& format, void *buf) const
} }
bool wxTextDataObject::SetData(const wxDataFormat& format, bool wxTextDataObject::SetData(const wxDataFormat& format,
size_t WXUNUSED(len), const void *buf) size_t len, const void *buf)
{ {
if ( buf == NULL ) if ( buf == NULL )
return false; return false;
wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf ); wxWCharBuffer buffer = GetConv(format).cMB2WC((const char*)buf, len, NULL);
SetText( buffer ); SetText( buffer );

View File

@ -532,7 +532,8 @@ bool wxDocument::OnSaveModified()
GetUserReadableName() GetUserReadableName()
), ),
wxTheApp->GetAppDisplayName(), wxTheApp->GetAppDisplayName(),
wxYES_NO | wxCANCEL | wxICON_QUESTION | wxCENTRE wxYES_NO | wxCANCEL | wxICON_QUESTION | wxCENTRE,
GetDocumentWindow()
) ) ) )
{ {
case wxNO: case wxNO:
@ -1147,17 +1148,21 @@ void wxDocManager::OnFileSaveAs(wxCommandEvent& WXUNUSED(event))
void wxDocManager::OnMRUFile(wxCommandEvent& event) void wxDocManager::OnMRUFile(wxCommandEvent& event)
{ {
if ( m_fileHistory )
{
// Check if the id is in the range assigned to MRU list entries. // Check if the id is in the range assigned to MRU list entries.
const int id = event.GetId(); const int id = event.GetId();
if ( id >= wxID_FILE1 && if ( id >= wxID_FILE1 &&
id < wxID_FILE1 + static_cast<int>(m_fileHistory->GetCount()) ) id < wxID_FILE1 + static_cast<int>(m_fileHistory->GetCount()) )
{ {
DoOpenMRUFile(id - wxID_FILE1); DoOpenMRUFile(id - wxID_FILE1);
// Don't skip the event below.
return;
} }
else }
{
event.Skip(); event.Skip();
}
} }
void wxDocManager::DoOpenMRUFile(unsigned n) void wxDocManager::DoOpenMRUFile(unsigned n)

View File

@ -179,8 +179,6 @@ wxDEFINE_EVENT( wxEVT_VLBOX, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMBOBOX, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_COMBOBOX, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_TOOL_RCLICKED, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_TOOL_RCLICKED, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_TOOL_ENTER, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_TOOL_ENTER, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_SPINCTRL, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_SPINCTRLDOUBLE, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_TOOL_DROPDOWN, wxCommandEvent ); wxDEFINE_EVENT( wxEVT_TOOL_DROPDOWN, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent); wxDEFINE_EVENT( wxEVT_COMBOBOX_DROPDOWN, wxCommandEvent);
wxDEFINE_EVENT( wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent); wxDEFINE_EVENT( wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent);

View File

@ -571,7 +571,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
} }
if ( *pEnd != wxT(']') ) { if ( *pEnd != wxT(']') ) {
wxLogError(_("file '%s': unexpected character %c at line %d."), wxLogError(_("file '%s': unexpected character %c at line %zu."),
buffer.GetName(), *pEnd, n + 1); buffer.GetName(), *pEnd, n + 1);
continue; // skip this line continue; // skip this line
} }
@ -607,7 +607,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
break; break;
default: default:
wxLogWarning(_("file '%s', line %d: '%s' ignored after group header."), wxLogWarning(_("file '%s', line %zu: '%s' ignored after group header."),
buffer.GetName(), n + 1, pEnd); buffer.GetName(), n + 1, pEnd);
bCont = false; bCont = false;
} }
@ -636,7 +636,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
pEnd++; pEnd++;
if ( *pEnd++ != wxT('=') ) { if ( *pEnd++ != wxT('=') ) {
wxLogError(_("file '%s', line %d: '=' expected."), wxLogError(_("file '%s', line %zu: '=' expected."),
buffer.GetName(), n + 1); buffer.GetName(), n + 1);
} }
else { else {
@ -649,7 +649,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
else { else {
if ( bLocal && pEntry->IsImmutable() ) { if ( bLocal && pEntry->IsImmutable() ) {
// immutable keys can't be changed by user // immutable keys can't be changed by user
wxLogWarning(_("file '%s', line %d: value for immutable key '%s' ignored."), wxLogWarning(_("file '%s', line %zu: value for immutable key '%s' ignored."),
buffer.GetName(), n + 1, strKey.c_str()); buffer.GetName(), n + 1, strKey.c_str());
continue; continue;
} }
@ -659,8 +659,8 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
// (c) key from global file now found in local one // (c) key from global file now found in local one
// which is exactly what we want. // which is exactly what we want.
else if ( !bLocal || pEntry->IsLocal() ) { else if ( !bLocal || pEntry->IsLocal() ) {
wxLogWarning(_("file '%s', line %d: key '%s' was first found at line %d."), wxLogWarning(_("file '%s', line %zu: key '%s' was first found at line %d."),
buffer.GetName(), (int)n + 1, strKey.c_str(), pEntry->Line()); buffer.GetName(), n + 1, strKey.c_str(), pEntry->Line());
} }
} }

View File

@ -90,6 +90,8 @@
#define HAVE_WGETCWD #define HAVE_WGETCWD
#endif #endif
wxDECL_FOR_STRICT_MINGW32(int, _fileno, (FILE*))
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// constants // constants
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -1090,7 +1092,11 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
return false; return false;
} }
wxDoCopyFile(fileIn, fbuf, file2, overwrite); if ( !wxDoCopyFile(fileIn, fbuf, file2, overwrite) )
{
wxLogError(_("Error copying the file '%s' to '%s'."), file1, file2);
return false;
}
#if defined(__WXMAC__) || defined(__WXCOCOA__) #if defined(__WXMAC__) || defined(__WXCOCOA__)
// copy the resource fork of the file too if it's present // copy the resource fork of the file too if it's present

View File

@ -50,6 +50,14 @@ wxString GetMRUEntryLabel(int n, const wxString& path)
wxString pathInMenu(path); wxString pathInMenu(path);
pathInMenu.Replace("&", "&&"); pathInMenu.Replace("&", "&&");
#ifdef __WXMSW__
// absolute paths always start with Latin characters even in RTL
// environments and should therefore be rendered as LTR text (possibly with
// RTL chunks in it). Ensure this on Windows by prepending
// LEFT-TO-RIGHT EMBEDDING (other platforms detect this automatically)
pathInMenu.insert(0, wchar_t(0x202a));
#endif
return wxString::Format("&%d %s", n + 1, pathInMenu); return wxString::Format("&%d %s", n + 1, pathInMenu);
} }

View File

@ -100,7 +100,7 @@
#ifdef __WINDOWS__ #ifdef __WINDOWS__
#include "wx/msw/private.h" #include "wx/msw/private.h"
#include <shlobj.h> // for CLSID_ShellLink #include "wx/msw/wrapshl.h" // for CLSID_ShellLink
#include "wx/msw/missing.h" #include "wx/msw/missing.h"
#include "wx/msw/ole/oleutils.h" #include "wx/msw/ole/oleutils.h"
#endif #endif
@ -1832,15 +1832,27 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
m_dirs.Insert(wxT(".."), 0u); m_dirs.Insert(wxT(".."), 0u);
} }
if ( format == wxPATH_UNIX || format == wxPATH_DOS ) switch ( GetFormat(format) )
{ {
// a directory made relative with respect to itself is '.' under Unix case wxPATH_NATIVE:
// and DOS, by definition (but we don't have to insert "./" for the case wxPATH_MAX:
// files) wxFAIL_MSG( wxS("unreachable") );
// fall through
case wxPATH_UNIX:
case wxPATH_DOS:
// a directory made relative with respect to itself is '.' under
// Unix and DOS, by definition (but we don't have to insert "./"
// for the files)
if ( m_dirs.IsEmpty() && IsDir() ) if ( m_dirs.IsEmpty() && IsDir() )
{ {
m_dirs.Add(wxT('.')); m_dirs.Add(wxT('.'));
} }
break;
case wxPATH_MAC:
case wxPATH_VMS:
break;
} }
m_relative = true; m_relative = true;
@ -2595,7 +2607,7 @@ bool wxFileName::SetPermissions(int permissions)
{ {
// Don't do anything for a symlink but first make sure it is one. // Don't do anything for a symlink but first make sure it is one.
if ( m_dontFollowLinks && if ( m_dontFollowLinks &&
Exists(wxFILE_EXISTS_SYMLINK|wxFILE_EXISTS_NO_FOLLOW) ) Exists(GetFullPath(), wxFILE_EXISTS_SYMLINK|wxFILE_EXISTS_NO_FOLLOW) )
{ {
// Looks like changing permissions for a symlinc is only supported // Looks like changing permissions for a symlinc is only supported
// on BSD where lchmod is present and correctly implemented. // on BSD where lchmod is present and correctly implemented.

View File

@ -124,7 +124,8 @@ bool wxFontEnumerator::EnumerateEncodingsUTF8(const wxString& facename)
for ( size_t n = 0; n < count; n++ ) for ( size_t n = 0; n < count; n++ )
{ {
OnFontEncoding(facenames[n], utf8); if ( !OnFontEncoding(facenames[n], utf8) )
break;
} }
return true; return true;

View File

@ -143,8 +143,8 @@ wxFileSystemWatcherBase::AddAny(const wxFileName& path,
} }
else else
{ {
wxFSWatchInfo& watch = it->second; wxFSWatchInfo& watch2 = it->second;
const int count = watch.IncRef(); const int count = watch2.IncRef();
wxLogTrace(wxTRACE_FSWATCHER, wxLogTrace(wxTRACE_FSWATCHER,
"'%s' is now watched %d times", canonical, count); "'%s' is now watched %d times", canonical, count);

View File

@ -79,8 +79,6 @@ wxFTP::wxFTP()
m_username = wxT("anonymous"); m_username = wxT("anonymous");
m_password << wxGetUserId() << wxT('@') << wxGetFullHostName(); m_password << wxGetUserId() << wxT('@') << wxGetFullHostName();
SetNotify(0);
SetFlags(wxSOCKET_NOWAIT);
m_bPassive = true; m_bPassive = true;
m_bEncounteredError = false; m_bEncounteredError = false;
} }
@ -461,20 +459,21 @@ wxString wxFTP::Pwd()
{ {
// the result is at least that long if CheckCommand() succeeded // the result is at least that long if CheckCommand() succeeded
wxString::const_iterator p = m_lastResult.begin() + LEN_CODE + 1; wxString::const_iterator p = m_lastResult.begin() + LEN_CODE + 1;
if ( *p != wxT('"') ) const wxString::const_iterator end = m_lastResult.end();
if ( p == end || *p != wxT('"') )
{ {
wxLogDebug(wxT("Missing starting quote in reply for PWD: %s"), wxLogDebug(wxT("Missing starting quote in reply for PWD: %s"),
wxString(p, m_lastResult.end())); wxString(p, end));
} }
else else
{ {
for ( ++p; (bool)*p; ++p ) // FIXME-DMARS for ( ++p; p != end; ++p )
{ {
if ( *p == wxT('"') ) if ( *p == wxT('"') )
{ {
// check if the quote is doubled // check if the quote is doubled
++p; ++p;
if ( !*p || *p != wxT('"') ) if ( p == end || *p != wxT('"') )
{ {
// no, this is the end // no, this is the end
break; break;
@ -486,7 +485,7 @@ wxString wxFTP::Pwd()
path += *p; path += *p;
} }
if ( !*p ) if ( p != end )
{ {
wxLogDebug(wxT("Missing ending quote in reply for PWD: %s"), wxLogDebug(wxT("Missing ending quote in reply for PWD: %s"),
m_lastResult.c_str() + LEN_CODE + 1); m_lastResult.c_str() + LEN_CODE + 1);
@ -782,8 +781,6 @@ wxInputStream *wxFTP::GetInputStream(const wxString& path)
return NULL; return NULL;
} }
sock->SetFlags(wxSOCKET_WAITALL);
m_streaming = true; m_streaming = true;
wxInputFTPStream *in_stream = new wxInputFTPStream(this, sock); wxInputFTPStream *in_stream = new wxInputFTPStream(this, sock);

View File

@ -22,7 +22,6 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/string.h" #include "wx/string.h"
#include "wx/app.h"
#endif #endif
#include "wx/tokenzr.h" #include "wx/tokenzr.h"
@ -48,8 +47,6 @@ wxHTTP::wxHTTP()
m_read = false; m_read = false;
m_proxy_mode = false; m_proxy_mode = false;
m_http_response = 0; m_http_response = 0;
SetNotify(wxSOCKET_LOST_FLAG);
} }
wxHTTP::~wxHTTP() wxHTTP::~wxHTTP()
@ -370,16 +367,6 @@ bool wxHTTP::BuildRequest(const wxString& path, const wxString& method)
SetHeader(wxT("Authorization"), GenerateAuthString(m_username, m_password)); SetHeader(wxT("Authorization"), GenerateAuthString(m_username, m_password));
} }
SaveState();
// we may use non blocking sockets only if we can dispatch events from them
int flags = wxIsMainThread() && wxApp::IsMainLoopRunning() ? wxSOCKET_NONE
: wxSOCKET_BLOCK;
// and we must use wxSOCKET_WAITALL to ensure that all data is sent
flags |= wxSOCKET_WAITALL;
SetFlags(flags);
Notify(false);
wxString buf; wxString buf;
buf.Printf(wxT("%s %s HTTP/1.0\r\n"), method, path); buf.Printf(wxT("%s %s HTTP/1.0\r\n"), method, path);
const wxWX2MBbuf pathbuf = buf.mb_str(); const wxWX2MBbuf pathbuf = buf.mb_str();
@ -395,10 +382,8 @@ bool wxHTTP::BuildRequest(const wxString& path, const wxString& method)
wxString tmp_str; wxString tmp_str;
m_lastError = ReadLine(this, tmp_str); m_lastError = ReadLine(this, tmp_str);
if (m_lastError != wxPROTO_NOERR) { if (m_lastError != wxPROTO_NOERR)
RestoreState();
return false; return false;
}
if (!tmp_str.Contains(wxT("HTTP/"))) { if (!tmp_str.Contains(wxT("HTTP/"))) {
// TODO: support HTTP v0.9 which can have no header. // TODO: support HTTP v0.9 which can have no header.
@ -441,7 +426,7 @@ bool wxHTTP::BuildRequest(const wxString& path, const wxString& method)
m_lastError = wxPROTO_NOERR; m_lastError = wxPROTO_NOERR;
ret_value = ParseHeaders(); ret_value = ParseHeaders();
RestoreState();
return ret_value; return ret_value;
} }
@ -540,9 +525,6 @@ wxInputStream *wxHTTP::GetInputStream(const wxString& path)
inp_stream->m_read_bytes = 0; inp_stream->m_read_bytes = 0;
Notify(false);
SetFlags(wxSOCKET_BLOCK | wxSOCKET_WAITALL);
// no error; reset m_lastError // no error; reset m_lastError
m_lastError = wxPROTO_NOERR; m_lastError = wxPROTO_NOERR;
return inp_stream; return inp_stream;

View File

@ -2040,6 +2040,8 @@ void wxImage::ClearAlpha()
{ {
wxCHECK_RET( HasAlpha(), wxT("image already doesn't have an alpha channel") ); wxCHECK_RET( HasAlpha(), wxT("image already doesn't have an alpha channel") );
AllocExclusive();
if ( !M_IMGDATA->m_staticAlpha ) if ( !M_IMGDATA->m_staticAlpha )
free( M_IMGDATA->m_alpha ); free( M_IMGDATA->m_alpha );

View File

@ -137,8 +137,8 @@ static struct InitData
nInitCount = 0; nInitCount = 0;
#if wxUSE_UNICODE #if wxUSE_UNICODE
argc = 0; argc = argcOrig = 0;
// argv = NULL; -- not even really needed // argv = argvOrig = NULL; -- not even really needed
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
} }
@ -157,6 +157,12 @@ static struct InitData
// for example), we remember the converted argv here because we'll have to // for example), we remember the converted argv here because we'll have to
// free it when doing cleanup to avoid memory leaks // free it when doing cleanup to avoid memory leaks
wchar_t **argv; wchar_t **argv;
// we also need to keep two copies, one passed to other functions, and one
// unmodified original; somebody may modify the former, so we need to have
// the latter to be able to free everything correctly
int argcOrig;
wchar_t **argvOrig;
#endif // wxUSE_UNICODE #endif // wxUSE_UNICODE
wxDECLARE_NO_COPY_CLASS(InitData); wxDECLARE_NO_COPY_CLASS(InitData);
@ -174,7 +180,9 @@ static struct InitData
static void ConvertArgsToUnicode(int argc, char **argv) static void ConvertArgsToUnicode(int argc, char **argv)
{ {
gs_initData.argvOrig = new wchar_t *[argc + 1];
gs_initData.argv = new wchar_t *[argc + 1]; gs_initData.argv = new wchar_t *[argc + 1];
int wargc = 0; int wargc = 0;
for ( int i = 0; i < argc; i++ ) for ( int i = 0; i < argc; i++ )
{ {
@ -190,25 +198,28 @@ static void ConvertArgsToUnicode(int argc, char **argv)
} }
else // converted ok else // converted ok
{ {
gs_initData.argv[wargc++] = wxStrdup(buf); gs_initData.argvOrig[wargc] = gs_initData.argv[wargc] = wxStrdup(buf);
wargc++;
} }
} }
gs_initData.argc = wargc; gs_initData.argcOrig = gs_initData.argc = wargc;
gs_initData.argv[wargc] = NULL; gs_initData.argvOrig[wargc] =gs_initData.argv[wargc] = NULL;
} }
static void FreeConvertedArgs() static void FreeConvertedArgs()
{ {
if ( gs_initData.argv ) if ( gs_initData.argvOrig )
{ {
for ( int i = 0; i < gs_initData.argc; i++ ) for ( int i = 0; i < gs_initData.argcOrig; i++ )
{ {
free(gs_initData.argv[i]); free(gs_initData.argvOrig[i]);
// gs_initData.argv[i] normally points to the same data
} }
wxDELETEA(gs_initData.argvOrig);
wxDELETEA(gs_initData.argv); wxDELETEA(gs_initData.argv);
gs_initData.argc = 0; gs_initData.argcOrig = gs_initData.argc = 0;
} }
} }

View File

@ -55,6 +55,7 @@
#endif #endif
#ifdef __WIN32__ #ifdef __WIN32__
#include "wx/dynlib.h"
#include "wx/msw/private.h" #include "wx/msw/private.h"
#endif #endif
@ -480,6 +481,18 @@ bool wxLocale::Init(int language, int flags)
// change locale used by Windows functions // change locale used by Windows functions
::SetThreadLocale(lcid); ::SetThreadLocale(lcid);
// SetThreadUILanguage() may be available on XP, but with unclear
// behavior, so avoid calling it there.
if ( wxGetWinVersion() >= wxWinVersion_Vista )
{
wxLoadedDLL dllKernel32(wxS("kernel32.dll"));
typedef LANGID(WINAPI *SetThreadUILanguage_t)(LANGID);
SetThreadUILanguage_t pfnSetThreadUILanguage = NULL;
wxDL_INIT_FUNC(pfn, SetThreadUILanguage, dllKernel32);
if (pfnSetThreadUILanguage)
pfnSetThreadUILanguage(LANGIDFROMLCID(lcid));
}
#endif #endif
// and also call setlocale() to change locale used by the CRT // and also call setlocale() to change locale used by the CRT
@ -541,6 +554,11 @@ bool wxLocale::Init(int language, int flags)
{ {
wxLogWarning(_("Cannot set locale to language \"%s\"."), name.c_str()); wxLogWarning(_("Cannot set locale to language \"%s\"."), name.c_str());
// As we failed to change locale, there is no need to restore the
// previous one: it's still valid.
free(const_cast<char *>(m_pszOldLocale));
m_pszOldLocale = NULL;
// continue nevertheless and try to load at least the translations for // continue nevertheless and try to load at least the translations for
// this language // this language
} }
@ -611,11 +629,6 @@ inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value)
return wxLANGUAGE_ENGLISH_US; return wxLANGUAGE_ENGLISH_US;
} }
if ( langFull == wxS("C") || langFull == wxS("POSIX") )
{
// default C locale is English too
return wxLANGUAGE_ENGLISH_US;
}
#endif #endif
// the language string has the following form // the language string has the following form
@ -651,6 +664,12 @@ inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value)
langFull.Truncate(posEndLang); langFull.Truncate(posEndLang);
} }
if ( langFull == wxS("C") || langFull == wxS("POSIX") )
{
// default C locale is English too
return wxLANGUAGE_ENGLISH_US;
}
// do we have just the language (or sublang too)? // do we have just the language (or sublang too)?
const bool justLang = langFull.find('_') == wxString::npos; const bool justLang = langFull.find('_') == wxString::npos;
@ -1035,8 +1054,11 @@ wxLocale::~wxLocale()
// restore old locale pointer // restore old locale pointer
wxSetLocale(m_pOldLocale); wxSetLocale(m_pOldLocale);
if ( m_pszOldLocale )
{
wxSetlocale(LC_ALL, m_pszOldLocale); wxSetlocale(LC_ALL, m_pszOldLocale);
free(const_cast<char *>(m_pszOldLocale)); free(const_cast<char *>(m_pszOldLocale));
}
} }
@ -1251,6 +1273,8 @@ static wxString TranslateFromUnicodeFormat(const wxString& fmt)
fmtWX += "%A"; fmtWX += "%A";
break; break;
case 5: // EEEEE case 5: // EEEEE
case 6: // EEEEEE
// no "narrow form" in strftime(), use abbrev.
fmtWX += "%a"; fmtWX += "%a";
break; break;
@ -1276,6 +1300,11 @@ static wxString TranslateFromUnicodeFormat(const wxString& fmt)
fmtWX += "%B"; fmtWX += "%B";
break; break;
case 5:
// no "narrow form" in strftime(), use abbrev.
fmtWX += "%b";
break;
default: default:
wxFAIL_MSG( "too many 'M's" ); wxFAIL_MSG( "too many 'M's" );
} }

View File

@ -118,6 +118,9 @@
#ifndef LANG_FRENCH #ifndef LANG_FRENCH
#define LANG_FRENCH (0) #define LANG_FRENCH (0)
#endif #endif
#ifndef LANG_FRISIAN
#define LANG_FRISIAN (0)
#endif
#ifndef LANG_GEORGIAN #ifndef LANG_GEORGIAN
#define LANG_GEORGIAN (0) #define LANG_GEORGIAN (0)
#endif #endif
@ -638,7 +641,7 @@ void wxLocale::InitLanguagesDB()
LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , wxLayout_LeftToRight, "French (Luxembourg)") LNG(wxLANGUAGE_FRENCH_LUXEMBOURG, "fr_LU", LANG_FRENCH , SUBLANG_FRENCH_LUXEMBOURG , wxLayout_LeftToRight, "French (Luxembourg)")
LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , wxLayout_LeftToRight, "French (Monaco)") LNG(wxLANGUAGE_FRENCH_MONACO, "fr_MC", LANG_FRENCH , SUBLANG_FRENCH_MONACO , wxLayout_LeftToRight, "French (Monaco)")
LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , wxLayout_LeftToRight, "French (Swiss)") LNG(wxLANGUAGE_FRENCH_SWISS, "fr_CH", LANG_FRENCH , SUBLANG_FRENCH_SWISS , wxLayout_LeftToRight, "French (Swiss)")
LNG(wxLANGUAGE_FRISIAN, "fy" , 0 , 0 , wxLayout_LeftToRight, "Frisian") LNG(wxLANGUAGE_FRISIAN, "fy" , LANG_FRISIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Frisian")
LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , wxLayout_LeftToRight, "Galician") LNG(wxLANGUAGE_GALICIAN, "gl_ES", 0 , 0 , wxLayout_LeftToRight, "Galician")
LNG(wxLANGUAGE_GEORGIAN, "ka_GE", LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian") LNG(wxLANGUAGE_GEORGIAN, "ka_GE", LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian")
LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , wxLayout_LeftToRight, "German") LNG(wxLANGUAGE_GERMAN, "de_DE", LANG_GERMAN , SUBLANG_GERMAN , wxLayout_LeftToRight, "German")

View File

@ -278,13 +278,13 @@ unsigned wxLog::LogLastRepeatIfNeeded()
// Notice that we still use wxPLURAL() to ensure that multiple // Notice that we still use wxPLURAL() to ensure that multiple
// numbers of times are correctly formatted, even though we never // numbers of times are correctly formatted, even though we never
// actually use the singular string. // actually use the singular string.
msg.Printf(wxPLURAL("The previous message repeated %lu time.", msg.Printf(wxPLURAL("The previous message repeated %u time.",
"The previous message repeated %lu times.", "The previous message repeated %u times.",
gs_prevLog.numRepeated), gs_prevLog.numRepeated),
gs_prevLog.numRepeated); gs_prevLog.numRepeated);
} }
#else #else
msg.Printf(wxS("The previous message was repeated %lu time(s)."), msg.Printf(wxS("The previous message was repeated %u time(s)."),
gs_prevLog.numRepeated); gs_prevLog.numRepeated);
#endif #endif
gs_prevLog.numRepeated = 0; gs_prevLog.numRepeated = 0;
@ -306,12 +306,12 @@ wxLog::~wxLog()
#if wxUSE_INTL #if wxUSE_INTL
wxPLURAL wxPLURAL
( (
"Last repeated message (\"%s\", %lu time) wasn't output", "Last repeated message (\"%s\", %u time) wasn't output",
"Last repeated message (\"%s\", %lu times) wasn't output", "Last repeated message (\"%s\", %u times) wasn't output",
gs_prevLog.numRepeated gs_prevLog.numRepeated
), ),
#else #else
wxS("Last repeated message (\"%s\", %lu time(s)) wasn't output"), wxS("Last repeated message (\"%s\", %u time(s)) wasn't output"),
#endif #endif
gs_prevLog.msg, gs_prevLog.msg,
gs_prevLog.numRepeated gs_prevLog.numRepeated

View File

@ -122,20 +122,16 @@ wxChar wxNumberFormatter::GetDecimalSeparator()
{ {
const wxString const wxString
s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER); s = wxLocale::GetInfo(wxLOCALE_DECIMAL_POINT, wxLOCALE_CAT_NUMBER);
if ( s.empty() ) if ( s.length() == 1 )
{
s_decimalSeparator = s[0];
}
else
{ {
// We really must have something for decimal separator, so fall // We really must have something for decimal separator, so fall
// back to the C locale default. // back to the C locale default.
s_decimalSeparator = '.'; s_decimalSeparator = '.';
} }
else
{
// To the best of my knowledge there are no locales like this.
wxASSERT_MSG( s.length() == 1,
"Multi-character decimal separator?" );
s_decimalSeparator = s[0];
}
} }
return s_decimalSeparator; return s_decimalSeparator;
@ -154,11 +150,8 @@ bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
{ {
const wxString const wxString
s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER); s = wxLocale::GetInfo(wxLOCALE_THOUSANDS_SEP, wxLOCALE_CAT_NUMBER);
if ( !s.empty() ) if ( s.length() == 1 )
{ {
wxASSERT_MSG( s.length() == 1,
"Multi-character thousands separator?" );
s_thousandsSeparator = s[0]; s_thousandsSeparator = s[0];
} }
//else: Unlike above it's perfectly fine for the thousands separator to //else: Unlike above it's perfectly fine for the thousands separator to
@ -223,6 +216,10 @@ wxString wxNumberFormatter::ToString(double val, int precision, int style)
void wxNumberFormatter::AddThousandsSeparators(wxString& s) void wxNumberFormatter::AddThousandsSeparators(wxString& s)
{ {
// Thousands separators for numbers in scientific format are not relevant.
if ( s.find_first_of("eE") != wxString::npos )
return;
wxChar thousandsSep; wxChar thousandsSep;
if ( !GetThousandsSeparatorIfUsed(&thousandsSep) ) if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
return; return;
@ -254,9 +251,14 @@ void wxNumberFormatter::AddThousandsSeparators(wxString& s)
void wxNumberFormatter::RemoveTrailingZeroes(wxString& s) void wxNumberFormatter::RemoveTrailingZeroes(wxString& s)
{ {
// If number is in scientific format, trailing zeroes belong to the exponent and cannot be removed.
if ( s.find_first_of("eE") != wxString::npos )
return;
const size_t posDecSep = s.find(GetDecimalSeparator()); const size_t posDecSep = s.find(GetDecimalSeparator());
wxCHECK_RET( posDecSep != wxString::npos, // No decimal point => removing trailing zeroes irrelevant for integer number.
wxString::Format("No decimal separator in \"%s\"", s) ); if ( posDecSep == wxString::npos )
return;
wxCHECK_RET( posDecSep, "Can't start with decimal separator" ); wxCHECK_RET( posDecSep, "Can't start with decimal separator" );
// Find the last character to keep. // Find the last character to keep.
@ -267,6 +269,9 @@ void wxNumberFormatter::RemoveTrailingZeroes(wxString& s)
posLastNonZero--; posLastNonZero--;
s.erase(posLastNonZero + 1); s.erase(posLastNonZero + 1);
// Remove sign from orphaned zero.
if ( s.compare("-0") == 0 )
s = "0";
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -72,6 +72,11 @@
#endif #endif
#endif // __WXMSW__ #endif // __WXMSW__
// The value traditionally used as the default max page number and meaning
// "infinitely many". It should probably be documented and exposed, but for now
// at least use it here instead of hardcoding the number.
static const int DEFAULT_MAX_PAGES = 32000;
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
// wxPrintFactory // wxPrintFactory
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
@ -541,7 +546,17 @@ void wxPrintAbortDialog::SetProgress(int currentPage, int totalPages,
int currentCopy, int totalCopies) int currentCopy, int totalCopies)
{ {
wxString text; wxString text;
if ( totalPages == DEFAULT_MAX_PAGES )
{
// This means that the user has not supplied a total number of pages so it
// is better not to show this value.
text.Printf(_("Printing page %d"), currentPage);
}
else
{
// We have a valid total number of pages so we show it.
text.Printf(_("Printing page %d of %d"), currentPage, totalPages); text.Printf(_("Printing page %d of %d"), currentPage, totalPages);
}
if ( totalCopies > 1 ) if ( totalCopies > 1 )
text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies); text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies);
m_progress->SetLabel(text); m_progress->SetLabel(text);
@ -607,7 +622,7 @@ bool wxPrintout::HasPage(int page)
void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage) void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage)
{ {
*minPage = 1; *minPage = 1;
*maxPage = 32000; *maxPage = DEFAULT_MAX_PAGES;
*fromPage = 1; *fromPage = 1;
*toPage = 1; *toPage = 1;
} }

View File

@ -21,6 +21,7 @@
#include "wx/protocol/log.h" #include "wx/protocol/log.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/module.h" #include "wx/module.h"
#endif #endif
@ -63,7 +64,10 @@ IMPLEMENT_ABSTRACT_CLASS(wxProtocol, wxObject)
wxProtocol::wxProtocol() wxProtocol::wxProtocol()
#if wxUSE_SOCKETS #if wxUSE_SOCKETS
: wxSocketClient() // Only use non blocking sockets if we can dispatch events.
: wxSocketClient((wxIsMainThread() && wxApp::IsMainLoopRunning()
? wxSOCKET_NONE
: wxSOCKET_BLOCK) | wxSOCKET_WAITALL)
#endif #endif
{ {
m_lastError = wxPROTO_NOERR; m_lastError = wxPROTO_NOERR;

View File

@ -136,7 +136,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
} }
}; };
#else #else
typedef char wxGethostBuf[1024]; typedef char wxGethostBuf[4096];
#endif #endif
#ifdef HAVE_FUNC_GETSERVBYNAME_R_4 #ifdef HAVE_FUNC_GETSERVBYNAME_R_4
@ -148,7 +148,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
} }
}; };
#else #else
typedef char wxGetservBuf[1024]; typedef char wxGetservBuf[4096];
#endif #endif
#if defined(wxHAS_MT_SAFE_GETBY_FUNCS) || !wxUSE_THREADS #if defined(wxHAS_MT_SAFE_GETBY_FUNCS) || !wxUSE_THREADS

View File

@ -232,12 +232,6 @@ wxMBConv::ToWChar(wchar_t *dst, size_t dstLen,
if ( !srcEnd ) if ( !srcEnd )
dstWritten++; dstWritten++;
if ( !lenChunk )
{
// nothing left in the input string, conversion succeeded
break;
}
if ( dst ) if ( dst )
{ {
if ( dstWritten > dstLen ) if ( dstWritten > dstLen )
@ -1057,16 +1051,8 @@ wxMBConvStrictUTF8::ToWChar(wchar_t *dst, size_t dstLen,
// length: // length:
static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 }; static const unsigned char leadValueMask[] = { 0x7F, 0x1F, 0x0F, 0x07 };
// mask and value of lead byte's most significant bits, by length:
static const unsigned char leadMarkerMask[] = { 0x80, 0xE0, 0xF0, 0xF8 };
static const unsigned char leadMarkerVal[] = { 0x00, 0xC0, 0xE0, 0xF0 };
len--; // it's more convenient to work with 0-based length here len--; // it's more convenient to work with 0-based length here
// extract the lead byte's value bits:
if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] )
break;
code = c & leadValueMask[len]; code = c & leadValueMask[len];
// all remaining bytes, if any, are handled in the same way // all remaining bytes, if any, are handled in the same way
@ -1716,8 +1702,18 @@ wxMBConvUTF16swap::ToWChar(wchar_t *dst, size_t dstLen,
wxUint16 tmp[2]; wxUint16 tmp[2];
tmp[0] = wxUINT16_SWAP_ALWAYS(*inBuff); tmp[0] = wxUINT16_SWAP_ALWAYS(*inBuff);
inBuff++; if ( ++inBuff < inEnd )
{
// Normal case, we have a next character to decode.
tmp[1] = wxUINT16_SWAP_ALWAYS(*inBuff); tmp[1] = wxUINT16_SWAP_ALWAYS(*inBuff);
}
else // End of input.
{
// Setting the second character to 0 ensures we correctly return
// wxCONV_FAILED if the first one is the first half of a surrogate
// as the second half can't be 0 in this case.
tmp[1] = 0;
}
const size_t numChars = decode_utf16(tmp, ch); const size_t numChars = decode_utf16(tmp, ch);
if ( numChars == wxCONV_FAILED ) if ( numChars == wxCONV_FAILED )

View File

@ -447,7 +447,7 @@ void wxToolBarBase::AdjustToolBitmapSize()
{ {
const wxBitmap& bmp = (*i)->GetNormalBitmap(); const wxBitmap& bmp = (*i)->GetNormalBitmap();
if ( bmp.IsOk() ) if ( bmp.IsOk() )
sizeActual.IncTo(bmp.GetSize()); sizeActual.IncTo(bmp.GetScaledSize());
} }
if ( sizeActual != sizeOrig ) if ( sizeActual != sizeOrig )

View File

@ -22,6 +22,23 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
// This is a horrible hack which only works because we don't currently include
// <time.h> from wx/wxprec.h. It is needed because we need timezone-related
// stuff from MinGW time.h, but it is not compiled in strict ANSI mode and it
// is too complicated to be dealt with using wxDECL_FOR_STRICT_MINGW32(). So we
// just include the header after undefining __STRICT_ANSI__ to get all the
// declarations we need -- and then define it back to avoid inconsistencies in
// all our other headers.
//
// Note that the same hack is used for "environ" in utilscmn.cpp, so if the
// code here is modified because this hack becomes unnecessary or a better
// solution is found, the code there should be updated as well.
#ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
#undef __STRICT_ANSI__
#include <time.h>
#define __STRICT_ANSI__
#endif
#include "wx/time.h" #include "wx/time.h"
#ifndef WX_PRECOMP #ifndef WX_PRECOMP

View File

@ -1719,7 +1719,7 @@ wxString wxTranslations::GetHeaderValue(const wxString& header,
if ( !trans || trans->empty() ) if ( !trans || trans->empty() )
return wxEmptyString; return wxEmptyString;
size_t found = trans->find(header); size_t found = trans->find(header + wxS(": "));
if ( found == wxString::npos ) if ( found == wxString::npos )
return wxEmptyString; return wxEmptyString;

View File

@ -23,6 +23,14 @@
#pragma hdrstop #pragma hdrstop
#endif #endif
// See comment about this hack in time.cpp: here we do it for environ external
// variable which can't be easily declared when using MinGW in strict ANSI mode.
#ifdef wxNEEDS_STRICT_ANSI_WORKAROUNDS
#undef __STRICT_ANSI__
#include <stdlib.h>
#define __STRICT_ANSI__
#endif
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/app.h" #include "wx/app.h"
#include "wx/string.h" #include "wx/string.h"

View File

@ -73,6 +73,10 @@
#include <xlocale.h> #include <xlocale.h>
#endif #endif
wxDECL_FOR_STRICT_MINGW32(int, vswprintf, (wchar_t*, const wchar_t*, __VALIST));
wxDECL_FOR_STRICT_MINGW32(int, _putws, (const wchar_t*));
wxDECL_FOR_STRICT_MINGW32(void, _wperror, (const wchar_t*));
WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n) WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n)
{ {
// assume that we have mbsrtowcs() too if we have wcsrtombs() // assume that we have mbsrtowcs() too if we have wcsrtombs()

View File

@ -59,6 +59,7 @@ BEGIN_EVENT_TABLE(wxGenericCalendarCtrl, wxControl)
EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick) EVT_LEFT_DOWN(wxGenericCalendarCtrl::OnClick)
EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick) EVT_LEFT_DCLICK(wxGenericCalendarCtrl::OnDClick)
EVT_MOUSEWHEEL(wxGenericCalendarCtrl::OnWheel)
EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged) EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged)
END_EVENT_TABLE() END_EVENT_TABLE()
@ -1512,6 +1513,31 @@ wxCalendarHitTestResult wxGenericCalendarCtrl::HitTest(const wxPoint& pos,
} }
} }
void wxGenericCalendarCtrl::OnWheel(wxMouseEvent& event)
{
wxDateSpan span;
switch ( event.GetWheelAxis() )
{
case wxMOUSE_WHEEL_VERTICAL:
// For consistency with the native controls, scrolling upwards
// should go to the past, even if the rotation is positive and
// could be normally expected to increase the date.
span = -wxDateSpan::Month();
break;
case wxMOUSE_WHEEL_HORIZONTAL:
span = wxDateSpan::Year();
break;
}
// Currently we only take into account the rotation direction, not its
// magnitude.
if ( event.GetWheelRotation() < 0 )
span = -span;
SetDateAndNotify(m_date + span);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// subcontrols events handling // subcontrols events handling
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -390,7 +390,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
const long styleBtns = styleDlg & (wxOK | wxCANCEL); const long styleBtns = styleDlg & (wxOK | wxCANCEL);
styleDlg &= ~styleBtns; styleDlg &= ~styleBtns;
if ( !wxDialog::Create(parent, wxID_ANY, caption, pos, wxDefaultSize, styleDlg) ) if ( !wxDialog::Create(GetParentForModalDialog(parent, styleDlg), wxID_ANY, caption, pos, wxDefaultSize, styleDlg) )
return false; return false;
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

View File

@ -48,6 +48,7 @@
#include "wx/dnd.h" #include "wx/dnd.h"
#include "wx/stopwatch.h" #include "wx/stopwatch.h"
#include "wx/weakref.h" #include "wx/weakref.h"
#include "wx/generic/private/widthcalc.h"
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// classes // classes
@ -1790,9 +1791,11 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxDataViewModel *model = GetModel(); wxDataViewModel *model = GetModel();
wxAutoBufferedPaintDC dc( this ); wxAutoBufferedPaintDC dc( this );
const wxSize size = GetClientSize();
dc.SetBrush(GetOwner()->GetBackgroundColour()); dc.SetBrush(GetOwner()->GetBackgroundColour());
dc.SetPen( *wxTRANSPARENT_PEN ); dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(GetClientSize()); dc.DrawRectangle(size);
if ( IsEmpty() ) if ( IsEmpty() )
{ {
@ -1878,13 +1881,16 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.SetPen(*wxTRANSPARENT_PEN); dc.SetPen(*wxTRANSPARENT_PEN);
dc.SetBrush(wxBrush(altRowColour)); dc.SetBrush(wxBrush(altRowColour));
// We only need to draw the visible part, so limit the rectangle to it.
const int xRect = m_owner->CalcUnscrolledPosition(wxPoint(0, 0)).x;
const int widthRect = size.x;
for (unsigned int item = item_start; item < item_last; item++) for (unsigned int item = item_start; item < item_last; item++)
{ {
if ( item % 2 ) if ( item % 2 )
{ {
dc.DrawRectangle(x_start, dc.DrawRectangle(xRect,
GetLineStart(item), GetLineStart(item),
GetClientSize().GetWidth(), widthRect,
GetLineHeight(item)); GetLineHeight(item));
} }
} }
@ -3208,6 +3214,11 @@ void wxDataViewMainWindow::Expand( unsigned int row )
ChangeCurrentRow(m_currentRow + rowAdjustment); ChangeCurrentRow(m_currentRow + rowAdjustment);
m_count = -1; m_count = -1;
// Expanding this item means the previously cached column widths could
// have become invalid as new items are now visible.
GetOwner()->InvalidateColBestWidths();
UpdateDisplay(); UpdateDisplay();
// Send the expanded event // Send the expanded event
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem()); SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem());
@ -3283,6 +3294,9 @@ void wxDataViewMainWindow::Collapse(unsigned int row)
} }
m_count = -1; m_count = -1;
GetOwner()->InvalidateColBestWidths();
UpdateDisplay(); UpdateDisplay();
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem()); SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
} }
@ -3992,7 +4006,7 @@ bool wxDataViewMainWindow::TryAdvanceCurrentColumn(wxDataViewTreeNode *node, boo
{ {
if ( forward ) if ( forward )
{ {
m_currentCol = GetOwner()->GetColumnAt(1); m_currentCol = GetOwner()->GetColumnAt(0);
m_currentColSetByKeyboard = true; m_currentColSetByKeyboard = true;
RefreshRow(m_currentRow); RefreshRow(m_currentRow);
return true; return true;
@ -4113,23 +4127,23 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
wxDataViewItem itemDragged = GetItemByRow( drag_item_row ); wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
// Notify cell about drag // Notify cell about drag
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() ); wxDataViewEvent evt( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
event.SetEventObject( m_owner ); evt.SetEventObject( m_owner );
event.SetItem( itemDragged ); evt.SetItem( itemDragged );
event.SetModel( model ); evt.SetModel( model );
if (!m_owner->HandleWindowEvent( event )) if (!m_owner->HandleWindowEvent( evt ))
return; return;
if (!event.IsAllowed()) if (!evt.IsAllowed())
return; return;
wxDataObject *obj = event.GetDataObject(); wxDataObject *obj = evt.GetDataObject();
if (!obj) if (!obj)
return; return;
wxDataViewDropSource drag( this, drag_item_row ); wxDataViewDropSource drag( this, drag_item_row );
drag.SetData( *obj ); drag.SetData( *obj );
/* wxDragResult res = */ drag.DoDragDrop(event.GetDragFlags()); /* wxDragResult res = */ drag.DoDragDrop(evt.GetDragFlags());
delete obj; delete obj;
} }
return; return;
@ -4838,33 +4852,21 @@ int wxDataViewCtrl::GetModelColumnIndex( unsigned int model_column ) const
return wxNOT_FOUND; return wxNOT_FOUND;
} }
unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const class wxDataViewMaxWidthCalculator : public wxMaxWidthCalculatorBase
{ {
if ( m_colsBestWidths[idx].width != 0 ) public:
return m_colsBestWidths[idx].width; wxDataViewMaxWidthCalculator(const wxDataViewCtrl *dvc,
const int count = m_clientArea->GetRowCount();
wxDataViewColumn *column = GetColumn(idx);
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
class MaxWidthCalculator
{
public:
MaxWidthCalculator(const wxDataViewCtrl *dvc,
wxDataViewMainWindow *clientArea, wxDataViewMainWindow *clientArea,
wxDataViewRenderer *renderer, wxDataViewRenderer *renderer,
const wxDataViewModel *model, const wxDataViewModel *model,
unsigned int model_column, size_t model_column,
int expanderSize) int expanderSize)
: m_width(0), : wxMaxWidthCalculatorBase(model_column),
m_dvc(dvc), m_dvc(dvc),
m_clientArea(clientArea), m_clientArea(clientArea),
m_renderer(renderer), m_renderer(renderer),
m_model(model), m_model(model),
m_model_column(model_column),
m_expanderSize(expanderSize) m_expanderSize(expanderSize)
{ {
int index = dvc->GetModelColumnIndex( model_column ); int index = dvc->GetModelColumnIndex( model_column );
wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index); wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index);
@ -4874,12 +4876,7 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
GetExpanderColumnOrFirstOne(const_cast<wxDataViewCtrl*>(dvc)) == column ); GetExpanderColumnOrFirstOne(const_cast<wxDataViewCtrl*>(dvc)) == column );
} }
void UpdateWithWidth(int width) virtual void UpdateWithRow(int row)
{
m_width = wxMax(m_width, width);
}
void UpdateWithRow(int row)
{ {
int indent = 0; int indent = 0;
wxDataViewItem item; wxDataViewItem item;
@ -4895,24 +4892,31 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
item = m_clientArea->GetItemByRow(row); item = m_clientArea->GetItemByRow(row);
} }
m_renderer->PrepareForItem(m_model, item, m_model_column); m_renderer->PrepareForItem(m_model, item, GetColumn());
m_width = wxMax(m_width, m_renderer->GetSize().x + indent); UpdateWithWidth(m_renderer->GetSize().x + indent);
} }
int GetMaxWidth() const { return m_width; } private:
private:
int m_width;
const wxDataViewCtrl *m_dvc; const wxDataViewCtrl *m_dvc;
wxDataViewMainWindow *m_clientArea; wxDataViewMainWindow *m_clientArea;
wxDataViewRenderer *m_renderer; wxDataViewRenderer *m_renderer;
const wxDataViewModel *m_model; const wxDataViewModel *m_model;
unsigned m_model_column;
bool m_isExpanderCol; bool m_isExpanderCol;
int m_expanderSize; int m_expanderSize;
}; };
MaxWidthCalculator calculator(this, m_clientArea, renderer,
unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
{
if ( m_colsBestWidths[idx].width != 0 )
return m_colsBestWidths[idx].width;
const int count = m_clientArea->GetRowCount();
wxDataViewColumn *column = GetColumn(idx);
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
wxDataViewMaxWidthCalculator calculator(this, m_clientArea, renderer,
GetModel(), column->GetModelColumn(), GetModel(), column->GetModelColumn(),
m_clientArea->GetRowHeight()); m_clientArea->GetRowHeight());
@ -4921,73 +4925,10 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
if ( m_headerArea ) if ( m_headerArea )
calculator.UpdateWithWidth(m_headerArea->GetColumnTitleWidth(*column)); calculator.UpdateWithWidth(m_headerArea->GetColumnTitleWidth(*column));
// The code below deserves some explanation. For very large controls, we
// simply can't afford to calculate sizes for all items, it takes too
// long. So the best we can do is to check the first and the last N/2
// items in the control for some sufficiently large N and calculate best
// sizes from that. That can result in the calculated best width being too
// small for some outliers, but it's better to get slightly imperfect
// result than to wait several seconds after every update. To avoid highly
// visible miscalculations, we also include all currently visible items
// no matter what. Finally, the value of N is determined dynamically by
// measuring how much time we spent on the determining item widths so far.
#if wxUSE_STOPWATCH
int top_part_end = count;
static const long CALC_TIMEOUT = 20/*ms*/;
// don't call wxStopWatch::Time() too often
static const unsigned CALC_CHECK_FREQ = 100;
wxStopWatch timer;
#else
// use some hard-coded limit, that's the best we can do without timer
int top_part_end = wxMin(500, count);
#endif // wxUSE_STOPWATCH/!wxUSE_STOPWATCH
int row = 0;
for ( row = 0; row < top_part_end; row++ )
{
#if wxUSE_STOPWATCH
if ( row % CALC_CHECK_FREQ == CALC_CHECK_FREQ-1 &&
timer.Time() > CALC_TIMEOUT )
break;
#endif // wxUSE_STOPWATCH
calculator.UpdateWithRow(row);
}
// row is the first unmeasured item now; that's our value of N/2
if ( row < count )
{
top_part_end = row;
// add bottom N/2 items now:
const int bottom_part_start = wxMax(row, count - row);
for ( row = bottom_part_start; row < count; row++ )
{
calculator.UpdateWithRow(row);
}
// finally, include currently visible items in the calculation:
const wxPoint origin = CalcUnscrolledPosition(wxPoint(0, 0)); const wxPoint origin = CalcUnscrolledPosition(wxPoint(0, 0));
int first_visible = m_clientArea->GetLineAt(origin.y); calculator.ComputeBestColumnWidth(count,
int last_visible = m_clientArea->GetLineAt(origin.y + GetClientSize().y); m_clientArea->GetLineAt(origin.y),
m_clientArea->GetLineAt(origin.y + GetClientSize().y));
first_visible = wxMax(first_visible, top_part_end);
last_visible = wxMin(bottom_part_start, last_visible);
for ( row = first_visible; row < last_visible; row++ )
{
calculator.UpdateWithRow(row);
}
wxLogTrace("dataview",
"determined best size from %d top, %d bottom plus %d more visible items out of %d total",
top_part_end,
count - bottom_part_start,
wxMax(0, last_visible - first_visible),
count);
}
int max_width = calculator.GetMaxWidth(); int max_width = calculator.GetMaxWidth();
if ( max_width > 0 ) if ( max_width > 0 )
@ -5293,20 +5234,14 @@ void wxDataViewCtrl::Expand( const wxDataViewItem & item )
int row = m_clientArea->GetRowByItem( item ); int row = m_clientArea->GetRowByItem( item );
if (row != -1) if (row != -1)
{
m_clientArea->Expand(row); m_clientArea->Expand(row);
InvalidateColBestWidths();
}
} }
void wxDataViewCtrl::Collapse( const wxDataViewItem & item ) void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
{ {
int row = m_clientArea->GetRowByItem( item ); int row = m_clientArea->GetRowByItem( item );
if (row != -1) if (row != -1)
{
m_clientArea->Collapse(row); m_clientArea->Collapse(row);
InvalidateColBestWidths();
}
} }
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const

View File

@ -1064,10 +1064,15 @@ wxFileName wxGenericFileCtrl::DoGetFileName() const
wxListItem item; wxListItem item;
item.m_itemId = m_list->GetNextItem(-1, wxLIST_NEXT_ALL, item.m_itemId = m_list->GetNextItem(-1, wxLIST_NEXT_ALL,
wxLIST_STATE_SELECTED); wxLIST_STATE_SELECTED);
// ... if anything is selected in the list
if ( item.m_itemId != wxNOT_FOUND )
{
m_list->GetItem(item); m_list->GetItem(item);
fn.Assign(m_list->GetDir(), item.m_text); fn.Assign(m_list->GetDir(), item.m_text);
} }
}
else // user entered the value else // user entered the value
{ {
// the path can be either absolute or relative // the path can be either absolute or relative

View File

@ -339,14 +339,40 @@ bool wxGenericFileDialog::Show( bool show )
void wxGenericFileDialog::OnOk( wxCommandEvent &WXUNUSED(event) ) void wxGenericFileDialog::OnOk( wxCommandEvent &WXUNUSED(event) )
{ {
wxArrayString selectedFiles; wxArrayString selectedFiles;
m_filectrl->GetFilenames(selectedFiles); m_filectrl->GetPaths(selectedFiles);
if (selectedFiles.Count() == 0) if (selectedFiles.Count() == 0)
return; return;
const wxString& path = selectedFiles[0];
if (selectedFiles.Count() == 1) if (selectedFiles.Count() == 1)
{ {
SetPath( selectedFiles[0] ); SetPath(path);
}
// check that the file [doesn't] exist if necessary
if ( HasFdFlag(wxFD_SAVE) && HasFdFlag(wxFD_OVERWRITE_PROMPT) &&
wxFileExists(path) )
{
if ( wxMessageBox
(
wxString::Format
(
_("File '%s' already exists, do you really want to overwrite it?"),
path
),
_("Confirm"),
wxYES_NO
) != wxYES)
return;
}
else if ( HasFdFlag(wxFD_OPEN) && HasFdFlag(wxFD_FILE_MUST_EXIST) &&
!wxFileExists(path) )
{
wxMessageBox(_("Please choose an existing file."), _("Error"),
wxOK | wxICON_ERROR );
return;
} }
EndModal(wxID_OK); EndModal(wxID_OK);

View File

@ -499,6 +499,11 @@ public:
} }
virtual ~wxCairoImageContext() virtual ~wxCairoImageContext()
{
Flush();
}
virtual void Flush()
{ {
m_image = m_data.ConvertToImage(); m_image = m_data.ConvertToImage();
} }
@ -1549,6 +1554,7 @@ wxImage wxCairoBitmapData::ConvertToImage() const
} }
// Prepare for copying data. // Prepare for copying data.
cairo_surface_flush(m_surface);
const wxUint32* src = (wxUint32*)cairo_image_surface_get_data(m_surface); const wxUint32* src = (wxUint32*)cairo_image_surface_get_data(m_surface);
wxCHECK_MSG( src, wxNullImage, wxS("Failed to get Cairo surface data.") ); wxCHECK_MSG( src, wxNullImage, wxS("Failed to get Cairo surface data.") );

View File

@ -1067,6 +1067,7 @@ void wxGridTableBase::SetRowAttr(wxGridCellAttr *attr, int row)
{ {
if ( m_attrProvider ) if ( m_attrProvider )
{ {
if ( attr )
attr->SetKind(wxGridCellAttr::Row); attr->SetKind(wxGridCellAttr::Row);
m_attrProvider->SetRowAttr(attr, row); m_attrProvider->SetRowAttr(attr, row);
} }
@ -1082,6 +1083,7 @@ void wxGridTableBase::SetColAttr(wxGridCellAttr *attr, int col)
{ {
if ( m_attrProvider ) if ( m_attrProvider )
{ {
if ( attr )
attr->SetKind(wxGridCellAttr::Col); attr->SetKind(wxGridCellAttr::Col);
m_attrProvider->SetColAttr(attr, col); m_attrProvider->SetColAttr(attr, col);
} }
@ -2114,6 +2116,7 @@ void wxGridWindow::OnFocus(wxFocusEvent& event)
m_owner->GetGridCursorCol()); m_owner->GetGridCursorCol());
const wxRect cursor = const wxRect cursor =
m_owner->BlockToDeviceRect(cursorCoords, cursorCoords); m_owner->BlockToDeviceRect(cursorCoords, cursorCoords);
if (cursor != wxGridNoCellRect)
Refresh(true, &cursor); Refresh(true, &cursor);
} }
@ -2725,7 +2728,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
for ( i = pos; i < m_numRows; i++ ) for ( i = pos; i < m_numRows; i++ )
{ {
bottom += m_rowHeights[i]; bottom += GetRowHeight(i);
m_rowBottoms[i] = bottom; m_rowBottoms[i] = bottom;
} }
} }
@ -2770,7 +2773,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
for ( i = oldNumRows; i < m_numRows; i++ ) for ( i = oldNumRows; i < m_numRows; i++ )
{ {
bottom += m_rowHeights[i]; bottom += GetRowHeight(i);
m_rowBottoms[i] = bottom; m_rowBottoms[i] = bottom;
} }
} }
@ -2806,7 +2809,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
int h = 0; int h = 0;
for ( i = 0; i < m_numRows; i++ ) for ( i = 0; i < m_numRows; i++ )
{ {
h += m_rowHeights[i]; h += GetRowHeight(i);
m_rowBottoms[i] = h; m_rowBottoms[i] = h;
} }
} }
@ -2890,7 +2893,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
{ {
i = GetColAt( colPos ); i = GetColAt( colPos );
right += m_colWidths[i]; right += GetColWidth(i);
m_colRights[i] = right; m_colRights[i] = right;
} }
} }
@ -2948,7 +2951,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
{ {
i = GetColAt( colPos ); i = GetColAt( colPos );
right += m_colWidths[i]; right += GetColWidth(i);
m_colRights[i] = right; m_colRights[i] = right;
} }
} }
@ -3009,7 +3012,7 @@ bool wxGrid::Redimension( wxGridTableMessage& msg )
{ {
i = GetColAt( colPos ); i = GetColAt( colPos );
w += m_colWidths[i]; w += GetColWidth(i);
m_colRights[i] = w; m_colRights[i] = w;
} }
} }
@ -3952,7 +3955,9 @@ wxGrid::DoGridCellDrag(wxMouseEvent& event,
case wxMOD_CONTROL: case wxMOD_CONTROL:
if ( m_selectedBlockCorner == wxGridNoCellCoords) if ( m_selectedBlockCorner == wxGridNoCellCoords)
m_selectedBlockCorner = coords; m_selectedBlockCorner = coords;
UpdateBlockBeingSelected(m_selectedBlockCorner, coords); if ( isFirstDrag )
SetGridCursor(coords);
UpdateBlockBeingSelected(m_currentCellCoords, coords);
break; break;
case wxMOD_NONE: case wxMOD_NONE:

View File

@ -39,6 +39,7 @@
#include "wx/imaglist.h" #include "wx/imaglist.h"
#include "wx/renderer.h" #include "wx/renderer.h"
#include "wx/generic/private/listctrl.h" #include "wx/generic/private/listctrl.h"
#include "wx/generic/private/widthcalc.h"
#ifdef __WXMAC__ #ifdef __WXMAC__
#include "wx/osx/private.h" #include "wx/osx/private.h"
@ -1935,6 +1936,13 @@ void wxListMainWindow::RefreshLines( size_t lineFrom, size_t lineTo )
size_t visibleFrom, visibleTo; size_t visibleFrom, visibleTo;
GetVisibleLinesRange(&visibleFrom, &visibleTo); GetVisibleLinesRange(&visibleFrom, &visibleTo);
if ( lineFrom > visibleTo || lineTo < visibleFrom )
{
// None of these lines are currently visible at all, don't bother
// doing anything.
return;
}
if ( lineFrom < visibleFrom ) if ( lineFrom < visibleFrom )
lineFrom = visibleFrom; lineFrom = visibleFrom;
if ( lineTo > visibleTo ) if ( lineTo > visibleTo )
@ -2433,7 +2441,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
evtCtx.SetEventObject(GetParent()); evtCtx.SetEventObject(GetParent());
GetParent()->GetEventHandler()->ProcessEvent(evtCtx); GetParent()->GetEventHandler()->ProcessEvent(evtCtx);
} }
else else if (event.LeftDown())
{ {
// reset the selection and bail out // reset the selection and bail out
HighlightAll(false); HighlightAll(false);
@ -2986,6 +2994,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
SetItemState(item, SetItemState(item,
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED, wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED); wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
EnsureVisible(item);
// Reset the bell flag if it had been temporarily disabled // Reset the bell flag if it had been temporarily disabled
// before. // before.
@ -3186,6 +3195,35 @@ void wxListMainWindow::SetColumn( int col, const wxListItem &item )
m_headerWidth = 0; m_headerWidth = 0;
} }
class wxListCtrlMaxWidthCalculator : public wxMaxWidthCalculatorBase
{
public:
wxListCtrlMaxWidthCalculator(wxListMainWindow *listmain, unsigned int column)
: wxMaxWidthCalculatorBase(column),
m_listmain(listmain)
{
}
virtual void UpdateWithRow(int row)
{
wxListLineData *line = m_listmain->GetLine( row );
wxListItemDataList::compatibility_iterator n = line->m_items.Item( GetColumn() );
wxCHECK_RET( n, wxS("no subitem?") );
wxListItemData* const itemData = n->GetData();
wxListItem item;
itemData->GetItem(item);
UpdateWithWidth(m_listmain->GetItemWidthWithImage(&item));
}
private:
wxListMainWindow* const m_listmain;
};
void wxListMainWindow::SetColumnWidth( int col, int width ) void wxListMainWindow::SetColumnWidth( int col, int width )
{ {
wxCHECK_RET( col >= 0 && col < GetColumnCount(), wxCHECK_RET( col >= 0 && col < GetColumnCount(),
@ -3207,48 +3245,42 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
size_t count = GetItemCount(); size_t count = GetItemCount();
if (width == wxLIST_AUTOSIZE_USEHEADER) if ( width == wxLIST_AUTOSIZE_USEHEADER || width == wxLIST_AUTOSIZE )
{ {
width = ComputeMinHeaderWidth(column); wxListCtrlMaxWidthCalculator calculator(this, col);
}
else if ( width == wxLIST_AUTOSIZE )
{
width = ComputeMinHeaderWidth(column);
if ( !IsVirtual() ) calculator.UpdateWithWidth(AUTOSIZE_COL_MARGIN);
{
wxClientDC dc(this);
dc.SetFont( GetFont() );
int max = AUTOSIZE_COL_MARGIN; if ( width == wxLIST_AUTOSIZE_USEHEADER )
calculator.UpdateWithWidth(ComputeMinHeaderWidth(column));
// if the cached column width isn't valid then recalculate it // if the cached column width isn't valid then recalculate it
if (m_aColWidths.Item(col)->bNeedsUpdate) wxColWidthInfo* const pWidthInfo = m_aColWidths.Item(col);
if ( pWidthInfo->bNeedsUpdate )
{ {
for (size_t i = 0; i < count; i++) size_t first_visible, last_visible;
GetVisibleLinesRange(&first_visible, &last_visible);
calculator.ComputeBestColumnWidth(count, first_visible, last_visible);
pWidthInfo->nMaxWidth = calculator.GetMaxWidth();
pWidthInfo->bNeedsUpdate = false;
}
else
{ {
wxListLineData *line = GetLine( i ); calculator.UpdateWithWidth(pWidthInfo->nMaxWidth);
wxListItemDataList::compatibility_iterator n = line->m_items.Item( col );
wxCHECK_RET( n, wxT("no subitem?") );
wxListItemData *itemData = n->GetData();
wxListItem item;
itemData->GetItem(item);
int itemWidth = GetItemWidthWithImage(&item);
if (itemWidth > max)
max = itemWidth;
} }
m_aColWidths.Item(col)->bNeedsUpdate = false; // expand the last column to fit the client size
m_aColWidths.Item(col)->nMaxWidth = max; // only for AUTOSIZE_USEHEADER to mimic MSW behaviour
int margin = 0;
if ( (width == wxLIST_AUTOSIZE_USEHEADER) && (col == GetColumnCount() - 1) )
{
margin = GetClientSize().GetX();
for ( int i = 0; i < col && margin > 0; ++i )
margin -= m_columns.Item(i)->GetData()->GetWidth();
} }
max = m_aColWidths.Item(col)->nMaxWidth + AUTOSIZE_COL_MARGIN; width = wxMax(margin, calculator.GetMaxWidth() + AUTOSIZE_COL_MARGIN);
if ( width < max )
width = max;
}
} }
column->SetWidth( width ); column->SetWidth( width );
@ -3315,8 +3347,12 @@ void wxListMainWindow::SetItem( wxListItem &item )
// update the Max Width Cache if needed // update the Max Width Cache if needed
int width = GetItemWidthWithImage(&item); int width = GetItemWidthWithImage(&item);
if (width > m_aColWidths.Item(item.m_col)->nMaxWidth) wxColWidthInfo* const pWidthInfo = m_aColWidths.Item(item.m_col);
m_aColWidths.Item(item.m_col)->nMaxWidth = width; if ( width > pWidthInfo->nMaxWidth )
{
pWidthInfo->nMaxWidth = width;
pWidthInfo->bNeedsUpdate = true;
}
} }
} }
@ -3959,8 +3995,9 @@ void wxListMainWindow::DeleteItem( long lindex )
itemWidth = GetItemWidthWithImage(&item); itemWidth = GetItemWidthWithImage(&item);
if (itemWidth >= m_aColWidths.Item(i)->nMaxWidth) wxColWidthInfo *pWidthInfo = m_aColWidths.Item(i);
m_aColWidths.Item(i)->bNeedsUpdate = true; if ( itemWidth >= pWidthInfo->nMaxWidth )
pWidthInfo->bNeedsUpdate = true;
} }
ResetVisibleLinesRange(); ResetVisibleLinesRange();
@ -4033,6 +4070,13 @@ void wxListMainWindow::DeleteColumn( int col )
void wxListMainWindow::DoDeleteAllItems() void wxListMainWindow::DoDeleteAllItems()
{ {
// We will need to update all columns if any items are inserted again.
if ( InReportView() )
{
for ( size_t i = 0; i < m_aColWidths.GetCount(); i++ )
m_aColWidths.Item(i)->bNeedsUpdate = true;
}
if ( IsEmpty() ) if ( IsEmpty() )
// nothing to do - in particular, don't send the event // nothing to do - in particular, don't send the event
return; return;
@ -4055,13 +4099,7 @@ void wxListMainWindow::DoDeleteAllItems()
} }
if ( InReportView() ) if ( InReportView() )
{
ResetVisibleLinesRange(); ResetVisibleLinesRange();
for (size_t i = 0; i < m_aColWidths.GetCount(); i++)
{
m_aColWidths.Item(i)->bNeedsUpdate = true;
}
}
m_lines.Clear(); m_lines.Clear();
} }
@ -4225,7 +4263,10 @@ void wxListMainWindow::InsertItem( wxListItem &item )
int width = GetItemWidthWithImage(&item); int width = GetItemWidthWithImage(&item);
item.SetWidth(width); item.SetWidth(width);
if (width > pWidthInfo->nMaxWidth) if (width > pWidthInfo->nMaxWidth)
{
pWidthInfo->nMaxWidth = width; pWidthInfo->nMaxWidth = width;
pWidthInfo->bNeedsUpdate = true;
}
} }
wxListLineData *line = new wxListLineData(this); wxListLineData *line = new wxListLineData(this);
@ -4271,7 +4312,7 @@ long wxListMainWindow::InsertColumn( long col, const wxListItem &item )
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER) if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
column->SetWidth(ComputeMinHeaderWidth(column)); column->SetWidth(ComputeMinHeaderWidth(column));
wxColWidthInfo *colWidthInfo = new wxColWidthInfo(); wxColWidthInfo *colWidthInfo = new wxColWidthInfo(0, IsVirtual());
bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount()); bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount());
if ( insert ) if ( insert )

View File

@ -52,7 +52,7 @@ public:
wxSizer *sizer = new wxBoxSizer(wxVERTICAL); wxSizer *sizer = new wxBoxSizer(wxVERTICAL);
m_notebook = new wxNotebook(this, wxID_ANY); m_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_MULTILINE);
sizer->Add(m_notebook, wxSizerFlags(1).Expand().DoubleBorder()); sizer->Add(m_notebook, wxSizerFlags(1).Expand().DoubleBorder());
#ifdef __WXGTK__ #ifdef __WXGTK__

View File

@ -39,8 +39,6 @@
#include "wx/scrolbar.h" #include "wx/scrolbar.h"
#endif #endif
#include "wx/recguard.h"
#ifdef __WXMSW__ #ifdef __WXMSW__
#include <windows.h> // for DLGC_WANTARROWS #include <windows.h> // for DLGC_WANTARROWS
#include "wx/msw/winundef.h" #include "wx/msw/winundef.h"
@ -58,6 +56,58 @@
#endif #endif
#endif #endif
typedef wxVector<wxScrollHelper *> wxScrollHelperRecGuardFlags;
class wxScrollHelperRecGuard
{
public:
wxScrollHelperRecGuard(wxScrollHelper *instance, wxScrollHelperRecGuardFlags& flags)
: m_flags(flags), m_instance(instance), m_inside(false)
{
// Determine if our instance is already inside a guard
for ( wxScrollHelperRecGuardFlags::iterator iter = flags.begin();
iter != flags.end();
++iter )
{
if ( *iter == instance )
{
m_inside = true;
return;
}
}
// Not inside so add it to the back
flags.push_back(instance);
}
~wxScrollHelperRecGuard()
{
if ( IsInside() )
return;
for ( wxScrollHelperRecGuardFlags::iterator iter = m_flags.begin();
iter != m_flags.end();
++iter )
{
if ( *iter == m_instance )
{
m_flags.erase(iter);
break;
}
}
}
bool IsInside() const { return m_inside; }
private:
wxScrollHelperRecGuardFlags& m_flags;
wxScrollHelper* m_instance;
// true if the flag had been already set when we were created
bool m_inside;
wxDECLARE_NO_COPY_CLASS(wxScrollHelperRecGuard);
};
/* /*
TODO PROPERTIES TODO PROPERTIES
style wxHSCROLL | wxVSCROLL style wxHSCROLL | wxVSCROLL
@ -214,9 +264,6 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true; return true;
} }
if ( processed && event.IsCommandEvent())
return true;
// For wxEVT_PAINT the user code can either handle this event as usual or // For wxEVT_PAINT the user code can either handle this event as usual or
// override virtual OnDraw(), so if the event hasn't been handled we need // override virtual OnDraw(), so if the event hasn't been handled we need
// to call this virtual function ourselves. // to call this virtual function ourselves.
@ -235,6 +282,11 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true; return true;
} }
// If the user code handled this event, it should prevent the default
// handling from taking place, so don't do anything else in this case.
if ( processed )
return true;
if ( evType == wxEVT_CHILD_FOCUS ) if ( evType == wxEVT_CHILD_FOCUS )
{ {
m_scrollHelper->HandleOnChildFocus((wxChildFocusEvent &)event); m_scrollHelper->HandleOnChildFocus((wxChildFocusEvent &)event);
@ -1303,8 +1355,8 @@ wxScrollHelper::DoAdjustScrollbar(int orient,
void wxScrollHelper::AdjustScrollbars() void wxScrollHelper::AdjustScrollbars()
{ {
static wxRecursionGuardFlag s_flagReentrancy; static wxScrollHelperRecGuardFlags s_flagReentrancy;
wxRecursionGuard guard(s_flagReentrancy); wxScrollHelperRecGuard guard(this, s_flagReentrancy);
if ( guard.IsInside() ) if ( guard.IsInside() )
{ {
// don't reenter AdjustScrollbars() while another call to // don't reenter AdjustScrollbars() while another call to

View File

@ -210,16 +210,6 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
m_max = max; m_max = max;
m_increment = increment; m_increment = increment;
m_textCtrl = new wxSpinCtrlTextGeneric(this, value, style);
m_spinButton = new wxSpinCtrlButtonGeneric(this, style);
#if wxUSE_TOOLTIPS
m_textCtrl->SetToolTip(GetToolTipText());
m_spinButton->SetToolTip(GetToolTipText());
#endif // wxUSE_TOOLTIPS
m_spin_value = m_spinButton->GetValue();
// the string value overrides the numeric one (for backwards compatibility // the string value overrides the numeric one (for backwards compatibility
// reasons and also because it is simpler to satisfy the string value which // reasons and also because it is simpler to satisfy the string value which
// comes much sooner in the list of arguments and leave the initial // comes much sooner in the list of arguments and leave the initial
@ -228,12 +218,19 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
{ {
double d; double d;
if ( DoTextToValue(value, &d) ) if ( DoTextToValue(value, &d) )
{
m_value = d; m_value = d;
m_textCtrl->ChangeValue(DoValueToText(m_value));
}
} }
m_textCtrl = new wxSpinCtrlTextGeneric(this, DoValueToText(m_value), style);
m_spinButton = new wxSpinCtrlButtonGeneric(this, style);
#if wxUSE_TOOLTIPS
m_textCtrl->SetToolTip(GetToolTipText());
m_spinButton->SetToolTip(GetToolTipText());
#endif // wxUSE_TOOLTIPS
m_spin_value = m_spinButton->GetValue();
SetInitialSize(size); SetInitialSize(size);
Move(pos); Move(pos);

View File

@ -192,21 +192,15 @@ void wxSplitterWindow::OnInternalIdle()
{ {
wxWindow::OnInternalIdle(); wxWindow::OnInternalIdle();
// We may need to update the children sizes in two cases: either because // We may need to update the children sizes if we're in the middle of
// we're in the middle of a live update as indicated by m_needUpdating or // a live update as indicated by m_needUpdating. The other possible case,
// because we have a requested but not yet set sash position as indicated // when we have a requested but not yet set sash position (as indicated
// by m_requestedSashPosition having a valid value. // by m_requestedSashPosition having a valid value) is handled by OnSize.
if ( m_needUpdating ) if ( m_needUpdating )
{ {
m_needUpdating = false; m_needUpdating = false;
}
else if ( m_requestedSashPosition == INT_MAX )
{
// We don't need to resize the children.
return;
}
SizeWindows(); SizeWindows();
}
} }
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event) void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)

View File

@ -456,7 +456,12 @@ wxSize wxSearchCtrl::DoGetBestSize() const
// buttons are square and equal to the height of the text control // buttons are square and equal to the height of the text control
int height = sizeText.y; int height = sizeText.y;
return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder, return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder,
#ifdef __WXMSW__
// Border is already added in wxSearchTextCtrl::DoGetBestSize()
height);
#else
height) + DoGetBorderSize(); height) + DoGetBorderSize();
#endif
} }
void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height) void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height)
@ -521,7 +526,17 @@ void wxSearchCtrl::DoLayoutControls()
x += sizeSearch.x; x += sizeSearch.x;
x += searchMargin; x += searchMargin;
m_text->SetSize(x, 0, textWidth, height); #ifdef __WXMSW__
// The text control is too high up on Windows; normally a text control looks OK because
// of the white border that's part of the theme border. We can also remove a pixel from
// the height to fit the text control in, because the padding in EDIT_HEIGHT_FROM_CHAR_HEIGHT
// is already generous.
int textY = 1;
#else
int textY = 0;
#endif
m_text->SetSize(x, textY, textWidth, height-textY);
x += textWidth; x += textWidth;
x += cancelMargin; x += cancelMargin;

View File

@ -26,6 +26,7 @@
#ifndef WX_PRECOMP #ifndef WX_PRECOMP
#include "wx/textctrl.h" #include "wx/textctrl.h"
#include "wx/utils.h" // wxMax()
#endif // WX_PRECOMP #endif // WX_PRECOMP
#include "wx/timectrl.h" #include "wx/timectrl.h"
@ -657,7 +658,7 @@ void wxTimePickerCtrlGeneric::DoMoveWindow(int x, int y, int width, int height)
return; return;
const int widthBtn = m_impl->m_btn->GetSize().x; const int widthBtn = m_impl->m_btn->GetSize().x;
const int widthText = width - widthBtn - HMARGIN_TEXT_SPIN; const int widthText = wxMax(width - widthBtn - HMARGIN_TEXT_SPIN, 0);
m_impl->m_text->SetSize(0, 0, widthText, height); m_impl->m_text->SetSize(0, 0, widthText, height);
m_impl->m_btn->SetSize(widthText + HMARGIN_TEXT_SPIN, 0, widthBtn, height); m_impl->m_btn->SetSize(widthText + HMARGIN_TEXT_SPIN, 0, widthBtn, height);

View File

@ -515,6 +515,13 @@ void wxTreeTextCtrl::Finish( bool setfocus )
{ {
m_owner->ResetTextControl(); m_owner->ResetTextControl();
#ifdef __WXMAC__
// On wxMac, modal event loops avoid deleting pending objects.
// Hide control so it does not remain visible e.g. if the tree
// control is used in a dialog.
Hide();
#endif
wxPendingDelete.Append(this); wxPendingDelete.Append(this);
if (setfocus) if (setfocus)

View File

@ -170,10 +170,15 @@ public:
wxScopedArray<wxString> oldTexts(m_columnsTexts); wxScopedArray<wxString> oldTexts(m_columnsTexts);
m_columnsTexts = new wxString[numColumns - 2]; m_columnsTexts = new wxString[numColumns - 2];
// As above, n is the index in the new column texts array and m is the
// index in the old one.
for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ ) for ( unsigned n = 1, m = 1; n < numColumns - 1; n++, m++ )
{ {
if ( n == col ) if ( m == col )
{ {
// Skip copying the deleted column and keep the new index the
// same (so compensate for "n++" done in the loop).
n--; n--;
} }
else // Not the deleted column. else // Not the deleted column.
@ -738,7 +743,10 @@ void wxTreeListModel::DeleteItem(Node* item)
previous->DeleteNext(); previous->DeleteNext();
} }
ItemDeleted(ToDVI(parent), ToDVI(item)); // Note that the item is already deleted by now, so we can't use it in any
// way, e.g. by calling ToDVI(item) which does dereference the pointer, but
// ToNonRootDVI() that we use here does not.
ItemDeleted(ToDVI(parent), ToNonRootDVI(item));
} }
void wxTreeListModel::DeleteAllItems() void wxTreeListModel::DeleteAllItems()

View File

@ -89,9 +89,6 @@ bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true; return true;
} }
if ( processed && event.IsCommandEvent())
return true;
// For wxEVT_PAINT the user code can either handle this event as usual or // For wxEVT_PAINT the user code can either handle this event as usual or
// override virtual OnDraw(), so if the event hasn't been handled we need // override virtual OnDraw(), so if the event hasn't been handled we need
// to call this virtual function ourselves. // to call this virtual function ourselves.
@ -110,6 +107,11 @@ bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true; return true;
} }
// If the user code handled this event, it should prevent the default
// handling from taking place, so don't do anything else in this case.
if ( processed )
return true;
// reset the skipped flag (which might have been set to true in // reset the skipped flag (which might have been set to true in
// ProcessEvent() above) to be able to test it below // ProcessEvent() above) to be able to test it below
bool wasSkipped = event.GetSkipped(); bool wasSkipped = event.GetSkipped();

View File

@ -519,8 +519,9 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
{ {
wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") ); wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") );
// account for the bitmap size // account for the bitmap size, including the user-specified margins
const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize(); const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize()
+ 2*m_imageData->GetBitmapMargins();
const wxDirection dirBmp = m_imageData->GetBitmapPosition(); const wxDirection dirBmp = m_imageData->GetBitmapPosition();
if ( dirBmp == wxLEFT || dirBmp == wxRIGHT ) if ( dirBmp == wxLEFT || dirBmp == wxRIGHT )
{ {
@ -535,9 +536,6 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
size.x = sizeBmp.x; size.x = sizeBmp.x;
} }
// account for the user-specified margins
size += 2*m_imageData->GetBitmapMargins();
// and also for the margins we always add internally (unless we have no // and also for the margins we always add internally (unless we have no
// border at all in which case the button has exactly the same size as // border at all in which case the button has exactly the same size as
// bitmap and so no margins should be used) // bitmap and so no margins should be used)

View File

@ -630,9 +630,9 @@ private:
}; };
//// Initialize //// Initialize
bool wxApp::Initialize(int& argc, wxChar **argv) bool wxApp::Initialize(int& argc_, wxChar **argv_)
{ {
if ( !wxAppBase::Initialize(argc, argv) ) if ( !wxAppBase::Initialize(argc_, argv_) )
return false; return false;
// ensure that base cleanup is done if we return too early // ensure that base cleanup is done if we return too early

View File

@ -197,7 +197,7 @@ wxBitmap wxWindowsArtProvider::CreateBitmap(const wxArtID& id,
wxIcon icon; wxIcon icon;
icon.CreateFromHICON( (WXHICON)sii.hIcon ); icon.CreateFromHICON( (WXHICON)sii.hIcon );
wxBitmap bitmap( icon ); bitmap = wxBitmap(icon);
::DestroyIcon(sii.hIcon); ::DestroyIcon(sii.hIcon);
if ( bitmap.IsOk() ) if ( bitmap.IsOk() )

View File

@ -573,7 +573,7 @@ wxBitmap::wxBitmap(const char bits[], int width, int height, int depth)
unsigned char val = *src++; unsigned char val = *src++;
unsigned char reversed = 0; unsigned char reversed = 0;
for ( int bits = 0; bits < 8; bits++) for ( int bit = 0; bit < 8; bit++)
{ {
reversed <<= 1; reversed <<= 1;
reversed |= (unsigned char)(val & 0x01); reversed |= (unsigned char)(val & 0x01);

View File

@ -449,9 +449,9 @@ bool wxBitmapComboBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT) item; LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT) item;
int pos = lpMeasureItem->itemID; int pos = lpMeasureItem->itemID;
// Measure item height if item list is not empty, // Measure edit field height if item list is not empty,
// otherwise leave default system value. // otherwise leave default system value.
if ( pos >= 0 ) if ( m_usedImgSize.y >= 0 || pos >= 0 )
{ {
lpMeasureItem->itemHeight = wxBitmapComboBoxBase::MeasureItem(pos); lpMeasureItem->itemHeight = wxBitmapComboBoxBase::MeasureItem(pos);
} }

View File

@ -157,7 +157,14 @@ bool wxCheckListBoxItem::OnDrawItem(wxDC& dc, const wxRect& rc,
int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2; int y = rc.GetY() + (rc.GetHeight() - size.GetHeight()) / 2;
UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL; UINT uState = stat & wxOwnerDrawn::wxODSelected ? wxDSB_SELECTED : wxDSB_NORMAL;
// checkmarks should not be mirrored in RTL layout
DWORD oldLayout = impl->GetLayoutDirection() == wxLayout_RightToLeft ? LAYOUT_RTL : 0;
if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout | LAYOUT_BITMAPORIENTATIONPRESERVED);
wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState); wxDrawStateBitmap(hdc, hBmpCheck, x, y, uState);
if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout);
return true; return true;
} }

View File

@ -2007,7 +2007,7 @@ void wxMSWDCImpl::RealizeScaleAndOrigin()
// Becaue only devExtX/logExtX ratio and devExtY/logExtY ratio are counted // Becaue only devExtX/logExtX ratio and devExtY/logExtY ratio are counted
// we can reduce the fractions to avoid large absolute numbers // we can reduce the fractions to avoid large absolute numbers
// and possible arithmetic overflows. // and possible arithmetic overflows.
unsigned int gcd = CalcGCD(abs(devExtX), abs(logExtX)); int gcd = CalcGCD(abs(devExtX), abs(logExtX));
devExtX /= gcd; devExtX /= gcd;
logExtX /= gcd; logExtX /= gcd;
gcd = CalcGCD(abs(devExtY), abs(logExtY)); gcd = CalcGCD(abs(devExtY), abs(logExtY));
@ -2127,6 +2127,8 @@ void wxMSWDCImpl::SetLogicalScale(double x, double y)
WXMICROWIN_CHECK_HDC WXMICROWIN_CHECK_HDC
wxDCImpl::SetLogicalScale(x,y); wxDCImpl::SetLogicalScale(x,y);
RealizeScaleAndOrigin();
} }
void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y) void wxMSWDCImpl::SetDeviceOrigin(wxCoord x, wxCoord y)

View File

@ -222,7 +222,7 @@ int wxDirDialog::ShowModal()
{ {
WX_HOOK_MODAL_DIALOG(); WX_HOOK_MODAL_DIALOG();
wxWindow* const parent = GetParent(); wxWindow* const parent = GetParentForModalDialog();
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL; WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
// Use IFileDialog under new enough Windows, it's more user-friendly. // Use IFileDialog under new enough Windows, it's more user-friendly.

View File

@ -664,7 +664,7 @@ int wxFileDialog::ShowModal()
const wxChar* extension = filterBuffer.t_str(); const wxChar* extension = filterBuffer.t_str();
int maxFilter = (int)(of.nFilterIndex*2L) - 1; int maxFilter = (int)(of.nFilterIndex*2L) - 1;
for( int i = 0; i < maxFilter; i++ ) // get extension for( int j = 0; j < maxFilter; j++ ) // get extension
extension = extension + wxStrlen( extension ) + 1; extension = extension + wxStrlen( extension ) + 1;
// use dummy name a to avoid assert in AppendExtension // use dummy name a to avoid assert in AppendExtension
@ -676,23 +676,30 @@ int wxFileDialog::ShowModal()
} }
} }
// Create a temporary struct to restore the CWD when we exit this function
// store off before the standard windows dialog can possibly change it // store off before the standard windows dialog can possibly change it
const wxString cwdOrig = wxGetCwd(); struct CwdRestore
{
//== Execute FileDialog >>================================================= wxString value;
~CwdRestore()
if ( !ShowCommFileDialog(&of, m_windowStyle) ) {
return wxID_CANCEL; if (!value.empty())
wxSetWorkingDirectory(value);
}
} cwdOrig;
// GetOpenFileName will always change the current working directory on // GetOpenFileName will always change the current working directory on
// (according to MSDN) "Windows NT 4.0/2000/XP" because the flag // (according to MSDN) "Windows NT 4.0/2000/XP" because the flag
// OFN_NOCHANGEDIR has no effect. If the user did not specify // OFN_NOCHANGEDIR has no effect. If the user did not specify
// wxFD_CHANGE_DIR let's restore the current working directory to what it // wxFD_CHANGE_DIR let's restore the current working directory to what it
// was before the dialog was shown. // was before the dialog was shown.
if ( msw_flags & OFN_NOCHANGEDIR ) if (msw_flags & OFN_NOCHANGEDIR)
{ cwdOrig.value = wxGetCwd();
wxSetWorkingDirectory(cwdOrig);
} //== Execute FileDialog >>=================================================
if ( !ShowCommFileDialog(&of, m_windowStyle) )
return wxID_CANCEL;
m_fileNames.Empty(); m_fileNames.Empty();
@ -726,11 +733,11 @@ int wxFileDialog::ShowModal()
m_fileNames.Add(toke.GetNextToken()); m_fileNames.Add(toke.GetNextToken());
#endif // OFN_EXPLORER #endif // OFN_EXPLORER
wxString dir(m_dir); m_path = m_dir;
if ( m_dir.Last() != wxT('\\') ) if ( m_dir.Last() != wxT('\\') )
dir += wxT('\\'); m_path += wxT('\\');
m_path = dir + m_fileName; m_path += m_fileName;
m_filterIndex = (int)of.nFilterIndex - 1; m_filterIndex = (int)of.nFilterIndex - 1;
} }
else else
@ -746,7 +753,7 @@ int wxFileDialog::ShowModal()
const wxChar* extension = filterBuffer.t_str(); const wxChar* extension = filterBuffer.t_str();
int maxFilter = (int)(of.nFilterIndex*2L) - 1; int maxFilter = (int)(of.nFilterIndex*2L) - 1;
for( int i = 0; i < maxFilter; i++ ) // get extension for( int j = 0; j < maxFilter; j++ ) // get extension
extension = extension + wxStrlen( extension ) + 1; extension = extension + wxStrlen( extension ) + 1;
m_fileName = AppendExtension(fileNameBuffer, extension); m_fileName = AppendExtension(fileNameBuffer, extension);

View File

@ -386,7 +386,8 @@ void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont)
m_hFont = (HFONT)hFont; m_hFont = (HFONT)hFont;
m_nativeFontInfo = info; m_nativeFontInfo = info;
// TODO: m_sizeUsingPixels? // size of native fonts is expressed in pixels
m_sizeUsingPixels = true;
} }
wxFontRefData::~wxFontRefData() wxFontRefData::~wxFontRefData()

View File

@ -258,6 +258,10 @@ wxFontEncoding wxGetFontEncFromCharSet(int cs)
fontEncoding = wxFONTENCODING_CP1361; fontEncoding = wxFONTENCODING_CP1361;
break; break;
case MAC_CHARSET:
fontEncoding = wxFONTENCODING_MACROMAN;
break;
#endif // Win32 #endif // Win32
case OEM_CHARSET: case OEM_CHARSET:

View File

@ -286,16 +286,6 @@ void wxFrame::PositionStatusBar()
int w, h; int w, h;
GetClientSize(&w, &h); GetClientSize(&w, &h);
// Resize the status bar to its default height, as it could have been set
// to a wrong value before by WM_SIZE sent during the frame creation and
// our status bars preserve their programmatically set size to avoid being
// resized by DefWindowProc() to the full window width, so if we didn't do
// this here, the status bar would retain the possibly wrong current height.
m_frameStatusBar->SetSize(wxDefaultSize, wxSIZE_AUTO_HEIGHT);
int sw, sh;
m_frameStatusBar->GetSize(&sw, &sh);
int x = 0; int x = 0;
#if wxUSE_TOOLBAR #if wxUSE_TOOLBAR
wxToolBar * const toolbar = GetToolBar(); wxToolBar * const toolbar = GetToolBar();
@ -319,6 +309,16 @@ void wxFrame::PositionStatusBar()
//else: no adjustments necessary for the toolbar on top //else: no adjustments necessary for the toolbar on top
#endif // wxUSE_TOOLBAR #endif // wxUSE_TOOLBAR
// Resize the status bar to its default height, as it could have been set
// to a wrong value before by WM_SIZE sent during the frame creation and
// our status bars preserve their programmatically set size to avoid being
// resized by DefWindowProc() to the full window width, so if we didn't do
// this here, the status bar would retain the possibly wrong current height.
m_frameStatusBar->SetSize(x, h, w, wxDefaultCoord, wxSIZE_AUTO_HEIGHT);
int sw, sh;
m_frameStatusBar->GetSize(&sw, &sh);
// Since we wish the status bar to be directly under the client area, // Since we wish the status bar to be directly under the client area,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS. // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
m_frameStatusBar->SetSize(x, h, w, sh); m_frameStatusBar->SetSize(x, h, w, sh);

View File

@ -217,7 +217,7 @@ wxThread::ExitCode wxIOCPThread::Entry()
} }
// wait for events to occur, read them and send to interested parties // wait for events to occur, read them and send to interested parties
// returns false it empty status was read, which means we whould exit // returns false it empty status was read, which means we would exit
// true otherwise // true otherwise
bool wxIOCPThread::ReadEvents() bool wxIOCPThread::ReadEvents()
{ {

View File

@ -45,7 +45,7 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
#endif #endif
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// define possibly missing WGL constants // define possibly missing WGL constants and types
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#ifndef WGL_ARB_pixel_format #ifndef WGL_ARB_pixel_format
@ -76,6 +76,49 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
#define WGL_SAMPLES_ARB 0x2042 #define WGL_SAMPLES_ARB 0x2042
#endif #endif
#ifndef WGL_ARB_create_context
#define WGL_ARB_create_context
#define WGL_CONTEXT_MAJOR_VERSION_ARB 0x2091
#define WGL_CONTEXT_MINOR_VERSION_ARB 0x2092
#define WGL_CONTEXT_LAYER_PLANE_ARB 0x2093
#define WGL_CONTEXT_FLAGS_ARB 0x2094
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#define WGL_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x0002
#ifndef WGL_ARB_create_context_profile
#define WGL_ARB_create_context_profile
#define WGL_CONTEXT_PROFILE_MASK_ARB 0x9126
#define WGL_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
#define WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
#endif
#ifndef WGL_ARB_create_context_robustness
#define WGL_ARB_create_context_robustness
#define WGL_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
#define WGL_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
#define WGL_NO_RESET_NOTIFICATION_ARB 0x8261
#define WGL_LOSE_CONTEXT_ON_RESET_ARB 0x8252
#endif
#endif
#ifndef WGL_EXT_create_context_es2_profile
#define WGL_EXT_create_context_es2_profile
#define WGL_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
#endif
#ifndef WGL_EXT_create_context_es_profile
#define WGL_EXT_create_context_es_profile
#define WGL_CONTEXT_ES_PROFILE_BIT_EXT 0x00000004
#endif
#ifndef WGL_ARB_framebuffer_sRGB
#define WGL_ARB_framebuffer_sRGB
#define WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20A9
#endif
typedef HGLRC(WINAPI * PFNWGLCREATECONTEXTATTRIBSARBPROC)
(HDC hDC, HGLRC hShareContext, const int *attribList);
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// libraries // libraries
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -108,10 +151,44 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
IMPLEMENT_CLASS(wxGLContext, wxObject) IMPLEMENT_CLASS(wxGLContext, wxObject)
// The window will always be created first so the array will be initialized
// and then the window will be assigned to the context.
// max 8 attributes plus terminator
// if first is 0, create legacy context
static int s_wglContextAttribs[9] = {0};
wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext* other) wxGLContext::wxGLContext(wxGLCanvas *win, const wxGLContext* other)
{ {
if ( s_wglContextAttribs[0] == 0 ) // create legacy context
{
m_glContext = wglCreateContext(win->GetHDC()); m_glContext = wglCreateContext(win->GetHDC());
wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") ); wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
}
else // create a context using attributes
{
// We need to create a temporary context to get the
// wglCreateContextAttribsARB function
HGLRC tempContext = wglCreateContext(win->GetHDC());
wxCHECK_RET( tempContext, wxT("Couldn't create OpenGL context") );
wglMakeCurrent(win->GetHDC(), tempContext);
PFNWGLCREATECONTEXTATTRIBSARBPROC wglCreateContextAttribsARB
= (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB");
wglMakeCurrent(win->GetHDC(), NULL);
wglDeleteContext(tempContext);
if ( !wglCreateContextAttribsARB )
{
wxLogError(_("Core OpenGL profile is not supported by the OpenGL driver."));
return;
}
m_glContext = wglCreateContextAttribsARB(
win->GetHDC(), 0, s_wglContextAttribs);
wxCHECK_RET( m_glContext,
wxT("Couldn't create core profile OpenGL context") );
}
if ( other ) if ( other )
{ {
@ -235,6 +312,58 @@ bool wxGLCanvas::Create(wxWindow *parent,
if ( !CreateWindow(parent, id, pos, size, style, name) ) if ( !CreateWindow(parent, id, pos, size, style, name) )
return false; return false;
// these will be used for the context creation attributes
// if a core profile is requested
bool useGLCoreProfile = false;
// the minimum gl core version is 3.0
int glVersionMajor = 3,
glVersionMinor = 0;
// Check for a core profile request
if ( attribList )
{
for ( int i = 0; attribList[i]; )
{
switch ( attribList[i++] )
{
case WX_GL_CORE_PROFILE:
useGLCoreProfile = true;
break;
case WX_GL_MAJOR_VERSION:
glVersionMajor = attribList[i++];
break;
case WX_GL_MINOR_VERSION:
glVersionMinor = attribList[i++];
break;
default:
// ignore all other flags for now
break;
}
}
}
if ( useGLCoreProfile )
{
s_wglContextAttribs[0] = WGL_CONTEXT_MAJOR_VERSION_ARB;
s_wglContextAttribs[1] = glVersionMajor;
s_wglContextAttribs[2] = WGL_CONTEXT_MINOR_VERSION_ARB;
s_wglContextAttribs[3] = glVersionMinor;
s_wglContextAttribs[4] = WGL_CONTEXT_FLAGS_ARB;
s_wglContextAttribs[5] = WGL_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
s_wglContextAttribs[6] = WGL_CONTEXT_PROFILE_MASK_ARB;
s_wglContextAttribs[7] = WGL_CONTEXT_CORE_PROFILE_BIT_ARB;
s_wglContextAttribs[8] = 0; // terminate
}
else // create legacy/compatibility context
{
s_wglContextAttribs[0] = 0;
}
PIXELFORMATDESCRIPTOR pfd; PIXELFORMATDESCRIPTOR pfd;
const int setupVal = DoSetup(pfd, attribList); const int setupVal = DoSetup(pfd, attribList);
if ( setupVal == 0 ) // PixelFormat error if ( setupVal == 0 ) // PixelFormat error

View File

@ -459,6 +459,11 @@ public:
} }
virtual ~wxGDIPlusImageContext() virtual ~wxGDIPlusImageContext()
{
Flush();
}
virtual void Flush()
{ {
m_image = m_bitmap.ConvertToImage(); m_image = m_bitmap.ConvertToImage();
} }
@ -1754,11 +1759,11 @@ void wxGDIPlusContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxD
interim.GetPixelFormat(),&data); interim.GetPixelFormat(),&data);
bool hasAlpha = false; bool hasAlpha = false;
for ( size_t y = 0 ; y < height && !hasAlpha ; ++y) for ( size_t yy = 0 ; yy < height && !hasAlpha ; ++yy)
{ {
for( size_t x = 0 ; x < width && !hasAlpha; ++x) for( size_t xx = 0 ; xx < width && !hasAlpha; ++xx)
{ {
ARGB *dest = (ARGB*)((BYTE*)data.Scan0 + data.Stride*y + x*4); ARGB *dest = (ARGB*)((BYTE*)data.Scan0 + data.Stride*yy + xx*4);
if ( ( *dest & Color::AlphaMask ) != 0 ) if ( ( *dest & Color::AlphaMask ) != 0 )
hasAlpha = true; hasAlpha = true;
} }

View File

@ -745,7 +745,7 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
if ( pStruct->itemID == (UINT)-1 ) if ( pStruct->itemID == (UINT)-1 )
return false; return false;
wxListBoxItem *pItem = (wxListBoxItem *)m_aItems[pStruct->itemID]; wxOwnerDrawn *pItem = m_aItems[pStruct->itemID];
wxDCTemp dc((WXHDC)pStruct->hDC); wxDCTemp dc((WXHDC)pStruct->hDC);

View File

@ -620,7 +620,15 @@ bool wxListCtrl::SetColumnWidth(int col, int width)
else if ( width == wxLIST_AUTOSIZE_USEHEADER) else if ( width == wxLIST_AUTOSIZE_USEHEADER)
width = LVSCW_AUTOSIZE_USEHEADER; width = LVSCW_AUTOSIZE_USEHEADER;
return ListView_SetColumnWidth(GetHwnd(), col, width) != 0; if ( !ListView_SetColumnWidth(GetHwnd(), col, width) )
return false;
// Failure to explicitly refresh the control with horizontal rules results
// in corrupted rules display.
if ( HasFlag(wxLC_HRULES) )
Refresh();
return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@ -297,8 +297,23 @@ void wxSetProcessDPIAware()
#endif // wxUSE_DYNLIB_CLASS #endif // wxUSE_DYNLIB_CLASS
} }
// It is sometimes undesirable to force DPI awareness on appplications, e.g.
// when they are artwork heavy and don't have appropriately scaled bitmaps, or
// when they are using non-wx, DPI-unaware code. Allow disabling
// SetProcessDPIAware() call.
//
// Further discussion:
// http://trac.wxwidgets.org/ticket/16116
// https://groups.google.com/d/topic/wx-dev/Z0VpgzCY34U/discussion
bool gs_allowChangingDPIAwareness = true;
} //anonymous namespace } //anonymous namespace
void wxMSWDisableSettingHighDPIAware()
{
gs_allowChangingDPIAwareness = false;
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Windows-specific wxEntry // Windows-specific wxEntry
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@ -405,6 +420,8 @@ WXDLLEXPORT int wxEntry(HINSTANCE hInstance,
// http://msdn.microsoft.com/en-us/library/dd464659%28VS.85%29.aspx). // http://msdn.microsoft.com/en-us/library/dd464659%28VS.85%29.aspx).
// Note that we intentionally do it here and not in wxApp, so that it // Note that we intentionally do it here and not in wxApp, so that it
// doesn't happen if wx code is hosted in another app (e.g. a plugin). // doesn't happen if wx code is hosted in another app (e.g. a plugin).
// It can be disabled by calling wxMSWAllowChangingDPIAwareness().
if ( gs_allowChangingDPIAwareness )
wxSetProcessDPIAware(); wxSetProcessDPIAware();
if ( !wxMSWEntryCommon(hInstance, nCmdShow) ) if ( !wxMSWEntryCommon(hInstance, nCmdShow) )

View File

@ -625,7 +625,7 @@ wxQTMediaBackend::~wxQTMediaBackend()
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
// wxQTMediaBackend::CreateControl // wxQTMediaBackend::CreateControl
// //
// 1) Intializes QuickTime // 1) Initializes QuickTime
// 2) Creates the control window // 2) Creates the control window
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent, bool wxQTMediaBackend::CreateControl(wxControl* ctrl, wxWindow* parent,

View File

@ -746,7 +746,7 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
{ {
// we must use position in SetOwnerDrawnMenuItem because // we must use position in SetOwnerDrawnMenuItem because
// all separators have the same id // all separators have the same id
int pos = 0; int position = 0;
wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
while (node) while (node)
{ {
@ -755,14 +755,14 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
if ( !item->IsOwnerDrawn()) if ( !item->IsOwnerDrawn())
{ {
item->SetOwnerDrawn(true); item->SetOwnerDrawn(true);
SetOwnerDrawnMenuItem(GetHmenu(), pos, SetOwnerDrawnMenuItem(GetHmenu(), position,
reinterpret_cast<ULONG_PTR>(item), TRUE); reinterpret_cast<ULONG_PTR>(item), TRUE);
} }
item->SetMarginWidth(m_maxBitmapWidth); item->SetMarginWidth(m_maxBitmapWidth);
node = node->GetNext(); node = node->GetNext();
pos++; position++;
} }
// set menu as ownerdrawn // set menu as ownerdrawn

View File

@ -557,11 +557,12 @@ void wxMenuItem::Enable(bool enable)
if ( m_isEnabled == enable ) if ( m_isEnabled == enable )
return; return;
if ( m_parentMenu ) const int itemPos = MSGetMenuItemPos();
if ( itemPos != -1 )
{ {
long rc = EnableMenuItem(GetHMenuOf(m_parentMenu), long rc = EnableMenuItem(GetHMenuOf(m_parentMenu),
GetMSWId(), itemPos,
MF_BYCOMMAND | MF_BYPOSITION |
(enable ? MF_ENABLED : MF_GRAYED)); (enable ? MF_ENABLED : MF_GRAYED));
if ( rc == -1 ) if ( rc == -1 )
@ -872,7 +873,8 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
data->SeparatorMargin.ApplyTo(rcSeparator); data->SeparatorMargin.ApplyTo(rcSeparator);
RECT rcGutter = rcSelection; RECT rcGutter = rcSelection;
rcGutter.right = data->ItemMargin.cxLeftWidth rcGutter.right = rcGutter.left
+ data->ItemMargin.cxLeftWidth
+ data->CheckBgMargin.cxLeftWidth + data->CheckBgMargin.cxLeftWidth
+ data->CheckMargin.cxLeftWidth + data->CheckMargin.cxLeftWidth
+ imgWidth + imgWidth
@ -993,13 +995,13 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
SIZE accelSize; SIZE accelSize;
::GetTextExtentPoint32(hdc, accel.c_str(), accel.length(), &accelSize); ::GetTextExtentPoint32(hdc, accel.c_str(), accel.length(), &accelSize);
int flags = DST_TEXT; flags = DST_TEXT;
// themes menu is using specified color for disabled labels // themes menu is using specified color for disabled labels
if ( data->MenuLayout() == MenuDrawData::Classic && if ( data->MenuLayout() == MenuDrawData::Classic &&
(stat & wxODDisabled) && !(stat & wxODSelected) ) (stat & wxODDisabled) && !(stat & wxODSelected) )
flags |= DSS_DISABLED; flags |= DSS_DISABLED;
int x = rcText.right - data->ArrowMargin.GetTotalX() x = rcText.right - data->ArrowMargin.GetTotalX()
- data->ArrowSize.cx - data->ArrowSize.cx
- data->ArrowBorder; - data->ArrowBorder;
@ -1009,7 +1011,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
else else
x -= m_parentMenu->GetMaxAccelWidth(); x -= m_parentMenu->GetMaxAccelWidth();
int y = rcText.top + (rcText.bottom - rcText.top - accelSize.cy) / 2; y = rcText.top + (rcText.bottom - rcText.top - accelSize.cy) / 2;
::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(accel), ::DrawState(hdc, NULL, NULL, wxMSW_CONV_LPARAM(accel),
accel.length(), x, y, 0, 0, flags); accel.length(), x, y, 0, 0, flags);
@ -1271,7 +1273,7 @@ int wxMenuItem::MSGetMenuItemPos() const
if ( state & MF_POPUP ) if ( state & MF_POPUP )
{ {
if ( ::GetSubMenu(hMenu, i) == (HMENU)id ) if ( ::GetSubMenu(hMenu, i) == (HMENU)wxUIntToPtr(id) )
return i; return i;
} }
else if ( !(state & MF_SEPARATOR) ) else if ( !(state & MF_SEPARATOR) )

View File

@ -66,6 +66,17 @@ class WXDLLIMPEXP_FWD_CORE wxIcon;
// to open/print the file (the positional parameters are introduced by %1, // to open/print the file (the positional parameters are introduced by %1,
// %2, ... in these strings, we change them to %s ourselves) // %2, ... in these strings, we change them to %s ourselves)
// Notice that HKCR can be used only when reading from the registry, when
// writing to it, we need to write to HKCU\Software\Classes instead as HKCR is
// a merged view of that location and HKLM\Software\Classes that we generally
// wouldn't have the write permissions to but writing to HKCR will try writing
// to the latter unless the key being written to already exists under the
// former, resulting in a "Permission denied" error without administrative
// permissions. So the right thing to do is to use HKCR when reading, to
// respect both per-user and machine-global associations, but only write under
// HKCU.
static const wxStringCharType *CLASSES_ROOT_KEY = wxS("Software\\Classes\\");
// although I don't know of any official documentation which mentions this // although I don't know of any official documentation which mentions this
// location, uses it, so it isn't likely to change // location, uses it, so it isn't likely to change
static const wxChar *MIME_DATABASE_KEY = wxT("MIME\\Database\\Content Type\\"); static const wxChar *MIME_DATABASE_KEY = wxT("MIME\\Database\\Content Type\\");
@ -190,7 +201,7 @@ size_t wxFileTypeImpl::GetAllCommands(wxArrayString *verbs,
bool wxFileTypeImpl::EnsureExtKeyExists() bool wxFileTypeImpl::EnsureExtKeyExists()
{ {
wxRegKey rkey(wxRegKey::HKCR, m_ext); wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + m_ext);
if ( !rkey.Exists() ) if ( !rkey.Exists() )
{ {
if ( !rkey.Create() || !rkey.SetValue(wxEmptyString, m_strFileType) ) if ( !rkey.Create() || !rkey.SetValue(wxEmptyString, m_strFileType) )
@ -514,20 +525,6 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& ext)
return CreateFileType(wxEmptyString, ext); return CreateFileType(wxEmptyString, ext);
} }
/*
wxFileType *
wxMimeTypesManagerImpl::GetOrAllocateFileTypeFromExtension(const wxString& ext)
{
wxFileType *fileType = GetFileTypeFromExtension(ext);
if ( !fileType )
{
fileType = CreateFileType(wxEmptyString, ext);
}
return fileType;
}
*/
// MIME type -> extension -> file type // MIME type -> extension -> file type
wxFileType * wxFileType *
wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType) wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
@ -591,11 +588,11 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
extWithDot = wxT('.'); extWithDot = wxT('.');
extWithDot += ext; extWithDot += ext;
// start by setting the HKCR\\.ext entries // start by setting the entries under ".ext"
// default is filetype; content type is mimetype // default is filetype; content type is mimetype
const wxString& filetypeOrig = ftInfo.GetShortDesc(); const wxString& filetypeOrig = ftInfo.GetShortDesc();
wxRegKey key(wxRegKey::HKCR, extWithDot); wxRegKey key(wxRegKey::HKCU, CLASSES_ROOT_KEY + extWithDot);
if ( !key.Exists() ) if ( !key.Exists() )
{ {
// create the mapping from the extension to the filetype // create the mapping from the extension to the filetype
@ -643,7 +640,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
// create the MIME key // create the MIME key
wxString strKey = MIME_DATABASE_KEY; wxString strKey = MIME_DATABASE_KEY;
strKey << mimetype; strKey << mimetype;
wxRegKey keyMIME(wxRegKey::HKCR, strKey); wxRegKey keyMIME(wxRegKey::HKCU, CLASSES_ROOT_KEY + strKey);
ok = keyMIME.Create(); ok = keyMIME.Create();
if ( ok ) if ( ok )
@ -664,7 +661,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
extWithDot = wxT('.'); extWithDot = wxT('.');
extWithDot += ext; extWithDot += ext;
wxRegKey key2(wxRegKey::HKCR, extWithDot); wxRegKey key2(wxRegKey::HKCU, CLASSES_ROOT_KEY + extWithDot);
if ( !key2.Exists() ) if ( !key2.Exists() )
key2.Create(); key2.Create();
key2.SetValue(wxEmptyString, filetype); key2.SetValue(wxEmptyString, filetype);
@ -681,7 +678,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
// create the MIME key // create the MIME key
wxString strKey = MIME_DATABASE_KEY; wxString strKey = MIME_DATABASE_KEY;
strKey << mimetype2; strKey << mimetype2;
wxRegKey keyMIME(wxRegKey::HKCR, strKey); wxRegKey keyMIME(wxRegKey::HKCU, CLASSES_ROOT_KEY + strKey);
ok = keyMIME.Create(); ok = keyMIME.Create();
if ( ok ) if ( ok )
@ -692,11 +689,11 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
} }
} }
} // end of for loop; all extensions now point to HKCR\.ext\Default } // end of for loop; all extensions now point to .ext\Default
// create the filetype key itself (it will be empty for now, but // create the filetype key itself (it will be empty for now, but
// SetCommand(), SetDefaultIcon() &c will use it later) // SetCommand(), SetDefaultIcon() &c will use it later)
wxRegKey keyFT(wxRegKey::HKCR, filetype); wxRegKey keyFT(wxRegKey::HKCU, CLASSES_ROOT_KEY + filetype);
keyFT.Create(); keyFT.Create();
wxFileType *ft = CreateFileType(filetype, extWithDot); wxFileType *ft = CreateFileType(filetype, extWithDot);
@ -724,66 +721,14 @@ bool wxFileTypeImpl::SetCommand(const wxString& cmd,
if ( !EnsureExtKeyExists() ) if ( !EnsureExtKeyExists() )
return false; return false;
wxRegKey rkey(wxRegKey::HKCR, GetVerbPath(verb)); wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + GetVerbPath(verb));
#if 0
if ( rkey.Exists() && overwriteprompt )
{
#if wxUSE_GUI
wxString old;
rkey.QueryValue(wxEmptyString, old);
if ( wxMessageBox
(
wxString::Format(
_("Do you want to overwrite the command used to %s "
"files with extension \"%s\" ?\nCurrent value is \n%s, "
"\nNew value is \n%s %1"), // bug here FIX need %1 ??
verb.c_str(),
m_ext.c_str(),
old.c_str(),
cmd.c_str()),
_("Confirm registry update"),
wxYES_NO | wxICON_QUESTION
) != wxYES )
#endif // wxUSE_GUI
{
// cancelled by user
return false;
}
}
#endif
// TODO: // TODO:
// 1. translate '%s' to '%1' instead of always adding it // 1. translate '%s' to '%1' instead of always adding it
// 2. create DDEExec value if needed (undo GetCommand) // 2. create DDEExec value if needed (undo GetCommand)
return rkey.Create() && rkey.SetValue(wxEmptyString, cmd + wxT(" \"%1\"") ); return rkey.Create() && rkey.SetValue(wxEmptyString, cmd + wxT(" \"%1\"") );
} }
/* // no longer used
bool wxFileTypeImpl::SetMimeType(const wxString& mimeTypeOrig)
{
wxCHECK_MSG( !m_ext.empty(), false, wxT("SetMimeType() needs extension") );
if ( !EnsureExtKeyExists() )
return false;
// VZ: is this really useful? (FIXME)
wxString mimeType;
if ( !mimeTypeOrig )
{
// make up a default value for it
wxString cmd;
wxFileName::SplitPath(GetCommand(wxT("open")), NULL, &cmd, NULL);
mimeType << wxT("application/x-") << cmd;
}
else
{
mimeType = mimeTypeOrig;
}
wxRegKey rkey(wxRegKey::HKCR, m_ext);
return rkey.Create() && rkey.SetValue(wxT("Content Type"), mimeType);
}
*/
bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index) bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
{ {
wxCHECK_MSG( !m_ext.empty(), false, wxT("SetDefaultIcon() needs extension") ); wxCHECK_MSG( !m_ext.empty(), false, wxT("SetDefaultIcon() needs extension") );
@ -794,7 +739,8 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
if ( !EnsureExtKeyExists() ) if ( !EnsureExtKeyExists() )
return false; return false;
wxRegKey rkey(wxRegKey::HKCR, m_strFileType + wxT("\\DefaultIcon")); wxRegKey rkey(wxRegKey::HKCU,
CLASSES_ROOT_KEY + m_strFileType + wxT("\\DefaultIcon"));
return rkey.Create() && return rkey.Create() &&
rkey.SetValue(wxEmptyString, rkey.SetValue(wxEmptyString,
@ -809,7 +755,7 @@ bool wxFileTypeImpl::SetDescription (const wxString& desc)
if ( !EnsureExtKeyExists() ) if ( !EnsureExtKeyExists() )
return false; return false;
wxRegKey rkey(wxRegKey::HKCR, m_strFileType ); wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + m_strFileType );
return rkey.Create() && return rkey.Create() &&
rkey.SetValue(wxEmptyString, desc); rkey.SetValue(wxEmptyString, desc);
@ -831,16 +777,6 @@ bool wxFileTypeImpl::Unassociate()
if ( !RemoveDescription() ) if ( !RemoveDescription() )
result = false; result = false;
/*
//this might hold other keys, eg some have CSLID keys
if ( result )
{
// delete the root key
wxRegKey key(wxRegKey::HKCR, m_ext);
if ( key.Exists() )
result = key.DeleteSelf();
}
*/
return result; return result;
} }
@ -854,7 +790,7 @@ bool wxFileTypeImpl::RemoveCommand(const wxString& verb)
wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false, wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false,
wxT("RemoveCommand() needs an extension and a verb") ); wxT("RemoveCommand() needs an extension and a verb") );
wxRegKey rkey(wxRegKey::HKCR, GetVerbPath(verb)); wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + GetVerbPath(verb));
// if the key already doesn't exist, it's a success // if the key already doesn't exist, it's a success
return !rkey.Exists() || rkey.DeleteSelf(); return !rkey.Exists() || rkey.DeleteSelf();
@ -864,7 +800,7 @@ bool wxFileTypeImpl::RemoveMimeType()
{ {
wxCHECK_MSG( !m_ext.empty(), false, wxT("RemoveMimeType() needs extension") ); wxCHECK_MSG( !m_ext.empty(), false, wxT("RemoveMimeType() needs extension") );
wxRegKey rkey(wxRegKey::HKCR, m_ext); wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + m_ext);
return !rkey.Exists() || rkey.DeleteSelf(); return !rkey.Exists() || rkey.DeleteSelf();
} }
@ -873,7 +809,8 @@ bool wxFileTypeImpl::RemoveDefaultIcon()
wxCHECK_MSG( !m_ext.empty(), false, wxCHECK_MSG( !m_ext.empty(), false,
wxT("RemoveDefaultIcon() needs extension") ); wxT("RemoveDefaultIcon() needs extension") );
wxRegKey rkey (wxRegKey::HKCR, m_strFileType + wxT("\\DefaultIcon")); wxRegKey rkey (wxRegKey::HKCU,
CLASSES_ROOT_KEY + m_strFileType + wxT("\\DefaultIcon"));
return !rkey.Exists() || rkey.DeleteSelf(); return !rkey.Exists() || rkey.DeleteSelf();
} }
@ -882,7 +819,7 @@ bool wxFileTypeImpl::RemoveDescription()
wxCHECK_MSG( !m_ext.empty(), false, wxCHECK_MSG( !m_ext.empty(), false,
wxT("RemoveDescription() needs extension") ); wxT("RemoveDescription() needs extension") );
wxRegKey rkey (wxRegKey::HKCR, m_strFileType ); wxRegKey rkey (wxRegKey::HKCU, CLASSES_ROOT_KEY + m_strFileType );
return !rkey.Exists() || rkey.DeleteSelf(); return !rkey.Exists() || rkey.DeleteSelf();
} }

Some files were not shown because too many files have changed in this diff Show More