summaryrefslogtreecommitdiff
path: root/vcl/unx/inc/salgdi.h
blob: eaa0651a3cd77451a5eb1e1683e445233ea7413f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
/*************************************************************************
 *
 *  $RCSfile: salgdi.h,v $
 *
 *  $Revision: 1.1.1.1 $
 *
 *  last change: $Author: hr $ $Date: 2000-09-18 17:05:41 $
 *
 *  The Contents of this file are made available subject to the terms of
 *  either of the following licenses
 *
 *         - GNU Lesser General Public License Version 2.1
 *         - Sun Industry Standards Source License Version 1.1
 *
 *  Sun Microsystems Inc., October, 2000
 *
 *  GNU Lesser General Public License Version 2.1
 *  =============================================
 *  Copyright 2000 by Sun Microsystems, Inc.
 *  901 San Antonio Road, Palo Alto, CA 94303, USA
 *
 *  This library is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public
 *  License version 2.1, as published by the Free Software Foundation.
 *
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 *  Lesser General Public License for more details.
 *
 *  You should have received a copy of the GNU Lesser General Public
 *  License along with this library; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 *  MA  02111-1307  USA
 *
 *
 *  Sun Industry Standards Source License Version 1.1
 *  =================================================
 *  The contents of this file are subject to the Sun Industry Standards
 *  Source License Version 1.1 (the "License"); You may not use this file
 *  except in compliance with the License. You may obtain a copy of the
 *  License at http://www.openoffice.org/license.html.
 *
 *  Software provided under this License is provided on an "AS IS" basis,
 *  WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
 *  WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
 *  MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
 *  See the License for the specific provisions governing your rights and
 *  obligations concerning the Software.
 *
 *  The Initial Developer of the Original Code is: Sun Microsystems, Inc.
 *
 *  Copyright: 2000 by Sun Microsystems, Inc.
 *
 *  All Rights Reserved.
 *
 *  Contributor(s): _______________________________________
 *
 *
 ************************************************************************/
// *=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-//
//                                                                            //
// (C) 1997 Star Division GmbH, Hamburg, Germany                              //
//                                                                            //
// $Revision: 1.1.1.1 $  $Author: hr $  $Date: 2000-09-18 17:05:41 $   //
//                                                                            //
// $Workfile:   salgdi.h  $                                                   //
//  $Modtime:   10 Sep 1997 11:55:36  $                                       //
//                                                                            //
// *=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-*=*-//

#ifndef _SV_SALGDI_H
#define _SV_SALGDI_H

// -=-= exports -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
class   SalFontCacheItem;
class   SalGraphicsContext;
class   SalGraphicsData;

// -=-= includes -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#ifndef _SALSTD_HXX
#include <salstd.hxx>
#endif
#ifndef _SV_SALGTYPE_HXX
#include <salgtype.hxx>
#endif
#ifndef _FRACT_HXX
#include <tools/fract.hxx>
#endif

#include "xfont.hxx"

// -=-= forwards -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
struct  ImplFontMetricData;
struct  ImplFontSelectData;
class   SalBitmap;
class   SalColormap;
class   SalDisplay;
class   SalFrame;
class   SalVirtualDevice;
class   SalPolyLine;

#ifndef _SV_SALDISP_HXX
typedef SalColormap        *SalColormapRef;
#endif

// -=-= SalGraphicsData =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

class SalGraphicsData
{
    friend  class           SalGraphics;

                            STDAPI( SalGraphicsData )

            SalColormapRef  xColormap_;
            Drawable        hDrawable_;         // use

            XLIB_Region     pPaintRegion_;
            XLIB_Region     pClipRegion_;

            GC              pPenGC_;            // Pen attributes
            SalColor        nPenColor_;
            Pixel           nPenPixel_;

            GC              pFontGC_;           // Font attributes
            ExtendedFontStructRef       xFont_;
            Fraction        aScale_;
            SalColor        nTextColor_;
            Pixel           nTextPixel_;
            short           nFontOrientation_;

            GC              pBrushGC_;          // Brush attributes
            SalColor        nBrushColor_;
            Pixel           nBrushPixel_;
            Pixmap          hBrush_;            // Dither

