3rdparty: Update wxWidgets to latest wx3.0.x branch

Fixes a whole bunch of warnings.

Updated to revision d77661c73bf6f9668077ac5a85b4854a1a2204ee.
This commit is contained in:
Jonathan Li 2016-09-25 21:19:07 +01:00
parent 013940250b
commit 43f5b5e2a6
123 changed files with 1679 additions and 843 deletions

View File

@ -164,13 +164,17 @@ private:
public: \
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 \
{ \
return IsSameClass(otherType); \
} \
private: \
static bool AreSameClasses(const wxAnyValueType& a, const wxAnyValueType& b) \
{ \
return wxTypeId(a) == wxTypeId(b); \
} \
static wxAnyValueTypeScopedPtr sm_instance; \
public: \
static wxAnyValueType* GetInstance() \

View File

@ -51,9 +51,11 @@ public:
if ( !m_argsA )
{
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++ )
m_argsA[n] = wxStrdup(m_args[n].ToAscii());
m_argsA[count] = NULL;
}
return m_argsA;
@ -64,9 +66,11 @@ public:
if ( !m_argsW )
{
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++ )
m_argsW[n] = wxStrdup(m_args[n].wc_str());
m_argsW[count] = NULL;
}
return m_argsW;

View File

@ -357,7 +357,21 @@ typedef short int WXTYPE;
#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(),
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,
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 __has_include(<type_traits>)
#if wx_has_cpp11_include(<type_traits>)
#define HAVE_TYPE_TRAITS
#elif __has_include(<tr1/type_traits>)
#define HAVE_TR1_TYPE_TRAITS
@ -374,7 +400,7 @@ typedef short int WXTYPE;
#endif
#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
#elif __has_include(<tr1/unordered_map>)
#define HAVE_TR1_UNORDERED_MAP
@ -382,7 +408,7 @@ typedef short int WXTYPE;
#endif
#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
#elif __has_include(<tr1/unordered_set>)
#define HAVE_TR1_UNORDERED_SET
@ -1787,7 +1813,12 @@ enum wxBorder
/*
* 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 wxCAPTION 0x20000000
@ -3169,14 +3200,22 @@ DECLARE_WXCOCOA_OBJC_CLASS(UIImage);
DECLARE_WXCOCOA_OBJC_CLASS(UIEvent);
DECLARE_WXCOCOA_OBJC_CLASS(NSSet);
DECLARE_WXCOCOA_OBJC_CLASS(EAGLContext);
DECLARE_WXCOCOA_OBJC_CLASS(UIWebView);
typedef WX_UIWindow WXWindow;
typedef WX_UIView WXWidget;
typedef WX_EAGLContext WXGLContext;
typedef WX_NSString* WXGLPixelFormat;
typedef WX_UIWebView OSXWebViewPtr;
#endif
#if wxOSX_USE_COCOA_OR_CARBON
DECLARE_WXCOCOA_OBJC_CLASS(WebView);
typedef WX_WebView OSXWebViewPtr;
#endif
#endif /* __WXMAC__ */
/* 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_
#define _WX_DIRDLG_H_BASE_
#include "wx/defs.h"
#if wxUSE_DIRDLG
#include "wx/dialog.h"

View File

@ -216,8 +216,22 @@ enum wxPosixPermissions
#define wxFtell _ftelli64
#elif wxCHECK_MINGW32_VERSION(3, 5) // mingw-runtime version (not gcc)
#define wxHAS_HUGE_STDIO_FILES
wxDECL_FOR_STRICT_MINGW32(int, fseeko64, (FILE*, long long, int));
#define wxFseek fseeko64
#define wxFtell ftello64
#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
#endif
#endif
// other Windows compilers (DMC, Watcom, and Borland) don't have huge file
@ -376,7 +390,7 @@ enum wxPosixPermissions
// finally the default char-type versions
#if wxUSE_UNICODE
#if wxUSE_UNICODE_MSLU || defined(__WX_STRICT_ANSI_GCC__)
#if wxUSE_UNICODE_MSLU
// implement the missing file functions in Win9x ourselves
WXDLLIMPEXP_BASE int wxMSLU__wopen(const wxChar *name,
int flags, int mode);
@ -404,6 +418,9 @@ enum wxPosixPermissions
#define wxCRT_MkDir wxCRT_MkDirW
#define wxCRT_RmDir wxCRT_RmDirW
#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
#else // !wxUSE_UNICODE
#define wxCRT_Open wxCRT_OpenA

View File

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

View File

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

View File

@ -863,6 +863,7 @@ private:
DECLARE_EVENT_TABLE()
friend class wxGenericListCtrl;
friend class wxListCtrlMaxWidthCalculator;
};
#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_ALPHA, // use alpha buffer with most bits (> MIN_ACCUM_ALPHA bits)
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")

View File

@ -1487,7 +1487,7 @@ WXDLLIMPEXP_BASE const wxChar* wxSysErrorMsg(unsigned long nErrCode = 0);
#define wxDEFINE_EMPTY_LOG_FUNCTION2(level, argclass) \
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 wchar_t*)) \
WX_DEFINE_VARARG_FUNC_NOP(wxLog##level, 2, (argclass, const wxCStrData&)) \

View File

@ -15,6 +15,17 @@
#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>
#ifndef M_PI
@ -53,11 +64,18 @@
#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
#include <cmath>
#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>
#define wxFinite(x) _finite(x)
#elif defined(__MINGW64_TOOLCHAIN__) || defined(__clang__)
@ -71,6 +89,10 @@
#else
#define wxFinite(x) isfinite(x)
#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__)|| \
defined(__SGI_CC__)||defined(__SUNCC__)||defined(__XLC__)|| \
defined(__HPUX__) ) && ( !defined(wxOSX_USE_IPHONE) || wxOSX_USE_IPHONE == 0 )
@ -93,6 +115,8 @@
#define wxIsNaN(x) ((x) != (x))
#endif
#endif /* C++11/C++98 */
#ifdef __INTELC__
inline bool wxIsSameDouble(double x, double y)

View File

@ -101,6 +101,11 @@ public:
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)
{
m_message = message;

View File

@ -15,7 +15,20 @@
#include "wx/msw/wrapwin.h"
#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>
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#endif // __WXWINCE__
#include "wx/msw/private.h"

View File

@ -156,5 +156,28 @@
#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
/* _WX_MSW_GCCPRIV_H_ */

View File

@ -30,6 +30,10 @@
typedef char *wxCmdLineArgType;
#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
// parameters passed to WinMain() instead of those passed to main()
extern WXDLLIMPEXP_CORE bool

View File

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

View File

@ -312,7 +312,7 @@ protected:
virtual ExitCode Entry();
// 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
bool ReadEvents();

View File

@ -123,7 +123,7 @@ public:
// hKey should be opened and will be closed in wxRegKey dtor
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.
wxString GetName(bool bShortPrefix = true) const;
// Retrieves the registry view used by this key.
@ -132,7 +132,7 @@ public:
bool Exists() const;
// get the info about key (any number of these pointers may be NULL)
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 *pnMaxValueLen) const;
// return true if the key is opened

View File

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

View File

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

View File

@ -692,7 +692,7 @@ public:
virtual HRESULT wxSTDCALL get_onpropertychange(VARIANT *p) = 0;
virtual HRESULT wxSTDCALL getClientRects(wxIHTMLRectCollection **pRectCol) = 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 removeExpression(BSTR propname, VARIANT_BOOL *pfSuccess) = 0;
virtual HRESULT wxSTDCALL put_tabIndex(short v) = 0;

View File

