1*b557fc96SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*b557fc96SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*b557fc96SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*b557fc96SAndrew Rist * distributed with this work for additional information 6*b557fc96SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*b557fc96SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*b557fc96SAndrew Rist * "License"); you may not use this file except in compliance 9*b557fc96SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 11*b557fc96SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 13*b557fc96SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*b557fc96SAndrew Rist * software distributed under the License is distributed on an 15*b557fc96SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*b557fc96SAndrew Rist * KIND, either express or implied. See the License for the 17*b557fc96SAndrew Rist * specific language governing permissions and limitations 18*b557fc96SAndrew Rist * under the License. 19cdf0e10cSrcweir * 20*b557fc96SAndrew Rist *************************************************************/ 21*b557fc96SAndrew Rist 22*b557fc96SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove 25cdf0e10cSrcweir #include "precompiled_fpicker.hxx" 26cdf0e10cSrcweir #include "customcontrolcontainer.hxx" 27cdf0e10cSrcweir 28cdf0e10cSrcweir #include <algorithm> 29cdf0e10cSrcweir #include <functional> 30cdf0e10cSrcweir 31cdf0e10cSrcweir //----------------------------------- 32cdf0e10cSrcweir // 33cdf0e10cSrcweir //----------------------------------- 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace /* private */ 36cdf0e10cSrcweir { 37cdf0e10cSrcweir void DeleteCustomControl(CCustomControl* aCustomControl) 38cdf0e10cSrcweir { 39cdf0e10cSrcweir delete aCustomControl; 40cdf0e10cSrcweir }; 41cdf0e10cSrcweir 42cdf0e10cSrcweir void AlignCustomControl(CCustomControl* aCustomControl) 43cdf0e10cSrcweir { 44cdf0e10cSrcweir aCustomControl->Align(); 45cdf0e10cSrcweir }; 46cdf0e10cSrcweir 47cdf0e10cSrcweir class CSetFontHelper 48cdf0e10cSrcweir { 49cdf0e10cSrcweir public: 50cdf0e10cSrcweir CSetFontHelper(HFONT hFont) : 51cdf0e10cSrcweir m_hFont(hFont) 52cdf0e10cSrcweir { 53cdf0e10cSrcweir } 54cdf0e10cSrcweir 55cdf0e10cSrcweir void SAL_CALL operator()(CCustomControl* aCustomControl) 56cdf0e10cSrcweir { 57cdf0e10cSrcweir aCustomControl->SetFont(m_hFont); 58cdf0e10cSrcweir } 59cdf0e10cSrcweir 60cdf0e10cSrcweir private: 61cdf0e10cSrcweir HFONT m_hFont; 62cdf0e10cSrcweir }; 63cdf0e10cSrcweir } 64cdf0e10cSrcweir 65cdf0e10cSrcweir //----------------------------------- 66cdf0e10cSrcweir // 67cdf0e10cSrcweir //----------------------------------- 68cdf0e10cSrcweir 69cdf0e10cSrcweir CCustomControlContainer::~CCustomControlContainer() 70cdf0e10cSrcweir { 71cdf0e10cSrcweir RemoveAllControls(); 72cdf0e10cSrcweir } 73cdf0e10cSrcweir 74cdf0e10cSrcweir //----------------------------------- 75cdf0e10cSrcweir // 76cdf0e10cSrcweir //----------------------------------- 77cdf0e10cSrcweir 78cdf0e10cSrcweir void SAL_CALL CCustomControlContainer::Align() 79cdf0e10cSrcweir { 80cdf0e10cSrcweir std::for_each( 81cdf0e10cSrcweir m_ControlContainer.begin(), 82cdf0e10cSrcweir m_ControlContainer.end(), 83cdf0e10cSrcweir AlignCustomControl); 84cdf0e10cSrcweir } 85cdf0e10cSrcweir 86cdf0e10cSrcweir //----------------------------------- 87cdf0e10cSrcweir // 88cdf0e10cSrcweir //----------------------------------- 89cdf0e10cSrcweir 90cdf0e10cSrcweir void SAL_CALL CCustomControlContainer::SetFont(HFONT hFont) 91cdf0e10cSrcweir { 92cdf0e10cSrcweir CSetFontHelper aSetFontHelper(hFont); 93cdf0e10cSrcweir 94cdf0e10cSrcweir std::for_each( 95cdf0e10cSrcweir m_ControlContainer.begin(), 96cdf0e10cSrcweir m_ControlContainer.end(), 97cdf0e10cSrcweir aSetFontHelper); 98cdf0e10cSrcweir } 99cdf0e10cSrcweir 100cdf0e10cSrcweir //----------------------------------- 101cdf0e10cSrcweir // 102cdf0e10cSrcweir //----------------------------------- 103cdf0e10cSrcweir 104cdf0e10cSrcweir void SAL_CALL CCustomControlContainer::AddControl(CCustomControl* aCustomControl) 105cdf0e10cSrcweir { 106cdf0e10cSrcweir m_ControlContainer.push_back(aCustomControl); 107cdf0e10cSrcweir } 108cdf0e10cSrcweir 109cdf0e10cSrcweir //----------------------------------- 110cdf0e10cSrcweir // 111cdf0e10cSrcweir //----------------------------------- 112cdf0e10cSrcweir 113cdf0e10cSrcweir void SAL_CALL CCustomControlContainer::RemoveControl(CCustomControl* aCustomControl) 114cdf0e10cSrcweir { 115cdf0e10cSrcweir ControlContainer_t::iterator iter_end = m_ControlContainer.end(); 116cdf0e10cSrcweir 117cdf0e10cSrcweir ControlContainer_t::iterator iter = 118cdf0e10cSrcweir std::find(m_ControlContainer.begin(),iter_end,aCustomControl); 119cdf0e10cSrcweir 120cdf0e10cSrcweir if (iter != iter_end) 121cdf0e10cSrcweir { 122cdf0e10cSrcweir delete *iter; 123cdf0e10cSrcweir m_ControlContainer.remove(aCustomControl); 124cdf0e10cSrcweir } 125cdf0e10cSrcweir } 126cdf0e10cSrcweir 127cdf0e10cSrcweir //----------------------------------- 128cdf0e10cSrcweir // 129cdf0e10cSrcweir //----------------------------------- 130cdf0e10cSrcweir 131cdf0e10cSrcweir void SAL_CALL CCustomControlContainer::RemoveAllControls() 132cdf0e10cSrcweir { 133cdf0e10cSrcweir std::for_each( 134cdf0e10cSrcweir m_ControlContainer.begin(), 135cdf0e10cSrcweir m_ControlContainer.end(), 136cdf0e10cSrcweir DeleteCustomControl); 137cdf0e10cSrcweir 138cdf0e10cSrcweir m_ControlContainer.clear(); 139cdf0e10cSrcweir } 140