1*5900e8ecSAndrew Rist /************************************************************** 2*5900e8ecSAndrew Rist * 3*5900e8ecSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*5900e8ecSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*5900e8ecSAndrew Rist * distributed with this work for additional information 6*5900e8ecSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*5900e8ecSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*5900e8ecSAndrew Rist * "License"); you may not use this file except in compliance 9*5900e8ecSAndrew Rist * with the License. You may obtain a copy of the License at 10*5900e8ecSAndrew Rist * 11*5900e8ecSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*5900e8ecSAndrew Rist * 13*5900e8ecSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*5900e8ecSAndrew Rist * software distributed under the License is distributed on an 15*5900e8ecSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*5900e8ecSAndrew Rist * KIND, either express or implied. See the License for the 17*5900e8ecSAndrew Rist * specific language governing permissions and limitations 18*5900e8ecSAndrew Rist * under the License. 19*5900e8ecSAndrew Rist * 20*5900e8ecSAndrew Rist *************************************************************/ 21*5900e8ecSAndrew Rist 22*5900e8ecSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_svtools.hxx" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "ctrlbox.hxx" 28cdf0e10cSrcweir #include "svtools/toolpanel/toolpaneldeck.hxx" 29cdf0e10cSrcweir #include "svtools/toolpanel/tablayouter.hxx" 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 32cdf0e10cSrcweir #include <com/sun/star/uno/XComponentContext.hpp> 33cdf0e10cSrcweir 34cdf0e10cSrcweir #include <comphelper/processfactory.hxx> 35cdf0e10cSrcweir #include <cppuhelper/bootstrap.hxx> 36cdf0e10cSrcweir #include <cppuhelper/servicefactory.hxx> 37cdf0e10cSrcweir #include <tools/diagnose_ex.h> 38cdf0e10cSrcweir #include <ucbhelper/contentbroker.hxx> 39cdf0e10cSrcweir #include <vcl/button.hxx> 40cdf0e10cSrcweir #include <vcl/edit.hxx> 41cdf0e10cSrcweir #include <vcl/fixed.hxx> 42cdf0e10cSrcweir #include <vcl/help.hxx> 43cdf0e10cSrcweir #include <vcl/lstbox.hxx> 44cdf0e10cSrcweir #include <vcl/svapp.hxx> 45cdf0e10cSrcweir #include <vcl/tabctrl.hxx> 46cdf0e10cSrcweir #include <vcl/taskpanelist.hxx> 47cdf0e10cSrcweir #include <vcl/wrkwin.hxx> 48cdf0e10cSrcweir 49cdf0e10cSrcweir namespace svt { namespace toolpanel 50cdf0e10cSrcweir { 51cdf0e10cSrcweir 52cdf0e10cSrcweir using ::com::sun::star::uno::Reference; 53cdf0e10cSrcweir using ::com::sun::star::uno::Sequence; 54cdf0e10cSrcweir using ::com::sun::star::uno::Any; 55cdf0e10cSrcweir using ::com::sun::star::lang::XMultiServiceFactory; 56cdf0e10cSrcweir using ::com::sun::star::uno::XComponentContext; 57cdf0e10cSrcweir using ::com::sun::star::accessibility::XAccessible; 58cdf0e10cSrcweir 59cdf0e10cSrcweir //============================================================================= 60cdf0e10cSrcweir //= PanelDemo 61cdf0e10cSrcweir //============================================================================= 62cdf0e10cSrcweir class PanelDemo : public Application 63cdf0e10cSrcweir { 64cdf0e10cSrcweir public: 65cdf0e10cSrcweir virtual void Main(); 66cdf0e10cSrcweir 67cdf0e10cSrcweir private: 68cdf0e10cSrcweir static Reference< XMultiServiceFactory > createApplicationServiceManager(); 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir //============================================================================= 72cdf0e10cSrcweir //= ColoredPanelWindow 73cdf0e10cSrcweir //============================================================================= 74cdf0e10cSrcweir class ColoredPanelWindow : public Window 75cdf0e10cSrcweir { 76cdf0e10cSrcweir public: 77cdf0e10cSrcweir ColoredPanelWindow( Window& i_rParent, const Color& i_rColor, const String& i_rTitle ) 78cdf0e10cSrcweir :Window( &i_rParent ) 79cdf0e10cSrcweir ,m_aEdit( this, WB_BORDER ) 80cdf0e10cSrcweir ,m_aTabControl( this ) 81cdf0e10cSrcweir ,m_sTitle( i_rTitle ) 82cdf0e10cSrcweir { 83cdf0e10cSrcweir SetLineColor(); 84cdf0e10cSrcweir SetFillColor( i_rColor ); 85cdf0e10cSrcweir 86cdf0e10cSrcweir m_aEdit.Show(); 87cdf0e10cSrcweir m_aTabControl.Show(); 88cdf0e10cSrcweir 89cdf0e10cSrcweir const sal_Char* pTabTitles[] = 90cdf0e10cSrcweir { 91cdf0e10cSrcweir "This", "is a", "Tab", "Control", "intended", "for", "comparison" 92cdf0e10cSrcweir }; 93cdf0e10cSrcweir for ( size_t i=0; i < sizeof( pTabTitles ) / sizeof( pTabTitles[0] ); ++i ) 94cdf0e10cSrcweir { 95cdf0e10cSrcweir String sText( String::CreateFromAscii( pTabTitles[i] ) ); 96cdf0e10cSrcweir m_aTabControl.InsertPage( i + 1, sText ); 97cdf0e10cSrcweir } 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir virtual void Paint( const Rectangle& /*i_rRect*/ ) 101cdf0e10cSrcweir { 102cdf0e10cSrcweir const Size aOutputSize( GetOutputSizePixel() ); 103cdf0e10cSrcweir const Rectangle aTitleRect( Point( 10, 10 ), Size( aOutputSize.Width() - 20, 20 ) ); 104cdf0e10cSrcweir DrawRect( aTitleRect ); 105cdf0e10cSrcweir SetTextColor( GetFillColor().IsDark() ? COL_WHITE : COL_BLACK ); 106cdf0e10cSrcweir DrawText( aTitleRect, m_sTitle, TEXT_DRAW_CENTER | TEXT_DRAW_VCENTER ); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir virtual void GetFocus() 110cdf0e10cSrcweir { 111cdf0e10cSrcweir m_aEdit.GrabFocus(); 112cdf0e10cSrcweir } 113cdf0e10cSrcweir 114cdf0e10cSrcweir virtual void Resize() 115cdf0e10cSrcweir { 116cdf0e10cSrcweir const Size aOutputSize( GetOutputSizePixel() ); 117cdf0e10cSrcweir m_aEdit.SetPosSizePixel( 118cdf0e10cSrcweir Point( 20, 40 ), 119cdf0e10cSrcweir Size( aOutputSize.Width() - 40, 20 ) 120cdf0e10cSrcweir ); 121cdf0e10cSrcweir m_aTabControl.SetPosSizePixel( 122cdf0e10cSrcweir Point( 20, 70 ), 123cdf0e10cSrcweir Size( aOutputSize.Width() - 40, 150 ) 124cdf0e10cSrcweir ); 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir private: 128cdf0e10cSrcweir Edit m_aEdit; 129cdf0e10cSrcweir TabControl m_aTabControl; 130cdf0e10cSrcweir String m_sTitle; 131cdf0e10cSrcweir }; 132cdf0e10cSrcweir 133cdf0e10cSrcweir //============================================================================= 134cdf0e10cSrcweir //= ColoredPanel 135cdf0e10cSrcweir //============================================================================= 136cdf0e10cSrcweir class ColoredPanel : public IToolPanel 137cdf0e10cSrcweir { 138cdf0e10cSrcweir public: 139cdf0e10cSrcweir ColoredPanel( Window& i_rParent, const Color& i_rColor, const sal_Char* i_pAsciiPanelName ); 140cdf0e10cSrcweir ColoredPanel( Window& i_rParent, const Color& i_rColor, const String& i_rPanelName ); 141cdf0e10cSrcweir ~ColoredPanel(); 142cdf0e10cSrcweir 143cdf0e10cSrcweir // IToolPanel 144cdf0e10cSrcweir virtual ::rtl::OUString GetDisplayName() const; 145cdf0e10cSrcweir virtual Image GetImage() const; 146cdf0e10cSrcweir virtual rtl::OString GetHelpID() const; 147cdf0e10cSrcweir virtual void Activate( Window& i_rParentWindow ); 148cdf0e10cSrcweir virtual void Deactivate(); 149cdf0e10cSrcweir virtual void SetSizePixel( const Size& i_rPanelWindowSize ); 150cdf0e10cSrcweir virtual void GrabFocus(); 151cdf0e10cSrcweir virtual void Dispose(); 152cdf0e10cSrcweir virtual Reference< XAccessible > CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ); 153cdf0e10cSrcweir 154cdf0e10cSrcweir // IReference 155cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL acquire(); 156cdf0e10cSrcweir virtual oslInterlockedCount SAL_CALL release(); 157cdf0e10cSrcweir 158cdf0e10cSrcweir private: 159cdf0e10cSrcweir oslInterlockedCount m_refCount; 160cdf0e10cSrcweir ::std::auto_ptr< ColoredPanelWindow > 161cdf0e10cSrcweir m_pWindow; 162cdf0e10cSrcweir ::rtl::OUString m_aPanelName; 163cdf0e10cSrcweir BitmapEx m_aPanelIcon; 164cdf0e10cSrcweir }; 165cdf0e10cSrcweir 166cdf0e10cSrcweir //============================================================================= 167cdf0e10cSrcweir //= ColoredPanel 168cdf0e10cSrcweir //============================================================================= 169cdf0e10cSrcweir //----------------------------------------------------------------------------- 170cdf0e10cSrcweir ColoredPanel::ColoredPanel( Window& i_rParent, const Color& i_rColor, const sal_Char* i_pAsciiPanelName ) 171cdf0e10cSrcweir :m_refCount(0) 172cdf0e10cSrcweir ,m_pWindow( new ColoredPanelWindow( i_rParent, i_rColor, ::rtl::OUString::createFromAscii( i_pAsciiPanelName ) ) ) 173cdf0e10cSrcweir ,m_aPanelName( ::rtl::OUString::createFromAscii( i_pAsciiPanelName ) ) 174cdf0e10cSrcweir ,m_aPanelIcon() 175cdf0e10cSrcweir { 176cdf0e10cSrcweir Bitmap aBitmap( Size( 16, 16 ), 8 ); 177cdf0e10cSrcweir m_aPanelIcon = BitmapEx( aBitmap ); 178cdf0e10cSrcweir m_aPanelIcon.Erase( i_rColor ); 179cdf0e10cSrcweir } 180cdf0e10cSrcweir 181cdf0e10cSrcweir //----------------------------------------------------------------------------- 182cdf0e10cSrcweir ColoredPanel::ColoredPanel( Window& i_rParent, const Color& i_rColor, const String& i_rPanelName ) 183cdf0e10cSrcweir :m_refCount(0) 184cdf0e10cSrcweir ,m_pWindow( new ColoredPanelWindow( i_rParent, i_rColor, i_rPanelName ) ) 185cdf0e10cSrcweir ,m_aPanelName( i_rPanelName ) 186cdf0e10cSrcweir ,m_aPanelIcon() 187cdf0e10cSrcweir { 188cdf0e10cSrcweir Bitmap aBitmap( Size( 16, 16 ), 8 ); 189cdf0e10cSrcweir m_aPanelIcon = BitmapEx( aBitmap ); 190cdf0e10cSrcweir m_aPanelIcon.Erase( i_rColor ); 191cdf0e10cSrcweir } 192cdf0e10cSrcweir 193cdf0e10cSrcweir //----------------------------------------------------------------------------- 194cdf0e10cSrcweir ColoredPanel::~ColoredPanel() 195cdf0e10cSrcweir { 196cdf0e10cSrcweir } 197cdf0e10cSrcweir 198cdf0e10cSrcweir //----------------------------------------------------------------------------- 199cdf0e10cSrcweir oslInterlockedCount SAL_CALL ColoredPanel::acquire() 200cdf0e10cSrcweir { 201cdf0e10cSrcweir return osl_incrementInterlockedCount( &m_refCount ); 202cdf0e10cSrcweir } 203cdf0e10cSrcweir 204cdf0e10cSrcweir //----------------------------------------------------------------------------- 205cdf0e10cSrcweir oslInterlockedCount SAL_CALL ColoredPanel::release() 206cdf0e10cSrcweir { 207cdf0e10cSrcweir oslInterlockedCount newCount = osl_decrementInterlockedCount( &m_refCount ); 208cdf0e10cSrcweir if ( 0 == newCount ) 209cdf0e10cSrcweir delete this; 210cdf0e10cSrcweir return newCount; 211cdf0e10cSrcweir } 212cdf0e10cSrcweir 213cdf0e10cSrcweir //----------------------------------------------------------------------------- 214cdf0e10cSrcweir void ColoredPanel::Activate( Window& i_rParentWindow ) 215cdf0e10cSrcweir { 216cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); 217cdf0e10cSrcweir OSL_ENSURE( &i_rParentWindow == m_pWindow->GetParent(), "ColoredPanel::Activate: unexpected new parent window!" ); 218cdf0e10cSrcweir // the documentation of IToolPanel::Activate says it is guaranteed that the parent window is 219cdf0e10cSrcweir // always the same ... 220cdf0e10cSrcweir m_pWindow->SetPosSizePixel( Point(), i_rParentWindow.GetSizePixel() ); 221cdf0e10cSrcweir m_pWindow->Show(); 222cdf0e10cSrcweir } 223cdf0e10cSrcweir 224cdf0e10cSrcweir //----------------------------------------------------------------------------- 225cdf0e10cSrcweir void ColoredPanel::Deactivate() 226cdf0e10cSrcweir { 227cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); 228cdf0e10cSrcweir m_pWindow->Hide(); 229cdf0e10cSrcweir } 230cdf0e10cSrcweir 231cdf0e10cSrcweir //----------------------------------------------------------------------------- 232cdf0e10cSrcweir void ColoredPanel::SetSizePixel( const Size& i_rPanelWindowSize ) 233cdf0e10cSrcweir { 234cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); 235cdf0e10cSrcweir m_pWindow->SetSizePixel( i_rPanelWindowSize ); 236cdf0e10cSrcweir } 237cdf0e10cSrcweir 238cdf0e10cSrcweir //----------------------------------------------------------------------------- 239cdf0e10cSrcweir void ColoredPanel::GrabFocus() 240cdf0e10cSrcweir { 241cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); 242cdf0e10cSrcweir m_pWindow->GrabFocus(); 243cdf0e10cSrcweir } 244cdf0e10cSrcweir 245cdf0e10cSrcweir //----------------------------------------------------------------------------- 246cdf0e10cSrcweir void ColoredPanel::Dispose() 247cdf0e10cSrcweir { 248cdf0e10cSrcweir ENSURE_OR_RETURN_VOID( m_pWindow.get(), "disposed!" ); 249cdf0e10cSrcweir m_pWindow.reset(); 250cdf0e10cSrcweir } 251cdf0e10cSrcweir 252cdf0e10cSrcweir //----------------------------------------------------------------------------- 253cdf0e10cSrcweir Reference< XAccessible > ColoredPanel::CreatePanelAccessible( const Reference< XAccessible >& i_rParentAccessible ) 254cdf0e10cSrcweir { 255cdf0e10cSrcweir ENSURE_OR_RETURN( m_pWindow.get(), "disposed!", NULL ); 256cdf0e10cSrcweir (void)i_rParentAccessible; 257cdf0e10cSrcweir return m_pWindow->GetAccessible(); 258cdf0e10cSrcweir } 259cdf0e10cSrcweir 260cdf0e10cSrcweir //----------------------------------------------------------------------------- 261cdf0e10cSrcweir ::rtl::OUString ColoredPanel::GetDisplayName() const 262cdf0e10cSrcweir { 263cdf0e10cSrcweir return m_aPanelName; 264cdf0e10cSrcweir } 265cdf0e10cSrcweir 266cdf0e10cSrcweir //----------------------------------------------------------------------------- 267cdf0e10cSrcweir Image ColoredPanel::GetImage() const 268cdf0e10cSrcweir { 269cdf0e10cSrcweir return Image( m_aPanelIcon ); 270cdf0e10cSrcweir } 271cdf0e10cSrcweir 272cdf0e10cSrcweir //----------------------------------------------------------------------------- 273cdf0e10cSrcweir rtl::OString ColoredPanel::GetHelpID() const 274cdf0e10cSrcweir { 275cdf0e10cSrcweir return rtl::OString(); 276cdf0e10cSrcweir } 277cdf0e10cSrcweir 278cdf0e10cSrcweir //============================================================================= 279cdf0e10cSrcweir //= OptionsWindow 280cdf0e10cSrcweir //============================================================================= 281cdf0e10cSrcweir class PanelDemoMainWindow; 282cdf0e10cSrcweir class OptionsWindow :public Window 283cdf0e10cSrcweir ,public ::svt::IToolPanelDeckListener 284cdf0e10cSrcweir { 285cdf0e10cSrcweir public: 286cdf0e10cSrcweir OptionsWindow( PanelDemoMainWindow& i_rParent ); 287cdf0e10cSrcweir ~OptionsWindow(); 288cdf0e10cSrcweir 289cdf0e10cSrcweir // Window overridables 290cdf0e10cSrcweir virtual void Resize(); 291cdf0e10cSrcweir virtual void GetFocus(); 292cdf0e10cSrcweir virtual void StateChanged( StateChangedType i_nStateChange ); 293cdf0e10cSrcweir 294cdf0e10cSrcweir // IToolPanelDeckListener 295cdf0e10cSrcweir virtual void PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ); 296cdf0e10cSrcweir virtual void PanelRemoved( const size_t i_nPosition ); 297cdf0e10cSrcweir virtual void ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ); 298cdf0e10cSrcweir virtual void LayouterChanged( const PDeckLayouter& i_rNewLayouter ); 299cdf0e10cSrcweir virtual void Dying(); 300cdf0e10cSrcweir 301cdf0e10cSrcweir private: 302cdf0e10cSrcweir DECL_LINK( OnRadioToggled, RadioButton* ); 303cdf0e10cSrcweir DECL_LINK( OnListEntrySelected, ListBox* ); 304cdf0e10cSrcweir DECL_LINK( OnListEntryDoubleClicked, ListBox* ); 305cdf0e10cSrcweir DECL_LINK( OnButtonClicked, PushButton* ); 306cdf0e10cSrcweir DECL_LINK( OnEditModified, Edit* ); 307cdf0e10cSrcweir 308cdf0e10cSrcweir void impl_initPanelList(); 309cdf0e10cSrcweir void impl_updateRemoveButton(); 310cdf0e10cSrcweir void impl_updateInsertButton(); 311cdf0e10cSrcweir 312cdf0e10cSrcweir private: 313cdf0e10cSrcweir FixedLine m_aAlignmentHeader; 314cdf0e10cSrcweir RadioButton m_aAlignLeft; 315cdf0e10cSrcweir RadioButton m_aAlignRight; 316cdf0e10cSrcweir RadioButton m_aAlignTop; 317cdf0e10cSrcweir RadioButton m_aAlignBottom; 318cdf0e10cSrcweir FixedLine m_aTabItemContent; 319cdf0e10cSrcweir RadioButton m_aImagesAndText; 320cdf0e10cSrcweir RadioButton m_aImagesOnly; 321cdf0e10cSrcweir RadioButton m_aTextOnly; 322cdf0e10cSrcweir RadioButton m_aAutomaticContent; 323cdf0e10cSrcweir 324cdf0e10cSrcweir FixedLine m_aPanelsHeader; 325cdf0e10cSrcweir ListBox m_aPanelList; 326cdf0e10cSrcweir PushButton m_aRemovePanel; 327cdf0e10cSrcweir ColorListBox m_aColors; 328cdf0e10cSrcweir Edit m_aNewPanelName; 329cdf0e10cSrcweir PushButton m_aInsertPanel; 330cdf0e10cSrcweir }; 331cdf0e10cSrcweir 332cdf0e10cSrcweir //============================================================================= 333cdf0e10cSrcweir //= PanelDemoMainWindow 334cdf0e10cSrcweir //============================================================================= 335cdf0e10cSrcweir class PanelDemoMainWindow : public WorkWindow 336cdf0e10cSrcweir { 337cdf0e10cSrcweir public: 338cdf0e10cSrcweir PanelDemoMainWindow(); 339cdf0e10cSrcweir ~PanelDemoMainWindow(); 340cdf0e10cSrcweir 341cdf0e10cSrcweir // window overridables 342cdf0e10cSrcweir virtual void Resize(); 343cdf0e10cSrcweir 344cdf0e10cSrcweir public: 345cdf0e10cSrcweir // operations 346cdf0e10cSrcweir void AlignTabs( const ::svt::TabAlignment i_eAlignment ); 347cdf0e10cSrcweir void SetTabItemContent( const TabItemContent i_eItemContent ); 348cdf0e10cSrcweir 349cdf0e10cSrcweir // member access 350cdf0e10cSrcweir IToolPanelDeck& GetToolPanelDeck(); 351cdf0e10cSrcweir PToolPanel CreateToolPanel( const Color& i_rColor, const String& i_rPanelName ); 352cdf0e10cSrcweir 353cdf0e10cSrcweir protected: 354cdf0e10cSrcweir virtual void GetFocus(); 355cdf0e10cSrcweir 356cdf0e10cSrcweir private: 357cdf0e10cSrcweir ToolPanelDeck m_aToolPanelDeck; 358cdf0e10cSrcweir OptionsWindow m_aDemoOptions; 359cdf0e10cSrcweir }; 360cdf0e10cSrcweir 361cdf0e10cSrcweir //============================================================================= 362cdf0e10cSrcweir //= PanelDemoMainWindow - implementation 363cdf0e10cSrcweir //============================================================================= 364cdf0e10cSrcweir //----------------------------------------------------------------------------- 365cdf0e10cSrcweir OptionsWindow::OptionsWindow( PanelDemoMainWindow& i_rParent ) 366cdf0e10cSrcweir :Window( &i_rParent, WB_BORDER | WB_DIALOGCONTROL ) 367cdf0e10cSrcweir ,m_aAlignmentHeader( this ) 368cdf0e10cSrcweir ,m_aAlignLeft( this, WB_GROUP ) 369cdf0e10cSrcweir ,m_aAlignRight( this, 0 ) 370cdf0e10cSrcweir ,m_aAlignTop( this, 0 ) 371cdf0e10cSrcweir ,m_aAlignBottom( this, 0 ) 372cdf0e10cSrcweir ,m_aTabItemContent( this ) 373cdf0e10cSrcweir ,m_aImagesAndText( this ) 374cdf0e10cSrcweir ,m_aImagesOnly( this ) 375cdf0e10cSrcweir ,m_aTextOnly( this ) 376cdf0e10cSrcweir ,m_aAutomaticContent( this ) 377cdf0e10cSrcweir ,m_aPanelsHeader( this ) 378cdf0e10cSrcweir ,m_aPanelList( this ) 379cdf0e10cSrcweir ,m_aRemovePanel( this ) 380cdf0e10cSrcweir ,m_aColors( this, WB_DROPDOWN ) 381cdf0e10cSrcweir ,m_aNewPanelName( this, WB_BORDER ) 382cdf0e10cSrcweir ,m_aInsertPanel( this ) 383cdf0e10cSrcweir { 384cdf0e10cSrcweir SetBorderStyle( WINDOW_BORDER_MONO ); 385cdf0e10cSrcweir 386cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_BLACK ), String( RTL_CONSTASCII_USTRINGPARAM( "Black" ) ) ); 387cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_BLUE ), String( RTL_CONSTASCII_USTRINGPARAM( "Blue" ) ) ); 388cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_GREEN ), String( RTL_CONSTASCII_USTRINGPARAM( "Green" ) ) ); 389cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_CYAN ), String( RTL_CONSTASCII_USTRINGPARAM( "Cyan" ) ) ); 390cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_RED ), String( RTL_CONSTASCII_USTRINGPARAM( "Red" ) ) ); 391cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_MAGENTA ), String( RTL_CONSTASCII_USTRINGPARAM( "Magenta" ) ) ); 392cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_BROWN ), String( RTL_CONSTASCII_USTRINGPARAM( "Brown" ) ) ); 393cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_GRAY ), String( RTL_CONSTASCII_USTRINGPARAM( "Gray" ) ) ); 394cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTGRAY ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Gray" ) ) ); 395cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTBLUE ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Blue" ) ) ); 396cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTGREEN ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Green" ) ) ); 397cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTCYAN ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Cyan" ) ) ); 398cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTRED ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Red" ) ) ); 399cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_LIGHTMAGENTA ), String( RTL_CONSTASCII_USTRINGPARAM( "Light Magenta" ) ) ); 400cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_YELLOW ), String( RTL_CONSTASCII_USTRINGPARAM( "Yellow" ) ) ); 401cdf0e10cSrcweir m_aColors.InsertEntry( Color( COL_WHITE ), String( RTL_CONSTASCII_USTRINGPARAM( "White" ) ) ); 402cdf0e10cSrcweir m_aColors.SetDropDownLineCount( 16 ); 403cdf0e10cSrcweir 404cdf0e10cSrcweir Window* pControls[] = 405cdf0e10cSrcweir { 406cdf0e10cSrcweir &m_aAlignmentHeader, &m_aAlignLeft, &m_aAlignRight, &m_aAlignTop, &m_aAlignBottom, &m_aTabItemContent, 407cdf0e10cSrcweir &m_aImagesAndText, &m_aImagesOnly, &m_aTextOnly, &m_aAutomaticContent, &m_aPanelsHeader, &m_aPanelList, 408cdf0e10cSrcweir &m_aRemovePanel, &m_aColors, &m_aNewPanelName, &m_aInsertPanel 409cdf0e10cSrcweir }; 410cdf0e10cSrcweir const sal_Char* pTexts[] = 411cdf0e10cSrcweir { 412cdf0e10cSrcweir "Tab Bar Alignment", "Left", "Right", "Top", "Bottom", "Tab Items", "Images and Text", "Images only", 413cdf0e10cSrcweir "Text only", "Automatic", "Panels", "", "Remove Panel", "", "", "Insert Panel" 414cdf0e10cSrcweir }; 415cdf0e10cSrcweir for ( size_t i=0; i < sizeof( pControls ) / sizeof( pControls[0] ); ++i ) 416cdf0e10cSrcweir { 417cdf0e10cSrcweir const WindowType eWindowType = pControls[i]->GetType(); 418cdf0e10cSrcweir 419cdf0e10cSrcweir pControls[i]->SetText( String::CreateFromAscii( pTexts[i] ) ); 420cdf0e10cSrcweir pControls[i]->Show(); 421cdf0e10cSrcweir 422cdf0e10cSrcweir if ( eWindowType == WINDOW_RADIOBUTTON ) 423cdf0e10cSrcweir static_cast< RadioButton* >( pControls[i] )->SetToggleHdl( LINK( this, OptionsWindow, OnRadioToggled ) ); 424cdf0e10cSrcweir 425cdf0e10cSrcweir if ( eWindowType == WINDOW_LISTBOX ) 426cdf0e10cSrcweir { 427cdf0e10cSrcweir static_cast< ListBox* >( pControls[i] )->SetSelectHdl( LINK( this, OptionsWindow, OnListEntrySelected ) ); 428cdf0e10cSrcweir static_cast< ListBox* >( pControls[i] )->SetDoubleClickHdl( LINK( this, OptionsWindow, OnListEntryDoubleClicked ) ); 429cdf0e10cSrcweir } 430cdf0e10cSrcweir 431cdf0e10cSrcweir if ( eWindowType == WINDOW_PUSHBUTTON ) 432cdf0e10cSrcweir { 433cdf0e10cSrcweir static_cast< PushButton* >( pControls[i] )->SetClickHdl( LINK( this, OptionsWindow, OnButtonClicked ) ); 434cdf0e10cSrcweir } 435cdf0e10cSrcweir 436cdf0e10cSrcweir if ( eWindowType == WINDOW_EDIT ) 437cdf0e10cSrcweir { 438cdf0e10cSrcweir static_cast< Edit* >( pControls[i] )->SetModifyHdl( LINK( this, OptionsWindow, OnEditModified ) ); 439cdf0e10cSrcweir } 440cdf0e10cSrcweir } 441cdf0e10cSrcweir 442cdf0e10cSrcweir m_aAlignRight.Check(); 443cdf0e10cSrcweir m_aImagesAndText.Check(); 444cdf0e10cSrcweir 445cdf0e10cSrcweir Show(); 446cdf0e10cSrcweir } 447cdf0e10cSrcweir 448cdf0e10cSrcweir //----------------------------------------------------------------------------- 449cdf0e10cSrcweir OptionsWindow::~OptionsWindow() 450cdf0e10cSrcweir { 451cdf0e10cSrcweir } 452cdf0e10cSrcweir 453cdf0e10cSrcweir //----------------------------------------------------------------------------- 454cdf0e10cSrcweir void OptionsWindow::impl_updateInsertButton() 455cdf0e10cSrcweir { 456cdf0e10cSrcweir m_aInsertPanel.Enable( ( m_aColors.GetSelectEntryPos() != LISTBOX_ENTRY_NOTFOUND ) && ( m_aNewPanelName.GetText().Len() > 0 ) ); 457cdf0e10cSrcweir } 458cdf0e10cSrcweir 459cdf0e10cSrcweir //----------------------------------------------------------------------------- 460cdf0e10cSrcweir void OptionsWindow::impl_updateRemoveButton() 461cdf0e10cSrcweir { 462cdf0e10cSrcweir m_aRemovePanel.Enable( m_aPanelList.GetSelectEntryCount() > 0 ); 463cdf0e10cSrcweir } 464cdf0e10cSrcweir 465cdf0e10cSrcweir //----------------------------------------------------------------------------- 466cdf0e10cSrcweir void OptionsWindow::impl_initPanelList() 467cdf0e10cSrcweir { 468cdf0e10cSrcweir m_aPanelList.Clear(); 469cdf0e10cSrcweir 470cdf0e10cSrcweir PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); 471cdf0e10cSrcweir IToolPanelDeck& rPanelDeck( rController.GetToolPanelDeck() ); 472cdf0e10cSrcweir 473cdf0e10cSrcweir for ( size_t i=0; i<rPanelDeck.GetPanelCount(); ++i ) 474cdf0e10cSrcweir { 475cdf0e10cSrcweir PToolPanel pPanel = rPanelDeck.GetPanel( i ); 476cdf0e10cSrcweir m_aPanelList.InsertEntry( pPanel->GetDisplayName(), pPanel->GetImage() ); 477cdf0e10cSrcweir } 478cdf0e10cSrcweir ActivePanelChanged( ::boost::optional< size_t >(), rPanelDeck.GetActivePanel() ); 479cdf0e10cSrcweir 480cdf0e10cSrcweir impl_updateRemoveButton(); 481cdf0e10cSrcweir impl_updateInsertButton(); 482cdf0e10cSrcweir 483cdf0e10cSrcweir rPanelDeck.AddListener( *this ); 484cdf0e10cSrcweir } 485cdf0e10cSrcweir 486cdf0e10cSrcweir //----------------------------------------------------------------------------- 487cdf0e10cSrcweir void OptionsWindow::StateChanged( StateChangedType i_nStateChange ) 488cdf0e10cSrcweir { 489cdf0e10cSrcweir Window::StateChanged( i_nStateChange ); 490cdf0e10cSrcweir 491cdf0e10cSrcweir if ( i_nStateChange == STATE_CHANGE_INITSHOW ) 492cdf0e10cSrcweir { 493cdf0e10cSrcweir impl_initPanelList(); 494cdf0e10cSrcweir } 495cdf0e10cSrcweir } 496cdf0e10cSrcweir 497cdf0e10cSrcweir //----------------------------------------------------------------------------- 498cdf0e10cSrcweir void OptionsWindow::GetFocus() 499cdf0e10cSrcweir { 500cdf0e10cSrcweir Window::GetFocus(); 501cdf0e10cSrcweir RadioButton* pRadios[] = 502cdf0e10cSrcweir { 503cdf0e10cSrcweir &m_aAlignLeft, &m_aAlignRight, &m_aAlignTop, &m_aAlignBottom 504cdf0e10cSrcweir }; 505cdf0e10cSrcweir for ( size_t i=0; i < sizeof( pRadios ) / sizeof( pRadios[0] ); ++i ) 506cdf0e10cSrcweir { 507cdf0e10cSrcweir if ( pRadios[i]->IsChecked() ) 508cdf0e10cSrcweir { 509cdf0e10cSrcweir pRadios[i]->GrabFocus(); 510cdf0e10cSrcweir break; 511cdf0e10cSrcweir } 512cdf0e10cSrcweir } 513cdf0e10cSrcweir } 514cdf0e10cSrcweir 515cdf0e10cSrcweir //----------------------------------------------------------------------------- 516cdf0e10cSrcweir void OptionsWindow::Resize() 517cdf0e10cSrcweir { 518cdf0e10cSrcweir Window::Resize(); 519cdf0e10cSrcweir 520cdf0e10cSrcweir const Size aOutputSize( GetOutputSizePixel() ); 521cdf0e10cSrcweir 522cdf0e10cSrcweir const Size aSpacing( LogicToPixel( Size( 3, 3 ), MAP_APPFONT ) ); 523cdf0e10cSrcweir const long nIndent( LogicToPixel( Size( 6, 9 ), MAP_APPFONT ).Width() ); 524cdf0e10cSrcweir const long nFixedLineHeight( LogicToPixel( Size( 0, 8 ), MAP_APPFONT ).Height() ); 525cdf0e10cSrcweir const long nEditLineHeight( LogicToPixel( Size( 0, 12 ), MAP_APPFONT ).Height() ); 526cdf0e10cSrcweir const long nButtonLineHeight( LogicToPixel( Size( 0, 14 ), MAP_APPFONT ).Height() ); 527cdf0e10cSrcweir 528cdf0e10cSrcweir const long nSuperordinateWidth = aOutputSize.Width() - 2 * aSpacing.Width(); 529cdf0e10cSrcweir const long nSuperordinateX = aSpacing.Width(); 530cdf0e10cSrcweir 531cdf0e10cSrcweir const long nSubordinateWidth = aOutputSize.Width() - 2 * aSpacing.Width() - nIndent; 532cdf0e10cSrcweir const long nSubordinateX = aSpacing.Width() + nIndent; 533cdf0e10cSrcweir 534cdf0e10cSrcweir Point aItemPos( nSuperordinateX, aSpacing.Height() ); 535cdf0e10cSrcweir 536cdf0e10cSrcweir struct ControlRow 537cdf0e10cSrcweir { 538cdf0e10cSrcweir Window* pWindow; 539cdf0e10cSrcweir bool bSubordinate; 540cdf0e10cSrcweir size_t nRows; 541cdf0e10cSrcweir 542cdf0e10cSrcweir ControlRow( Window& i_rWindow, const bool i_bSubordinate, const size_t i_nRows = 1 ) 543cdf0e10cSrcweir :pWindow( &i_rWindow ) 544cdf0e10cSrcweir ,bSubordinate( i_bSubordinate ) 545cdf0e10cSrcweir ,nRows( i_nRows ) 546cdf0e10cSrcweir { 547cdf0e10cSrcweir } 548cdf0e10cSrcweir }; 549cdf0e10cSrcweir ControlRow aControlRows[] = 550cdf0e10cSrcweir { 551cdf0e10cSrcweir ControlRow( m_aAlignmentHeader, false ), 552cdf0e10cSrcweir ControlRow( m_aAlignLeft, true ), 553cdf0e10cSrcweir ControlRow( m_aAlignRight, true ), 554cdf0e10cSrcweir ControlRow( m_aAlignTop, true ), 555cdf0e10cSrcweir ControlRow( m_aAlignBottom, true ), 556cdf0e10cSrcweir ControlRow( m_aTabItemContent, false ), 557cdf0e10cSrcweir ControlRow( m_aImagesAndText, true ), 558cdf0e10cSrcweir ControlRow( m_aImagesOnly, true ), 559cdf0e10cSrcweir ControlRow( m_aTextOnly, true ), 560cdf0e10cSrcweir ControlRow( m_aAutomaticContent, true ), 561cdf0e10cSrcweir ControlRow( m_aPanelsHeader, false ), 562cdf0e10cSrcweir ControlRow( m_aPanelList, true, 6 ), 563cdf0e10cSrcweir ControlRow( m_aRemovePanel, true ), 564cdf0e10cSrcweir ControlRow( m_aColors, true ), 565cdf0e10cSrcweir ControlRow( m_aNewPanelName, true ), 566cdf0e10cSrcweir ControlRow( m_aInsertPanel, true ) 567cdf0e10cSrcweir }; 568cdf0e10cSrcweir bool bPreviousWasSubordinate = false; 569cdf0e10cSrcweir for ( size_t i=0; i < sizeof( aControlRows ) / sizeof( aControlRows[0] ); ++i ) 570cdf0e10cSrcweir { 571cdf0e10cSrcweir aItemPos.X() = ( aControlRows[i].bSubordinate ) ? nSubordinateX : nSuperordinateX; 572cdf0e10cSrcweir 573cdf0e10cSrcweir if ( bPreviousWasSubordinate && !aControlRows[i].bSubordinate ) 574cdf0e10cSrcweir aItemPos.Y() += aSpacing.Height(); 575cdf0e10cSrcweir bPreviousWasSubordinate = aControlRows[i].bSubordinate; 576cdf0e10cSrcweir 577cdf0e10cSrcweir // height depends on the window type 578cdf0e10cSrcweir const WindowType eWindowType = aControlRows[i].pWindow->GetType(); 579cdf0e10cSrcweir long nControlHeight( nFixedLineHeight ); 580cdf0e10cSrcweir if ( ( eWindowType == WINDOW_EDIT ) 581cdf0e10cSrcweir || ( eWindowType == WINDOW_LISTBOX ) 582cdf0e10cSrcweir ) 583cdf0e10cSrcweir { 584cdf0e10cSrcweir nControlHeight = nEditLineHeight; 585cdf0e10cSrcweir } 586cdf0e10cSrcweir else 587cdf0e10cSrcweir if ( ( eWindowType == WINDOW_PUSHBUTTON ) 588cdf0e10cSrcweir ) 589cdf0e10cSrcweir { 590cdf0e10cSrcweir nControlHeight = nButtonLineHeight; 591cdf0e10cSrcweir } 592cdf0e10cSrcweir 593cdf0e10cSrcweir Size aControlSize( 594cdf0e10cSrcweir aControlRows[i].bSubordinate ? nSubordinateWidth : nSuperordinateWidth, 595cdf0e10cSrcweir nControlHeight * aControlRows[i].nRows 596cdf0e10cSrcweir ); 597cdf0e10cSrcweir aControlRows[i].pWindow->SetPosSizePixel( aItemPos, aControlSize ); 598cdf0e10cSrcweir 599cdf0e10cSrcweir aItemPos.Move( 0, aControlSize.Height() + aSpacing.Height() ); 600cdf0e10cSrcweir } 601cdf0e10cSrcweir } 602cdf0e10cSrcweir 603cdf0e10cSrcweir //----------------------------------------------------------------------------- 604cdf0e10cSrcweir void OptionsWindow::PanelInserted( const PToolPanel& i_pPanel, const size_t i_nPosition ) 605cdf0e10cSrcweir { 606cdf0e10cSrcweir m_aPanelList.InsertEntry( i_pPanel->GetDisplayName(), i_pPanel->GetImage(), sal_uInt16( i_nPosition ) ); 607cdf0e10cSrcweir } 608cdf0e10cSrcweir 609cdf0e10cSrcweir //----------------------------------------------------------------------------- 610cdf0e10cSrcweir void OptionsWindow::PanelRemoved( const size_t i_nPosition ) 611cdf0e10cSrcweir { 612cdf0e10cSrcweir m_aPanelList.RemoveEntry( sal_uInt16( i_nPosition ) ); 613cdf0e10cSrcweir impl_updateRemoveButton(); 614cdf0e10cSrcweir } 615cdf0e10cSrcweir 616cdf0e10cSrcweir //----------------------------------------------------------------------------- 617cdf0e10cSrcweir void OptionsWindow::ActivePanelChanged( const ::boost::optional< size_t >& i_rOldActive, const ::boost::optional< size_t >& i_rNewActive ) 618cdf0e10cSrcweir { 619cdf0e10cSrcweir (void)i_rOldActive; 620cdf0e10cSrcweir 621cdf0e10cSrcweir if ( !i_rNewActive ) 622cdf0e10cSrcweir m_aPanelList.SetNoSelection(); 623cdf0e10cSrcweir else 624cdf0e10cSrcweir m_aPanelList.SelectEntryPos( sal_uInt16( *i_rNewActive ) ); 625cdf0e10cSrcweir } 626cdf0e10cSrcweir 627cdf0e10cSrcweir //----------------------------------------------------------------------------- 628cdf0e10cSrcweir void OptionsWindow::LayouterChanged( const PDeckLayouter& i_rNewLayouter ) 629cdf0e10cSrcweir { 630cdf0e10cSrcweir (void)i_rNewLayouter; 631cdf0e10cSrcweir // not interested in 632cdf0e10cSrcweir } 633cdf0e10cSrcweir 634cdf0e10cSrcweir //----------------------------------------------------------------------------- 635cdf0e10cSrcweir void OptionsWindow::Dying() 636cdf0e10cSrcweir { 637cdf0e10cSrcweir // not interested in 638cdf0e10cSrcweir } 639cdf0e10cSrcweir 640cdf0e10cSrcweir //----------------------------------------------------------------------------- 641cdf0e10cSrcweir IMPL_LINK( OptionsWindow, OnListEntrySelected, ListBox*, i_pListBox ) 642cdf0e10cSrcweir { 643cdf0e10cSrcweir if ( i_pListBox == &m_aColors ) 644cdf0e10cSrcweir { 645cdf0e10cSrcweir m_aNewPanelName.SetText( m_aColors.GetEntry( m_aColors.GetSelectEntryPos() ) ); 646cdf0e10cSrcweir impl_updateInsertButton(); 647cdf0e10cSrcweir } 648cdf0e10cSrcweir else if ( i_pListBox == &m_aPanelList ) 649cdf0e10cSrcweir { 650cdf0e10cSrcweir impl_updateRemoveButton(); 651cdf0e10cSrcweir } 652cdf0e10cSrcweir return 0L; 653cdf0e10cSrcweir } 654cdf0e10cSrcweir 655cdf0e10cSrcweir //----------------------------------------------------------------------------- 656cdf0e10cSrcweir IMPL_LINK( OptionsWindow, OnListEntryDoubleClicked, ListBox*, i_pListBox ) 657cdf0e10cSrcweir { 658cdf0e10cSrcweir PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); 659cdf0e10cSrcweir 660cdf0e10cSrcweir if ( i_pListBox == &m_aPanelList ) 661cdf0e10cSrcweir { 662cdf0e10cSrcweir size_t nActivatePanel = size_t( m_aPanelList.GetSelectEntryPos() ); 663cdf0e10cSrcweir rController.GetToolPanelDeck().ActivatePanel( nActivatePanel ); 664cdf0e10cSrcweir } 665cdf0e10cSrcweir 666cdf0e10cSrcweir return 0L; 667cdf0e10cSrcweir } 668cdf0e10cSrcweir 669cdf0e10cSrcweir //----------------------------------------------------------------------------- 670cdf0e10cSrcweir IMPL_LINK( OptionsWindow, OnEditModified, Edit*, i_pEdit ) 671cdf0e10cSrcweir { 672cdf0e10cSrcweir if ( i_pEdit && &m_aNewPanelName ) 673cdf0e10cSrcweir { 674cdf0e10cSrcweir impl_updateInsertButton(); 675cdf0e10cSrcweir } 676cdf0e10cSrcweir 677cdf0e10cSrcweir return 0L; 678cdf0e10cSrcweir } 679cdf0e10cSrcweir 680cdf0e10cSrcweir //----------------------------------------------------------------------------- 681cdf0e10cSrcweir IMPL_LINK( OptionsWindow, OnButtonClicked, PushButton*, i_pPushButton ) 682cdf0e10cSrcweir { 683cdf0e10cSrcweir PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); 684cdf0e10cSrcweir 685cdf0e10cSrcweir if ( i_pPushButton == &m_aRemovePanel ) 686cdf0e10cSrcweir { 687cdf0e10cSrcweir rController.GetToolPanelDeck().RemovePanel( size_t( m_aPanelList.GetSelectEntryPos() ) ); 688cdf0e10cSrcweir } 689cdf0e10cSrcweir else if ( i_pPushButton == &m_aInsertPanel ) 690cdf0e10cSrcweir { 691cdf0e10cSrcweir PToolPanel pNewPanel( rController.CreateToolPanel( m_aColors.GetEntryColor( m_aColors.GetSelectEntryPos() ), m_aNewPanelName.GetText() ) ); 692cdf0e10cSrcweir 693cdf0e10cSrcweir ::boost::optional< size_t > aActivePanel( rController.GetToolPanelDeck().GetActivePanel() ); 694cdf0e10cSrcweir size_t nNewPanelPos = !aActivePanel ? rController.GetToolPanelDeck().GetPanelCount() : *aActivePanel + 1; 695cdf0e10cSrcweir 696cdf0e10cSrcweir rController.GetToolPanelDeck().InsertPanel( pNewPanel, nNewPanelPos ); 697cdf0e10cSrcweir } 698cdf0e10cSrcweir return 0L; 699cdf0e10cSrcweir } 700cdf0e10cSrcweir 701cdf0e10cSrcweir //----------------------------------------------------------------------------- 702cdf0e10cSrcweir IMPL_LINK( OptionsWindow, OnRadioToggled, RadioButton*, i_pRadioButton ) 703cdf0e10cSrcweir { 704cdf0e10cSrcweir PanelDemoMainWindow& rController( dynamic_cast< PanelDemoMainWindow& >( *GetParent() ) ); 705cdf0e10cSrcweir 706cdf0e10cSrcweir if ( i_pRadioButton->IsChecked() ) 707cdf0e10cSrcweir { 708cdf0e10cSrcweir if ( i_pRadioButton == &m_aAlignLeft ) 709cdf0e10cSrcweir { 710cdf0e10cSrcweir rController.AlignTabs( TABS_LEFT ); 711cdf0e10cSrcweir } 712cdf0e10cSrcweir else if ( i_pRadioButton == &m_aAlignRight ) 713cdf0e10cSrcweir { 714cdf0e10cSrcweir rController.AlignTabs( TABS_RIGHT ); 715cdf0e10cSrcweir } 716cdf0e10cSrcweir else if ( i_pRadioButton == &m_aAlignTop ) 717cdf0e10cSrcweir { 718cdf0e10cSrcweir rController.AlignTabs( TABS_TOP ); 719cdf0e10cSrcweir } 720cdf0e10cSrcweir else if ( i_pRadioButton == &m_aAlignBottom ) 721cdf0e10cSrcweir { 722cdf0e10cSrcweir rController.AlignTabs( TABS_BOTTOM ); 723cdf0e10cSrcweir } 724cdf0e10cSrcweir else if ( i_pRadioButton == &m_aImagesAndText ) 725cdf0e10cSrcweir { 726cdf0e10cSrcweir rController.SetTabItemContent( TABITEM_IMAGE_AND_TEXT ); 727cdf0e10cSrcweir } 728cdf0e10cSrcweir else if ( i_pRadioButton == &m_aImagesOnly ) 729cdf0e10cSrcweir { 730cdf0e10cSrcweir rController.SetTabItemContent( TABITEM_IMAGE_ONLY ); 731cdf0e10cSrcweir } 732cdf0e10cSrcweir else if ( i_pRadioButton == &m_aTextOnly ) 733cdf0e10cSrcweir { 734cdf0e10cSrcweir rController.SetTabItemContent( TABITEM_TEXT_ONLY ); 735cdf0e10cSrcweir } 736cdf0e10cSrcweir else if ( i_pRadioButton == &m_aAutomaticContent ) 737cdf0e10cSrcweir { 738cdf0e10cSrcweir rController.SetTabItemContent( TABITEM_AUTO ); 739cdf0e10cSrcweir } 740cdf0e10cSrcweir } 741cdf0e10cSrcweir return 0L; 742cdf0e10cSrcweir } 743cdf0e10cSrcweir //============================================================================= 744cdf0e10cSrcweir //= PanelDemoMainWindow - implementation 745cdf0e10cSrcweir //============================================================================= 746cdf0e10cSrcweir //----------------------------------------------------------------------------- 747cdf0e10cSrcweir PanelDemoMainWindow::PanelDemoMainWindow() 748cdf0e10cSrcweir :WorkWindow( NULL, WB_APP | WB_STDWORK | WB_CLIPCHILDREN ) 749cdf0e10cSrcweir ,m_aToolPanelDeck( *this, WB_BORDER ) 750cdf0e10cSrcweir ,m_aDemoOptions( *this ) 751cdf0e10cSrcweir { 752cdf0e10cSrcweir m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), Size( 500, 300 ) ); 753cdf0e10cSrcweir m_aToolPanelDeck.SetBorderStyle( WINDOW_BORDER_MONO ); 754cdf0e10cSrcweir 755cdf0e10cSrcweir m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), Color( COL_RED ), "Red" ) ), m_aToolPanelDeck.GetPanelCount() ); 756cdf0e10cSrcweir m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), Color( COL_GREEN ), "Some flavor of Green" ) ), m_aToolPanelDeck.GetPanelCount() ); 757cdf0e10cSrcweir m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), RGB_COLORDATA( 255, 255, 0 ), "Yellow is ugly" ) ), m_aToolPanelDeck.GetPanelCount() ); 758cdf0e10cSrcweir m_aToolPanelDeck.InsertPanel( PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), RGB_COLORDATA( 0, 0, 128 ), "Blue is the Color" ) ), m_aToolPanelDeck.GetPanelCount() ); 759cdf0e10cSrcweir 760cdf0e10cSrcweir m_aToolPanelDeck.ActivatePanel( size_t( 0 ) ); 761cdf0e10cSrcweir m_aToolPanelDeck.Show(); 762cdf0e10cSrcweir 763cdf0e10cSrcweir SetText( String::CreateFromAscii( "ToolPanelDeck Demo Application" ) ); 764cdf0e10cSrcweir Show(); 765cdf0e10cSrcweir 766cdf0e10cSrcweir Help::EnableQuickHelp(); 767cdf0e10cSrcweir 768cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->AddWindow( &m_aToolPanelDeck ); 769cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->AddWindow( &m_aDemoOptions ); 770cdf0e10cSrcweir } 771cdf0e10cSrcweir 772cdf0e10cSrcweir //----------------------------------------------------------------------------- 773cdf0e10cSrcweir PanelDemoMainWindow::~PanelDemoMainWindow() 774cdf0e10cSrcweir { 775cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->RemoveWindow( &m_aDemoOptions ); 776cdf0e10cSrcweir GetSystemWindow()->GetTaskPaneList()->RemoveWindow( &m_aToolPanelDeck ); 777cdf0e10cSrcweir } 778cdf0e10cSrcweir 779cdf0e10cSrcweir //----------------------------------------------------------------------------- 780cdf0e10cSrcweir void PanelDemoMainWindow::GetFocus() 781cdf0e10cSrcweir { 782cdf0e10cSrcweir WorkWindow::GetFocus(); 783cdf0e10cSrcweir m_aToolPanelDeck.GrabFocus(); 784cdf0e10cSrcweir } 785cdf0e10cSrcweir 786cdf0e10cSrcweir //----------------------------------------------------------------------------- 787cdf0e10cSrcweir void PanelDemoMainWindow::Resize() 788cdf0e10cSrcweir { 789cdf0e10cSrcweir WorkWindow::Resize(); 790cdf0e10cSrcweir Size aSize( GetOutputSizePixel() ); 791cdf0e10cSrcweir aSize.Width() -= 240; 792cdf0e10cSrcweir aSize.Height() -= 40; 793cdf0e10cSrcweir m_aToolPanelDeck.SetPosSizePixel( Point( 20, 20 ), aSize ); 794cdf0e10cSrcweir 795cdf0e10cSrcweir m_aDemoOptions.SetPosSizePixel( 796cdf0e10cSrcweir Point( 20 + aSize.Width(), 20 ), 797cdf0e10cSrcweir Size( 200, aSize.Height() ) 798cdf0e10cSrcweir ); 799cdf0e10cSrcweir } 800cdf0e10cSrcweir 801cdf0e10cSrcweir //----------------------------------------------------------------------------- 802cdf0e10cSrcweir void PanelDemoMainWindow::AlignTabs( const ::svt::TabAlignment i_eAlignment ) 803cdf0e10cSrcweir { 804cdf0e10cSrcweir TabItemContent eCurrentItemContent( TABITEM_IMAGE_AND_TEXT ); 805cdf0e10cSrcweir TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() ); 806cdf0e10cSrcweir OSL_ENSURE( pLayouter, "PanelDemoMainWindow::AlignTabs: wrong layouter!" ); 807cdf0e10cSrcweir if ( pLayouter ) 808cdf0e10cSrcweir eCurrentItemContent = pLayouter->GetTabItemContent(); 809cdf0e10cSrcweir 810cdf0e10cSrcweir m_aToolPanelDeck.SetLayouter( PDeckLayouter( new TabDeckLayouter( m_aToolPanelDeck, m_aToolPanelDeck, i_eAlignment, eCurrentItemContent ) ) ); 811cdf0e10cSrcweir } 812cdf0e10cSrcweir 813cdf0e10cSrcweir //----------------------------------------------------------------------------- 814cdf0e10cSrcweir void PanelDemoMainWindow::SetTabItemContent( const TabItemContent i_eItemContent ) 815cdf0e10cSrcweir { 816cdf0e10cSrcweir TabDeckLayouter* pLayouter = dynamic_cast< TabDeckLayouter* >( m_aToolPanelDeck.GetLayouter().get() ); 817cdf0e10cSrcweir OSL_ENSURE( pLayouter, "PanelDemoMainWindow::SetTabItemContent: wrong layouter!" ); 818cdf0e10cSrcweir // we currently use tab layouters only ... 819cdf0e10cSrcweir if ( !pLayouter ) 820cdf0e10cSrcweir return; 821cdf0e10cSrcweir 822cdf0e10cSrcweir pLayouter->SetTabItemContent( i_eItemContent ); 823cdf0e10cSrcweir } 824cdf0e10cSrcweir 825cdf0e10cSrcweir //----------------------------------------------------------------------------- 826cdf0e10cSrcweir IToolPanelDeck& PanelDemoMainWindow::GetToolPanelDeck() 827cdf0e10cSrcweir { 828cdf0e10cSrcweir return m_aToolPanelDeck; 829cdf0e10cSrcweir } 830cdf0e10cSrcweir 831cdf0e10cSrcweir //----------------------------------------------------------------------------- 832cdf0e10cSrcweir PToolPanel PanelDemoMainWindow::CreateToolPanel( const Color& i_rColor, const String& i_rPanelName ) 833cdf0e10cSrcweir { 834cdf0e10cSrcweir return PToolPanel( new ColoredPanel( m_aToolPanelDeck.GetPanelWindowAnchor(), i_rColor, i_rPanelName ) ); 835cdf0e10cSrcweir } 836cdf0e10cSrcweir 837cdf0e10cSrcweir //============================================================================= 838cdf0e10cSrcweir //= PanelDemo 839cdf0e10cSrcweir //============================================================================= 840cdf0e10cSrcweir //----------------------------------------------------------------------------- 841cdf0e10cSrcweir Reference< XMultiServiceFactory > PanelDemo::createApplicationServiceManager() 842cdf0e10cSrcweir { 843cdf0e10cSrcweir Reference< XMultiServiceFactory > xMS; 844cdf0e10cSrcweir try 845cdf0e10cSrcweir { 846cdf0e10cSrcweir Reference< XComponentContext > xComponentContext = ::cppu::defaultBootstrap_InitialComponentContext(); 847cdf0e10cSrcweir if ( xComponentContext.is() ) 848cdf0e10cSrcweir xMS = xMS.query( xComponentContext->getServiceManager() ); 849cdf0e10cSrcweir } 850cdf0e10cSrcweir catch( const ::com::sun::star::uno::Exception& ) 851cdf0e10cSrcweir { 852cdf0e10cSrcweir DBG_UNHANDLED_EXCEPTION(); 853cdf0e10cSrcweir } 854cdf0e10cSrcweir 855cdf0e10cSrcweir return xMS; 856cdf0e10cSrcweir } 857cdf0e10cSrcweir 858cdf0e10cSrcweir //----------------------------------------------------------------------------- 859cdf0e10cSrcweir void __EXPORT PanelDemo::Main() 860cdf0e10cSrcweir { 861cdf0e10cSrcweir // create service factory 862cdf0e10cSrcweir Reference< XMultiServiceFactory > xSMgr = createApplicationServiceManager(); 863cdf0e10cSrcweir ::comphelper::setProcessServiceFactory( xSMgr ); 864cdf0e10cSrcweir 865cdf0e10cSrcweir // initialize the UCB 866cdf0e10cSrcweir Sequence< Any > aArgs(2); 867cdf0e10cSrcweir aArgs[0] <<= rtl::OUString::createFromAscii( "Local" ); 868cdf0e10cSrcweir aArgs[1] <<= rtl::OUString::createFromAscii( "Office" ); 869cdf0e10cSrcweir ::ucbhelper::ContentBroker::initialize( xSMgr, aArgs ); 870cdf0e10cSrcweir 871cdf0e10cSrcweir // run the application 872cdf0e10cSrcweir PanelDemoMainWindow aWindow; 873cdf0e10cSrcweir Execute(); 874cdf0e10cSrcweir } 875cdf0e10cSrcweir 876cdf0e10cSrcweir PanelDemo aTheApplication; 877cdf0e10cSrcweir 878cdf0e10cSrcweir } } // namespace ::svt::toolpanel 879