From 3b51329a04a18f06489716234919d0bf49be57d2 Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Wed, 16 Jul 2008 16:24:12 +0200
Subject: [PATCH] Add wrappers for {Get,Set}{Pointer,Text}.

---
 toolkit/inc/layout/layout.hxx        |   26 ++++++++++++++++++++------
 toolkit/source/vclcompat/wfield.cxx  |   18 ++++++++++++++++--
 toolkit/source/vclcompat/wrapper.cxx |   25 +++++++++++++++++++++++++
 toolkit/source/vclcompat/wrapper.hxx |    5 ++++-
 4 files changed, 65 insertions(+), 9 deletions(-)

diff --git a/toolkit/inc/layout/layout.hxx b/toolkit/inc/layout/layout.hxx
index 37e77a4..bfbe10a 100644
--- a/toolkit/inc/layout/layout.hxx
+++ b/toolkit/inc/layout/layout.hxx
@@ -54,10 +54,12 @@
 
 class Control;
 class Image;
+class Pointer;
 class SfxPoolItem;
 class SfxItemSet;
 class VCLXWindow;
 class Window;
+class MultiListBox;
 class TabPage;
 
 namespace com { namespace sun { namespace star { namespace awt { class XWindow; } } } }
@@ -93,6 +95,9 @@ public:
 #define DECL_GET_IMPL(t) \
         inline t##Impl &getImpl() const
 
+#define DECL_GET_WINDOW( cls ) ::cls* Get##cls()
+#define IMPL_GET_WINDOW( cls ) ::cls* cls::Get##cls() { return reinterpret_cast< ::cls*>( GetWindow() ); }
+
 // follows the VCL inheritance hierarchy ...
 
 class WindowImpl;
@@ -125,9 +130,13 @@ public:
     ::Window* GetWindow() const;
     ::Window* GetParent() const;
 
+    void SetPointer( Pointer const& pointer );
+    Pointer const& GetPointer() const;
     WinBits GetStyle();
-    void SetStyle( WinBits nStyle );
-    void SetUpdateMode( bool /*bUpdate*/ ) { }
+    void SetText( String const& str );
+    String GetText() const;
+    void SetStyle( WinBits style );
+    void SetUpdateMode( bool mode );
     void SetHelpId( ULONG id );
     ULONG GetHelpId() const;
     void SetSmartHelpId( SmartId const&, SmartIdUpdateMode mode=SMART_SET_SMART );
@@ -450,6 +459,14 @@ public:
     bool IsLanguageSelected( const LanguageType/*eLangType*/) const { return true; }
 };
 
+class MultiListBoxImpl;
+class TOOLKIT_DLLPUBLIC MultiListBox : public ListBox
+{
+    DECL_GET_IMPL( MultiListBox );
+    DECL_CONSTRUCTORS( MultiListBox, ListBox, 0 );
+    DECL_GET_WINDOW( MultiListBox );
+};
+
 class DialogImpl;
 class TOOLKIT_DLLPUBLIC Dialog : public Context, public Window
 {
@@ -462,8 +479,6 @@ public:
     void SetText( String const& rStr );
 };
 
-#define DECL_GET_WINDOW( cls ) ::cls* Get##cls()
-#define IMPL_GET_WINDOW( cls ) ::cls* cls::Get##cls() { return reinterpret_cast< ::cls*>( GetWindow() ); }
 class TabPageImpl;
 class TOOLKIT_DLLPUBLIC TabPage : public Context, public Window
 {
@@ -474,8 +489,7 @@ public:
     TabPage( Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0, SfxItemSet const* set = 0 );
     TabPage( ::Window *pOptParent, char const* pXMLPath, char const* pId, sal_uInt32 nId = 0, SfxItemSet const* set = 0 );
     ~TabPage();
-    //DECL_GET_WINDOW( TabPage );
-    ::TabPage* GetTabPage();
+    DECL_GET_WINDOW( TabPage );
     virtual void ActivatePage();
     virtual void DeactivatePage();
 #if 0
diff --git a/toolkit/source/vclcompat/wfield.cxx b/toolkit/source/vclcompat/wfield.cxx
index 8d9ab13..b6e2830 100644
--- a/toolkit/source/vclcompat/wfield.cxx
+++ b/toolkit/source/vclcompat/wfield.cxx
@@ -44,6 +44,7 @@
 #include <cppuhelper/implbase1.hxx>
 #include <com/sun/star/awt/XActionListener.hpp>
 #include <com/sun/star/awt/XItemListener.hpp>
+#include <vcl/lstbox.hxx>
 
 using namespace ::com::sun::star;
 
@@ -537,8 +538,7 @@ public:
         if ( !rLink )
             mxListBox->removeItemListener( this );
         else
-            mxListBox->addItemListener( this );
-    }
+            mxListBox->addItemListener( this );    }
 
     virtual void SAL_CALL disposing( const css::lang::EventObject& /* Source */ )
         throw (css::uno::RuntimeException)
