Files
libreoffice/toolkit/source/vclcompat/wbutton.cxx
Rüdiger Timm 0351de75e3 INTEGRATION: CWS layoutdialogs (1.2.6); FILE MERGED
2008/07/30 11:16:45 rt 1.2.6.4: Update license header.
2008/03/28 09:50:42 cl 1.2.6.3: merged tklayout into tk lib
2008/03/26 13:42:01 cl 1.2.6.2: fixing warnings
2008/03/20 11:56:29 jcn 1.2.6.1: Update from http://lilypond.org/~janneke/vc/toolkit.git/.git

2008-03-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/awt/vclxwindow.cxx: Fix compile warning.

2008-03-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* util/makefile.mk: Revert obsolete VERSION addition.

2008-03-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/controls/dialogcontrol.cxx,
	source/controls/unocontrol.cxx, source/helper/tkresmgr.cxx,
	util/defs/wntmsci11: Revert weird initial patch.

2008-03-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO: Doc update.

2008-03-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, source/awt/vclxbutton.cxx,
	source/vclcompat/wbutton.cxx, workben/layout/recover.xml: Implement
	MoreButton.  TODO: images.

2008-03-19  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/vclcompat/wbutton.cxx: Remove redraw cruft, rename
	redrawAlready to redraw.

2008-03-19  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, source/vclcompat/wbutton.cxx: Step
	towards cleaner redraw.

2008-03-19  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, source/awt/vclxbutton.cxx,
	source/awt/vclxbutton.hxx, source/layout/helper.cxx,
	source/vclcompat/wbutton.cxx, workben/layout/recover.cxx,
	workben/layout/recover.hxx: Extract AdvancedButton implementation
	from recover.cxx into new widget.

2008-03-19  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/recover.cxx, workben/layout/recover.hxx,
	workben/layout/recover.xml: Update recover dialog, make
	advanced/simple switching work.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/zoom.cxx: In test mode, enable everything.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/localize.sdf: Manually add new translatable strings
	and translations for de, nl.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/zoom.xml: Update zoom to have hbox of Zoom factor
	and View layout alongside each other.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/zoom.cxx, workben/layout/zoom.hxx,
	workben/layout/zoom.xml: Merge upstream's zoom.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/vclcompat/wbutton.cxx, source/vclcompat/wrapper.hxx:
	Nitpick, debugging aid.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout.hxx, source/vclcompat/wrapper.cxx: Implement
	FixedLine.IsEnabled().

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* util/makefile.mk: Build lib name fix.

2008-03-14  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, source/vclcompat/wcontainer.cxx,
	workben/layout/recover.cxx, workben/layout/recover.hxx,
	workben/layout/recover.xml: Complete VBox/HBox wrappers.  Not use
	them in recover, spacing still wrong.

2008-03-13  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, workben/layout/recover.cxx,
	workben/layout/recover.hxx, workben/layout/recover.xml: More
	recovery dialog mockuping.

2008-03-13  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/layout/box-base.cxx: Implement visibility of
	elements/containers better.

2008-03-13  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, source/layout/helper.cxx,
	source/layout/import.cxx, source/layout/proplist.cxx,
	source/vclcompat/wbutton.cxx, source/vclcompat/wfield.cxx,
	source/vclcompat/wrapper.cxx, source/vclcompat/wrapper.hxx:
	Implement FixedImage.  Needed for recovery dialog.

2008-02-28  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/layout/box-base.hxx, workben/layout/editor.cxx: Give
	ChildData virtual distructor.

2008-02-28  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, source/layout/helper.cxx,
	source/vclcompat/makefile.mk, source/vclcompat/wrapper.cxx,
	util/makefile.mk, workben/layout/makefile.mk,
	workben/layout/recover.cxx, workben/layout/recover.hxx,
	workben/layout/recover.xml, workben/layout/test.cxx: Stab at new
	recover dialog.

2008-02-28  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/editor.cxx: Do not clear fresh container.  Disable
	debug printing.

2008-02-27  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, workben/layout/localize.sdf: Fix localize.sdf for
	wordcount.

2008-02-27  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-pre.hxx, source/layout/dialogbuttonhbox.cxx: Fix
	ID for displaying dialogs.

