xref: /trunk/main/cui/source/inc/grfpage.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
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.
14  *
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).
20  *
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.
25  *
26  ************************************************************************/
27 
28 #ifndef _SVX_GRFPAGE_HXX
29 #define _SVX_GRFPAGE_HXX
30 
31 #ifndef _FIXED_HXX //autogen
32 #include <vcl/fixed.hxx>
33 #endif
34 #ifndef _BUTTON_HXX //autogen
35 #include <vcl/button.hxx>
36 #endif
37 #ifndef _FIELD_HXX //autogen
38 #include <vcl/field.hxx>
39 #endif
40 #include <vcl/graph.hxx>
41 #include <sfx2/tabdlg.hxx>
42 
43 
44 class SvxGrfCropPage : public SfxTabPage
45 {
46     using Window::CalcZoom;
47     using TabPage::ActivatePage;
48     using TabPage::DeactivatePage;
49 
50     class SvxCropExample : public Window
51     {
52         Size        aFrameSize;
53         Point       aTopLeft, aBottomRight;
54         Graphic     aGrf;
55 
56     public:
57         SvxCropExample( Window* pPar, const ResId& rResId );
58 
59         virtual void Paint( const Rectangle& rRect );
60 
61         void SetTopLeft( const Point& rNew )    { aTopLeft = rNew; }
62         void SetTop( long nVal )                { aTopLeft.X() = nVal; }
63         void SetBottom( long nVal )             { aBottomRight.X() = nVal; }
64         void SetLeft( long nVal )               { aTopLeft.Y() = nVal; }
65         void SetRight( long nVal)               { aBottomRight.Y() = nVal; }
66         void SetBottomRight(const Point& rNew ) { aBottomRight = rNew; }
67         void SetFrameSize( const Size& rSz );
68         void SetGraphic( const Graphic& rGrf )  { aGrf = rGrf; }
69         const Graphic& GetGraphic() const       { return aGrf; }
70     };
71 
72     FixedLine       aCropFL;
73     RadioButton     aZoomConstRB;
74     RadioButton     aSizeConstRB;
75     FixedText       aLeftFT;
76     MetricField     aLeftMF;
77     FixedText       aRightFT;
78     MetricField     aRightMF;
79     FixedText       aTopFT;
80     MetricField     aTopMF;
81     FixedText       aBottomFT;
82     MetricField     aBottomMF;
83 
84     FixedLine       aZoomFL;
85     FixedText       aWidthZoomFT;
86     MetricField     aWidthZoomMF;
87     FixedText       aHeightZoomFT;
88     MetricField     aHeightZoomMF;
89 
90     FixedLine       aSizeFL;
91     FixedText       aWidthFT;
92     MetricField     aWidthMF;
93     FixedText       aHeightFT;
94     MetricField     aHeightMF;
95     FixedText       aOrigSizeFT;
96     PushButton      aOrigSizePB;
97 
98     // Example
99     SvxCropExample  aExampleWN;
100 
101 
102     Timer           aTimer;
103     String          aGraphicName;
104     Size            aOrigSize;
105     Size            aPageSize;
106     const MetricField*  pLastCropField;
107     long            nOldWidth;
108     long            nOldHeight;
109     sal_Bool            bReset;
110     sal_Bool            bInitialized;
111     sal_Bool            bSetOrigSize;
112 
113 
114     SvxGrfCropPage( Window *pParent, const SfxItemSet &rSet );
115     virtual ~SvxGrfCropPage();
116 
117     DECL_LINK( ZoomHdl, MetricField * );
118     DECL_LINK( SizeHdl, MetricField * );
119     DECL_LINK( CropHdl, const MetricField * );
120     DECL_LINK( CropLoseFocusHdl, MetricField * );
121     DECL_LINK( CropModifyHdl, MetricField * );
122     DECL_LINK( OrigSizeHdl, PushButton * );
123     DECL_LINK( Timeout, Timer * );
124 
125     void            CalcZoom();
126     void            CalcMinMaxBorder();
127     void            GraphicHasChanged(sal_Bool bFound);
128     virtual void    ActivatePage(const SfxItemSet& rSet);
129 
130     Size            GetGrfOrigSize( const Graphic& ) const;
131 public:
132     static SfxTabPage *Create( Window *pParent, const SfxItemSet &rSet );
133 
134     virtual sal_Bool FillItemSet( SfxItemSet &rSet );
135     virtual void Reset( const SfxItemSet &rSet );
136     virtual int DeactivatePage( SfxItemSet *pSet );
137 };
138 
139 
140 #endif
141