xref: /trunk/main/svx/inc/svx/bmpmask.hxx (revision 914d351e5f5b84e4342a86d6ab8d4aca7308b9bd)
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 #ifndef _BMPMASK_HXX_
24 #define _BMPMASK_HXX_
25 
26 #include <sfx2/ctrlitem.hxx>
27 #include <sfx2/dockwin.hxx>
28 #include <vcl/toolbox.hxx>
29 #include <vcl/fixed.hxx>
30 #include <vcl/group.hxx>
31 #include <vcl/graph.hxx>
32 #include "svx/svxdllapi.h"
33 
34 #include <svx/dlgctrl.hxx>
35 
36 /*************************************************************************
37 |*
38 |*  class SvxBmpMaskSelectItem
39 |*
40 \************************************************************************/
41 class SvxBmpMask;
42 
43 class SvxBmpMaskSelectItem : public SfxControllerItem
44 {
45 private:
46     SvxBmpMask  &rBmpMask;
47 
48 protected:
49     virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState,
50                                const SfxPoolItem* pState );
51 
52 public:
53     SvxBmpMaskSelectItem( sal_uInt16 nId, SvxBmpMask& rMask,
54                           SfxBindings& rBindings );
55 };
56 
57 /*************************************************************************
58 |*
59 |* Ableitung vom SfxChildWindow als 'Beh"alter' f"ur Float
60 |*
61 \************************************************************************/
62 
63 class SVX_DLLPUBLIC SvxBmpMaskChildWindow : public SfxChildWindow
64 {
65  public:
66                             SvxBmpMaskChildWindow( Window*,
67                                                    sal_uInt16, SfxBindings*,
68                                                    SfxChildWinInfo* );
69 
70     SFX_DECL_CHILDWINDOW(SvxBmpMaskChildWindow);
71 };
72 
73 /*************************************************************************
74 |*
75 |*  class SvxBmpMask
76 |*
77 \************************************************************************/
78 
79 class MaskData;
80 class MaskSet;
81 class ColorWindow;
82 
83 class SVX_DLLPUBLIC SvxBmpMask : public SfxDockingWindow
84 {
85     friend class MaskData;
86     friend class MaskSet;
87 
88     Window*             pParentWin;
89     Size                aLastSize;
90     ToolBox             aTbxPipette;
91     ColorWindow*        pCtlPipette;
92     PushButton          aBtnExec;
93     FixedLine           aGrpQ;
94 
95     FixedText           aFt1;
96     FixedText           aFt2;
97     FixedText           aFt3;
98     CheckBox            aCbx1;
99     MaskSet*            pQSet1;
100     MetricField         aSp1;
101     ColorLB             aLbColor1;
102 
103     CheckBox            aCbx2;
104     MaskSet*            pQSet2;
105     MetricField         aSp2;
106     ColorLB             aLbColor2;
107 
108     CheckBox            aCbx3;
109     MaskSet*            pQSet3;
110     MetricField         aSp3;
111     ColorLB             aLbColor3;
112 
113     CheckBox            aCbx4;
114     MaskSet*            pQSet4;
115     MetricField         aSp4;
116     ColorLB             aLbColor4;
117 
118     MaskData*           pData;
119     CheckBox            aCbxTrans;
120     ColorLB             aLbColorTrans;
121 
122     XColorListSharedPtr maColTab;
123     Color               aPipetteColor;
124     SvxBmpMaskSelectItem aSelItem;
125 
126     Image               maImgPipette;
127     Image               maImgPipetteH;
128 
129     virtual sal_Bool        Close();
130 
131 #ifdef BMPMASK_PRIVATE
132 
133     sal_uInt16              InitColorArrays( Color* pSrcCols, Color* pDstCols,
134                                          sal_uIntPtr* pTols );
135 
136     Bitmap              ImpMask( const Bitmap& rBitmap );
137     BitmapEx            ImpMask( const BitmapEx& rBitmapEx );
138     GDIMetaFile         ImpMask( const GDIMetaFile& rMtf );
139     Animation           ImpMask( const Animation& rAnimation );
140     BitmapEx            ImpMaskTransparent( const BitmapEx& rBitmapEx,
141                                             const Color& rColor,
142                                             const long nTol );
143     BitmapEx            ImpReplaceTransparency( const BitmapEx& rBmpEx,
144                                                 const Color& rColor );
145     Animation           ImpReplaceTransparency( const Animation& rAnim,
146                                                 const Color& rColor );
147     GDIMetaFile         ImpReplaceTransparency( const GDIMetaFile& rMtf,
148                                                 const Color& rColor );
149 
150 #endif // BMPMASK_PRIVATE
151 
152 public:
153 
154                         SvxBmpMask( SfxBindings *pBindinx,
155                                     SfxChildWindow *pCW,
156                                     Window* pParent,
157                                     const ResId& rResId );
158                         ~SvxBmpMask();
159 
160     void                SetColor( const Color& rColor );
161     void                PipetteClicked();
162 
163     sal_Bool                NeedsColorTable() const;
164     void                SetColorTable( XColorListSharedPtr aColorTable );
165 
166     void                SetExecState( sal_Bool bEnable );
167 
168     Graphic             Mask( const Graphic& rGraphic );
169 
170     sal_Bool                IsEyedropping() const;
171 
172     void                onSelect( MaskSet* pSet );
173 
174     virtual void DataChanged( const DataChangedEvent& rDCEvt );
175     void ApplyStyle();
176 
177 private:
178 
179     /** Set names for accessible objects.  This is necessary for objects
180         like the source color checkboxes which initially have no name and
181         for which the description would be read by AT.
182     */
183     SVX_DLLPRIVATE void SetAccessibleNames (void);
184 };
185 
186 /*************************************************************************
187 |*
188 |* Defines
189 |*
190 \************************************************************************/
191 
192 #define SVXBMPMASK() ( (SvxBmpMask*) ( SfxViewFrame::Current()->GetChildWindow(     \
193                      SvxBmpMaskChildWindow::GetChildWindowId() )->  \
194                      GetWindow() ) )
195 
196 #endif // _BMPMASK_HXX_
197