2008-02-27  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, workben/layout/localize.sdf,
	workben/layout/wordcount.xml, workben/layout/zoom.xml: Add strings
	for all languages.

2008-02-27  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, source/awt/vclxsplitter.cxx,
	source/awt/vclxsplitter.hxx, source/awt/vclxtabcontrol.cxx,
	source/awt/vclxtabcontrol.hxx, source/layout/box-base.cxx,
	source/layout/box-base.hxx, source/layout/box.cxx,
	source/layout/box.hxx, source/layout/container.cxx,
	source/layout/dialogbuttonhbox.cxx,
	source/layout/dialogbuttonhbox.hxx, source/layout/factory.cxx,
	source/layout/flow.cxx, source/layout/helper.cxx,
	source/layout/import.hxx, source/layout/makefile.mk,
	source/layout/proplist.cxx, source/layout/root.cxx,
	source/layout/table.cxx, source/layout/table.hxx,
	source/layout/timer.cxx, source/vclcompat/wcontainer.cxx,
	source/vclcompat/wfield.cxx, source/vclcompat/wrapper.cxx: Clean-up
	code duplication from layout: new Box_Base class implements
	addChild, removeChild, getChildren, getChildProperties for Box,
	Table, VCLXSplitter, VCLXTabControl.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, source/layout/root.cxx: Document more fixmes.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, source/layout/proplist.cxx: Remove m237
	workaround.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/layout/helper.cxx: More comment cleanups.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/awt/vclxtabcontrol.cxx, source/layout/box.cxx,
	source/layout/container.cxx, source/vclcompat/wrapper.cxx:
	Commented-out code cleanups.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout-post.hxx, inc/layout/layout-pre.hxx,
	inc/layout/layout.hxx, inc/layout/layoutcore.hxx,
	source/awt/forward.hxx, source/awt/vclxbutton.cxx,
	source/awt/vclxbutton.hxx, source/awt/vclxdialog.cxx,
	source/awt/vclxdialog.hxx, source/awt/vclxfixedline.cxx,
	source/awt/vclxfixedline.hxx, source/awt/vclxscroller.cxx,
	source/awt/vclxscroller.hxx, source/awt/vclxsplitter.cxx,
	source/awt/vclxsplitter.hxx, source/awt/vclxtabcontrol.cxx,
	source/awt/vclxtabcontrol.hxx, source/layout/bin.cxx,
	source/layout/bin.hxx, source/layout/box.cxx,
	source/layout/box.hxx, source/layout/container.cxx,
	source/layout/container.hxx, source/layout/dialogbuttonhbox.cxx,
	source/layout/dialogbuttonhbox.hxx, source/layout/factory.cxx,
	source/layout/factory.hxx, source/layout/flow.cxx,
	source/layout/flow.hxx, source/layout/helper.cxx,
	source/layout/helper.hxx, source/layout/import.cxx,
	source/layout/import.hxx, source/layout/makefile.mk,
	source/layout/precompiled_xmlscript.hxx,
	source/layout/proplist.cxx, source/layout/proplist.hxx,
	source/layout/root.cxx, source/layout/root.hxx,
	source/layout/table.cxx, source/layout/table.hxx,
	source/layout/timer.cxx, source/layout/timer.hxx,
	source/layout/translate.cxx, source/layout/translate.hxx,
	source/vclcompat/makefile.mk, source/vclcompat/wbutton.cxx,
	source/vclcompat/wcontainer.cxx, source/vclcompat/wfield.cxx,
	source/vclcompat/wrapper.cxx, source/vclcompat/wrapper.hxx,
	workben/layout/editor.cxx, workben/layout/editor.hxx,
	workben/layout/makefile.mk, workben/layout/simple-paragraph.cxx,
	workben/layout/simple-paragraph.hxx, workben/layout/test.cxx,
	workben/layout/uno.hxx, workben/layout/zoom_def.hxx: Add licence
	headers.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* workben/layout/meekfile.mk: Junk meekfile.mk

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO: Update TODO.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/toolkit/awt/vclxwindows.hxx, source/awt/vclxwindow.cxx,
	source/awt/vclxwindows.cxx: Move VCLXScrollBar's getMinimumSize()
	from VCLXWindow's switch to method.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/toolkit/awt/vclxwindows.hxx, source/awt/vclxwindow.cxx,
	source/awt/vclxwindows.cxx: Move VCLXMessageBox's getMinimumSize()
	from VCLXWindow's switch to method.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, inc/toolkit/awt/vclxtopwindow.hxx,
	source/awt/vclxdialog.cxx, source/awt/vclxdialog.hxx,
	source/awt/vclxtopwindow.cxx: Remove code duplication from
	VCLXDialog.

2008-02-26  Jan Nieuwenhuizen <janneke@gnu.org>

	* source/awt/vclxdialog.cxx, source/vclcompat/wbutton.cxx,
	source/vclcompat/wcontainer.cxx, source/vclcompat/wrapper.hxx:
	Comment cleanup.

2008-02-21  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, source/layout/helper.hxx,
	workben/layout/editor.cxx, workben/layout/wordcountdialog.cxx: Fix
	remaining SUN warnings.

2008-02-21  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/layout/layout.hxx, source/awt/vclxfixedline.hxx,
	source/layout/byteseq.cxx, source/layout/helper.hxx,
	source/layout/import.cxx, source/layout/makefile.mk,
	source/layout/proplist.cxx, source/layout/translate.hxx,
	source/vclcompat/wbutton.cxx, source/vclcompat/wcontainer.cxx,
	source/vclcompat/wfield.cxx, source/vclcompat/wrapper.cxx,
	source/vclcompat/wrapper.hxx, workben/layout/editor.cxx: Fix some
	sunstudio12 warnings.

2008-02-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* doc/layout/TODO, source/awt/makefile.mk,
	source/awt/vclxbutton.cxx, source/awt/vclxbutton.hxx,
	source/awt/vclxproxy.cxx, source/awt/vclxproxy.hxx,
	source/layout/helper.cxx: Junk VCLXProxy.

2008-02-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* inc/toolkit/awt/vclxwindows.hxx,
	inc/toolkit/helper/listenermultiplexer.hxx,
	source/awt/vclxbutton.cxx, source/awt/vclxbutton.hxx,
	source/awt/vclxtabcontrol.cxx, source/awt/vclxtabcontrol.hxx,
	source/layout/helper.cxx: Hello world on AWTVCLXCancelButton() label
	and images.

2008-02-20  Jan Nieuwenhuizen <janneke@gnu.org>

	* .gitignore, source/awt/forward.hxx, source/awt/makefile.mk,
	source/awt/vclxdialog.cxx, source/awt/vclxdialog.hxx,
	source/awt/vclxfixedline.cxx, source/awt/vclxfixedline.hxx,
	source/awt/vclxscroller.cxx, source/awt/vclxscroller.hxx,
	source/awt/vclxsplitter.cxx, source/awt/vclxsplitter.hxx,
	source/awt/vclxtabcontrol.cxx, source/awt/vclxtabcontrol.hxx,
	source/layout/makefile.mk, workben/layout/localize-de.sdf,
	workben/layout/localize-nl.sdf: Cleanup of includes, namespace in
	headers in awt.
2008-07-30 13:05:34 +00:00

583 lines
16 KiB
C++

