LCOV - code coverage report
Current view: top level - include/vcl - layout.hxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 132 236 55.9 %
Date: 2015-06-13 12:38:46 Functions: 65 119 54.6 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.11