nss: upgrade to release 3.73
[LibreOffice.git] / sfx2 / source / notebookbar / ContextVBox.cxx
blobb1494340fdc8a19cf8bde86aecf467ccec4854e2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
22 #include <vcl/NotebookbarContextControl.hxx>
23 #include <vcl/builderfactory.hxx>
24 #include <vcl/layout.hxx>
25 #include <sfx2/dllapi.h>
28 * ContextVBox is a VclVBox which shows own children depending on current context.
29 * This control can be used in the notebookbar .ui files
32 class SFX2_DLLPUBLIC ContextVBox : public VclVBox,
33 public NotebookbarContextControl
35 public:
36 explicit ContextVBox( vcl::Window *pParent )
37 : VclVBox( pParent )
41 virtual ~ContextVBox() override
43 disposeOnce();
46 void SetContext( vcl::EnumContext::Context eContext ) override
48 for (int nChild = 0; nChild < GetChildCount(); ++nChild)
50 if ( GetChild( nChild )->GetType() == WindowType::CONTAINER )
52 VclContainer* pChild = static_cast<VclContainer*>( GetChild( nChild ) );
54 if ( pChild->HasContext( eContext ) || pChild->HasContext( vcl::EnumContext::Context::Any ) )
56 Size aSize( pChild->GetOptimalSize() );
57 aSize.AdjustHeight(6 );
58 pChild->Show();
59 pChild->SetSizePixel( aSize );
61 else
63 pChild->Hide();
64 pChild->SetSizePixel( Size( 0, 0 ) );
68 Size aSize( GetOptimalSize() );
69 aSize.AdjustWidth(6 );
70 SetSizePixel( aSize );
74 VCL_BUILDER_FACTORY(ContextVBox)
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */