2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-11-21 22:06:52 +00:00
|
|
|
/*
|
|
|
|
* This file is part of the LibreOffice project.
|
|
|
|
*
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
*
|
|
|
|
* This file incorporates work covered by the following license notice:
|
|
|
|
*
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed
|
|
|
|
* with this work for additional information regarding copyright
|
|
|
|
* ownership. The ASF licenses this file to you under the Apache
|
|
|
|
* License, Version 2.0 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
|
|
|
|
*/
|
2004-08-02 16:46:10 +00:00
|
|
|
|
2017-10-23 22:30:42 +02:00
|
|
|
#include <svx/orienthelper.hxx>
|
2004-08-02 16:46:10 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include <vcl/button.hxx>
|
2017-10-23 22:30:42 +02:00
|
|
|
#include <svx/dialcontrol.hxx>
|
2004-08-02 16:46:10 +00:00
|
|
|
|
|
|
|
namespace svx {
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2004-08-02 16:46:10 +00:00
|
|
|
struct OrientationHelper_Impl
|
|
|
|
{
|
2015-03-09 14:29:30 +02:00
|
|
|
typedef std::pair< VclPtr<vcl::Window>, TriState > WindowPair;
|
2004-08-02 16:46:10 +00:00
|
|
|
typedef std::vector< WindowPair > WindowVec;
|
|
|
|
|
2008-11-26 15:19:48 +00:00
|
|
|
DialControl& mrCtrlDial;
|
2004-08-02 16:46:10 +00:00
|
|
|
CheckBox& mrCbStacked;
|
2008-11-26 15:19:48 +00:00
|
|
|
WindowVec maWinVec;
|
|
|
|
bool mbEnabled;
|
|
|
|
bool mbVisible;
|
2004-08-02 16:46:10 +00:00
|
|
|
|
2008-11-26 15:19:48 +00:00
|
|
|
explicit OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void AddDependentWindow( vcl::Window& rWindow, TriState eDisableIfStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
|
|
|
|
void EnableDependentWindows();
|
2014-09-23 11:20:40 +02:00
|
|
|
void EnableWindow( vcl::Window& rWindow, TriState eDisableIfStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
|
|
|
|
void ShowDependentWindows();
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
DECL_LINK( ClickHdl, Button*, void );
|
2004-08-02 16:46:10 +00:00
|
|
|
};
|
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2008-11-26 15:19:48 +00:00
|
|
|
OrientationHelper_Impl::OrientationHelper_Impl( DialControl& rCtrlDial, CheckBox& rCbStacked ) :
|
2004-08-02 16:46:10 +00:00
|
|
|
mrCtrlDial( rCtrlDial ),
|
2008-11-26 15:19:48 +00:00
|
|
|
mrCbStacked( rCbStacked ),
|
|
|
|
mbEnabled( rCtrlDial.IsEnabled() ),
|
|
|
|
mbVisible( rCtrlDial.IsVisible() )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
2017-09-13 11:04:58 +02:00
|
|
|
maWinVec.emplace_back( &mrCtrlDial, TRISTATE_TRUE );
|
|
|
|
maWinVec.emplace_back( &mrCbStacked, TRISTATE_INDET );
|
2004-08-02 16:46:10 +00:00
|
|
|
mrCbStacked.SetClickHdl( LINK( this, OrientationHelper_Impl, ClickHdl ) );
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void OrientationHelper_Impl::AddDependentWindow( vcl::Window& rWindow, TriState eDisableIfStacked )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
2017-09-13 11:04:58 +02:00
|
|
|
maWinVec.emplace_back( &rWindow, eDisableIfStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
EnableWindow( rWindow, eDisableIfStacked );
|
|
|
|
}
|
|
|
|
|
|
|
|
void OrientationHelper_Impl::EnableDependentWindows()
|
|
|
|
{
|
2016-04-13 21:20:25 +02:00
|
|
|
WindowVec::const_iterator aEnd = maWinVec.end();
|
|
|
|
for( WindowVec::iterator aIt = maWinVec.begin(); aIt != aEnd; ++aIt )
|
2004-08-02 16:46:10 +00:00
|
|
|
EnableWindow( *aIt->first, aIt->second );
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void OrientationHelper_Impl::EnableWindow( vcl::Window& rWindow, TriState eDisableIfStacked )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
|
|
|
bool bDisableOnStacked = false;
|
|
|
|
switch( eDisableIfStacked )
|
|
|
|
{
|
2014-02-24 12:25:02 +01:00
|
|
|
// TRISTATE_TRUE: Disable window, if stacked text is turned on or "don't know".
|
|
|
|
case TRISTATE_TRUE: bDisableOnStacked = (mrCbStacked.GetState() != TRISTATE_FALSE); break;
|
|
|
|
// TRISTATE_FALSE: Disable window, if stacked text is turned off or "don't know".
|
|
|
|
case TRISTATE_FALSE: bDisableOnStacked = (mrCbStacked.GetState() != TRISTATE_TRUE); break;
|
2006-06-19 14:24:40 +00:00
|
|
|
default: ;//prevent warning
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
2008-11-26 15:19:48 +00:00
|
|
|
rWindow.Enable( mbEnabled && !bDisableOnStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OrientationHelper_Impl::ShowDependentWindows()
|
|
|
|
{
|
2016-04-13 21:20:25 +02:00
|
|
|
WindowVec::const_iterator aEnd = maWinVec.end();
|
|
|
|
for( WindowVec::iterator aIt = maWinVec.begin(); aIt != aEnd; ++aIt )
|
2008-11-26 15:19:48 +00:00
|
|
|
aIt->first->Show( mbVisible );
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
2016-10-05 07:56:12 +02:00
|
|
|
IMPL_LINK_NOARG(OrientationHelper_Impl, ClickHdl, Button*, void)
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
|
|
|
EnableDependentWindows();
|
|
|
|
}
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2008-11-26 15:19:48 +00:00
|
|
|
OrientationHelper::OrientationHelper( DialControl& rCtrlDial, NumericField& rNfRotation, CheckBox& rCbStacked ) :
|
|
|
|
mpImpl( new OrientationHelper_Impl( rCtrlDial, rCbStacked ) )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
2008-11-26 15:19:48 +00:00
|
|
|
rCtrlDial.SetLinkedField( &rNfRotation );
|
2004-08-02 16:46:10 +00:00
|
|
|
mpImpl->EnableDependentWindows();
|
2008-11-26 15:19:48 +00:00
|
|
|
mpImpl->ShowDependentWindows();
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
OrientationHelper::~OrientationHelper()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-09-23 11:20:40 +02:00
|
|
|
void OrientationHelper::AddDependentWindow( vcl::Window& rWindow, TriState eDisableIfStacked )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
2008-11-26 15:19:48 +00:00
|
|
|
mpImpl->AddDependentWindow( rWindow, eDisableIfStacked );
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
2008-11-26 15:19:48 +00:00
|
|
|
void OrientationHelper::Enable( bool bEnable )
|
2004-08-02 16:46:10 +00:00
|
|
|
{
|
2008-11-26 15:19:48 +00:00
|
|
|
mpImpl->mbEnabled = bEnable;
|
|
|
|
mpImpl->EnableDependentWindows();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OrientationHelper::Show( bool bShow )
|
|
|
|
{
|
|
|
|
mpImpl->mbVisible = bShow;
|
|
|
|
mpImpl->ShowDependentWindows();
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OrientationHelper::SetStackedState( TriState eState )
|
|
|
|
{
|
|
|
|
if( eState != GetStackedState() )
|
|
|
|
{
|
|
|
|
mpImpl->mrCbStacked.SetState( eState );
|
|
|
|
mpImpl->EnableDependentWindows();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
TriState OrientationHelper::GetStackedState() const
|
|
|
|
{
|
|
|
|
return mpImpl->mrCbStacked.GetState();
|
|
|
|
}
|
|
|
|
|
|
|
|
void OrientationHelper::EnableStackedTriState( bool bEnable )
|
|
|
|
{
|
|
|
|
mpImpl->mrCbStacked.EnableTriState( bEnable );
|
|
|
|
}
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2004-08-02 16:46:10 +00:00
|
|
|
OrientStackedWrapper::OrientStackedWrapper( OrientationHelper& rOrientHlp ) :
|
|
|
|
SingleControlWrapperType( rOrientHlp )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OrientStackedWrapper::IsControlDontKnow() const
|
|
|
|
{
|
2014-02-24 12:25:02 +01:00
|
|
|
return GetControl().GetStackedState() == TRISTATE_INDET;
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OrientStackedWrapper::SetControlDontKnow( bool bSet )
|
|
|
|
{
|
|
|
|
GetControl().EnableStackedTriState( bSet );
|
2014-02-24 12:25:02 +01:00
|
|
|
GetControl().SetStackedState( bSet ? TRISTATE_INDET : TRISTATE_FALSE );
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool OrientStackedWrapper::GetControlValue() const
|
|
|
|
{
|
2014-02-24 12:25:02 +01:00
|
|
|
return GetControl().GetStackedState() == TRISTATE_TRUE;
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OrientStackedWrapper::SetControlValue( bool bValue )
|
|
|
|
{
|
2014-02-24 12:25:02 +01:00
|
|
|
GetControl().SetStackedState( bValue ? TRISTATE_TRUE : TRISTATE_FALSE );
|
2004-08-02 16:46:10 +00:00
|
|
|
}
|
|
|
|
|
2014-02-25 20:51:35 +01:00
|
|
|
|
2015-05-15 13:27:19 +02:00
|
|
|
}
|
2004-08-02 16:46:10 +00:00
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|