/************************************************************************* * * $RCSfile: stbcontrl.cxx,v $ * * $Revision: 1.1.1.1 $ * * last change: $Author: mt $ $Date: 2004-07-12 13:15:24 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses * * - GNU Lesser General Public License Version 2.1 * - Sun Industry Standards Source License Version 1.1 * * Sun Microsystems Inc., October, 2000 * * GNU Lesser General Public License Version 2.1 * ============================================= * Copyright 2000 by Sun Microsystems, Inc. * 901 San Antonio Road, Palo Alto, CA 94303, USA * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License version 2.1, as published by the Free Software Foundation. * * This library 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 for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, * MA 02111-1307 USA * * * Sun Industry Standards Source License Version 1.1 * ================================================= * The contents of this file are subject to the Sun Industry Standards * Source License Version 1.1 (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.openoffice.org/license.html. * * Software provided under this License is provided on an "AS IS" basis, * WITHOUT WARRUNTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, * WITHOUT LIMITATION, WARRUNTIES THAT THE SOFTWARE IS FREE OF DEFECTS, * MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING. * See the License for the specific provisions governing your rights and * obligations concerning the Software. * * The Initial Developer of the Original Code is: Sun Microsystems, Inc.. * * Copyright: 2000 by Sun Microsystems, Inc. * * All Rights Reserved. * * Contributor(s): _______________________________________ * * ************************************************************************/ // include --------------------------------------------------------------- #ifndef _SHL_HXX //autogen #include #endif #ifndef _STATUS_HXX //autogen #include #endif #ifndef _MENU_HXX //autogen #include #endif #ifndef _SV_IMAGE_HXX #include #endif //#ifndef _SFXITEMPOOL_HXX //#include //#endif #ifndef _SFXAPP_HXX #include #endif #ifndef _SFXMODULE_HXX #include #endif #ifndef _SFXDISPATCH_HXX //autogen #include #endif #ifndef _SFX_OBJSH_HXX //autogen #include #endif #include #include #define PAINT_OFFSET 5 //#include "sizeitem.hxx" //#include "dialmgr.hxx" //#include "dlgutil.hxx" //#include "stbctrls.h" //#include "dialogs.hrc" /*#ifndef _UNOTOOLS_LOCALEDATAWRAPPER_HXX #include #endif #ifndef _UNOTOOLS_PROCESSFACTORY_HXX #include #endif*/ SFX_IMPL_STATUSBAR_CONTROL( XmlSecStatusBarControl, SfxBoolItem ); /* class FunctionPopup_Impl : public PopupMenu { public: FunctionPopup_Impl( USHORT nCheck ); USHORT GetSelected() const { return nSelected; } private: USHORT nSelected; virtual void Select(); }; // ----------------------------------------------------------------------- FunctionPopup_Impl::FunctionPopup_Impl( USHORT nCheck ) : PopupMenu( ResId( RID_SVXMNU_PSZ_FUNC, DIALOG_MGR() ) ), nSelected( 0 ) { if (nCheck) CheckItem( nCheck ); } // ----------------------------------------------------------------------- void FunctionPopup_Impl::Select() { nSelected = GetCurItemId(); } */ struct XmlSecStatusBarControl::XmlSecStatusBarControl_Impl { Point maPos; Size maSize; bool mbSigned; Image maImage; }; XmlSecStatusBarControl::XmlSecStatusBarControl( USHORT _nId, StatusBar& _rStb, SfxBindings& _rBind ) :SfxStatusBarControl( _nId, _rStb, _rBind ) ,mpImpl( new XmlSecStatusBarControl_Impl ) { mpImpl->mbSigned = false; // pImp->maImage = Image( ResId( RID_SVXBMP_POSITION, DIALOG_MGR() ) ); } XmlSecStatusBarControl::~XmlSecStatusBarControl() { delete mpImpl; } void XmlSecStatusBarControl::StateChanged( USHORT nSID, SfxItemState eState, const SfxPoolItem* pState ) { GetStatusBar().SetHelpText( GetId(), String() ); // necessary ? GetStatusBar().SetHelpId( GetId(), nSID ); // necessary ? if( SFX_ITEM_AVAILABLE != eState ) { mpImpl->mbSigned = false; } else if( pState->ISA( SfxBoolItem ) ) { mpImpl->mbSigned = ( ( SfxBoolItem* ) pState )->GetValue(); } else { DBG_ERRORFILE( "+XmlSecStatusBarControl::StateChanged(): invalid item type" ); mpImpl->mbSigned = false; } if( GetStatusBar().AreItemsVisible() ) // necessary ? GetStatusBar().SetItemData( GetId(), 0 ); GetStatusBar().SetItemText( GetId(), String() ); // necessary ? } void XmlSecStatusBarControl::Command( const CommandEvent& rCEvt ) { // can / has to be done when integrated in Office! // if( rCEvt.GetCommand() == .... ) if( false ) { // GetBindings().GetDispatcher()->Execute( SID_PSZ_FUNCTION, SFX_CALLMODE_RECORD, &aItem, 0L ); } else SfxStatusBarControl::Command( rCEvt ); } void XmlSecStatusBarControl::Paint( const UserDrawEvent& rUsrEvt ) { OutputDevice* pDev = rUsrEvt.GetDevice(); DBG_ASSERT( pDev, "-XmlSecStatusBarControl::Paint(): no Output Device... this will lead to nirvana..." ); const Rectangle& rRect = rUsrEvt.GetRect(); StatusBar& rBar = GetStatusBar(); Point aItemPos = rBar.GetItemTextPos( GetId() ); Color aOldLineColor = pDev->GetLineColor(); Color aOldFillColor = pDev->GetFillColor(); // just 4 testing until we've got a bitmap pDev->SetLineColor(); pDev->SetFillColor( pDev->GetBackground().GetColor() ); String s( String::CreateFromAscii( mpImpl->mbSigned? "X" : "-" ) ); pDev->DrawRect( rRect ); pDev->DrawText( Point( rRect.Left() + rRect.GetWidth() / 2 - pDev->GetTextWidth( s ) / 2, aItemPos.Y() ), s ); pDev->SetLineColor( aOldLineColor ); pDev->SetFillColor( aOldFillColor ); }