Use wxWindowID in wxNewId() and related functions.

wxNewId(), wxRegisterId() and wxGetCurrentId() functions all work with
window IDs, so they should use the dedicated type. Previously, they
worked with long, which is not even the same type (wxWindowID is int),
causing implicit type conversion warnings.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74485 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík
2013-07-11 06:58:35 +00:00
parent 7e05f038b9
commit 1c6a98048b
3 changed files with 9 additions and 9 deletions

View File

@@ -273,13 +273,13 @@ inline bool wxPlatformIs(int platform) { return wxPlatform::Is(platform); }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Ensure subsequent IDs don't clash with this one // Ensure subsequent IDs don't clash with this one
WXDLLIMPEXP_BASE void wxRegisterId(long id); WXDLLIMPEXP_BASE void wxRegisterId(wxWindowID id);
// Return the current ID // Return the current ID
WXDLLIMPEXP_BASE long wxGetCurrentId(); WXDLLIMPEXP_BASE wxWindowID wxGetCurrentId();
// Generate a unique ID // Generate a unique ID
WXDLLIMPEXP_BASE long wxNewId(); WXDLLIMPEXP_BASE wxWindowID wxNewId();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Various conversions // Various conversions

View File

@@ -459,7 +459,7 @@ int wxFindMenuItemId(wxFrame* frame, const wxString& menuString,
@header{wx/utils.h} @header{wx/utils.h}
*/ */
long wxNewId(); wxWindowID wxNewId();
/** /**
Ensures that Ids subsequently generated by wxNewId() do not clash with the Ensures that Ids subsequently generated by wxNewId() do not clash with the
@@ -467,7 +467,7 @@ long wxNewId();
@header{wx/utils.h} @header{wx/utils.h}
*/ */
void wxRegisterId(long id); void wxRegisterId(wxWindowID id);
/** /**
Opens the @a document in the application associated with the files of this Opens the @a document in the application associated with the files of this

View File

@@ -714,9 +714,9 @@ long wxExecute(const wxString& command,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Id generation // Id generation
static long wxCurrentId = 100; static wxWindowID wxCurrentId = 100;
long wxNewId() wxWindowID wxNewId()
{ {
// skip the part of IDs space that contains hard-coded values: // skip the part of IDs space that contains hard-coded values:
if (wxCurrentId == wxID_LOWEST) if (wxCurrentId == wxID_LOWEST)
@@ -725,11 +725,11 @@ long wxNewId()
return wxCurrentId++; return wxCurrentId++;
} }
long wxWindowID
wxGetCurrentId(void) { return wxCurrentId; } wxGetCurrentId(void) { return wxCurrentId; }
void void
wxRegisterId (long id) wxRegisterId (wxWindowID id)
{ {
if (id >= wxCurrentId) if (id >= wxCurrentId)
wxCurrentId = id + 1; wxCurrentId = id + 1;