@@ -636,4 +636,18 @@ void ListBox::SetClickHdl( const Link& rLink )
 IMPL_CONSTRUCTORS( ListBox, Control, "listbox" );
 IMPL_GET_IMPL( ListBox );
 
+// Window/Control/List/MultiListBox
+class MultiListBoxImpl : public ListBoxImpl
+{
+public:
+    MultiListBoxImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
+        : ListBoxImpl( pCtx, xPeer, pWindow )
+    {
+    }
+};
+
+IMPL_CONSTRUCTORS_BODY( MultiListBox, ListBox, "multilistbox", GetMultiListBox()->EnableMultiSelection( true ); );
+IMPL_GET_IMPL( MultiListBox );
+IMPL_GET_WINDOW( MultiListBox );
+
 } // namespace layout
diff --git a/toolkit/source/vclcompat/wrapper.cxx b/toolkit/source/vclcompat/wrapper.cxx
index ee526d2..204cd4e 100644
--- a/toolkit/source/vclcompat/wrapper.cxx
+++ b/toolkit/source/vclcompat/wrapper.cxx
@@ -398,6 +398,31 @@ void Window::GrabFocus()
     getImpl().mxWindow->setFocus();
 }
 
+void Window::SetUpdateMode(bool mode)
+{
+    GetWindow()->SetUpdateMode( mode );
+}
+
+void Window::SetPointer( Pointer const& pointer )
+{
+    GetWindow()->SetPointer( pointer );
+}
+
+Pointer const& Window::GetPointer() const
+{
+    return GetWindow()->GetPointer();
+}
+
+void Window::SetText( String const& str )
+{
+    GetWindow()->SetText( str );
+}
+
+String Window::GetText() const
+{
+    return GetWindow()->GetText();
+}
+
 class DialogImpl : public WindowImpl
 {
 public:
diff --git a/toolkit/source/vclcompat/wrapper.hxx b/toolkit/source/vclcompat/wrapper.hxx
index 5df64bc..e5332de 100644
--- a/toolkit/source/vclcompat/wrapper.hxx
+++ b/toolkit/source/vclcompat/wrapper.hxx
@@ -116,15 +116,18 @@ inline WindowImpl &Window::getImpl() const
     { \
         return *(static_cast<t##Impl *>(mpImpl)); \
     }
-#define IMPL_CONSTRUCTORS(t,par,unoName) \
+#define IMPL_CONSTRUCTORS_BODY(t,par,unoName,body) \
     t::t( Context *pCtx, const char *pId, sal_uInt32 nId ) \
         : par( new t##Impl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) ) \
     { \
+      body\
     } \
     t::t( Window *pParent, WinBits nBits) \
         : par( new t##Impl( pParent->getContext(), Window::CreatePeer( pParent, nBits, unoName ), this ) ) \
     { \
+      body\
     }
+#define IMPL_CONSTRUCTORS(t,par,unoName) IMPL_CONSTRUCTORS_BODY(t, par, unoName, )
 #define IMPL_CONSTRUCTORS_2(t,win_par,other_par,unoName) \
     t::t( Context *pCtx, const char *pId, sal_uInt32 nId ) \
         : win_par( new t##Impl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) ) \
-- 
1.5.6.3.317.g5d44c9.dirty