@ -24,8 +24,21 @@
#define min(a,b) (((a) < (b)) ? (a) : (b))
#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>
using namespace Gdiplus;
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#endif // _WX_MSW_WRAPGDIP_H_

View File

@ -20,8 +20,21 @@
#include <shellapi.h>
#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>
#ifdef __VISUALC__
#pragma warning(pop)
#endif
#include "wx/msw/winundef.h"
#include "wx/log.h"

View File

@ -310,7 +310,7 @@
*/
#elif defined(__UNIX__) || defined(__unix) || defined(__unix__) || \
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__)
# define __UNIX_LIKE__
@ -459,6 +459,7 @@
# define wxCHECK_W32API_VERSION(maj, min) (0)
# undef wxCHECK_MINGW32_VERSION
# define wxCHECK_MINGW32_VERSION( major, minor ) (0)
# define wxDECL_FOR_STRICT_MINGW32(rettype, func, params)
#endif

View File

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

View File

@ -381,7 +381,7 @@ struct wxPixelDataOut<wxImage>
{
m_pRGB += data.GetRowStride()*y + PixelFormat::SizePixel*x;
if ( m_pAlpha )
m_pAlpha += data.GetWidth() + x;
m_pAlpha += data.GetWidth()*y + x;
}
// move x pixels to the right (again, no row wrapping)
@ -397,7 +397,7 @@ struct wxPixelDataOut<wxImage>
{
m_pRGB += data.GetRowStride()*y;
if ( m_pAlpha )
m_pAlpha += data.GetWidth();
m_pAlpha += data.GetWidth()*y;
}
// 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! */
#define wxMAJOR_VERSION 3
#define wxMINOR_VERSION 0
#define wxRELEASE_NUMBER 2
#define wxRELEASE_NUMBER 3
#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 */
/* ---------------------------------------------------------------------------- */

View File

@ -73,6 +73,9 @@
#ifdef wxNEED_ISASCII
inline int isascii(int c) { return (unsigned)c < 0x80; }
// Avoid further (re)definitions of it.
#define isascii isascii
#endif
#ifdef _WIN32_WCE
@ -445,7 +448,7 @@ WXDLLIMPEXP_BASE wchar_t *wxCRT_StrtokW(wchar_t *psz, const wchar_t *delim, wcha
#else /* Unicode filenames */
/* special case: these functions are missing under Win9x with Unicows so we
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__wfreopen(const wchar_t *name, const wchar_t *mode, FILE *stream);
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_Rename wxMSLU__wrename
#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 */
#ifdef __WXWINCE__
WXDLLIMPEXP_BASE int wxCRT_Rename(const wchar_t *src,

View File

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

View File

@ -315,9 +315,9 @@ wxAppTraits *wxAppConsoleBase::GetTraitsIfExists()
wxAppTraits& wxAppConsoleBase::GetValidTraits()
{
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;
}
#ifdef __WXOSX__
if ( arg == wxT("-ApplePersistenceIgnoreState") )
if ( arg == wxS("-ApplePersistenceIgnoreState") ||
arg == wxS("-AppleTextDirection") ||
arg == wxS("-AppleLocale") ||
arg == wxS("-AppleLanguages") )
{
maybeOption = false;
n++;
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
// 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 )

View File

@ -343,9 +343,12 @@ wxString wxDateTime::Format(const wxString& formatp, const TimeZone& tz) const
wxString format = formatp;
#ifdef __WXOSX__
format.Replace("%c",wxLocale::GetInfo(wxLOCALE_DATE_TIME_FMT));
format.Replace("%x",wxLocale::GetInfo(wxLOCALE_SHORT_DATE_FMT));
format.Replace("%X",wxLocale::GetInfo(wxLOCALE_TIME_FMT));
if ( format.Contains("%c") )
format.Replace("%c", wxLocale::GetInfo(wxLOCALE_DATE_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
// we have to use our own implementation if the date is out of range of
// 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
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 )
*end = p;

View File

@ -646,13 +646,12 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
m_graphicContext->PushState();
m_graphicContext->Translate(dx, dy);
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
// get clockwise angles
if ( m_brush.GetStyle() != wxTRANSPARENT )
{
path = m_graphicContext->CreatePath();
path.MoveToPoint( 0, 0 );
path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
path.AddLineToPoint( 0, 0 );
@ -664,7 +663,6 @@ void wxGCDCImpl::DoDrawEllipticArc( wxCoord x, wxCoord y, wxCoord w, wxCoord h,
}
else
{
wxGraphicsPath path = m_graphicContext->CreatePath();
path.AddArc( 0, 0, h/2.0 , DegToRad(-sa) , DegToRad(-ea), sa > ea );
m_graphicContext->DrawPath( path );
}
@ -878,10 +876,9 @@ void wxGCDCImpl::DoDrawRectangle(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
CalcBoundingBox(x, y);
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
// border line gets off by 1
// outline is one pixel larger than what raster-based wxDC implementations draw
w -= 1;
h -= 1;
}
@ -907,10 +904,9 @@ void wxGCDCImpl::DoDrawRoundedRectangle(wxCoord x, wxCoord y,
CalcBoundingBox(x, y);
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
// border line gets off by 1
// outline is one pixel larger than what raster-based wxDC implementations draw
w -= 1;
h -= 1;
}
@ -927,13 +923,6 @@ void wxGCDCImpl::DoDrawEllipse(wxCoord x, wxCoord y, wxCoord w, wxCoord h)
CalcBoundingBox(x, y);
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);
}
@ -1213,9 +1202,10 @@ void wxGCDCImpl::Clear(void)
wxCompositionMode formerMode = m_graphicContext->GetCompositionMode();
m_graphicContext->SetCompositionMode(wxCOMPOSITION_SOURCE);
// 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(
DeviceToLogicalX(0), DeviceToLogicalY(0),
DeviceToLogicalXRel(0x007fffff), DeviceToLogicalYRel(0x007fffff));
DeviceToLogicalXRel(0x800000 - 64), DeviceToLogicalYRel(0x800000 - 64));
m_graphicContext->SetCompositionMode(formerMode);
m_graphicContext->SetPen( m_pen );
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,
size_t WXUNUSED(len), const void *buf)
size_t len, const void *buf)
{
if ( buf == NULL )
return false;
wxWCharBuffer buffer = GetConv(format).cMB2WX( (const char*)buf );
wxWCharBuffer buffer = GetConv(format).cMB2WC((const char*)buf, len, NULL);
SetText( buffer );

View File

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

View File

@ -179,8 +179,6 @@ wxDEFINE_EVENT( wxEVT_VLBOX, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_COMBOBOX, wxCommandEvent );
wxDEFINE_EVENT( wxEVT_TOOL_RCLICKED, 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_COMBOBOX_DROPDOWN, wxCommandEvent);
wxDEFINE_EVENT( wxEVT_COMBOBOX_CLOSEUP, wxCommandEvent);

View File

@ -571,7 +571,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
}
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);
continue; // skip this line
}
@ -607,7 +607,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
break;
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);
bCont = false;
}
@ -636,7 +636,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
pEnd++;
if ( *pEnd++ != wxT('=') ) {
wxLogError(_("file '%s', line %d: '=' expected."),
wxLogError(_("file '%s', line %zu: '=' expected."),
buffer.GetName(), n + 1);
}
else {
@ -649,7 +649,7 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
else {
if ( bLocal && pEntry->IsImmutable() ) {
// 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());
continue;
}
@ -659,8 +659,8 @@ void wxFileConfig::Parse(const wxTextBuffer& buffer, bool bLocal)
// (c) key from global file now found in local one
// which is exactly what we want.
else if ( !bLocal || pEntry->IsLocal() ) {
wxLogWarning(_("file '%s', line %d: key '%s' was first found at line %d."),
buffer.GetName(), (int)n + 1, strKey.c_str(), pEntry->Line());
wxLogWarning(_("file '%s', line %zu: key '%s' was first found at line %d."),
buffer.GetName(), n + 1, strKey.c_str(), pEntry->Line());
}
}

View File

@ -90,6 +90,8 @@
#define HAVE_WGETCWD
#endif
wxDECL_FOR_STRICT_MINGW32(int, _fileno, (FILE*))
// ----------------------------------------------------------------------------
// constants
// ----------------------------------------------------------------------------
@ -1090,7 +1092,11 @@ wxCopyFile (const wxString& file1, const wxString& file2, bool overwrite)
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__)
// 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);
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);
}

