Make wxNewId() and others return/take wxWindowID rather than int

wxWindowID is a typedef of int, so nothing should really change, except
for the improved readability.

Closes https://github.com/wxWidgets/wxWidgets/pull/1682
This commit is contained in:
Lauri Nurmi
2019-12-18 00:21:09 +02:00
committed by Vadim Zeitlin
parent fdc2e1b8bd
commit e8b8b0288f
3 changed files with 10 additions and 9 deletions

View File

@@ -15,6 +15,7 @@
// headers // headers
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
#include "wx/windowid.h"
#include "wx/object.h" #include "wx/object.h"
#include "wx/list.h" #include "wx/list.h"
#include "wx/filefn.h" #include "wx/filefn.h"
@@ -274,13 +275,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(int id); WXDLLIMPEXP_BASE void wxRegisterId(wxWindowID id);
// Return the current ID // Return the current ID
WXDLLIMPEXP_BASE int wxGetCurrentId(); WXDLLIMPEXP_BASE wxWindowID wxGetCurrentId();
// Generate a unique ID // Generate a unique ID
WXDLLIMPEXP_BASE int wxNewId(); WXDLLIMPEXP_BASE wxWindowID wxNewId();
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Various conversions // Various conversions

View File

@@ -484,7 +484,7 @@ int wxFindMenuItemId(wxFrame* frame, const wxString& menuString,
@header{wx/utils.h} @header{wx/utils.h}
*/ */
int 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
@@ -492,7 +492,7 @@ int wxNewId();
@header{wx/utils.h} @header{wx/utils.h}
*/ */
void wxRegisterId(int 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

@@ -697,9 +697,9 @@ long wxExecute(const wxString& command,
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// Id generation // Id generation
static int wxCurrentId = 100; static wxWindowID wxCurrentId = 100;
int 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)
@@ -708,11 +708,11 @@ int wxNewId()
return wxCurrentId++; return wxCurrentId++;
} }
int wxWindowID
wxGetCurrentId(void) { return wxCurrentId; } wxGetCurrentId(void) { return wxCurrentId; }
void void
wxRegisterId (int id) wxRegisterId (wxWindowID id)
{ {
if (id >= wxCurrentId) if (id >= wxCurrentId)
wxCurrentId = id + 1; wxCurrentId = id + 1;