             GC             pMonoGC_;
            GC              pCopyGC_;
             GC             pMaskGC_;
            GC              pInvertGC_;
            GC              pInvert50GC_;
            GC              pStippleGC_;
            GC              pTrackingGC_;

            BOOL            bWindow_ : 1;       // is Window
            BOOL            bPrinter_ : 1;      // is Printer
            BOOL            bVirDev_ : 1;       // is VirDev
            BOOL            bPenGC_ : 1;        // is Pen GC valid
            BOOL            bFontGC_ : 1;       // is Font GC valid
            BOOL            bBrushGC_ : 1;      // is Brush GC valid
            BOOL            bMonoGC_ : 1;       // is Mono GC valid
            BOOL            bCopyGC_ : 1;       // is Copy GC valid
            BOOL            bInvertGC_ : 1;     // is Invert GC valid
            BOOL            bInvert50GC_ : 1;   // is Invert50 GC valid
            BOOL            bStippleGC_ : 1;    // is Stipple GC valid
            BOOL            bTrackingGC_ : 1;   // is Tracking GC valid
            BOOL            bXORMode_ : 1;      // is ROP XOR Mode set
            BOOL            bDitherBrush_ : 1;  // is solid or tile

            void            SetClipRegion( GC          pGC,
                                           XLIB_Region pXReg = NULL ) const;


#if defined(_SV_SALGDI_CXX) || defined (_SV_SALGDI2_CXX)
            GC              GetTrackingGC();
            GC              GetInvertGC();
            GC              GetInvert50GC();
            GC              CreateGC( Drawable      hDrawable,
                                      unsigned long nMask = GCGraphicsExposures );
#endif

#if defined _SV_SALGDI_CXX
            GC              SelectPen();
            GC              SelectBrush();
            void            DrawLines( ULONG              nPoints,
                                       const SalPolyLine &rPoints,
                                       GC                 pGC );
            BOOL            GetDitherPixmap ( SalColor nSalColor );
#endif

#if defined _SV_SALGDI2_CXX

    inline  GC              GetMonoGC( Pixmap hPixmap );
    inline  GC              GetCopyGC();
    inline  GC              GetStippleGC();

            int             Clip      ( XLIB_Region   pRegion,
                                        int          &nX,
                                        int          &nY,
                                        unsigned int &nDX,
                                        unsigned int &nDY,
                                        int          &nSrcX,
                                        int          &nSrcY ) const;
            int             Clip      ( int          &nX,
                                        int          &nY,
                                        unsigned int &nDX,
                                        unsigned int &nDY,
                                        int          &nSrcX,
                                        int          &nSrcY ) const;
            GC              SetMask   ( int          &nX,
                                        int          &nY,
                                        unsigned int &nDX,
                                        unsigned int &nDY,
                                        int          &nSrcX,
                                        int          &nSrcY,
                                        Pixmap        hClipMask );
            void            DrawBitmap( const SalTwoRect *pPosAry,
                                        SalGraphics      *pThis,
                                        const SalBitmap  &rSalBitmap,
                                        const SalBitmap  &rTransparentBitmap,
                                        SalColor          nTransparentColor );
#endif

#if defined _SV_SALGDI3_CXX
            GC              SelectFont();

            void            SetFont( const ImplFontSelectData* pEntry );
            void            DrawText( long          nX,
                                      long          nY,
                                      const xub_Unicode* pStr,
                                      USHORT        nLen,
                                      const long*   pDXAry );
            void            DrawText( long nX,
                                      long nY,
                                      const xub_Unicode* pStr,
                                      USHORT nLen );
#endif
public:
                            SalGraphicsData();
                            ~SalGraphicsData();

            void            Init( SalFrame         *pFrame );
            void            Init( SalVirtualDevice *pVirtualDevice,
                                  SalGraphics      *pSalGraphics );
            void            Init( class ImplSalPrinterData  *pPrinter );
            void            DeInit();

