xref: /AOO41X/main/cui/source/inc/grfpage.hxx (revision c4eee24dc018e70cce741d2c2ecfc43b06c69c41)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _SVX_GRFPAGE_HXX
25 #define _SVX_GRFPAGE_HXX
26 
27 #ifndef _FIXED_HXX //autogen
28 #include <vcl/fixed.hxx>
29 #endif
30 #ifndef _BUTTON_HXX //autogen
31 #include <vcl/button.hxx>
32 #endif
33 #ifndef _FIELD_HXX //autogen
34 #include <vcl/field.hxx>
35 #endif
36 #include <vcl/graph.hxx>
37 #include <sfx2/tabdlg.hxx>
38 
39 
40 class SvxGrfCropPage : public SfxTabPage
41 {
42     using Window::CalcZoom;
43     using TabPage::ActivatePage;
44     using TabPage::DeactivatePage;
45 
46     class SvxCropExample : public Window
47     {
48         Size        aFrameSize;
49         Point       aTopLeft, aBottomRight;
50         Graphic     aGrf;
51 
52     public:
53         SvxCropExample( Window* pPar, const ResId& rResId );
54 
55         virtual void Paint( const Rectangle& rRect );
56 
SetTopLeft(const Point & rNew)57         void SetTopLeft( const Point& rNew )    { aTopLeft = rNew; }
SetTop(long nVal)58         void SetTop( long nVal )                { aTopLeft.X() = nVal; }
SetBottom(long nVal)59         void SetBottom( long nVal )             { aBottomRight.X() = nVal; }
SetLeft(long nVal)60         void SetLeft( long nVal )               { aTopLeft.Y() = nVal; }
SetRight(long nVal)61         void SetRight( long nVal)               { aBottomRight.Y() = nVal; }
SetBottomRight(const Point & rNew)62         void SetBottomRight(const Point& rNew ) { aBottomRight = rNew; }
63         void SetFrameSize( const Size& rSz );
SetGraphic(const Graphic & rGrf)64         void SetGraphic( const Graphic& rGrf )  { aGrf = rGrf; }
GetGraphic() const65         const Graphic& GetGraphic() const       { return aGrf; }
66     };
67 
68     FixedLine       aCropFL;
69     RadioButton     aZoomConstRB;
70     RadioButton     aSizeConstRB;
71     FixedText       aLeftFT;
72     MetricField     aLeftMF;
73     FixedText       aRightFT;
74     MetricField     aRightMF;
75     FixedText       aTopFT;
76     MetricField     aTopMF;
77     FixedText       aBottomFT;
78     MetricField     aBottomMF;
79 
80     FixedLine       aZoomFL;
81     FixedText       aWidthZoomFT;
82     MetricField     aWidthZoomMF;
83     FixedText       aHeightZoomFT;
84     MetricField     aHeightZoomMF;
85 
86     FixedLine       aSizeFL;
87     FixedText       aWidthFT;
88     MetricField     aWidthMF;
89     FixedText       aHeightFT;
90     MetricField     aHeightMF;
91     FixedText       aOrigSizeFT;
92     PushButton      aOrigSizePB;
93 
94     // Example
95     SvxCropExample  aExampleWN;
96 
97 
98     Timer           aTimer;
99     String          aGraphicName;
100     Size            aOrigSize;
101     Size            aPageSize;
102     const MetricField*  pLastCropField;
103     long            nOldWidth;
104     long            nOldHeight;
105     sal_Bool            bReset;
106     sal_Bool            bInitialized;
107     sal_Bool            bSetOrigSize;
108 
109 
110     SvxGrfCropPage( Window *pParent, const SfxItemSet &rSet );
111     virtual ~SvxGrfCropPage();
112 
113     DECL_LINK( ZoomHdl, MetricField * );
114     DECL_LINK( SizeHdl, MetricField * );
115     DECL_LINK( CropHdl, const MetricField * );
116     DECL_LINK( CropLoseFocusHdl, MetricField * );
117     DECL_LINK( CropModifyHdl, MetricField * );
118     DECL_LINK( OrigSizeHdl, PushButton * );
119     DECL_LINK( Timeout, Timer * );
120 
121     void            CalcZoom();
122     void            CalcMinMaxBorder();
123     void            GraphicHasChanged(sal_Bool bFound);
124     virtual void    ActivatePage(const SfxItemSet& rSet);
125 
126     Size            GetGrfOrigSize( const Graphic& ) const;
127 public:
128     static SfxTabPage *Create( Window *pParent, const SfxItemSet &rSet );
129 
130     virtual sal_Bool FillItemSet( SfxItemSet &rSet );
131     virtual void Reset( const SfxItemSet &rSet );
132     virtual int DeactivatePage( SfxItemSet *pSet );
133 };
134 
135 
136 #endif
137