Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : */
9 :
10 : #ifndef INCLUDED_VCL_LAYOUT_HXX
11 : #define INCLUDED_VCL_LAYOUT_HXX
12 :
13 : #include <vcl/dllapi.h>
14 : #include <vcl/button.hxx>
15 : #include <vcl/dialog.hxx>
16 : #include <vcl/fixed.hxx>
17 : #include <vcl/scrbar.hxx>
18 : #include <vcl/vclmedit.hxx>
19 : #include <vcl/window.hxx>
20 : #include <boost/multi_array.hpp>
21 : #include <set>
22 :
23 11160 : class VCL_DLLPUBLIC VclContainer : public vcl::Window
24 : {
25 : public:
26 : VclContainer(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN);
27 :
28 : //These take into account the external margins of the rWindow widget
29 : //while GetOptimalSize/get_preferred_size and SetPosSizePixel are
30 : //oblivious to them
31 : static Size getLayoutRequisition(const vcl::Window &rWindow);
32 : static void setLayoutPosSize(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
33 :
34 : //applies the allocation pos and size onto rWindow via setLayoutPosSize taking into account
35 : //the rWindows alignment desires within that allocation
36 : static void setLayoutAllocation(vcl::Window &rWindow, const Point &rPos, const Size &rSize);
37 :
38 454522 : void markLayoutDirty()
39 : {
40 454522 : m_bLayoutDirty = true;
41 454522 : }
42 :
43 : virtual void queue_resize(StateChangedType eReason = StateChangedType::LAYOUT) SAL_OVERRIDE;
44 : protected:
45 : //these are the two that need to be implemented by
46 : //containers, figure out how much space you want...
47 : virtual Size calculateRequisition() const = 0;
48 : //..and decide what to do when set to this size
49 : virtual void setAllocation(const Size &rAllocation) = 0;
50 :
51 : virtual sal_uInt16 getDefaultAccessibleRole() const SAL_OVERRIDE;
52 : public:
53 : //you don't want to override these
54 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
55 : virtual void SetPosSizePixel(const Point& rNewPos, const Size& rNewSize) SAL_OVERRIDE;
56 : virtual void SetPosPixel(const Point& rAllocPos) SAL_OVERRIDE;
57 : virtual void SetSizePixel(const Size& rAllocation) SAL_OVERRIDE;
58 : private:
59 : bool m_bLayoutDirty;
60 : };
61 :
62 9646 : class VCL_DLLPUBLIC VclBox : public VclContainer
63 : {
64 : protected:
65 : bool m_bHomogeneous;
66 : bool m_bVerticalContainer;
67 : int m_nSpacing;
68 : public:
69 9646 : VclBox(vcl::Window *pParent, bool bHomogeneous, int nSpacing)
70 : : VclContainer(pParent)
71 : , m_bHomogeneous(bHomogeneous)
72 : , m_bVerticalContainer(false)
73 9646 : , m_nSpacing(nSpacing)
74 : {
75 9646 : }
76 8860 : void set_spacing(int nSpacing)
77 : {
78 8860 : m_nSpacing = nSpacing;
79 8860 : }
80 0 : int get_spacing() const
81 : {
82 0 : return m_nSpacing;
83 : }
84 2 : void set_homogeneous(bool bHomogeneous)
85 : {
86 2 : m_bHomogeneous = bHomogeneous;
87 2 : }
88 : bool get_homogeneous() const
89 : {
90 : return m_bHomogeneous;
91 : }
92 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
93 : protected:
94 : virtual sal_uInt16 getDefaultAccessibleRole() const SAL_OVERRIDE;
95 : void accumulateMaxes(const Size &rChildSize, Size &rSize) const;
96 : Size finalizeMaxes(const Size &rSize, sal_uInt16 nVisibleChildren) const;
97 :
98 : virtual Size calculateRequisition() const SAL_OVERRIDE;
99 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
100 :
101 : virtual long getPrimaryDimension(const Size &rSize) const = 0;
102 : virtual void setPrimaryDimension(Size &rSize, long) const = 0;
103 : virtual long getPrimaryCoordinate(const Point &rPos) const = 0;
104 : virtual void setPrimaryCoordinate(Point &rPos, long) const = 0;
105 : virtual long getSecondaryDimension(const Size &rSize) const = 0;
106 : virtual void setSecondaryDimension(Size &rSize, long) const = 0;
107 : virtual long getSecondaryCoordinate(const Point &rPos) const = 0;
108 : virtual void setSecondaryCoordinate(Point &rPos, long) const = 0;
109 :
110 : virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const = 0;
111 : };
112 :
113 4524 : class VCL_DLLPUBLIC VclVBox : public VclBox
114 : {
115 : public:
116 2262 : VclVBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
117 2262 : : VclBox(pParent, bHomogeneous, nSpacing)
118 : {
119 2262 : m_bVerticalContainer = true;
120 2262 : }
121 : protected:
122 101938 : virtual long getPrimaryDimension(const Size &rSize) const SAL_OVERRIDE
123 : {
124 101938 : return rSize.getHeight();
125 : }
126 65920 : virtual void setPrimaryDimension(Size &rSize, long nHeight) const SAL_OVERRIDE
127 : {
128 65920 : rSize.setHeight(nHeight);
129 65920 : }
130 24006 : virtual long getPrimaryCoordinate(const Point &rPos) const SAL_OVERRIDE
131 : {
132 24006 : return rPos.getY();
133 : }
134 43456 : virtual void setPrimaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
135 : {
136 43456 : rPos.setY(nPos);
137 43456 : }
138 46470 : virtual long getSecondaryDimension(const Size &rSize) const SAL_OVERRIDE
139 : {
140 46470 : return rSize.getWidth();
141 : }
142 34490 : virtual void setSecondaryDimension(Size &rSize, long nWidth) const SAL_OVERRIDE
143 : {
144 34490 : rSize.setWidth(nWidth);
145 34490 : }
146 0 : virtual long getSecondaryCoordinate(const Point &rPos) const SAL_OVERRIDE
147 : {
148 0 : return rPos.getX();
149 : }
150 0 : virtual void setSecondaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
151 : {
152 0 : rPos.setX(nPos);
153 0 : }
154 38900 : virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const SAL_OVERRIDE
155 : {
156 38900 : return rWindow.get_expand() || rWindow.get_vexpand();
157 : }
158 : };
159 :
160 14768 : class VCL_DLLPUBLIC VclHBox : public VclBox
161 : {
162 : public:
163 7384 : VclHBox(vcl::Window *pParent, bool bHomogeneous = false, int nSpacing = 0)
164 7384 : : VclBox(pParent, bHomogeneous, nSpacing)
165 : {
166 7384 : m_bVerticalContainer = false;
167 7384 : }
168 : protected:
169 246430 : virtual long getPrimaryDimension(const Size &rSize) const SAL_OVERRIDE
170 : {
171 246430 : return rSize.getWidth();
172 : }
173 144312 : virtual void setPrimaryDimension(Size &rSize, long nWidth) const SAL_OVERRIDE
174 : {
175 144312 : rSize.setWidth(nWidth);
176 144312 : }
177 50342 : virtual long getPrimaryCoordinate(const Point &rPos) const SAL_OVERRIDE
178 : {
179 50342 : return rPos.getX();
180 : }
181 79948 : virtual void setPrimaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
182 : {
183 79948 : rPos.setX(nPos);
184 79948 : }
185 114706 : virtual long getSecondaryDimension(const Size &rSize) const SAL_OVERRIDE
186 : {
187 114706 : return rSize.getHeight();
188 : }
189 80662 : virtual void setSecondaryDimension(Size &rSize, long nHeight) const SAL_OVERRIDE
190 : {
191 80662 : rSize.setHeight(nHeight);
192 80662 : }
193 0 : virtual long getSecondaryCoordinate(const Point &rPos) const SAL_OVERRIDE
194 : {
195 0 : return rPos.getY();
196 : }
197 0 : virtual void setSecondaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
198 : {
199 0 : rPos.setY(nPos);
200 0 : }
201 59204 : virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const SAL_OVERRIDE
202 : {
203 59204 : return rWindow.get_expand() || rWindow.get_hexpand();
204 : }
205 : };
206 :
207 : enum VclButtonBoxStyle
208 : {
209 : VCL_BUTTONBOX_DEFAULT_STYLE,
210 : VCL_BUTTONBOX_SPREAD,
211 : VCL_BUTTONBOX_EDGE,
212 : VCL_BUTTONBOX_START,
213 : VCL_BUTTONBOX_END,
214 : VCL_BUTTONBOX_CENTER
215 : };
216 :
217 0 : class VCL_DLLPUBLIC VclButtonBox : public VclBox
218 : {
219 : public:
220 0 : VclButtonBox(vcl::Window *pParent, int nSpacing)
221 : : VclBox(pParent, false, nSpacing)
222 0 : , m_eLayoutStyle(VCL_BUTTONBOX_DEFAULT_STYLE)
223 : {
224 0 : }
225 0 : void set_layout(VclButtonBoxStyle eStyle)
226 : {
227 0 : m_eLayoutStyle = eStyle;
228 0 : }
229 : VclButtonBoxStyle get_layout() const
230 : {
231 : return m_eLayoutStyle;
232 : }
233 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
234 : void sort_native_button_order();
235 : protected:
236 : virtual Size calculateRequisition() const SAL_OVERRIDE;
237 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
238 : Size addSpacing(const Size &rSize, sal_uInt16 nVisibleChildren) const;
239 : private:
240 : VclButtonBoxStyle m_eLayoutStyle;
241 0 : struct Requisition
242 : {
243 : std::vector<long> m_aMainGroupDimensions;
244 : std::vector<long> m_aSubGroupDimensions;
245 : Size m_aMainGroupSize;
246 : Size m_aSubGroupSize;
247 : };
248 : Requisition calculatePrimarySecondaryRequisitions() const;
249 : Size addReqGroups(const VclButtonBox::Requisition &rReq) const;
250 : };
251 :
252 0 : class VCL_DLLPUBLIC VclVButtonBox : public VclButtonBox
253 : {
254 : public:
255 0 : VclVButtonBox(vcl::Window *pParent, int nSpacing = 0)
256 0 : : VclButtonBox(pParent, nSpacing)
257 : {
258 0 : m_bVerticalContainer = true;
259 0 : }
260 : protected:
261 0 : virtual long getPrimaryDimension(const Size &rSize) const SAL_OVERRIDE
262 : {
263 0 : return rSize.getHeight();
264 : }
265 0 : virtual void setPrimaryDimension(Size &rSize, long nHeight) const SAL_OVERRIDE
266 : {
267 0 : rSize.setHeight(nHeight);
268 0 : }
269 0 : virtual long getPrimaryCoordinate(const Point &rPos) const SAL_OVERRIDE
270 : {
271 0 : return rPos.getY();
272 : }
273 0 : virtual void setPrimaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
274 : {
275 0 : rPos.setY(nPos);
276 0 : }
277 0 : virtual long getSecondaryDimension(const Size &rSize) const SAL_OVERRIDE
278 : {
279 0 : return rSize.getWidth();
280 : }
281 0 : virtual void setSecondaryDimension(Size &rSize, long nWidth) const SAL_OVERRIDE
282 : {
283 0 : rSize.setWidth(nWidth);
284 0 : }
285 0 : virtual long getSecondaryCoordinate(const Point &rPos) const SAL_OVERRIDE
286 : {
287 0 : return rPos.getX();
288 : }
289 0 : virtual void setSecondaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
290 : {
291 0 : rPos.setX(nPos);
292 0 : }
293 0 : virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const SAL_OVERRIDE
294 : {
295 0 : return rWindow.get_expand() || rWindow.get_vexpand();
296 : }
297 : };
298 :
299 0 : class VCL_DLLPUBLIC VclHButtonBox : public VclButtonBox
300 : {
301 : public:
302 0 : VclHButtonBox(vcl::Window *pParent, int nSpacing = 0)
303 0 : : VclButtonBox(pParent, nSpacing)
304 : {
305 0 : m_bVerticalContainer = false;
306 0 : }
307 : protected:
308 0 : virtual long getPrimaryDimension(const Size &rSize) const SAL_OVERRIDE
309 : {
310 0 : return rSize.getWidth();
311 : }
312 0 : virtual void setPrimaryDimension(Size &rSize, long nWidth) const SAL_OVERRIDE
313 : {
314 0 : rSize.setWidth(nWidth);
315 0 : }
316 0 : virtual long getPrimaryCoordinate(const Point &rPos) const SAL_OVERRIDE
317 : {
318 0 : return rPos.getX();
319 : }
320 0 : virtual void setPrimaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
321 : {
322 0 : rPos.setX(nPos);
323 0 : }
324 0 : virtual long getSecondaryDimension(const Size &rSize) const SAL_OVERRIDE
325 : {
326 0 : return rSize.getHeight();
327 : }
328 0 : virtual void setSecondaryDimension(Size &rSize, long nHeight) const SAL_OVERRIDE
329 : {
330 0 : rSize.setHeight(nHeight);
331 0 : }
332 0 : virtual long getSecondaryCoordinate(const Point &rPos) const SAL_OVERRIDE
333 : {
334 0 : return rPos.getY();
335 : }
336 0 : virtual void setSecondaryCoordinate(Point &rPos, long nPos) const SAL_OVERRIDE
337 : {
338 0 : rPos.setY(nPos);
339 0 : }
340 0 : virtual bool getPrimaryDimensionChildExpand(const vcl::Window &rWindow) const SAL_OVERRIDE
341 : {
342 0 : return rWindow.get_expand() || rWindow.get_hexpand();
343 : }
344 : };
345 :
346 3028 : class VCL_DLLPUBLIC VclGrid : public VclContainer
347 : {
348 : private:
349 : bool m_bRowHomogeneous;
350 : bool m_bColumnHomogeneous;
351 : int m_nRowSpacing;
352 : int m_nColumnSpacing;
353 :
354 : struct GridEntry
355 : {
356 : vcl::Window *pChild;
357 : sal_Int32 nSpanWidth;
358 : sal_Int32 nSpanHeight;
359 40940 : GridEntry()
360 : : pChild(0)
361 : , nSpanWidth(0)
362 40940 : , nSpanHeight(0)
363 : {
364 40940 : }
365 : };
366 :
367 : typedef boost::multi_array<GridEntry, 2> array_type;
368 :
369 : struct ExtendedGridEntry : GridEntry
370 : {
371 : int x;
372 : int y;
373 33467 : ExtendedGridEntry()
374 : : x(-1)
375 33467 : , y(-1)
376 : {
377 33467 : }
378 : };
379 :
380 : typedef boost::multi_array<ExtendedGridEntry, 2> ext_array_type;
381 :
382 : array_type assembleGrid() const;
383 : bool isNullGrid(const array_type& A) const;
384 : public:
385 : struct Value
386 : {
387 : long m_nValue;
388 : bool m_bExpand;
389 52561 : Value() : m_nValue(0), m_bExpand(false) {}
390 : };
391 : private:
392 : void calcMaxs(const array_type &A, std::vector<Value> &rWidths, std::vector<Value> &rHeights) const;
393 :
394 : Size calculateRequisitionForSpacings(sal_Int32 nRowSpacing, sal_Int32 nColSpacing) const;
395 : virtual Size calculateRequisition() const SAL_OVERRIDE;
396 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
397 : public:
398 1514 : VclGrid(vcl::Window *pParent)
399 : : VclContainer(pParent)
400 : , m_bRowHomogeneous(false), m_bColumnHomogeneous(false)
401 1514 : , m_nRowSpacing(0), m_nColumnSpacing(0)
402 : {
403 1514 : }
404 0 : void set_row_homogeneous(bool bHomogeneous)
405 : {
406 0 : m_bRowHomogeneous = bHomogeneous;
407 0 : }
408 1480 : void set_column_homogeneous(bool bHomogeneous)
409 : {
410 1480 : m_bColumnHomogeneous = bHomogeneous;
411 1480 : }
412 50521 : bool get_row_homogeneous() const
413 : {
414 50521 : return m_bRowHomogeneous;
415 : }
416 50589 : bool get_column_homogeneous() const
417 : {
418 50589 : return m_bColumnHomogeneous;
419 : }
420 1514 : void set_row_spacing(int nSpacing)
421 : {
422 1514 : m_nRowSpacing = nSpacing;
423 1514 : }
424 1480 : void set_column_spacing(int nSpacing)
425 : {
426 1480 : m_nColumnSpacing = nSpacing;
427 1480 : }
428 5328 : int get_row_spacing() const
429 : {
430 5328 : return m_nRowSpacing;
431 : }
432 5328 : int get_column_spacing() const
433 : {
434 5328 : return m_nColumnSpacing;
435 : }
436 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
437 : };
438 :
439 : VCL_DLLPUBLIC void setGridAttach(vcl::Window &rWidget, sal_Int32 nLeft, sal_Int32 nTop,
440 : sal_Int32 nWidth = 1, sal_Int32 nHeight = 1);
441 :
442 0 : class VCL_DLLPUBLIC VclBin : public VclContainer
443 : {
444 : public:
445 0 : VclBin(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN)
446 0 : : VclContainer(pParent, nStyle)
447 : {
448 0 : }
449 : virtual vcl::Window *get_child();
450 : virtual const vcl::Window *get_child() const;
451 : virtual Size calculateRequisition() const SAL_OVERRIDE;
452 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
453 : };
454 :
455 0 : class VCL_DLLPUBLIC VclFrame : public VclBin
456 : {
457 : private:
458 : vcl::Window *m_pLabel;
459 : private:
460 : friend class VclBuilder;
461 : void designate_label(vcl::Window *pWindow);
462 : DECL_LINK(WindowEventListener, VclSimpleEvent*);
463 : public:
464 0 : VclFrame(vcl::Window *pParent)
465 : : VclBin(pParent)
466 0 : , m_pLabel(NULL)
467 : {
468 0 : }
469 : void set_label(const OUString &rLabel);
470 : OUString get_label() const;
471 : virtual vcl::Window *get_child() SAL_OVERRIDE;
472 : virtual const vcl::Window *get_child() const SAL_OVERRIDE;
473 : vcl::Window *get_label_widget();
474 : const vcl::Window *get_label_widget() const;
475 : protected:
476 : virtual Size calculateRequisition() const SAL_OVERRIDE;
477 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
478 : virtual OUString getDefaultAccessibleName() const SAL_OVERRIDE;
479 : };
480 :
481 0 : class VCL_DLLPUBLIC VclAlignment : public VclBin
482 : {
483 : public:
484 0 : VclAlignment(vcl::Window *pParent)
485 : : VclBin(pParent)
486 : , m_nBottomPadding(0)
487 : , m_nLeftPadding(0)
488 : , m_nRightPadding(0)
489 : , m_nTopPadding(0)
490 : , m_fXAlign(0.0)
491 : , m_fXScale(1.0)
492 : , m_fYAlign(0.0)
493 0 : , m_fYScale(1.0)
494 : {
495 0 : }
496 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
497 : protected:
498 : virtual Size calculateRequisition() const SAL_OVERRIDE;
499 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
500 : private:
501 : sal_Int32 m_nBottomPadding;
502 : sal_Int32 m_nLeftPadding;
503 : sal_Int32 m_nRightPadding;
504 : sal_Int32 m_nTopPadding;
505 : float m_fXAlign;
506 : float m_fXScale;
507 : float m_fYAlign;
508 : float m_fYScale;
509 : };
510 :
511 0 : class VCL_DLLPUBLIC VclExpander : public VclBin
512 : {
513 : public:
514 0 : VclExpander(vcl::Window *pParent)
515 : : VclBin(pParent)
516 : , m_bResizeTopLevel(true)
517 0 : , m_pDisclosureButton(new DisclosureButton(this))
518 : {
519 0 : m_pDisclosureButton->SetToggleHdl(LINK(this, VclExpander, ClickHdl));
520 0 : m_pDisclosureButton->Show();
521 0 : }
522 : virtual vcl::Window *get_child() SAL_OVERRIDE;
523 : virtual const vcl::Window *get_child() const SAL_OVERRIDE;
524 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
525 0 : bool get_expanded() const
526 : {
527 0 : return m_pDisclosureButton->IsChecked();
528 : }
529 0 : void set_expanded(bool bExpanded)
530 : {
531 0 : m_pDisclosureButton->Check(bExpanded);
532 0 : }
533 0 : void set_label(const OUString& rLabel)
534 : {
535 0 : m_pDisclosureButton->SetText(rLabel);
536 0 : }
537 : OUString get_label() const
538 : {
539 : return m_pDisclosureButton->GetText();
540 : }
541 : virtual void StateChanged(StateChangedType nType) SAL_OVERRIDE;
542 0 : void SetExpandedHdl( const Link& rLink ) { maExpandedHdl = rLink; }
543 : const Link& GetExpandedHdl() const { return maExpandedHdl; }
544 : protected:
545 : virtual Size calculateRequisition() const SAL_OVERRIDE;
546 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
547 0 : void dispose() SAL_OVERRIDE { m_pDisclosureButton.clear(); VclBin::dispose(); }
548 : private:
549 : bool m_bResizeTopLevel;
550 : DisclosureButtonPtr m_pDisclosureButton;
551 : Link maExpandedHdl;
552 : DECL_DLLPRIVATE_LINK(ClickHdl, DisclosureButton* pBtn);
553 : };
554 :
555 0 : class VCL_DLLPUBLIC VclScrolledWindow : public VclBin
556 : {
557 : public:
558 : VclScrolledWindow(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN | WB_AUTOHSCROLL | WB_AUTOVSCROLL);
559 : virtual vcl::Window *get_child() SAL_OVERRIDE;
560 : virtual const vcl::Window *get_child() const SAL_OVERRIDE;
561 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
562 0 : ScrollBar& getVertScrollBar() { return *m_pVScroll.get(); }
563 0 : ScrollBar& getHorzScrollBar() { return *m_pHScroll.get(); }
564 : Size getVisibleChildSize() const;
565 : //set to true to disable the built-in scrolling callbacks to allow the user
566 : //to override it
567 0 : void setUserManagedScrolling(bool bUserManagedScrolling) { m_bUserManagedScrolling = bUserManagedScrolling;}
568 : protected:
569 : virtual Size calculateRequisition() const SAL_OVERRIDE;
570 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
571 : DECL_LINK(ScrollBarHdl, void *);
572 : void InitScrollBars(const Size &rRequest);
573 : virtual bool Notify(NotifyEvent& rNEvt) SAL_OVERRIDE;
574 0 : void dispose() SAL_OVERRIDE { m_pVScroll.clear(); m_pHScroll.clear(); VclBin::dispose(); }
575 : private:
576 : bool m_bUserManagedScrolling;
577 : ScrollBarPtr m_pVScroll;
578 : ScrollBarPtr m_pHScroll;
579 : ScrollBarBox m_aScrollBarBox;
580 : };
581 :
582 0 : class VCL_DLLPUBLIC VclViewport : public VclBin
583 : {
584 : public:
585 0 : VclViewport(vcl::Window *pParent, WinBits nStyle = WB_HIDE | WB_CLIPCHILDREN)
586 0 : : VclBin(pParent, nStyle)
587 : {
588 0 : }
589 : protected:
590 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
591 : };
592 :
593 : //Enforces that its children are always the same size as itself.
594 : //Intercepts any Commands intended for its children.
595 : //
596 : //by default the Commands are discarded, inherit from this
597 : //and implement "Command" to get them
598 0 : class VCL_DLLPUBLIC VclEventBox : public VclBin
599 : {
600 : private:
601 : //Any Commands an EventBoxHelper receives are forwarded to its parent
602 : //The VclEventBox ensures that m_aEventBoxHelper is the
603 : //first child and is transparent, but covers the rest of the children
604 0 : class EventBoxHelper : public vcl::Window
605 : {
606 : public:
607 0 : EventBoxHelper(vcl::Window* pParent)
608 0 : : Window(pParent, 0)
609 : {
610 0 : SetSizePixel(pParent->GetSizePixel());
611 0 : EnableChildTransparentMode();
612 0 : SetPaintTransparent(true);
613 0 : SetBackground();
614 0 : }
615 0 : virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE
616 : {
617 0 : GetParent()->Command(rCEvt);
618 0 : }
619 : };
620 :
621 : EventBoxHelper m_aEventBoxHelper;
622 : public:
623 0 : VclEventBox(vcl::Window* pParent)
624 : : VclBin(pParent)
625 0 : , m_aEventBoxHelper(this)
626 : {
627 0 : m_aEventBoxHelper.Show();
628 0 : }
629 : virtual vcl::Window *get_child() SAL_OVERRIDE;
630 : virtual const vcl::Window *get_child() const SAL_OVERRIDE;
631 : virtual Size calculateRequisition() const SAL_OVERRIDE;
632 : virtual void setAllocation(const Size &rAllocation) SAL_OVERRIDE;
633 :
634 : virtual void Command(const CommandEvent& rCEvt) SAL_OVERRIDE;
635 : };
636 :
637 : enum VclSizeGroupMode
638 : {
639 : VCL_SIZE_GROUP_NONE,
640 : VCL_SIZE_GROUP_HORIZONTAL,
641 : VCL_SIZE_GROUP_VERTICAL,
642 : VCL_SIZE_GROUP_BOTH
643 : };
644 :
645 738 : class VCL_DLLPUBLIC VclSizeGroup
646 : {
647 : private:
648 : std::set<vcl::Window*> m_aWindows;
649 : bool m_bIgnoreHidden;
650 : VclSizeGroupMode m_eMode;
651 :
652 : void trigger_queue_resize();
653 : public:
654 738 : VclSizeGroup()
655 : : m_bIgnoreHidden(false)
656 738 : , m_eMode(VCL_SIZE_GROUP_HORIZONTAL)
657 : {
658 738 : }
659 4428 : void insert(vcl::Window *pWindow)
660 : {
661 4428 : m_aWindows.insert(pWindow);
662 4428 : }
663 4428 : void erase(vcl::Window *pWindow)
664 : {
665 4428 : m_aWindows.erase(pWindow);
666 4428 : }
667 : const std::set<vcl::Window*>& get_widgets() const
668 : {
669 : return m_aWindows;
670 : }
671 40590 : std::set<vcl::Window*>& get_widgets()
672 : {
673 40590 : return m_aWindows;
674 : }
675 : void set_ignore_hidden(bool bIgnoreHidden);
676 13284 : bool get_ignore_hidden() const
677 : {
678 13284 : return m_bIgnoreHidden;
679 : }
680 : void set_mode(VclSizeGroupMode eMode);
681 49446 : VclSizeGroupMode get_mode() const
682 : {
683 49446 : return m_eMode;
684 : }
685 : bool set_property(const OString &rKey, const OString &rValue);
686 : };
687 :
688 : enum VclButtonsType
689 : {
690 : VCL_BUTTONS_NONE,
691 : VCL_BUTTONS_OK,
692 : VCL_BUTTONS_CLOSE,
693 : VCL_BUTTONS_CANCEL,
694 : VCL_BUTTONS_YES_NO,
695 : VCL_BUTTONS_OK_CANCEL
696 : };
697 :
698 : enum VclMessageType
699 : {
700 : VCL_MESSAGE_INFO,
701 : VCL_MESSAGE_WARNING,
702 : VCL_MESSAGE_QUESTION,
703 : VCL_MESSAGE_ERROR
704 : };
705 :
706 : class VCL_DLLPUBLIC MessageDialog : public Dialog
707 : {
708 : private:
709 : VclButtonsType m_eButtonsType;
710 : VclMessageType m_eMessageType;
711 : VclBox *m_pOwnedContentArea;
712 : VclButtonBox *m_pOwnedActionArea;
713 : VclGrid* m_pGrid;
714 : FixedImage* m_pImage;
715 : VclMultiLineEdit* m_pPrimaryMessage;
716 : VclMultiLineEdit* m_pSecondaryMessage;
717 : std::vector<PushButton*> m_aOwnedButtons;
718 : std::map<const vcl::Window*, short> m_aResponses;
719 : OUString m_sPrimaryString;
720 : OUString m_sSecondaryString;
721 : DECL_DLLPRIVATE_LINK(ButtonHdl, Button *);
722 : void setButtonHandlers(VclButtonBox *pButtonBox);
723 : short get_response(const vcl::Window *pWindow) const;
724 : void create_owned_areas();
725 :
726 : friend class VclBuilder;
727 : MessageDialog(vcl::Window* pParent, WinBits nStyle = WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE);
728 : public:
729 :
730 : MessageDialog(vcl::Window* pParent,
731 : const OUString &rMessage,
732 : VclMessageType eMessageType = VCL_MESSAGE_ERROR,
733 : VclButtonsType eButtonsType = VCL_BUTTONS_OK,
734 : WinBits nStyle = WB_MOVEABLE | WB_3DLOOK | WB_CLOSEABLE);
735 : MessageDialog(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription);
736 : virtual bool set_property(const OString &rKey, const OString &rValue) SAL_OVERRIDE;
737 : virtual short Execute() SAL_OVERRIDE;
738 : ///Emitted when an action widget is clicked
739 : virtual void response(short nResponseId);
740 : OUString get_primary_text() const;
741 : OUString get_secondary_text() const;
742 : void set_primary_text(const OUString &rPrimaryString);
743 : void set_secondary_text(const OUString &rSecondaryString);
744 : virtual ~MessageDialog();
745 :
746 : static void SetMessagesWidths(vcl::Window *pParent, VclMultiLineEdit *pPrimaryMessage,
747 : VclMultiLineEdit *pSecondaryMessage);
748 : };
749 :
750 : VCL_DLLPUBLIC Size bestmaxFrameSizeForScreenSize(const Size &rScreenSize);
751 :
752 : //Get first window of a pTopLevel window as
753 : //if any intermediate layout widgets didn't exist
754 : //i.e. acts like pChild = pChild->GetWindow(WINDOW_FIRSTCHILD);
755 : //in a flat hierarchy where dialogs only have one layer
756 : //of children
757 : VCL_DLLPUBLIC vcl::Window* firstLogicalChildOfParent(vcl::Window *pTopLevel);
758 :
759 : //Get next window after pChild of a pTopLevel window as
760 : //if any intermediate layout widgets didn't exist
761 : //i.e. acts like pChild = pChild->GetWindow(WINDOW_NEXT);
762 : //in a flat hierarchy where dialogs only have one layer
763 : //of children
764 : VCL_DLLPUBLIC vcl::Window* nextLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild);
765 :
766 : //Get previous window before pChild of a pTopLevel window as
767 : //if any intermediate layout widgets didn't exist
768 : //i.e. acts like pChild = pChild->GetWindow(WINDOW_PREV);
769 : //in a flat hierarchy where dialogs only have one layer
770 : //of children
771 : VCL_DLLPUBLIC vcl::Window* prevLogicalChildOfParent(vcl::Window *pTopLevel, vcl::Window *pChild);
772 :
773 : //Returns true is the Window has a single child which is a container
774 : VCL_DLLPUBLIC bool isLayoutEnabled(const vcl::Window *pWindow);
775 :
776 4581774 : inline bool isContainerWindow(const vcl::Window &rWindow)
777 : {
778 4581774 : WindowType eType = rWindow.GetType();
779 4581774 : return (eType == WINDOW_CONTAINER || eType == WINDOW_SCROLLWINDOW);
780 : }
781 :
782 56768 : inline bool isContainerWindow(const vcl::Window *pWindow)
783 : {
784 56768 : return pWindow && isContainerWindow(*pWindow);
785 : }
786 :
787 : //Returns true if the containing dialog is doing its initial
788 : //layout and isn't visible yet
789 : VCL_DLLPUBLIC bool isInitialLayout(const vcl::Window *pWindow);
790 :
791 : // retro-fitting utilities
792 :
793 : //Get a Size which is large enough to contain all children with
794 : //an equal amount of space at top left and bottom right
795 : Size getLegacyBestSizeForChildren(const vcl::Window &rWindow);
796 :
797 : //Get first parent which is not a layout widget
798 : VCL_DLLPUBLIC vcl::Window* getNonLayoutParent(vcl::Window *pParent);
799 :
800 : //Get first real parent which is not a layout widget
801 : vcl::Window* getNonLayoutRealParent(vcl::Window *pParent);
802 :
803 : //return true if this window and its stack of containers are all shown
804 : bool isVisibleInLayout(const vcl::Window *pWindow);
805 :
806 : //return true if this window and its stack of containers are all enabled
807 : bool isEnabledInLayout(const vcl::Window *pWindow);
808 :
809 : #endif
810 :
811 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|