LibreOffice Module svx (master) 1
insctrl.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include <vcl/status.hxx>
21#include <svl/eitem.hxx>
22#include <tools/debug.hxx>
23
24#include <svx/strings.hrc>
25
26#include <svx/insctrl.hxx>
27#include <svx/dialmgr.hxx>
28
30
32 sal_uInt16 _nId,
33 StatusBar& rStb ) :
34
35 SfxStatusBarControl( _nSlotId, _nId, rStb ),
36 bInsert( true )
37{
38}
39
41{
42}
43
45 const SfxPoolItem* pState )
46{
47 if ( SfxItemState::DEFAULT != eState )
49 else
50 {
51 DBG_ASSERT( dynamic_cast<const SfxBoolItem*>( pState) != nullptr, "invalid item type" );
52 const SfxBoolItem* pItem = static_cast<const SfxBoolItem*>(pState);
53 bInsert = pItem->GetValue();
54
55 if ( bInsert )
56 GetStatusBar().SetQuickHelpText( GetId(), SvxResId( RID_SVXSTR_INSERT_HELPTEXT ) );
57 else
58 GetStatusBar().SetQuickHelpText( GetId(), SvxResId( RID_SVXSTR_OVERWRITE_HELPTEXT ) );
59
61 }
62}
63
65{
66}
67
69{
70 OUString aText = "";
71 // tdf#107918 on macOS without an Insert key it's hard to figure out how to switch modes
72 // so we show both Insert and Overwrite
73#ifdef MACOSX
74 if ( bInsert )
75 aText = SvxResId( RID_SVXSTR_INSERT_TEXT );
76#endif
77 if ( !bInsert )
78 aText = SvxResId( RID_SVXSTR_OVERWRITE_TEXT );
79
80 GetStatusBar().SetItemText( GetId(), aText );
81}
82
83/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
bool GetValue() const
StatusBar & GetStatusBar() const
sal_uInt16 GetId() const
void SetItemText(sal_uInt16 nItemId, const OUString &rText, int nCharsWidth=-1)
void SetQuickHelpText(sal_uInt16 nItemId, const OUString &rText)
virtual void Paint(const UserDrawEvent &rEvt) override
Definition: insctrl.cxx:64
virtual void StateChangedAtStatusBarControl(sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem *pState) override
Definition: insctrl.cxx:44
virtual ~SvxInsertStatusBarControl() override
Definition: insctrl.cxx:40
SvxInsertStatusBarControl(sal_uInt16 nSlotId, sal_uInt16 nId, StatusBar &rStb)
Definition: insctrl.cxx:31
SVX_DLLPRIVATE void DrawItemText_Impl()
Definition: insctrl.cxx:68
#define DBG_ASSERT(sCon, aError)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
SFX_IMPL_STATUSBAR_CONTROL(SvxInsertStatusBarControl, SfxBoolItem)
SfxItemState