/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * 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 .
*/
// tdf#142458 Measure the preferred width of an empty ScrolledWindow // to add to the width of the union of panel widths when calculating // the minimal width of the deck
mxVerticalScrollBar->set_hpolicy(VclPolicyType::NEVER);
mxVerticalScrollBar->set_vpolicy(VclPolicyType::NEVER);
mnScrolledWindowExtraWidth = mxVerticalScrollBar->get_preferred_size().Width();
mxVerticalScrollBar->set_hpolicy(VclPolicyType::AUTOMATIC);
mxVerticalScrollBar->set_vpolicy(VclPolicyType::AUTOMATIC);
}
// We have to explicitly trigger the destruction of panels. // Otherwise that is done by one of our base class destructors // without updating maPanels. for (auto& rpPanel : aPanels)
rpPanel.reset();
/* * Get the ordering as is shown in the layout, and our type as 'deck' * also elide nested panel windows.
*/ void Deck::DumpAsPropertyTree(tools::JsonWriter& rJsonWriter)
{
rJsonWriter.put("id", get_id().isEmpty() ? msId : get_id());
rJsonWriter.put("type", "deck");
rJsonWriter.put("text", GetText());
rJsonWriter.put("enabled", IsEnabled()); if (!IsVisible())
rJsonWriter.put("visible", false);
auto childrenNode = rJsonWriter.startArray("children"); for (constauto &it : maPanels)
{ // collapse the panel itself out auto xContent = it->GetContents(); if (!xContent) continue;
auto childNode = rJsonWriter.startStruct(); // JSDialog references widget by vcl id
rJsonWriter.put("id", it->GetContainer()->get_buildable_name());
rJsonWriter.put("name", it->GetId());
rJsonWriter.put("type", "panel");
rJsonWriter.put("text", it->GetTitle());
rJsonWriter.put("enabled", true);
rJsonWriter.put("hidden", it->IsLurking());
rJsonWriter.put("expanded", it->IsExpanded());
if (it->GetTitleBar() && !it->GetTitleBar()->GetMoreOptionsCommand().isEmpty())
rJsonWriter.put("command", it->GetTitleBar()->GetMoreOptionsCommand());
{ auto children2Node = rJsonWriter.startArray("children");
{ auto child2Node = rJsonWriter.startStruct();
xContent->get_property_tree(rJsonWriter);
}
}
}
}
/** * This container may contain existing panels that are * being re-used, and new ones too.
*/ void Deck::ResetPanels(SharedPanelContainer&& rPanelContainer)
{
SharedPanelContainer aHiddens;
// First hide old panels we don't need just now. for (auto& rpPanel : maPanels)
{ bool bFound = false; for (constauto & i : rPanelContainer)
bFound = bFound || (rpPanel.get() == i.get()); if (!bFound) // this one didn't survive.
{
rpPanel->SetLurkMode(true);
aHiddens.push_back(rpPanel);
}
}
if (mnMinimalWidth)
{ // tdf#142458 at this point mnMinimalWidth contains the width required // by the panels, but extra space may be needed by the scrolledwindow // that will contain the panels
mnMinimalWidth += mnScrolledWindowExtraWidth;
}
}
// Get vertical extent of the panel.
tools::Rectangle aExtents; if (!rPanel.get_extents(aExtents)) return;
auto nPanelTop = aExtents.Top(); auto nPanelBottom = aExtents.Bottom() - 1;
// Determine what the new thumb position should be like. // When the whole panel does not fit then make its top visible // and it off at the bottom.
sal_Int32 nNewThumbPos(mxVerticalScrollBar->vadjustment_get_value()); if (nPanelBottom >= nNewThumbPos + mxVerticalScrollBar->vadjustment_get_page_size())
nNewThumbPos = nPanelBottom - mxVerticalScrollBar->vadjustment_get_page_size(); if (nPanelTop < nNewThumbPos)
nNewThumbPos = nPanelTop;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.