View File

@ -100,7 +100,7 @@
#ifdef __WINDOWS__
#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/ole/oleutils.h"
#endif
@ -1832,15 +1832,27 @@ bool wxFileName::MakeRelativeTo(const wxString& pathBase, wxPathFormat format)
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
// and DOS, by definition (but we don't have to insert "./" for the
// files)
if ( m_dirs.IsEmpty() && IsDir() )
{
m_dirs.Add(wxT('.'));
}
case wxPATH_NATIVE:
case wxPATH_MAX:
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() )
{
m_dirs.Add(wxT('.'));
}
break;
case wxPATH_MAC:
case wxPATH_VMS:
break;
}
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.
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
// 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++ )
{
OnFontEncoding(facenames[n], utf8);
if ( !OnFontEncoding(facenames[n], utf8) )
break;
}
return true;

View File

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

View File

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

View File

@ -22,7 +22,6 @@
#ifndef WX_PRECOMP
#include "wx/string.h"
#include "wx/app.h"
#endif
#include "wx/tokenzr.h"
@ -48,8 +47,6 @@ wxHTTP::wxHTTP()
m_read = false;
m_proxy_mode = false;
m_http_response = 0;
SetNotify(wxSOCKET_LOST_FLAG);
}
wxHTTP::~wxHTTP()
@ -370,16 +367,6 @@ bool wxHTTP::BuildRequest(const wxString& path, const wxString& method)
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;
buf.Printf(wxT("%s %s HTTP/1.0\r\n"), method, path);
const wxWX2MBbuf pathbuf = buf.mb_str();
@ -395,10 +382,8 @@ bool wxHTTP::BuildRequest(const wxString& path, const wxString& method)
wxString tmp_str;
m_lastError = ReadLine(this, tmp_str);
if (m_lastError != wxPROTO_NOERR) {
RestoreState();
if (m_lastError != wxPROTO_NOERR)
return false;
}
if (!tmp_str.Contains(wxT("HTTP/"))) {
// 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;
ret_value = ParseHeaders();
RestoreState();
return ret_value;
}
@ -540,9 +525,6 @@ wxInputStream *wxHTTP::GetInputStream(const wxString& path)
inp_stream->m_read_bytes = 0;
Notify(false);
SetFlags(wxSOCKET_BLOCK | wxSOCKET_WAITALL);
// no error; reset m_lastError
m_lastError = wxPROTO_NOERR;
return inp_stream;

View File

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

View File

@ -137,8 +137,8 @@ static struct InitData
nInitCount = 0;
#if wxUSE_UNICODE
argc = 0;
// argv = NULL; -- not even really needed
argc = argcOrig = 0;
// argv = argvOrig = NULL; -- not even really needed
#endif // wxUSE_UNICODE
}
@ -157,6 +157,12 @@ static struct InitData
// for example), we remember the converted argv here because we'll have to
// free it when doing cleanup to avoid memory leaks
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
wxDECLARE_NO_COPY_CLASS(InitData);
@ -174,7 +180,9 @@ static struct InitData
static void ConvertArgsToUnicode(int argc, char **argv)
{
gs_initData.argvOrig = new wchar_t *[argc + 1];
gs_initData.argv = new wchar_t *[argc + 1];
int wargc = 0;
for ( int i = 0; i < argc; i++ )
{
@ -190,25 +198,28 @@ static void ConvertArgsToUnicode(int argc, char **argv)
}
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.argv[wargc] = NULL;
gs_initData.argcOrig = gs_initData.argc = wargc;
gs_initData.argvOrig[wargc] =gs_initData.argv[wargc] = NULL;
}
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);
gs_initData.argc = 0;
gs_initData.argcOrig = gs_initData.argc = 0;
}
}

View File

@ -55,6 +55,7 @@
#endif
#ifdef __WIN32__
#include "wx/dynlib.h"
#include "wx/msw/private.h"
#endif
@ -480,6 +481,18 @@ bool wxLocale::Init(int language, int flags)
// change locale used by Windows functions
::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
// 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());
// 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
// this language
}
@ -611,11 +629,6 @@ inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value)
return wxLANGUAGE_ENGLISH_US;
}
if ( langFull == wxS("C") || langFull == wxS("POSIX") )
{
// default C locale is English too
return wxLANGUAGE_ENGLISH_US;
}
#endif
// the language string has the following form
@ -651,6 +664,12 @@ inline bool wxGetNonEmptyEnvVar(const wxString& name, wxString* value)
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)?
const bool justLang = langFull.find('_') == wxString::npos;
@ -1035,8 +1054,11 @@ wxLocale::~wxLocale()
// restore old locale pointer
wxSetLocale(m_pOldLocale);
wxSetlocale(LC_ALL, m_pszOldLocale);
free(const_cast<char *>(m_pszOldLocale));
if ( m_pszOldLocale )
{
wxSetlocale(LC_ALL, m_pszOldLocale);
free(const_cast<char *>(m_pszOldLocale));
}
}
@ -1251,6 +1273,8 @@ static wxString TranslateFromUnicodeFormat(const wxString& fmt)
fmtWX += "%A";
break;
case 5: // EEEEE
case 6: // EEEEEE
// no "narrow form" in strftime(), use abbrev.
fmtWX += "%a";
break;
@ -1276,6 +1300,11 @@ static wxString TranslateFromUnicodeFormat(const wxString& fmt)
fmtWX += "%B";
break;
case 5:
// no "narrow form" in strftime(), use abbrev.
fmtWX += "%b";
break;
default:
wxFAIL_MSG( "too many 'M's" );
}

View File

