1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 // MARKER(update_precomp.py): autogen include statement, do not remove
29 #include "precompiled_sd.hxx"
31 #include "TestPanel.hxx"
32 #include "taskpane/ScrollPanel.hxx"
33 #include "taskpane/TaskPaneControlFactory.hxx"
35 #include <vcl/lstbox.hxx>
36 #include <vcl/button.hxx>
38 namespace sd
{ namespace toolpanel
{
40 #ifdef SHOW_TEST_PANEL
41 /** This factory class is used to create instances of TestPanel. It can be
42 extended so that its constructor stores arguments that later are passed
43 to new TestPanel objects.
45 class TestPanelFactory
46 : public ControlFactory
49 virtual TreeNode
* InternalCreateControl( ::Window
& i_rParent
)
51 return new TestPanel (i_rParent
);
63 ::Window
* pWrappedControl
,
66 maPreferredSize(aPreferredSize
),
67 mpWrappedControl(pWrappedControl
),
68 mbIsResizable(bIsResizable
)
70 mpWrappedControl
->Show();
72 virtual ~Wrapper (void)
74 delete mpWrappedControl
;
77 virtual Size
GetPreferredSize (void)
79 return maPreferredSize
;
81 virtual sal_Int32
GetPreferredWidth (sal_Int32
)
83 return maPreferredSize
.Width();
85 virtual sal_Int32
GetPreferredHeight (sal_Int32
)
87 return maPreferredSize
.Height();
89 virtual ::Window
* GetWindow (void)
91 return mpWrappedControl
;
93 virtual bool IsResizable (void)
97 virtual bool IsExpandable (void) const
101 virtual bool IsExpanded (void) const
107 Size maPreferredSize
;
108 ::Window
* mpWrappedControl
;
113 TestPanel::TestPanel (::Window
& i_rParent
)
114 : SubToolPanel (i_rParent
)
116 // Create a scrollable panel with two list boxes.
117 ScrollPanel
* pScrollPanel
= new ScrollPanel (this);
119 ListBox
* pBox
= new ListBox (pScrollPanel
->GetWindow());
121 for (i
=1; i
<=20; i
++)
123 XubString
aString (XubString::CreateFromAscii("Text "));
124 aString
.Append (XubString::CreateFromInt32(i
));
125 aString
.Append (XubString::CreateFromAscii("/20"));
126 pBox
->InsertEntry (aString
);
128 pScrollPanel
->AddControl (
129 ::std::auto_ptr
<TreeNode
>(new Wrapper (
130 pScrollPanel
, Size (200,300), pBox
, true)),
131 String::CreateFromAscii ("First ListBox"),
134 pBox
= new ListBox (pScrollPanel
->GetWindow());
135 for (i
=1; i
<=20; i
++)
137 XubString
aString (XubString::CreateFromAscii("More Text "));
138 aString
.Append (XubString::CreateFromInt32(i
));
139 aString
.Append (XubString::CreateFromAscii("/20"));
140 pBox
->InsertEntry (aString
);
142 pScrollPanel
->AddControl (
143 ::std::auto_ptr
<TreeNode
>(new Wrapper (
144 pScrollPanel
, Size (200,300), pBox
, true)),
145 String::CreateFromAscii ("Second ListBox"),
148 AddControl (::std::auto_ptr
<TreeNode
>(pScrollPanel
));
150 // Add a fixed size button.
151 Button
* pButton
= new OKButton (this);
153 ::std::auto_ptr
<TreeNode
>(new Wrapper (
154 this, Size (100,30), pButton
, false)),
155 String::CreateFromAscii ("Button Area"),
163 TestPanel::~TestPanel (void)
167 std::auto_ptr
<ControlFactory
> TestPanel::CreateControlFactory (void)
169 return std::auto_ptr
<ControlFactory
>(new TestPanelFactory());
174 } } // end of namespace ::sd::toolpanel