From 6c5d62917d14278d8925a73d754965713e11e32f Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Thu, 16 Mar 2006 16:07:24 +0000
Subject: [PATCH] added wxDisplay::GetClientArea() (currently implemented for
 single display and MSW implementations only)

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@38147 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/changes.txt            |  1 +
 docs/latex/wx/display.tex   | 18 ++++++++++++++++++
 include/wx/display.h        |  5 ++++-
 include/wx/display_impl.h   |  3 +++
 samples/display/display.cpp |  9 +++++++++
 src/common/dpycmn.cpp       |  9 +++++++++
 src/msw/display.cpp         | 13 +++++++++++++
 7 files changed, 57 insertions(+), 1 deletion(-)

diff --git a/docs/changes.txt b/docs/changes.txt
index a3d46f88de..1fe885015c 100644
--- a/docs/changes.txt
+++ b/docs/changes.txt
@@ -94,6 +94,7 @@ All (GUI):
 - UpdateUI handler can now show/hide the window too (Ronald Weiss)
 - More than one filter allowed in in wxDocTemplate filter.
 - Added wxListBox::HitTest()
+- Added wxDisplay::GetClientArea()
 
 wxMSW:
 
diff --git a/docs/latex/wx/display.tex b/docs/latex/wx/display.tex
index b2c80bd300..fd78c8f15e 100644
--- a/docs/latex/wx/display.tex
+++ b/docs/latex/wx/display.tex
@@ -57,6 +57,20 @@ function that changed the video mode to the system
 default by using the system's 'scrn' resource.
 
 
+\membersection{wxDisplay::GetClientArea}\label{wxdisplaygetclientarea}
+
+\constfunc{wxRect }{GetClientArea}{\void}
+
+Returns the client area of the display. The client area is the part of the
+display available for the normal (non full screen) windows, usually it is the
+same as \helpref{GetGeometry}{wxdisplaygetgeometry} but it could be less if
+there is a taskbar (or equivalent) on this display.
+
+\wxheading{See also:}
+
+\helpref{wxClientDisplayRect}{wxclientdisplayrect}
+
+
 \membersection{wxDisplay::GetCount}\label{wxdisplaygetcount}
 
 \func{static size\_t}{GetCount}{\void}
@@ -112,6 +126,10 @@ Returns \texttt{wxNOT\_FOUND} if the window is not on any connected display.
 Returns the bounding rectangle of the display whose index was passed to the
 constructor.
 
+\wxheading{See also:}
+
+\helpref{GetClientArea}{wxdisplaygetclientarea}, \helpref{wxDisplaySize}{wxdisplaysize}
+
 
 \membersection{wxDisplay::GetModes}\label{wxdisplaygetmodes}
 
diff --git a/include/wx/display.h b/include/wx/display.h
index 3429258eb6..002ce99ced 100644
--- a/include/wx/display.h
+++ b/include/wx/display.h
@@ -68,9 +68,12 @@ public:
     // return true if the object was initialized successfully
     bool IsOk() const { return m_impl != NULL; }
 
-    // get the display size
+    // get the full display size
     wxRect GetGeometry() const;
 
+    // get the client area of the display, i.e. without taskbars and such
+    wxRect GetClientArea() const;
+
     // name may be empty
     wxString GetName() const;
 
diff --git a/include/wx/display_impl.h b/include/wx/display_impl.h
index aa7e05ff0d..2a36d49d15 100644
--- a/include/wx/display_impl.h
+++ b/include/wx/display_impl.h
@@ -52,6 +52,9 @@ public:
     // return the full area of this display
     virtual wxRect GetGeometry() const = 0;
 
+    // return the area of the display available for normal windows
+    virtual wxRect GetClientArea() const { return GetGeometry(); }
+
     // return the name (may be empty)
     virtual wxString GetName() const = 0;
 
diff --git a/samples/display/display.cpp b/samples/display/display.cpp
index ff358cd01a..7ee089971d 100644
--- a/samples/display/display.cpp
+++ b/samples/display/display.cpp
@@ -260,6 +260,15 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size,
                                          r.width, r.height)
                        ));
 
+        const wxRect rc(display.GetClientArea());
+        sizer->Add(new wxStaticText(page, wxID_ANY, _T("Client area: ")));
+        sizer->Add(new wxStaticText
+                       (
+                        page,
+                        wxID_ANY,
+                        wxString::Format(_T("(%d, %d)-(%d, %d)"),
+                                         rc.x, rc.y, rc.width, rc.height)
+                       ));
 
         sizer->Add(new wxStaticText(page, wxID_ANY, _T("Name: ")));
         sizer->Add(new wxStaticText(page, wxID_ANY, display.GetName()));
diff --git a/src/common/dpycmn.cpp b/src/common/dpycmn.cpp
index b30084f099..d375d9e494 100644
--- a/src/common/dpycmn.cpp
+++ b/src/common/dpycmn.cpp
@@ -68,6 +68,8 @@ public:
         return r;
     }
 
+    virtual wxRect GetClientArea() const { return wxGetClientDisplayRect(); }
+
     virtual wxString GetName() const { return wxString(); }
 
 #if wxUSE_DISPLAY
@@ -162,6 +164,13 @@ wxRect wxDisplay::GetGeometry() const
     return m_impl->GetGeometry();
 }
 
+wxRect wxDisplay::GetClientArea() const
+{
+    wxCHECK_MSG( IsOk(), wxRect(), _T("invalid wxDisplay object") );
+
+    return m_impl->GetClientArea();
+}
+
 wxString wxDisplay::GetName() const
 {
     wxCHECK_MSG( IsOk(), wxString(), _T("invalid wxDisplay object") );
diff --git a/src/msw/display.cpp b/src/msw/display.cpp
index 639737d549..40300953d5 100644
--- a/src/msw/display.cpp
+++ b/src/msw/display.cpp
@@ -142,6 +142,9 @@ struct wxDisplayInfo
     // the entire area of this monitor in virtual screen coordinates
     wxRect m_rect;
 
+    // the work or client area, i.e. the area available for the normal windows
+    wxRect m_rectClient;
+
     // the display device name for this monitor, empty initially and retrieved
     // on demand by DoGetName()
     wxString m_devName;
@@ -167,6 +170,7 @@ public:
     }
 
     virtual wxRect GetGeometry() const;
+    virtual wxRect GetClientArea() const;
     virtual wxString GetName() const;
     virtual bool IsPrimary() const;
 
@@ -415,6 +419,7 @@ void wxDisplayInfo::Initialize()
         }
 
         wxCopyRECTToRect(monInfo.rcMonitor, m_rect);
+        wxCopyRECTToRect(monInfo.rcWork, m_rectClient);
         m_devName = monInfo.szDevice;
         m_flags = monInfo.dwFlags;
     }
@@ -432,6 +437,14 @@ wxRect wxDisplayImplWin32Base::GetGeometry() const
     return m_info.m_rect;
 }
 
+wxRect wxDisplayImplWin32Base::GetClientArea() const
+{
+    if ( m_info.m_rectClient.IsEmpty() )
+        m_info.Initialize();
+
+    return m_info.m_rectClient;
+}
+
 wxString wxDisplayImplWin32Base::GetName() const
 {
     if ( m_info.m_devName.IsEmpty() )
-- 
2.47.2