@ -118,6 +118,9 @@
#ifndef LANG_FRENCH
#define LANG_FRENCH (0)
#endif
#ifndef LANG_FRISIAN
#define LANG_FRISIAN (0)
#endif
#ifndef LANG_GEORGIAN
#define LANG_GEORGIAN (0)
#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_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_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_GEORGIAN, "ka_GE", LANG_GEORGIAN , SUBLANG_DEFAULT , wxLayout_LeftToRight, "Georgian")
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
// numbers of times are correctly formatted, even though we never
// actually use the singular string.
msg.Printf(wxPLURAL("The previous message repeated %lu time.",
"The previous message repeated %lu times.",
msg.Printf(wxPLURAL("The previous message repeated %u time.",
"The previous message repeated %u times.",
gs_prevLog.numRepeated),
gs_prevLog.numRepeated);
}
#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);
#endif
gs_prevLog.numRepeated = 0;
@ -306,12 +306,12 @@ wxLog::~wxLog()
#if wxUSE_INTL
wxPLURAL
(
"Last repeated message (\"%s\", %lu time) wasn't output",
"Last repeated message (\"%s\", %lu times) wasn't output",
"Last repeated message (\"%s\", %u time) wasn't output",
"Last repeated message (\"%s\", %u times) wasn't output",
gs_prevLog.numRepeated
),
#else
wxS("Last repeated message (\"%s\", %lu time(s)) wasn't output"),
wxS("Last repeated message (\"%s\", %u time(s)) wasn't output"),
#endif
gs_prevLog.msg,
gs_prevLog.numRepeated

View File

@ -122,20 +122,16 @@ wxChar wxNumberFormatter::GetDecimalSeparator()
{
const wxString
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
// back to the C locale default.
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;
@ -154,11 +150,8 @@ bool wxNumberFormatter::GetThousandsSeparatorIfUsed(wxChar *sep)
{
const wxString
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];
}
//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)
{
// Thousands separators for numbers in scientific format are not relevant.
if ( s.find_first_of("eE") != wxString::npos )
return;
wxChar thousandsSep;
if ( !GetThousandsSeparatorIfUsed(&thousandsSep) )
return;
@ -254,9 +251,14 @@ void wxNumberFormatter::AddThousandsSeparators(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());
wxCHECK_RET( posDecSep != wxString::npos,
wxString::Format("No decimal separator in \"%s\"", s) );
// No decimal point => removing trailing zeroes irrelevant for integer number.
if ( posDecSep == wxString::npos )
return;
wxCHECK_RET( posDecSep, "Can't start with decimal separator" );
// Find the last character to keep.
@ -267,6 +269,9 @@ void wxNumberFormatter::RemoveTrailingZeroes(wxString& s)
posLastNonZero--;
s.erase(posLastNonZero + 1);
// Remove sign from orphaned zero.
if ( s.compare("-0") == 0 )
s = "0";
}
// ----------------------------------------------------------------------------

View File

@ -72,6 +72,11 @@
#endif
#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
//----------------------------------------------------------------------------
@ -541,7 +546,17 @@ void wxPrintAbortDialog::SetProgress(int currentPage, int totalPages,
int currentCopy, int totalCopies)
{
wxString text;
text.Printf(_("Printing page %d of %d"), currentPage, totalPages);
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);
}
if ( totalCopies > 1 )
text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies);
m_progress->SetLabel(text);
@ -607,7 +622,7 @@ bool wxPrintout::HasPage(int page)
void wxPrintout::GetPageInfo(int *minPage, int *maxPage, int *fromPage, int *toPage)
{
*minPage = 1;
*maxPage = 32000;
*maxPage = DEFAULT_MAX_PAGES;
*fromPage = 1;
*toPage = 1;
}

View File

@ -21,6 +21,7 @@
#include "wx/protocol/log.h"
#ifndef WX_PRECOMP
#include "wx/app.h"
#include "wx/module.h"
#endif
@ -63,7 +64,10 @@ IMPLEMENT_ABSTRACT_CLASS(wxProtocol, wxObject)
wxProtocol::wxProtocol()
#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
{
m_lastError = wxPROTO_NOERR;

View File

@ -136,7 +136,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
}
};
#else
typedef char wxGethostBuf[1024];
typedef char wxGethostBuf[4096];
#endif
#ifdef HAVE_FUNC_GETSERVBYNAME_R_4
@ -148,7 +148,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
}
};
#else
typedef char wxGetservBuf[1024];
typedef char wxGetservBuf[4096];
#endif
#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 )
dstWritten++;
if ( !lenChunk )
{
// nothing left in the input string, conversion succeeded
break;
}
if ( dst )
{
if ( dstWritten > dstLen )
@ -1057,16 +1051,8 @@ wxMBConvStrictUTF8::ToWChar(wchar_t *dst, size_t dstLen,
// length:
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
// extract the lead byte's value bits:
if ( (c & leadMarkerMask[len]) != leadMarkerVal[len] )
break;
code = c & leadValueMask[len];
// 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];
tmp[0] = wxUINT16_SWAP_ALWAYS(*inBuff);
inBuff++;
tmp[1] = wxUINT16_SWAP_ALWAYS(*inBuff);
if ( ++inBuff < inEnd )
{
// Normal case, we have a next character to decode.
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);
if ( numChars == wxCONV_FAILED )

View File

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

View File

@ -22,6 +22,23 @@
#pragma hdrstop
#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"
#ifndef WX_PRECOMP

View File

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

View File

@ -23,6 +23,14 @@
#pragma hdrstop
#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
#include "wx/app.h"
#include "wx/string.h"

View File

@ -73,6 +73,10 @@
#include <xlocale.h>
#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)
{
// 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_DCLICK(wxGenericCalendarCtrl::OnDClick)
EVT_MOUSEWHEEL(wxGenericCalendarCtrl::OnWheel)
EVT_SYS_COLOUR_CHANGED(wxGenericCalendarCtrl::OnSysColourChanged)
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
// ----------------------------------------------------------------------------

View File

@ -390,7 +390,7 @@ bool wxAnyChoiceDialog::Create(wxWindow *parent,
const long styleBtns = styleDlg & (wxOK | wxCANCEL);
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;
wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

View File

@ -48,6 +48,7 @@
#include "wx/dnd.h"
#include "wx/stopwatch.h"
#include "wx/weakref.h"
#include "wx/generic/private/widthcalc.h"
//-----------------------------------------------------------------------------
// classes
@ -1790,9 +1791,11 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
wxDataViewModel *model = GetModel();
wxAutoBufferedPaintDC dc( this );
const wxSize size = GetClientSize();
dc.SetBrush(GetOwner()->GetBackgroundColour());
dc.SetPen( *wxTRANSPARENT_PEN );
dc.DrawRectangle(GetClientSize());
dc.DrawRectangle(size);
if ( IsEmpty() )
{
@ -1878,13 +1881,16 @@ void wxDataViewMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
dc.SetPen(*wxTRANSPARENT_PEN);
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++)
{
if ( item % 2 )
{
dc.DrawRectangle(x_start,
dc.DrawRectangle(xRect,
GetLineStart(item),
GetClientSize().GetWidth(),
widthRect,
GetLineHeight(item));
}
}
@ -3208,6 +3214,11 @@ void wxDataViewMainWindow::Expand( unsigned int row )
ChangeCurrentRow(m_currentRow + rowAdjustment);
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();
// Send the expanded event
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_EXPANDED,node->GetItem());
@ -3283,6 +3294,9 @@ void wxDataViewMainWindow::Collapse(unsigned int row)
}
m_count = -1;
GetOwner()->InvalidateColBestWidths();
UpdateDisplay();
SendExpanderEvent(wxEVT_DATAVIEW_ITEM_COLLAPSED,node->GetItem());
}
@ -3992,7 +4006,7 @@ bool wxDataViewMainWindow::TryAdvanceCurrentColumn(wxDataViewTreeNode *node, boo
{
if ( forward )
{
m_currentCol = GetOwner()->GetColumnAt(1);
m_currentCol = GetOwner()->GetColumnAt(0);
m_currentColSetByKeyboard = true;
RefreshRow(m_currentRow);
return true;
@ -4113,23 +4127,23 @@ void wxDataViewMainWindow::OnMouse( wxMouseEvent &event )
wxDataViewItem itemDragged = GetItemByRow( drag_item_row );
// Notify cell about drag
wxDataViewEvent event( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
event.SetEventObject( m_owner );
event.SetItem( itemDragged );
event.SetModel( model );
if (!m_owner->HandleWindowEvent( event ))
wxDataViewEvent evt( wxEVT_DATAVIEW_ITEM_BEGIN_DRAG, m_owner->GetId() );
evt.SetEventObject( m_owner );
evt.SetItem( itemDragged );
evt.SetModel( model );
if (!m_owner->HandleWindowEvent( evt ))
return;
if (!event.IsAllowed())
if (!evt.IsAllowed())
return;
wxDataObject *obj = event.GetDataObject();
wxDataObject *obj = evt.GetDataObject();
if (!obj)
return;
wxDataViewDropSource drag( this, drag_item_row );
drag.SetData( *obj );
/* wxDragResult res = */ drag.DoDragDrop(event.GetDragFlags());
/* wxDragResult res = */ drag.DoDragDrop(evt.GetDragFlags());
delete obj;
}
return;
@ -4838,6 +4852,60 @@ int wxDataViewCtrl::GetModelColumnIndex( unsigned int model_column ) const
return wxNOT_FOUND;
}
class wxDataViewMaxWidthCalculator : public wxMaxWidthCalculatorBase
{
public:
wxDataViewMaxWidthCalculator(const wxDataViewCtrl *dvc,
wxDataViewMainWindow *clientArea,
wxDataViewRenderer *renderer,
const wxDataViewModel *model,
size_t model_column,
int expanderSize)
: wxMaxWidthCalculatorBase(model_column),
m_dvc(dvc),
m_clientArea(clientArea),
m_renderer(renderer),
m_model(model),
m_expanderSize(expanderSize)
{
int index = dvc->GetModelColumnIndex( model_column );
wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index);
m_isExpanderCol =
!clientArea->IsList() &&
(column == 0 ||
GetExpanderColumnOrFirstOne(const_cast<wxDataViewCtrl*>(dvc)) == column );
}
virtual void UpdateWithRow(int row)
{
int indent = 0;
wxDataViewItem item;
if ( m_isExpanderCol )
{
wxDataViewTreeNode *node = m_clientArea->GetTreeNodeByRow(row);
item = node->GetItem();
indent = m_dvc->GetIndent() * node->GetIndentLevel() + m_expanderSize;
}
else
{
item = m_clientArea->GetItemByRow(row);
}
m_renderer->PrepareForItem(m_model, item, GetColumn());
UpdateWithWidth(m_renderer->GetSize().x + indent);
}
private:
const wxDataViewCtrl *m_dvc;
wxDataViewMainWindow *m_clientArea;
wxDataViewRenderer *m_renderer;
const wxDataViewModel *m_model;
bool m_isExpanderCol;
int m_expanderSize;
};
unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
{
if ( m_colsBestWidths[idx].width != 0 )
@ -4848,146 +4916,19 @@ unsigned int wxDataViewCtrl::GetBestColumnWidth(int idx) const
wxDataViewRenderer *renderer =
const_cast<wxDataViewRenderer*>(column->GetRenderer());
class MaxWidthCalculator
{
public:
MaxWidthCalculator(const wxDataViewCtrl *dvc,
wxDataViewMainWindow *clientArea,
wxDataViewRenderer *renderer,
const wxDataViewModel *model,
unsigned int model_column,
int expanderSize)
: m_width(0),
m_dvc(dvc),
m_clientArea(clientArea),
m_renderer(renderer),
m_model(model),
m_model_column(model_column),
m_expanderSize(expanderSize)
{
int index = dvc->GetModelColumnIndex( model_column );
wxDataViewColumn* column = index == wxNOT_FOUND ? NULL : dvc->GetColumn(index);
m_isExpanderCol =
!clientArea->IsList() &&
(column == 0 ||
GetExpanderColumnOrFirstOne(const_cast<wxDataViewCtrl*>(dvc)) == column );
}
void UpdateWithWidth(int width)
{
m_width = wxMax(m_width, width);
}
void UpdateWithRow(int row)
{
int indent = 0;
wxDataViewItem item;
if ( m_isExpanderCol )
{
wxDataViewTreeNode *node = m_clientArea->GetTreeNodeByRow(row);
item = node->GetItem();
indent = m_dvc->GetIndent() * node->GetIndentLevel() + m_expanderSize;
}
else
{
item = m_clientArea->GetItemByRow(row);
}
m_renderer->PrepareForItem(m_model, item, m_model_column);
m_width = wxMax(m_width, m_renderer->GetSize().x + indent);
}
int GetMaxWidth() const { return m_width; }
private:
int m_width;
const wxDataViewCtrl *m_dvc;
wxDataViewMainWindow *m_clientArea;
wxDataViewRenderer *m_renderer;
const wxDataViewModel *m_model;
unsigned m_model_column;
bool m_isExpanderCol;
int m_expanderSize;
};
MaxWidthCalculator calculator(this, m_clientArea, renderer,
GetModel(), column->GetModelColumn(),
m_clientArea->GetRowHeight());
wxDataViewMaxWidthCalculator calculator(this, m_clientArea, renderer,
GetModel(), column->GetModelColumn(),
m_clientArea->GetRowHeight());
calculator.UpdateWithWidth(column->GetMinWidth());
if ( m_headerArea )
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));
int first_visible = m_clientArea->GetLineAt(origin.y);
int last_visible = 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);
}
const wxPoint origin = CalcUnscrolledPosition(wxPoint(0, 0));
calculator.ComputeBestColumnWidth(count,
m_clientArea->GetLineAt(origin.y),
m_clientArea->GetLineAt(origin.y + GetClientSize().y));
int max_width = calculator.GetMaxWidth();
if ( max_width > 0 )
@ -5293,20 +5234,14 @@ void wxDataViewCtrl::Expand( const wxDataViewItem & item )
int row = m_clientArea->GetRowByItem( item );
if (row != -1)
{
m_clientArea->Expand(row);
InvalidateColBestWidths();
}
}
void wxDataViewCtrl::Collapse( const wxDataViewItem & item )
{
int row = m_clientArea->GetRowByItem( item );
if (row != -1)
{
m_clientArea->Collapse(row);
InvalidateColBestWidths();
}
}
bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const

View File

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

View File

@ -339,14 +339,40 @@ bool wxGenericFileDialog::Show( bool show )
void wxGenericFileDialog::OnOk( wxCommandEvent &WXUNUSED(event) )
{
wxArrayString selectedFiles;
m_filectrl->GetFilenames(selectedFiles);
m_filectrl->GetPaths(selectedFiles);
if (selectedFiles.Count() == 0)
return;
const wxString& path = selectedFiles[0];
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);

View File

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

View File

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

View File

