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 authored and Vadim Zeitlin committed 2020-01-15 14:28:33 +01:00
1 parent fdc2e1b8bd
commit e8b8b0288f
3 files changed
+10 -9

No files matched your search

+4 -3
View File
@@ -15,6 +15,7 @@
// headers
// ----------------------------------------------------------------------------
#include "wx/windowid.h"
#include "wx/object.h"
#include "wx/list.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
WXDLLIMPEXP_BASE void wxRegisterId(int id);
WXDLLIMPEXP_BASE void wxRegisterId(wxWindowID id);
// Return the current ID
WXDLLIMPEXP_BASE int wxGetCurrentId();
WXDLLIMPEXP_BASE wxWindowID wxGetCurrentId();
// Generate a unique ID
WXDLLIMPEXP_BASE int wxNewId();
WXDLLIMPEXP_BASE wxWindowID wxNewId();
// ----------------------------------------------------------------------------
// Various conversions
+2 -2
View File
@@ -484,7 +484,7 @@ int wxFindMenuItemId(wxFrame* frame, const wxString& menuString,
@header{wx/utils.h}
*/
int wxNewId();
wxWindowID wxNewId();
/**
Ensures that Ids subsequently generated by wxNewId() do not clash with the
@@ -492,7 +492,7 @@ int wxNewId();
@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
+4 -4
View File
@@ -697,9 +697,9 @@ long wxExecute(const wxString& command,
// ----------------------------------------------------------------------------
// 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:
if (wxCurrentId == wxID_LOWEST)
@@ -708,11 +708,11 @@ int wxNewId()
return wxCurrentId++;
}
int
wxWindowID
wxGetCurrentId(void) { return wxCurrentId; }
void
wxRegisterId (int id)
wxRegisterId (wxWindowID id)
{
if (id >= wxCurrentId)
wxCurrentId = id + 1;