From 706f14210b7d782742b4fdbaea0adc25bdcced4d Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 4 Apr 2004 17:24:56 +0000 Subject: [PATCH] added and documented wxSize::IsFullySpecified() and SetDefaults() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26614 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/latex/wx/size.tex | 39 +++++++++++++++++++++++++++++++++++++++ include/wx/gdicmn.h | 16 ++++++++++++++-- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/docs/latex/wx/size.tex b/docs/latex/wx/size.tex index 738f5b2edd..22bf9c998c 100644 --- a/docs/latex/wx/size.tex +++ b/docs/latex/wx/size.tex @@ -26,6 +26,7 @@ None \latexignore{\rtfignore{\wxheading{Members}}} + \membersection{wxSize::wxSize} \func{}{wxSize}{\void} @@ -35,6 +36,7 @@ None Creates a size object. + \membersection{wxSize::DecTo}\label{wxsizedecto} \func{wxSize\&}{DecTo}{\param{const wxSize\& }{size}} @@ -47,12 +49,25 @@ corresponding dimensions of the \arg{size}. \helpref{IncTo}{wxsizeincto} +\membersection{wxSize::IsFullySpecified}\label{wxsizeisfullyspecified} + +\constfunc{IsFullySpecified}{\void} + +Returns \true if neither of the size object components is equal to $-1$, which +is used as default for the size values in wxWindows (hence the predefined +\texttt{wxDefaultSize} has both of its components equal to $-1$). + +This method is typically used before calling +\helpref{SetDefaults}{wxsizesetdefaults}. + + \membersection{wxSize::GetWidth}\label{wxsizegetwidth} \constfunc{int}{GetWidth}{\void} Gets the width member. + \membersection{wxSize::GetHeight}\label{wxsizegetheight} \constfunc{int}{GetHeight}{\void} @@ -60,6 +75,7 @@ Gets the width member. Gets the height member. + \membersection{wxSize::IncTo}\label{wxsizeincto} \func{wxSize\&}{IncTo}{\param{const wxSize\& }{size}} @@ -72,24 +88,47 @@ corresponding dimensions of the \arg{size}. \helpref{DecTo}{wxsizedecto} + \membersection{wxSize::Set}\label{wxsizeset} \func{void}{Set}{\param{int}{ width}, \param{int}{ height}} Sets the width and height members. + +\membersection{wxSize::SetDefaults}\label{wxsizesetdefaults} + +\func{void}{SetDefaults}{\param{const wxSize\& }{sizeDefault}} + +Combine this size object with another one replacing the default (i.e. equal +to $-1$) components of this object with those of the other. It is typically +used like this: +\begin{verbatim} + if ( !size.IsFullySpecified() ) + { + size.SetDefaults(GetDefaultSize()); + } +\end{verbatim} + +\wxheading{See also} + +\helpref{IsFullySpecified}{wxsizeisfullyspecified} + + \membersection{wxSize::SetHeight}\label{wxsizesetheight} \func{void}{SetHeight}{\param{int}{ height}} Sets the height. + \membersection{wxSize::SetWidth}\label{wxsizesetwidth} \func{void}{SetWidth}{\param{int}{ width}} Sets the width. + \membersection{wxSize::operator $=$} \func{void}{operator $=$}{\param{const wxSize\& }{sz}} diff --git a/include/wx/gdicmn.h b/include/wx/gdicmn.h index 7be6d7bcb4..85d5ad6150 100644 --- a/include/wx/gdicmn.h +++ b/include/wx/gdicmn.h @@ -116,7 +116,7 @@ enum wxStockCursor wxCURSOR_DEFAULT, // standard X11 cursor #endif #ifdef __WXMAC__ - wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow + wxCURSOR_COPY_ARROW , // MacOS Theme Plus arrow #endif #ifdef __X__ // Not yet implemented for Windows @@ -214,7 +214,7 @@ public: // FIXME are these really useful? If they're, we should have += &c as well wxSize operator+(const wxSize& sz) { return wxSize(x + sz.x, y + sz.y); } wxSize operator-(const wxSize& sz) { return wxSize(x - sz.x, y - sz.y); } - + void IncTo(const wxSize& sz) { if ( sz.x > x ) x = sz.x; if ( sz.y > y ) y = sz.y; } void DecTo(const wxSize& sz) @@ -228,6 +228,18 @@ public: int GetWidth() const { return x; } int GetHeight() const { return y; } + bool IsFullySpecified() const { return x != -1 && y != -1; } + + // combine this size with the other one replacing the default (i.e. equal + // to -1) components of this object with those of the other + void SetDefaults(const wxSize& size) + { + if ( x == -1 ) + x = size.x; + if ( y == -1 ) + y = size.y; + } + // compatibility int GetX() const { return x; } int GetY() const { return y; } -- 2.45.2