@ -39,6 +39,7 @@
#include "wx/imaglist.h"
#include "wx/renderer.h"
#include "wx/generic/private/listctrl.h"
#include "wx/generic/private/widthcalc.h"
#ifdef __WXMAC__
#include "wx/osx/private.h"
@ -1935,6 +1936,13 @@ void wxListMainWindow::RefreshLines( size_t lineFrom, size_t lineTo )
size_t 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 )
lineFrom = visibleFrom;
if ( lineTo > visibleTo )
@ -2433,7 +2441,7 @@ void wxListMainWindow::OnMouse( wxMouseEvent &event )
evtCtx.SetEventObject(GetParent());
GetParent()->GetEventHandler()->ProcessEvent(evtCtx);
}
else
else if (event.LeftDown())
{
// reset the selection and bail out
HighlightAll(false);
@ -2986,6 +2994,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
SetItemState(item,
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED,
wxLIST_STATE_FOCUSED | wxLIST_STATE_SELECTED);
EnsureVisible(item);
// Reset the bell flag if it had been temporarily disabled
// before.
@ -3186,6 +3195,35 @@ void wxListMainWindow::SetColumn( int col, const wxListItem &item )
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 )
{
wxCHECK_RET( col >= 0 && col < GetColumnCount(),
@ -3207,48 +3245,42 @@ void wxListMainWindow::SetColumnWidth( int col, int width )
size_t count = GetItemCount();
if (width == wxLIST_AUTOSIZE_USEHEADER)
if ( width == wxLIST_AUTOSIZE_USEHEADER || width == wxLIST_AUTOSIZE )
{
width = ComputeMinHeaderWidth(column);
}
else if ( width == wxLIST_AUTOSIZE )
{
width = ComputeMinHeaderWidth(column);
wxListCtrlMaxWidthCalculator calculator(this, col);
if ( !IsVirtual() )
calculator.UpdateWithWidth(AUTOSIZE_COL_MARGIN);
if ( width == wxLIST_AUTOSIZE_USEHEADER )
calculator.UpdateWithWidth(ComputeMinHeaderWidth(column));
// if the cached column width isn't valid then recalculate it
wxColWidthInfo* const pWidthInfo = m_aColWidths.Item(col);
if ( pWidthInfo->bNeedsUpdate )
{
wxClientDC dc(this);
dc.SetFont( GetFont() );
size_t first_visible, last_visible;
GetVisibleLinesRange(&first_visible, &last_visible);
int max = AUTOSIZE_COL_MARGIN;
// if the cached column width isn't valid then recalculate it
if (m_aColWidths.Item(col)->bNeedsUpdate)
{
for (size_t i = 0; i < count; i++)
{
wxListLineData *line = GetLine( i );
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;
m_aColWidths.Item(col)->nMaxWidth = max;
}
max = m_aColWidths.Item(col)->nMaxWidth + AUTOSIZE_COL_MARGIN;
if ( width < max )
width = max;
calculator.ComputeBestColumnWidth(count, first_visible, last_visible);
pWidthInfo->nMaxWidth = calculator.GetMaxWidth();
pWidthInfo->bNeedsUpdate = false;
}
else
{
calculator.UpdateWithWidth(pWidthInfo->nMaxWidth);
}
// expand the last column to fit the client size
// 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();
}
width = wxMax(margin, calculator.GetMaxWidth() + AUTOSIZE_COL_MARGIN);
}
column->SetWidth( width );
@ -3315,8 +3347,12 @@ void wxListMainWindow::SetItem( wxListItem &item )
// update the Max Width Cache if needed
int width = GetItemWidthWithImage(&item);
if (width > m_aColWidths.Item(item.m_col)->nMaxWidth)
m_aColWidths.Item(item.m_col)->nMaxWidth = width;
wxColWidthInfo* const pWidthInfo = m_aColWidths.Item(item.m_col);
if ( width > pWidthInfo->nMaxWidth )
{
pWidthInfo->nMaxWidth = width;
pWidthInfo->bNeedsUpdate = true;
}
}
}
@ -3959,8 +3995,9 @@ void wxListMainWindow::DeleteItem( long lindex )
itemWidth = GetItemWidthWithImage(&item);
if (itemWidth >= m_aColWidths.Item(i)->nMaxWidth)
m_aColWidths.Item(i)->bNeedsUpdate = true;
wxColWidthInfo *pWidthInfo = m_aColWidths.Item(i);
if ( itemWidth >= pWidthInfo->nMaxWidth )
pWidthInfo->bNeedsUpdate = true;
}
ResetVisibleLinesRange();
@ -4033,6 +4070,13 @@ void wxListMainWindow::DeleteColumn( int col )
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() )
// nothing to do - in particular, don't send the event
return;
@ -4055,13 +4099,7 @@ void wxListMainWindow::DoDeleteAllItems()
}
if ( InReportView() )
{
ResetVisibleLinesRange();
for (size_t i = 0; i < m_aColWidths.GetCount(); i++)
{
m_aColWidths.Item(i)->bNeedsUpdate = true;
}
}
m_lines.Clear();
}
@ -4225,7 +4263,10 @@ void wxListMainWindow::InsertItem( wxListItem &item )
int width = GetItemWidthWithImage(&item);
item.SetWidth(width);
if (width > pWidthInfo->nMaxWidth)
{
pWidthInfo->nMaxWidth = width;
pWidthInfo->bNeedsUpdate = true;
}
}
wxListLineData *line = new wxListLineData(this);
@ -4271,7 +4312,7 @@ long wxListMainWindow::InsertColumn( long col, const wxListItem &item )
if (item.m_width == wxLIST_AUTOSIZE_USEHEADER)
column->SetWidth(ComputeMinHeaderWidth(column));
wxColWidthInfo *colWidthInfo = new wxColWidthInfo();
wxColWidthInfo *colWidthInfo = new wxColWidthInfo(0, IsVirtual());
bool insert = (col >= 0) && ((size_t)col < m_columns.GetCount());
if ( insert )

View File

@ -52,7 +52,7 @@ public:
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());
#ifdef __WXGTK__

View File

