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 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_CUI_SOURCE_INC_GRFPAGE_HXX
21 : #define INCLUDED_CUI_SOURCE_INC_GRFPAGE_HXX
22 :
23 : #include <vcl/fixed.hxx>
24 : #include <vcl/button.hxx>
25 : #include <vcl/field.hxx>
26 : #include <vcl/graph.hxx>
27 : #include <sfx2/tabdlg.hxx>
28 :
29 0 : class SvxCropExample : public vcl::Window
30 : {
31 : Size aFrameSize;
32 : Point aTopLeft, aBottomRight;
33 : Graphic aGrf;
34 :
35 : public:
36 : SvxCropExample( vcl::Window* pPar, WinBits nStyle );
37 :
38 : virtual void Paint(vcl::RenderContext& rRenderContext, const Rectangle& rRect) SAL_OVERRIDE;
39 : virtual void Resize() SAL_OVERRIDE;
40 : virtual Size GetOptimalSize() const SAL_OVERRIDE;
41 :
42 : void SetTopLeft( const Point& rNew ) { aTopLeft = rNew; }
43 0 : void SetTop( long nVal ) { aTopLeft.X() = nVal; }
44 0 : void SetBottom( long nVal ) { aBottomRight.X() = nVal; }
45 0 : void SetLeft( long nVal ) { aTopLeft.Y() = nVal; }
46 0 : void SetRight( long nVal) { aBottomRight.Y() = nVal; }
47 : void SetBottomRight(const Point& rNew ) { aBottomRight = rNew; }
48 : void SetFrameSize( const Size& rSz );
49 0 : void SetGraphic( const Graphic& rGrf ) { aGrf = rGrf; }
50 : const Graphic& GetGraphic() const { return aGrf; }
51 : };
52 :
53 : class SvxGrfCropPage : public SfxTabPage
54 : {
55 : friend class VclPtr<SvxGrfCropPage>;
56 : using Window::CalcZoom;
57 : using TabPage::ActivatePage;
58 : using TabPage::DeactivatePage;
59 :
60 : VclPtr<VclContainer> m_pCropFrame;
61 : VclPtr<RadioButton> m_pZoomConstRB;
62 : VclPtr<RadioButton> m_pSizeConstRB;
63 : VclPtr<MetricField> m_pLeftMF;
64 : VclPtr<MetricField> m_pRightMF;
65 : VclPtr<MetricField> m_pTopMF;
66 : VclPtr<MetricField> m_pBottomMF;
67 :
68 : VclPtr<VclContainer> m_pScaleFrame;
69 : VclPtr<MetricField> m_pWidthZoomMF;
70 : VclPtr<MetricField> m_pHeightZoomMF;
71 :
72 : VclPtr<VclContainer> m_pSizeFrame;
73 : VclPtr<MetricField> m_pWidthMF;
74 : VclPtr<MetricField> m_pHeightMF;
75 :
76 : VclPtr<VclContainer> m_pOrigSizeGrid;
77 : VclPtr<FixedText> m_pOrigSizeFT;
78 : VclPtr<PushButton> m_pOrigSizePB;
79 :
80 : // Example
81 : VclPtr<SvxCropExample> m_pExampleWN;
82 :
83 :
84 : Timer aTimer;
85 : OUString aGraphicName;
86 : Size aOrigSize;
87 : Size aOrigPixelSize;
88 : Size aPageSize;
89 : VclPtr<MetricField> pLastCropField;
90 : long nOldWidth;
91 : long nOldHeight;
92 : bool bReset;
93 : bool bInitialized;
94 : bool bSetOrigSize;
95 :
96 :
97 : SvxGrfCropPage( vcl::Window *pParent, const SfxItemSet &rSet );
98 : virtual ~SvxGrfCropPage();
99 : virtual void dispose() SAL_OVERRIDE;
100 :
101 : DECL_LINK( ZoomHdl, MetricField * );
102 : DECL_LINK( SizeHdl, MetricField * );
103 : DECL_LINK( CropHdl, const MetricField * );
104 : DECL_LINK( CropLoseFocusHdl, MetricField * );
105 : DECL_LINK( CropModifyHdl, MetricField * );
106 : DECL_LINK(OrigSizeHdl, void *);
107 : DECL_LINK_TYPED(Timeout, Timer *, void);
108 :
109 : void CalcZoom();
110 : void CalcMinMaxBorder();
111 : void GraphicHasChanged(bool bFound);
112 : virtual void ActivatePage(const SfxItemSet& rSet) SAL_OVERRIDE;
113 :
114 : Size GetGrfOrigSize( const Graphic& ) const;
115 : public:
116 : static VclPtr<SfxTabPage> Create( vcl::Window *pParent, const SfxItemSet *rSet );
117 :
118 : virtual bool FillItemSet( SfxItemSet *rSet ) SAL_OVERRIDE;
119 : virtual void Reset( const SfxItemSet *rSet ) SAL_OVERRIDE;
120 : virtual sfxpg DeactivatePage( SfxItemSet *pSet ) SAL_OVERRIDE;
121 : };
122 :
123 :
124 : #endif
125 :
126 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|