/*************************************************************************
*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* Copyright 2008 by Sun Microsystems, Inc.
*
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: wbutton.cxx,v $
*
* $Revision: 1.3 $
*
* This file is part of OpenOffice.org.
*
* OpenOffice.org is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* OpenOffice.org is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details
* (a copy is included in the LICENSE file that accompanied this code).
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with OpenOffice.org. If not, see
* <http://www.openoffice.org/license.html>
* for a copy of the LGPLv3 License.
*
************************************************************************/
#include "wrapper.hxx"
#include <com/sun/star/awt/PosSize.hpp>
#include <com/sun/star/awt/XActionListener.hpp>
#include <com/sun/star/awt/XButton.hpp>
#include <com/sun/star/awt/XCheckBox.hpp>
#include <com/sun/star/awt/XRadioButton.hpp>
#include <com/sun/star/graphic/XGraphic.hpp>
#include <cppuhelper/implbase1.hxx>
#include <toolkit/awt/vclxwindow.hxx>
#include <toolkit/helper/convert.hxx>
#include <vcl/button.hxx>
#include <vcl/event.hxx>
#include <vcl/msgbox.hxx>
#include <vcl/svapp.hxx>
#include <vcl/window.hxx>
#include <list>
#include "layout/layoutcore.hxx"
using namespace ::com::sun::star;
namespace layout
{
class ImageImpl
{
public:
css::uno::Reference< css::graphic::XGraphic > mxGraphic;
ImageImpl( const char *pName )
: mxGraphic( layoutimpl::loadGraphic( pName ) )
{
if ( !mxGraphic.is() )
{
DBG_ERROR1( "ERROR: failed to load image: `%s'\n", pName );
}
}
};
Image::Image( const char *pName )
: pImpl( new ImageImpl( pName ) )
{
}
Image::~Image()
{
delete pImpl;
}
class ButtonImpl : public ControlImpl
, public ::cppu::WeakImplHelper1< awt::XActionListener >
, public ::cppu::WeakImplHelper1< awt::XItemListener >
{
Link maClickHdl;
protected:
// we add toggle hooks here to cut on code
Link maToggleHdl;
public:
uno::Reference< awt::XButton > mxButton;
ButtonImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
: ControlImpl( pCtx, xPeer, pWindow )
, mxButton( xPeer, uno::UNO_QUERY )
{
mxButton->addActionListener( this );
}
~ButtonImpl()
{
}
virtual void Click() { /* make me pure virtual? */ };
void SetClickHdl( const Link& rLink )
{
maClickHdl = rLink;
if ( !rLink )
mxButton->removeActionListener( this );
else
mxButton->addActionListener( this );
}
virtual void SAL_CALL disposing( const css::lang::EventObject& /* Source */ )
throw (css::uno::RuntimeException)
{ mxButton.clear(); }
virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& /* rEvent */ )
throw (css::uno::RuntimeException)
{
if ( !maClickHdl )
Click();
else
maClickHdl.Call( static_cast<Window *>( mpWindow ) );
}
virtual // HACK: doesn't need to be virtual... remove in future...
void SAL_CALL itemStateChanged( const css::awt::ItemEvent& /* rEvent */ )
throw (css::uno::RuntimeException)
{
maToggleHdl.Call( static_cast<Window *>( mpWindow ) );
}
BOOL SetModeImage( css::uno::Reference< css::graphic::XGraphic > xGraph )
{
setProperty( "Graphic", uno::Any( xGraph ) );
return true;
}
};
void Button::SetText( const String& rStr )
{
if ( !getImpl().mxButton.is() )
return;
getImpl().mxButton->setLabel( rStr );
}
void Button::SetClickHdl( const Link& rLink )
{
getImpl().SetClickHdl( rLink );
}
BOOL Button::SetModeImage( const Image& rImage )
{
return getImpl().SetModeImage( rImage.getImpl().mxGraphic );
}
void Button::SetImageAlign( ImageAlign eAlign )
{
getImpl().setProperty( "ImageAlign", uno::Any( (sal_Int16) eAlign ) );
}
void Button::Click()
{
}
DECL_GET_IMPL_IMPL( Button );
DECL_CONSTRUCTOR_IMPLS( Button, Control, "button" );
class PushButtonImpl : public ButtonImpl
{
public:
PushButtonImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
: ButtonImpl( pCtx, xPeer, pWindow ) {}
void SetToggleHdl( const Link& rLink )
{
// XButton doesn't have an explicit event for Toggle. Anyway, it is a
// superset of the clicks: all clicks, and explicit toggles
maToggleHdl = rLink;
if ( !rLink )
mxButton->removeActionListener( this );
else
mxButton->addActionListener( this );
}
virtual void SAL_CALL actionPerformed( const css::awt::ActionEvent& rEvent )
throw (css::uno::RuntimeException)
{
ButtonImpl::actionPerformed( rEvent );
fireToggle();
}
inline void fireToggle()
{
maToggleHdl.Call( static_cast<Window *>( mpWindow ) );
}
};
void PushButton::Check( BOOL bCheck )
{
getImpl().setProperty( "State", uno::Any( (sal_Int16) !!bCheck ) );
// XButton doesn't have explicit toggle event
getImpl().fireToggle();
}
BOOL PushButton::IsChecked() const
{
return !!( getImpl().getProperty( "State" ).get< sal_Int16 >() );
}
void PushButton::Toggle()
{
Check( true );
}
void PushButton::SetToggleHdl( const Link& rLink )
{
getImpl().SetToggleHdl( rLink );
}
DECL_GET_IMPL_IMPL( PushButton );
DECL_CONSTRUCTOR_IMPLS( PushButton, Button, "pushbutton" );
// HACK: put every radio button into a group :/
static std::list< RadioButtonImpl*> mpRadioGroup;
class RadioButtonImpl : public ButtonImpl
{
public:
uno::Reference< awt::XRadioButton > mxRadioButton;
RadioButtonImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
: ButtonImpl( pCtx, xPeer, pWindow )
, mxRadioButton( xPeer, uno::UNO_QUERY )
{
// TEMP:
mpRadioGroup.push_back( this );
mxRadioButton->addItemListener( this );
}
~RadioButtonImpl()
{
//mxRadioButton->removeItemListener( this );
mpRadioGroup.pop_front();
}
void Check( BOOL bCheck )
{
if ( !mxRadioButton.is() )
return;
mxRadioButton->setState( !!bCheck );
fireToggle();
if ( bCheck )
unsetOthersGroup( this );
}
BOOL IsChecked()
{
if ( !mxRadioButton.is() )
return FALSE;
return mxRadioButton->getState();
}
static void unsetOthersGroup( RadioButtonImpl* current )
{
// set all others to false
for ( std::list< RadioButtonImpl*>::iterator i = mpRadioGroup.begin();
i != mpRadioGroup.end(); i++ )
{
if ( *i != current )
( *i )->Check( false );
}
}
void SetToggleHdl( const Link& rLink )
{
maToggleHdl = rLink;
#if 0
if ( !rLink )
mxRadioButton->removeItemListener( this );
else
mxRadioButton->addItemListener( this );
#endif
}
inline void fireToggle()
{
maToggleHdl.Call( static_cast<Window *>( mpWindow ) );
}
//HACK: temp
virtual void SAL_CALL itemStateChanged( const css::awt::ItemEvent& rEvent )
throw (css::uno::RuntimeException)
{
if ( !!maToggleHdl )
ButtonImpl::itemStateChanged( rEvent );
if ( IsChecked() )
unsetOthersGroup( this );
}
};
void RadioButton::Check( BOOL bCheck )
{
getImpl().Check( bCheck );
}
BOOL RadioButton::IsChecked() const
{
return getImpl().IsChecked();
}
void RadioButton::SetToggleHdl( const Link& rLink )
{
getImpl().SetToggleHdl( rLink );
}
DECL_GET_IMPL_IMPL( RadioButton );
#if 1
DECL_CONSTRUCTOR_IMPLS( RadioButton, Button, "radiobutton" );
#else //debugging aid
RadioButton::RadioButton( Context *pCtx, const char *pId, sal_uInt32 nId )
: Button( new RadioButtonImpl( pCtx, pCtx->GetPeerHandle( pId, nId ), this ) )
{
printf( "%s: name=%s\n", __PRETTY_FUNCTION__, pId );
}
RadioButton::RadioButton( Window *pParent, WinBits nBits )
: Button( new RadioButtonImpl( pParent->getContext(), Window::CreatePeer( pParent, nBits, "radiobutton" ), this ) )
{
}
#endif
class CheckBoxImpl : public ButtonImpl
{
public:
uno::Reference< awt::XCheckBox > mxCheckBox;
CheckBoxImpl( Context *pCtx, const PeerHandle &xPeer, Window *pWindow )
: ButtonImpl( pCtx, xPeer, pWindow )
, mxCheckBox( xPeer, uno::UNO_QUERY ) {}
void SetToggleHdl( const Link& rLink )
{
maToggleHdl = rLink;
if ( !rLink )
mxCheckBox->removeItemListener( this );
else
mxCheckBox->addItemListener( this );
}
};
void CheckBox::Check( BOOL bCheck )
{
if ( !getImpl().mxCheckBox.is() )
return;
getImpl().mxCheckBox->setState( !!bCheck );
}
BOOL CheckBox::IsChecked() const
{
if ( !getImpl().mxCheckBox.is() )
return FALSE;
return getImpl().mxCheckBox->getState() != 0;
}
void CheckBox::SetToggleHdl( const Link& rLink )
{
getImpl().SetToggleHdl( rLink );
}
DECL_GET_IMPL_IMPL( CheckBox );
DECL_CONSTRUCTOR_IMPLS( CheckBox, Button, "checkbox" );
#define BUTTON_IMPL(t, parent, response) \
class t##Impl : public parent##Impl \
{ \
public: \
t##Impl( Context *pCtx, PeerHandle const& xPeer, Window *pWindow ) \
: parent##Impl( pCtx, xPeer, pWindow ) \
{ \
} \
void Click() \
{ \
Dialog *d = static_cast<Dialog *>( mpCtx ); \
d->EndDialog( response ); \
} \
}
/* Common button types currently unavailable in OOo: */
/* mpReset */
/* mpApply */
/* mpAction */
#define RET_RESET 6
#define RET_APPLY 7
#define BUTTONID_RESET RET_RESET
#define BUTTONID_APPLY RET_APPLY
BUTTON_IMPL( OKButton, PushButton, BUTTONID_OK );
BUTTON_IMPL( CancelButton, PushButton, BUTTONID_CANCEL );
BUTTON_IMPL( YesButton, PushButton, BUTTONID_YES );
BUTTON_IMPL( NoButton, PushButton, BUTTONID_NO );
BUTTON_IMPL( RetryButton, PushButton, BUTTONID_RETRY );
BUTTON_IMPL( IgnoreButton, PushButton, BUTTONID_IGNORE );
BUTTON_IMPL( ResetButton, PushButton, BUTTONID_RESET );
BUTTON_IMPL( ApplyButton, PushButton, BUTTONID_APPLY ); /* Deprecated? */
BUTTON_IMPL( HelpButton, PushButton, BUTTONID_HELP );
DECL_CONSTRUCTOR_IMPLS( OKButton, PushButton, "okbutton" );
DECL_CONSTRUCTOR_IMPLS( CancelButton, PushButton, "cancelbutton" );
DECL_CONSTRUCTOR_IMPLS( YesButton, PushButton, "yesbutton" );
DECL_CONSTRUCTOR_IMPLS( NoButton, PushButton, "nobutton" );
DECL_CONSTRUCTOR_IMPLS( RetryButton, PushButton, "retrybutton" );
DECL_CONSTRUCTOR_IMPLS( IgnoreButton, PushButton, "ignorebutton" );
DECL_CONSTRUCTOR_IMPLS( ResetButton, PushButton, "resetbutton" );
DECL_CONSTRUCTOR_IMPLS( ApplyButton, PushButton, "applybutton" ); /* Deprecated? */
DECL_CONSTRUCTOR_IMPLS( HelpButton, PushButton, "helpbutton" );
class AdvancedButtonImpl : public PushButtonImpl
{
protected:
bool bAdvancedMode;
std::list< Window*> maAdvanced;
std::list< Window*> maSimple;
rtl::OUString mSimpleLabel;
rtl::OUString mAdvancedLabel;
Window* Remove( std::list< Window*> lst, Window* w )
{
for ( std::list< Window*>::iterator it = maAdvanced.begin();
it != maAdvanced.end(); it++ )
if ( *it == w )
{
lst.erase( it );
return *it;
}
return 0;
}
void redraw()
{
uno::Reference <awt::XWindow> ref( mxWindow, uno::UNO_QUERY );
::Window* window = VCLXWindow::GetImplementation( ref )->GetWindow();
::Window* parent = window->GetParent();
::Rectangle r = Rectangle( parent->GetPosPixel(),
parent->GetSizePixel() );
parent->Invalidate( r, INVALIDATE_CHILDREN | INVALIDATE_NOCHILDREN );
parent->SetPosSizePixel( 0, 0, r.nRight - r.nLeft, r.nBottom - r.nTop,
awt::PosSize::SIZE );
}
public:
AdvancedButtonImpl( Context *pCtx, PeerHandle const& xPeer, Window *pWindow )
: PushButtonImpl( pCtx, xPeer, pWindow )
, bAdvancedMode( false )
// TODO: i18n
// Button::GetStandardText( BUTTON_ADVANCED );
// Button::GetStandardText( BUTTON_SIMPLE );
, mSimpleLabel( rtl::OUString::createFromAscii( "Advanced..." ) )
, mAdvancedLabel( rtl::OUString::createFromAscii( "Simple..." ) )
{
}
void Click()
{
bAdvancedMode = !bAdvancedMode;
if ( bAdvancedMode )
advancedMode();
else
simpleMode();
}
void advancedMode()
{
// TODO: set symbol/image?
// SYMBOL_PAGEUP, SYMBOL_PAGEDOWN
#if 0
// How to set images from here?
// XImageConsumer looks like a disaster
// Should move all this switching functionality to VCLXAdvancedButton?
/biek/home/janneke/vc/layout-cws/default_images/res/commandimagelist/
sc_arrowshapes_down.png
sch_flowchartshapes.flowchart-extract.png
sch_flowchartshapes.flowchart-merge.png
#endif
mxButton->setLabel( mAdvancedLabel );
for ( std::list< Window*>::iterator it = maAdvanced.begin();
it != maAdvanced.end(); it++ )
( *it )->Show();
for ( std::list< Window*>::iterator it = maSimple.begin();
it != maSimple.end(); it++ )
( *it )->Hide();
redraw();
}
void simpleMode()
{
mxButton->setLabel( mSimpleLabel );
for ( std::list< Window*>::iterator it = maAdvanced.begin();
it != maAdvanced.end(); it++ )
( *it )->Hide();
for ( std::list< Window*>::iterator it = maSimple.begin();
it != maSimple.end(); it++ )
( *it )->Show();
redraw();
}
void AddAdvanced( Window* w )
{
maAdvanced.push_back( w );
if ( !bAdvancedMode )
w->Hide();
}
void AddSimple( Window* w )
{
maSimple.push_back( w );
if ( bAdvancedMode )
w->Hide();
}
void RemoveAdvanced( Window* w )
{
Remove( maAdvanced, w );
}
void RemoveSimple( Window* w )
{
Remove( maSimple, w );
}
};
void AdvancedButton::AddAdvanced( Window* w )
{
getImpl().AddAdvanced( w );
}
void AdvancedButton::AddSimple( Window* w )
{
getImpl().AddSimple( w );
}
void AdvancedButton::RemoveAdvanced( Window* w )
{
getImpl().RemoveAdvanced( w );
}
void AdvancedButton::RemoveSimple( Window* w )
{
getImpl().RemoveSimple( w );
}
DECL_CONSTRUCTOR_IMPLS( AdvancedButton, PushButton, "advancedbutton" );
DECL_GET_IMPL_IMPL( AdvancedButton );
class MoreButtonImpl : public AdvancedButtonImpl
{
public:
MoreButtonImpl( Context *pCtx, PeerHandle const& xPeer, Window *pWindow )
: AdvancedButtonImpl( pCtx, xPeer, pWindow)
{
mAdvancedLabel = ::Button::GetStandardText( BUTTON_LESS );
mSimpleLabel = ::Button::GetStandardText( BUTTON_MORE );
}
void AddWindow( Window* w ) { AddAdvanced( w ); }
void RemoveWindow( Window* w ) { RemoveAdvanced( w ); }
};
// TODO
//BUTTON_IMPL( MoreButton, PushButton, 0 );
DECL_CONSTRUCTOR_IMPLS( MoreButton, AdvancedButton, "morebutton" );
DECL_GET_IMPL_IMPL( MoreButton );
void MoreButton::AddWindow( Window* w )
{
getImpl().AddWindow( w );
}
void MoreButton::RemoveWindow( Window* w )
{
getImpl().RemoveWindow( w );
}
} // namespace layout