@ -39,8 +39,6 @@
#include "wx/scrolbar.h"
#endif
#include "wx/recguard.h"
#ifdef __WXMSW__
#include <windows.h> // for DLGC_WANTARROWS
#include "wx/msw/winundef.h"
@ -58,6 +56,58 @@
#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
style wxHSCROLL | wxVSCROLL
@ -214,9 +264,6 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true;
}
if ( processed && event.IsCommandEvent())
return true;
// 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
// to call this virtual function ourselves.
@ -235,6 +282,11 @@ bool wxScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
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 )
{
m_scrollHelper->HandleOnChildFocus((wxChildFocusEvent &)event);
@ -1303,8 +1355,8 @@ wxScrollHelper::DoAdjustScrollbar(int orient,
void wxScrollHelper::AdjustScrollbars()
{
static wxRecursionGuardFlag s_flagReentrancy;
wxRecursionGuard guard(s_flagReentrancy);
static wxScrollHelperRecGuardFlags s_flagReentrancy;
wxScrollHelperRecGuard guard(this, s_flagReentrancy);
if ( guard.IsInside() )
{
// don't reenter AdjustScrollbars() while another call to

View File

@ -210,16 +210,6 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
m_max = max;
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
// 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
@ -228,12 +218,19 @@ bool wxSpinCtrlGenericBase::Create(wxWindow *parent,
{
double d;
if ( DoTextToValue(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);
Move(pos);

View File

@ -192,21 +192,15 @@ void wxSplitterWindow::OnInternalIdle()
{
wxWindow::OnInternalIdle();
// We may need to update the children sizes in two cases: either because
// we're in the middle of a live update as indicated by m_needUpdating or
// because we have a requested but not yet set sash position as indicated
// by m_requestedSashPosition having a valid value.
// We may need to update the children sizes if we're in the middle of
// a live update as indicated by m_needUpdating. The other possible case,
// when we have a requested but not yet set sash position (as indicated
// by m_requestedSashPosition having a valid value) is handled by OnSize.
if ( m_needUpdating )
{
m_needUpdating = false;
SizeWindows();
}
else if ( m_requestedSashPosition == INT_MAX )
{
// We don't need to resize the children.
return;
}
SizeWindows();
}
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
int height = sizeText.y;
return wxSize(sizeSearch.x + searchMargin + sizeText.x + cancelMargin + sizeCancel.x + 2*horizontalBorder,
height) + DoGetBorderSize();
#ifdef __WXMSW__
// Border is already added in wxSearchTextCtrl::DoGetBestSize()
height);
#else
height) + DoGetBorderSize();
#endif
}
void wxSearchCtrl::DoMoveWindow(int x, int y, int width, int height)
@ -521,7 +526,17 @@ void wxSearchCtrl::DoLayoutControls()
x += sizeSearch.x;
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 += cancelMargin;

View File

@ -26,6 +26,7 @@
#ifndef WX_PRECOMP
#include "wx/textctrl.h"
#include "wx/utils.h" // wxMax()
#endif // WX_PRECOMP
#include "wx/timectrl.h"
@ -657,7 +658,7 @@ void wxTimePickerCtrlGeneric::DoMoveWindow(int x, int y, int width, int height)
return;
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_btn->SetSize(widthText + HMARGIN_TEXT_SPIN, 0, widthBtn, height);

View File

@ -515,6 +515,13 @@ void wxTreeTextCtrl::Finish( bool setfocus )
{
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);
if (setfocus)

View File

@ -170,10 +170,15 @@ public:
wxScopedArray<wxString> oldTexts(m_columnsTexts);
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++ )
{
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--;
}
else // Not the deleted column.
@ -738,7 +743,10 @@ void wxTreeListModel::DeleteItem(Node* item)
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()

View File

@ -89,9 +89,6 @@ bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
return true;
}
if ( processed && event.IsCommandEvent())
return true;
// 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
// to call this virtual function ourselves.
@ -110,6 +107,11 @@ bool wxVarScrollHelperEvtHandler::ProcessEvent(wxEvent& event)
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
// ProcessEvent() above) to be able to test it below
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") );
// account for the bitmap size
const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize();
// account for the bitmap size, including the user-specified margins
const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize()
+ 2*m_imageData->GetBitmapMargins();
const wxDirection dirBmp = m_imageData->GetBitmapPosition();
if ( dirBmp == wxLEFT || dirBmp == wxRIGHT )
{
@ -535,9 +536,6 @@ void wxAnyButton::AdjustForBitmapSize(wxSize &size) const
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
// border at all in which case the button has exactly the same size as
// bitmap and so no margins should be used)

View File

@ -630,9 +630,9 @@ private:
};
//// 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;
// 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;
icon.CreateFromHICON( (WXHICON)sii.hIcon );
wxBitmap bitmap( icon );
bitmap = wxBitmap(icon);
::DestroyIcon(sii.hIcon);
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 reversed = 0;
for ( int bits = 0; bits < 8; bits++)
for ( int bit = 0; bit < 8; bit++)
{
reversed <<= 1;
reversed |= (unsigned char)(val & 0x01);

View File

@ -449,9 +449,9 @@ bool wxBitmapComboBox::MSWOnMeasure(WXMEASUREITEMSTRUCT *item)
LPMEASUREITEMSTRUCT lpMeasureItem = (LPMEASUREITEMSTRUCT) item;
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.
if ( pos >= 0 )
if ( m_usedImgSize.y >= 0 || pos >= 0 )
{
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;
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);
if ( oldLayout & LAYOUT_RTL )
::SetLayout(hdc, oldLayout);
return true;
}

View File

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

View File

@ -222,7 +222,7 @@ int wxDirDialog::ShowModal()
{
WX_HOOK_MODAL_DIALOG();
wxWindow* const parent = GetParent();
wxWindow* const parent = GetParentForModalDialog();
WXHWND hWndParent = parent ? GetHwndOf(parent) : NULL;
// 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();
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;
// 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
const wxString cwdOrig = wxGetCwd();
//== Execute FileDialog >>=================================================
if ( !ShowCommFileDialog(&of, m_windowStyle) )
return wxID_CANCEL;
struct CwdRestore
{
wxString value;
~CwdRestore()
{
if (!value.empty())
wxSetWorkingDirectory(value);
}
} cwdOrig;
// GetOpenFileName will always change the current working directory on
// (according to MSDN) "Windows NT 4.0/2000/XP" because the flag
// OFN_NOCHANGEDIR has no effect. If the user did not specify
// wxFD_CHANGE_DIR let's restore the current working directory to what it
// was before the dialog was shown.
if ( msw_flags & OFN_NOCHANGEDIR )
{
wxSetWorkingDirectory(cwdOrig);
}
if (msw_flags & OFN_NOCHANGEDIR)
cwdOrig.value = wxGetCwd();
//== Execute FileDialog >>=================================================
if ( !ShowCommFileDialog(&of, m_windowStyle) )
return wxID_CANCEL;
m_fileNames.Empty();
@ -726,11 +733,11 @@ int wxFileDialog::ShowModal()
m_fileNames.Add(toke.GetNextToken());
#endif // OFN_EXPLORER
wxString dir(m_dir);
m_path = m_dir;
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;
}
else
@ -746,7 +753,7 @@ int wxFileDialog::ShowModal()
const wxChar* extension = filterBuffer.t_str();
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;
m_fileName = AppendExtension(fileNameBuffer, extension);

View File

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

View File

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

View File

@ -286,16 +286,6 @@ void wxFrame::PositionStatusBar()
int 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;
#if wxUSE_TOOLBAR
wxToolBar * const toolbar = GetToolBar();
@ -319,6 +309,16 @@ void wxFrame::PositionStatusBar()
//else: no adjustments necessary for the toolbar on top
#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,
// we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
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
// 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
bool wxIOCPThread::ReadEvents()
{

View File

@ -45,7 +45,7 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
#endif
// ----------------------------------------------------------------------------
// define possibly missing WGL constants
// define possibly missing WGL constants and types
// ----------------------------------------------------------------------------
#ifndef WGL_ARB_pixel_format
@ -76,6 +76,49 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
#define WGL_SAMPLES_ARB 0x2042
#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
// ----------------------------------------------------------------------------
@ -108,10 +151,44 @@ LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
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)
{
m_glContext = wglCreateContext(win->GetHDC());
wxCHECK_RET( m_glContext, wxT("Couldn't create OpenGL context") );
if ( s_wglContextAttribs[0] == 0 ) // create legacy context
{
m_glContext = wglCreateContext(win->GetHDC());
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 )
{
@ -235,6 +312,58 @@ bool wxGLCanvas::Create(wxWindow *parent,
if ( !CreateWindow(parent, id, pos, size, style, name) )
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;
const int setupVal = DoSetup(pfd, attribList);
if ( setupVal == 0 ) // PixelFormat error

View File

@ -459,6 +459,11 @@ public:
}
virtual ~wxGDIPlusImageContext()
{
Flush();
}
virtual void Flush()
{
m_image = m_bitmap.ConvertToImage();
}
@ -1754,11 +1759,11 @@ void wxGDIPlusContext::DrawIcon( const wxIcon &icon, wxDouble x, wxDouble y, wxD
interim.GetPixelFormat(),&data);
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 )
hasAlpha = true;
}

View File

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

View File

@ -620,7 +620,15 @@ bool wxListCtrl::SetColumnWidth(int col, int width)
else if ( width == wxLIST_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
}
// 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
void wxMSWDisableSettingHighDPIAware()
{
gs_allowChangingDPIAwareness = false;
}
// ----------------------------------------------------------------------------
// Windows-specific wxEntry
// ----------------------------------------------------------------------------
@ -405,7 +420,9 @@ WXDLLEXPORT int wxEntry(HINSTANCE hInstance,
// 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
// doesn't happen if wx code is hosted in another app (e.g. a plugin).
wxSetProcessDPIAware();
// It can be disabled by calling wxMSWAllowChangingDPIAwareness().
if ( gs_allowChangingDPIAwareness )
wxSetProcessDPIAware();
if ( !wxMSWEntryCommon(hInstance, nCmdShow) )
return -1;

View File

@ -625,7 +625,7 @@ wxQTMediaBackend::~wxQTMediaBackend()
//---------------------------------------------------------------------------
// wxQTMediaBackend::CreateControl
//
// 1) Intializes QuickTime
// 1) Initializes QuickTime
// 2) Creates the control window
//---------------------------------------------------------------------------
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
// all separators have the same id
int pos = 0;
int position = 0;
wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();
while (node)
{
@ -755,14 +755,14 @@ bool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos)
if ( !item->IsOwnerDrawn())
{
item->SetOwnerDrawn(true);
SetOwnerDrawnMenuItem(GetHmenu(), pos,
SetOwnerDrawnMenuItem(GetHmenu(), position,
reinterpret_cast<ULONG_PTR>(item), TRUE);
}
item->SetMarginWidth(m_maxBitmapWidth);
node = node->GetNext();
pos++;
position++;
}
// set menu as ownerdrawn

View File

@ -557,11 +557,12 @@ void wxMenuItem::Enable(bool enable)
if ( m_isEnabled == enable )
return;
if ( m_parentMenu )
const int itemPos = MSGetMenuItemPos();
if ( itemPos != -1 )
{
long rc = EnableMenuItem(GetHMenuOf(m_parentMenu),
GetMSWId(),
MF_BYCOMMAND |
itemPos,
MF_BYPOSITION |
(enable ? MF_ENABLED : MF_GRAYED));
if ( rc == -1 )
@ -872,7 +873,8 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
data->SeparatorMargin.ApplyTo(rcSeparator);
RECT rcGutter = rcSelection;
rcGutter.right = data->ItemMargin.cxLeftWidth
rcGutter.right = rcGutter.left
+ data->ItemMargin.cxLeftWidth
+ data->CheckBgMargin.cxLeftWidth
+ data->CheckMargin.cxLeftWidth
+ imgWidth
@ -993,13 +995,13 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
SIZE 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
if ( data->MenuLayout() == MenuDrawData::Classic &&
(stat & wxODDisabled) && !(stat & wxODSelected) )
flags |= DSS_DISABLED;
int x = rcText.right - data->ArrowMargin.GetTotalX()
x = rcText.right - data->ArrowMargin.GetTotalX()
- data->ArrowSize.cx
- data->ArrowBorder;
@ -1009,7 +1011,7 @@ bool wxMenuItem::OnDrawItem(wxDC& dc, const wxRect& rc,
else
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),
accel.length(), x, y, 0, 0, flags);
@ -1271,7 +1273,7 @@ int wxMenuItem::MSGetMenuItemPos() const
if ( state & MF_POPUP )
{
if ( ::GetSubMenu(hMenu, i) == (HMENU)id )
if ( ::GetSubMenu(hMenu, i) == (HMENU)wxUIntToPtr(id) )
return i;
}
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,
// %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
// location, uses it, so it isn't likely to change
static const wxChar *MIME_DATABASE_KEY = wxT("MIME\\Database\\Content Type\\");
@ -190,7 +201,7 @@ size_t wxFileTypeImpl::GetAllCommands(wxArrayString *verbs,
bool wxFileTypeImpl::EnsureExtKeyExists()
{
wxRegKey rkey(wxRegKey::HKCR, m_ext);
wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + m_ext);
if ( !rkey.Exists() )
{
if ( !rkey.Create() || !rkey.SetValue(wxEmptyString, m_strFileType) )
@ -514,20 +525,6 @@ wxMimeTypesManagerImpl::GetFileTypeFromExtension(const wxString& 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
wxFileType *
wxMimeTypesManagerImpl::GetFileTypeFromMimeType(const wxString& mimeType)
@ -591,11 +588,11 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
extWithDot = wxT('.');
extWithDot += ext;
// start by setting the HKCR\\.ext entries
// start by setting the entries under ".ext"
// default is filetype; content type is mimetype
const wxString& filetypeOrig = ftInfo.GetShortDesc();
wxRegKey key(wxRegKey::HKCR, extWithDot);
wxRegKey key(wxRegKey::HKCU, CLASSES_ROOT_KEY + extWithDot);
if ( !key.Exists() )
{
// create the mapping from the extension to the filetype
@ -643,7 +640,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
// create the MIME key
wxString strKey = MIME_DATABASE_KEY;
strKey << mimetype;
wxRegKey keyMIME(wxRegKey::HKCR, strKey);
wxRegKey keyMIME(wxRegKey::HKCU, CLASSES_ROOT_KEY + strKey);
ok = keyMIME.Create();
if ( ok )
@ -664,7 +661,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
extWithDot = wxT('.');
extWithDot += ext;
wxRegKey key2(wxRegKey::HKCR, extWithDot);
wxRegKey key2(wxRegKey::HKCU, CLASSES_ROOT_KEY + extWithDot);
if ( !key2.Exists() )
key2.Create();
key2.SetValue(wxEmptyString, filetype);
@ -681,7 +678,7 @@ wxFileType *wxMimeTypesManagerImpl::Associate(const wxFileTypeInfo& ftInfo)
// create the MIME key
wxString strKey = MIME_DATABASE_KEY;
strKey << mimetype2;
wxRegKey keyMIME(wxRegKey::HKCR, strKey);
wxRegKey keyMIME(wxRegKey::HKCU, CLASSES_ROOT_KEY + strKey);
ok = keyMIME.Create();
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
// SetCommand(), SetDefaultIcon() &c will use it later)
wxRegKey keyFT(wxRegKey::HKCR, filetype);
wxRegKey keyFT(wxRegKey::HKCU, CLASSES_ROOT_KEY + filetype);
keyFT.Create();
wxFileType *ft = CreateFileType(filetype, extWithDot);
@ -724,66 +721,14 @@ bool wxFileTypeImpl::SetCommand(const wxString& cmd,
if ( !EnsureExtKeyExists() )
return false;
wxRegKey rkey(wxRegKey::HKCR, 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
wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + GetVerbPath(verb));
// TODO:
// 1. translate '%s' to '%1' instead of always adding it
// 2. create DDEExec value if needed (undo GetCommand)
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)
{
wxCHECK_MSG( !m_ext.empty(), false, wxT("SetDefaultIcon() needs extension") );
@ -794,7 +739,8 @@ bool wxFileTypeImpl::SetDefaultIcon(const wxString& cmd, int index)
if ( !EnsureExtKeyExists() )
return false;
wxRegKey rkey(wxRegKey::HKCR, m_strFileType + wxT("\\DefaultIcon"));
wxRegKey rkey(wxRegKey::HKCU,
CLASSES_ROOT_KEY + m_strFileType + wxT("\\DefaultIcon"));
return rkey.Create() &&
rkey.SetValue(wxEmptyString,
@ -809,7 +755,7 @@ bool wxFileTypeImpl::SetDescription (const wxString& desc)
if ( !EnsureExtKeyExists() )
return false;
wxRegKey rkey(wxRegKey::HKCR, m_strFileType );
wxRegKey rkey(wxRegKey::HKCU, CLASSES_ROOT_KEY + m_strFileType );
return rkey.Create() &&
rkey.SetValue(wxEmptyString, desc);
@ -831,16 +777,6 @@ bool wxFileTypeImpl::Unassociate()
if ( !RemoveDescription() )
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;
}
@ -854,7 +790,7 @@ bool wxFileTypeImpl::RemoveCommand(const wxString& verb)
wxCHECK_MSG( !m_ext.empty() && !verb.empty(), false,
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
return !rkey.Exists() || rkey.DeleteSelf();
@ -864,7 +800,7 @@ bool wxFileTypeImpl::RemoveMimeType()
{
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();
}
@ -873,7 +809,8 @@ bool wxFileTypeImpl::RemoveDefaultIcon()
wxCHECK_MSG( !m_ext.empty(), false,
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();
}
@ -882,7 +819,7 @@ bool wxFileTypeImpl::RemoveDescription()
wxCHECK_MSG( !m_ext.empty(), false,
wxT("RemoveDescription() needs extension") );
wxRegKey rkey (wxRegKey::HKCR, m_strFileType );
wxRegKey rkey (wxRegKey::HKCU, CLASSES_ROOT_KEY + m_strFileType );
return !rkey.Exists() || rkey.DeleteSelf();
}

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