    inline  SalDisplay     *GetDisplay() const;
    inline  Display        *GetXDisplay() const;
    inline  Drawable        GetDrawable() const { return hDrawable_; }
    inline  void            SetDrawable( Drawable d ) { hDrawable_ = d; }
    inline  SalColormap    &GetColormap() const { return *xColormap_; }
    inline  BOOL            IsCompatible( USHORT       nDepth,
                                          SalColormap *pMap ) const;
    inline  Pixel           GetPixel( SalColor nSalColor ) const;
};

#ifdef _SV_SALDATA_HXX

inline SalDisplay *SalGraphicsData::GetDisplay() const
{ return GetColormap().GetDisplay(); }

inline Display *SalGraphicsData::GetXDisplay() const
{ return GetColormap().GetXDisplay(); }

inline BOOL SalGraphicsData::IsCompatible( USHORT       nDepth,
                                           SalColormap *pMap ) const
{
    return (GetDisplay()->GetImageDepths() & (1 << (nDepth-1))) != 0
           && &xColormap_ == pMap;
}

inline Pixel SalGraphicsData::GetPixel( SalColor nSalColor ) const
{ return GetColormap().GetPixel( nSalColor ); }

#endif

// -=-= Shortcuts =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
#if defined _SV_SALGDI_CXX || defined _SV_SALGDI2_CXX || defined _SV_SALGDI3_CXX
#define _GetXDisplay()      maGraphicsData.GetXDisplay()
#define _GetDisplay()       maGraphicsData.GetDisplay()
#define _GetVisual()        maGraphicsData.GetDisplay()->GetVisual()
#define _GetDrawable()      maGraphicsData.hDrawable_
#define _GetColormap()      maGraphicsData.GetColormap()
#define _GetClipRegion()    maGraphicsData.pClipRegion_
#define _GetPenPixel()      maGraphicsData.nPenPixel_
#define _GetTextPixel()     maGraphicsData.nTextPixel_
#define _GetBrushPixel()    maGraphicsData.nBrushPixel_
#define _GetPenColor()      maGraphicsData.nPenColor_
#define _GetTextColor()     maGraphicsData.nTextColor_
#define _GetBrushColor()    maGraphicsData.nBrushColor_
#define _GetPixel(n)        maGraphicsData.GetPixel( n )
#define _GetColor(n)        maGraphicsData.GetColormap().GetColor( n )
#define _IsPenGC()          maGraphicsData.bPenGC_
#define _IsFontGC()         maGraphicsData.bFontGC_
#define _IsBrushGC()        maGraphicsData.bBrushGC_
#define _IsMonoGC()         maGraphicsData.bMonoGC_
#define _IsCopyGC()         maGraphicsData.bCopyGC_
#define _IsInvertGC()       maGraphicsData.bInvertGC_
#define _IsInvert50GC()     maGraphicsData.bInvert50GC_
#define _IsStippleGC()      maGraphicsData.bStippleGC_
#define _IsTrackingGC()     maGraphicsData.bTrackingGC_
#define _IsXORMode()        maGraphicsData.bXORMode_
#define _IsWindow()         maGraphicsData.bWindow_
#define _IsPrinter()        maGraphicsData.bPrinter_
#define _IsVirtualDevice()  maGraphicsData.bVirDev_
#define _IsDitherBrush()    maGraphicsData.bDitherBrush_
#define _SelectPen()        maGraphicsData.SelectPen()
#define _SelectBrush()      maGraphicsData.SelectBrush()
#define _GetTrackingGC()    maGraphicsData.GetTrackingGC()
#endif

#ifdef DBG_UTIL
#define stderr0( s )            fprintf( stderr, s )
#define stderr1( s, a )         fprintf( stderr, s, a )
#define stderr2( s, a, b )      fprintf( stderr, s, a, b )
#define stderr3( s, a, b, c )   fprintf( stderr, s, a, b, c )
#define stdass0( b )            (void)( !(b) \
                                        ? fprintf( stderr, "\"%s\" (%s line %d)\n", \
                                                    #b, __FILE__, __LINE__ ) \
                                        : 0 )
#else
#define stderr0( s )            nop
#define stderr1( s, a )         nop
#define stderr2( s, a, b )      nop
#define stderr3( s, a, b, c )   nop
#define stdass0( b )            nop
#endif
#endif // _SV_SALGDI_H