1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 #ifndef SD_TASKPANE_CONTROL_FACTORY_HXX
21 #define SD_TASKPANE_CONTROL_FACTORY_HXX
23 #include "taskpane/TaskPaneTreeNode.hxx"
27 namespace sd
{ namespace toolpanel
{
34 namespace sd
{ namespace toolpanel
{
36 /** A simple factory base class defines the interface that is used by
37 some of the control containers of the task pane to create controls on
38 demand when they are about to be displayed for the first time.
40 It provides the InternalCreateControl() method as hook that can be
41 overloaded by derived classes to provide a new control.
46 ControlFactory (void);
47 virtual ~ControlFactory (void);
49 /** creates a tree node which acts as root of an own tree
51 Derived classes should overload InternalCreateControl.
53 ::std::auto_ptr
<TreeNode
> CreateControl( ::Window
& i_rParent
);
56 virtual TreeNode
* InternalCreateControl( ::Window
& i_rParent
) = 0;
61 /** A simple helper class that realizes a ControlFactory that is able to create root controls, providing
62 the to-be-created control with an additional parameter.
64 template<class ControlType
, class ArgumentType
>
65 class RootControlFactoryWithArg
66 : public ControlFactory
69 RootControlFactoryWithArg (ArgumentType
& rArgument
)
70 : mrArgument(rArgument
)
74 virtual TreeNode
* InternalCreateControl( ::Window
& i_rParent
)
76 return new ControlType( i_rParent
, mrArgument
);
80 ArgumentType
& mrArgument
;
84 } } // end of namespace ::sd::toolpanel
88 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */