\end{twocollist}}
}
+\membersection{wxWindow::ClientToWindowSize}\label{wxwindowclienttowindowsize}
+
+\func{virtual wxSize}{ClientToWindowSize}{\param{const wxSize\&}{ size}}
+
+Converts client area size \arg{size} to corresponding window size. In other
+words, the returned value is what would \helpref{GetSize}{wxwindowgetsize}
+return if this window had client area of given size.
+Components with $wxDefaultCoord$ value are left unchanged.
+
+Note that the conversion is not always exact, it assumes that non-client area
+doesn't change and so doesn't take into account things like menu bar
+(un)wrapping or (dis)appearance of the scrollbars.
+
+\wxheading{See also}
+
+\helpref{wxWindow::WindowToClientSize}{wxwindowwindowtoclientsize}
+
\membersection{wxWindow::Close}\label{wxwindowclose}
\docparam{y}{The new y position for the cursor.}
+\membersection{wxWindow::WindowToClientSize}\label{wxwindowwindowtoclientsize}
+
+\func{virtual wxSize}{WindowToClientSize}{\param{const wxSize\&}{ size}}
+
+Converts window size \arg{size} to corresponding client area size. In other
+words, the returned value is what would
+\helpref{GetClientSize}{wxwindowgetclientsize} return if this window had
+given window size. Components with $wxDefaultCoord$ value are left unchanged.
+
+Note that the conversion is not always exact, it assumes that non-client area
+doesn't change and so doesn't take into account things like menu bar
+(un)wrapping or (dis)appearance of the scrollbars.
+
+\wxheading{See also}
+
+\helpref{wxWindow::ClientToWindowSize}{wxwindowclienttowindowsize}
return wxRect(GetClientAreaOrigin(), GetClientSize());
}
+ // client<->window size conversion
+ virtual wxSize ClientToWindowSize(const wxSize& size) const;
+ virtual wxSize WindowToClientSize(const wxSize& size) const;
+
// get the size best suited for the window (in fact, minimal
// acceptable size using which it will still look "nice" in
// most situations)
return wxPoint(0,0);
}
+wxSize wxWindowBase::ClientToWindowSize(const wxSize& size) const
+{
+ const wxSize diff(GetSize() - GetClientSize());
+
+ return wxSize(size.x == -1 ? -1 : size.x + diff.x,
+ size.y == -1 ? -1 : size.y + diff.y);
+}
+
+wxSize wxWindowBase::WindowToClientSize(const wxSize& size) const
+{
+ const wxSize diff(GetSize() - GetClientSize());
+
+ return wxSize(size.x == -1 ? -1 : size.x - diff.x,
+ size.y == -1 ? -1 : size.y - diff.y);
+}
+
void wxWindowBase::SetWindowVariant( wxWindowVariant variant )
{
if ( m_windowVariant != variant )
test_gui_size.o \
test_gui_point.o \
test_gui_config.o \
+ test_gui_clientsize.o \
test_gui_textctrltest.o
TEST_GUI_ODEP = $(___pch_testprec_test_gui_testprec_h_gch___depname)
PRINTFBENCH_CXXFLAGS = $(__printfbench_PCH_INC) -D__WX$(TOOLKIT)__ \
test_gui_config.o: $(srcdir)/config/config.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/config/config.cpp
+test_gui_clientsize.o: $(srcdir)/controls/clientsize.cpp $(TEST_GUI_ODEP)
+ $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/clientsize.cpp
+
test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP)
$(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp
--- /dev/null
+///////////////////////////////////////////////////////////////////////////////
+// Name: tests/controls/clientsize.cpp
+// Purpose: Client vs. window size handling unit test
+// Author: Vaclav Slavik
+// Created: 2008-02-12
+// RCS-ID: $Id$
+// Copyright: (c) 2008 Vaclav Slavik <vslavik@fastmail.fm>
+///////////////////////////////////////////////////////////////////////////////
+
+// ----------------------------------------------------------------------------
+// headers
+// ----------------------------------------------------------------------------
+
+#include "testprec.h"
+
+#ifdef __BORLANDC__
+ #pragma hdrstop
+#endif
+
+#ifndef WX_PRECOMP
+ #include "wx/app.h"
+ #include "wx/window.h"
+#endif // WX_PRECOMP
+
+// ----------------------------------------------------------------------------
+// test class
+// ----------------------------------------------------------------------------
+
+class ClientSizeTestCase : public CppUnit::TestCase
+{
+public:
+ ClientSizeTestCase() { }
+
+ virtual void setUp();
+ virtual void tearDown();
+
+private:
+ CPPUNIT_TEST_SUITE( ClientSizeTestCase );
+ CPPUNIT_TEST( ClientToWindow );
+ CPPUNIT_TEST( WindowToClient );
+ CPPUNIT_TEST_SUITE_END();
+
+ void ClientToWindow();
+ void WindowToClient();
+
+ wxWindow *m_win;
+
+ DECLARE_NO_COPY_CLASS(ClientSizeTestCase)
+};
+
+// register in the unnamed registry so that these tests are run by default
+CPPUNIT_TEST_SUITE_REGISTRATION( ClientSizeTestCase );
+
+// also include in it's own registry so that these tests can be run alone
+CPPUNIT_TEST_SUITE_NAMED_REGISTRATION( ClientSizeTestCase, "ClientSizeTestCase" );
+
+// ----------------------------------------------------------------------------
+// test initialization
+// ----------------------------------------------------------------------------
+
+void ClientSizeTestCase::setUp()
+{
+ m_win = wxTheApp->GetTopWindow();
+}
+
+void ClientSizeTestCase::tearDown()
+{
+ m_win = NULL;
+}
+
+// ----------------------------------------------------------------------------
+// tests themselves
+// ----------------------------------------------------------------------------
+
+void ClientSizeTestCase::ClientToWindow()
+{
+ CPPUNIT_ASSERT(m_win->GetSize() ==
+ m_win->ClientToWindowSize(m_win->GetClientSize()));
+}
+
+void ClientSizeTestCase::WindowToClient()
+{
+ CPPUNIT_ASSERT(m_win->GetClientSize() ==
+ m_win->WindowToClientSize(m_win->GetSize()));
+}
$(OBJS)\test_gui_size.obj \
$(OBJS)\test_gui_point.obj \
$(OBJS)\test_gui_config.obj \
+ $(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_textctrltest.obj
PRINTFBENCH_CXXFLAGS = $(__RUNTIME_LIBS) -I$(BCCDIR)\include $(__DEBUGINFO) \
$(__OPTIMIZEFLAG) $(__THREADSFLAG_1) -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(OBJS)\test_gui_config.obj: .\config\config.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
+$(OBJS)\test_gui_clientsize.obj: .\controls\clientsize.cpp
+ $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\clientsize.cpp
+
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
$(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
$(OBJS)\test_gui_size.o \
$(OBJS)\test_gui_point.o \
$(OBJS)\test_gui_config.o \
+ $(OBJS)\test_gui_clientsize.o \
$(OBJS)\test_gui_textctrltest.o
PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) \
$(GCCFLAGS) -DHAVE_W32API_H -D__WXMSW__ $(__WXUNIV_DEFINE_p) \
$(OBJS)\test_gui_config.o: ./config/config.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+$(OBJS)\test_gui_clientsize.o: ./controls/clientsize.cpp
+ $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
+
$(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp
$(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $<
$(OBJS)\test_gui_size.obj \
$(OBJS)\test_gui_point.obj \
$(OBJS)\test_gui_config.obj \
+ $(OBJS)\test_gui_clientsize.obj \
$(OBJS)\test_gui_textctrltest.obj
PRINTFBENCH_CXXFLAGS = /M$(__RUNTIME_LIBS_38)$(__DEBUGRUNTIME) /DWIN32 \
$(__DEBUGINFO) /Fd$(OBJS)\printfbench.pdb $(____DEBUGRUNTIME) \
$(OBJS)\test_gui_config.obj: .\config\config.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\config\config.cpp
+$(OBJS)\test_gui_clientsize.obj: .\controls\clientsize.cpp
+ $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\clientsize.cpp
+
$(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp
$(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp
$(OBJS)\test_gui_size.obj &
$(OBJS)\test_gui_point.obj &
$(OBJS)\test_gui_config.obj &
+ $(OBJS)\test_gui_clientsize.obj &
$(OBJS)\test_gui_textctrltest.obj
PRINTFBENCH_CXXFLAGS = $(__DEBUGINFO) $(__OPTIMIZEFLAG) $(__THREADSFLAG) &
$(__RUNTIME_LIBS) -d__WXMSW__ $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) &
$(OBJS)\test_gui_config.obj : .AUTODEPEND .\config\config.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+$(OBJS)\test_gui_clientsize.obj : .AUTODEPEND .\controls\clientsize.cpp
+ $(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
+
$(OBJS)\test_gui_textctrltest.obj : .AUTODEPEND .\controls\textctrltest.cpp
$(CXX) -bt=nt -zq -fo=$^@ $(TEST_GUI_CXXFLAGS) $<
geometry/size.cpp
geometry/point.cpp
config/config.cpp
+ controls/clientsize.cpp
controls/textctrltest.cpp
</sources>
<wx-lib>core</wx-lib>
# PROP Default_Filter ""\r
# Begin Source File\r
\r
+SOURCE=.\controls\clientsize.cpp\r
+# End Source File\r
+# Begin Source File\r
+\r
SOURCE=.\config\config.cpp\r
# End Source File\r
# Begin Source File\r
Name="Source Files"\r
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx">\r
+ <File\r
+ RelativePath=".\controls\clientsize.cpp"/>\r
<File\r
RelativePath=".\config\config.cpp"/>\r
<File\r
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"\r
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"\r
>\r
+ <File\r
+ RelativePath=".\controls\clientsize.cpp"\r
+ />\r
<File\r
RelativePath=".\config\config.cpp"\r
/>\r