File: FXDC.cpp

package info (click to toggle)
gogglesmm 1.2.5-6
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 16,812 kB
  • sloc: cpp: 231,960; ansic: 893; xml: 222; makefile: 33
file content (475 lines) | stat: -rw-r--r-- 11,583 bytes parent folder | download | duplicates (2)
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
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
/********************************************************************************
*                                                                               *
*               D e v i c e   C o n t e x t   B a s e   C l a s s               *
*                                                                               *
*********************************************************************************
* Copyright (C) 1998,2022 by Jeroen van der Zijp.   All Rights Reserved.        *
*********************************************************************************
* This library is free software; you can redistribute it and/or modify          *
* it under the terms of the GNU Lesser General Public License as published by   *
* the Free Software Foundation; either version 3 of the License, or             *
* (at your option) any later version.                                           *
*                                                                               *
* 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 program.  If not, see <http://www.gnu.org/licenses/>          *
********************************************************************************/
#include "xincs.h"
#include "fxver.h"
#include "fxdefs.h"
#include "fxmath.h"
#include "FXArray.h"
#include "FXHash.h"
#include "FXMutex.h"
#include "FXStream.h"
#include "FXString.h"
#include "FXSize.h"
#include "FXPoint.h"
#include "FXRectangle.h"
#include "FXStringDictionary.h"
#include "FXSettings.h"
#include "FXRegistry.h"
#include "FXVisual.h"
#include "FXRegion.h"
#include "FXEvent.h"
#include "FXWindow.h"
#include "FXApp.h"
#include "FXDC.h"


/*
  Notes:

  - Major Contributions for Windows NT by Lyle Johnson.

  - This is not an abstract base class; rather, its a NULL-implementation,
    i.e. drawing commands to FXDC will go to into the bit bucket.

  - All functions in the DC are virtuals.

  - A DC is associated with a certain drawing surface, using:

      FXDC::begin(FXDrawable* drawable)

    and disassociated with:

      FXDC::end()

  - While associated with a certain surface, no other association may be made
    until after the association is broken.

  - One possible exception to the above rule COULD be made: repeated locks
    on the same surface might be OK; the surface should only be unlocked
    when an equal number of unlocks takes place [[[]][]].

  - One DC object is created for all windows of the same depth and other attributes.

  - We like the OpenGL model of write-only, i.e. we [typically] don't read
    back any info from the DC. [Except stuff like device characteristics].

  - We envision the following flavors of DC's:

      1) A NULL context, in which all output goes to /dev/null

      2) A Window context, in which output goes to a on- or off-screen
         window or pixmap.

      3) A printer context, in which output is rendered e.g. as PostScript.

  - Implementations of DC's for specific target devices may cache various
    things such as patterns, stipples, colors, etc, so as to optimize performance.

  - Since DC's may be shared between windows, you should leave the DC in the
    same state as you found it before releasing it.

  - You acquire a DC by asking the drawable surface on which you want to draw
    for a DC.  You receive a subclass of FXDC, and have no knowledge of device
    specific details, except as revealed by the basic FXDC API's.

  - After you're through with drawing, you should release the DC.

  - Motto: Nobody knows about any other DC that FXDC!!!  The other ones
    are implementations, not directly accessible by any but a few select
    FOX implementation files.

  - In FOX, a FXDC is NOT a wrapper class:- we do NOT assume the O.S. provides
    its own DC abstraction:- hence all those virtuals.
    This also means it is possible to make your own, simply by subclassing FXDC!
*/

using namespace FX;

/*******************************************************************************/

namespace FX {

// Initialize nicely
FXDC::FXDC(FXApp* a):app(a){
  ctx=nullptr;
  font=nullptr;
  pattern=STIPPLE_NONE;
  stipple=nullptr;
  tile=nullptr;
  mask=nullptr;
  clip.x=0;
  clip.y=0;
  clip.w=32767;
  clip.h=32767;
  fg=0;
  bg=1;
  width=1;      // SANDER FIX
  cap=CAP_BUTT;
  join=JOIN_MITER;
  style=LINE_SOLID;
  fill=FILL_SOLID;
  rule=RULE_EVEN_ODD;
  rop=BLT_SRC;
  fillElms(dashpat,4,32);
  dashpat[0]=4;
  dashpat[1]=4;
  dashlen=2;
  dashoff=0;
  tx=0;
  ty=0;
  cx=0;
  cy=0;
  }


// Read back pixel
FXColor FXDC::readPixel(FXint,FXint){ return FXRGBA(0,0,0,0); }


// Draw a point in the current pen color
void FXDC::drawPoint(FXint,FXint){ }


// Draw points in the current pen color.
// Each point's position is relative to the drawable's origin (as usual).
void FXDC::drawPoints(const FXPoint*,FXuint){ }


// Draw points in the current pen color. The first point's position is
// relative to the drawable's origin, but each subsequent point's position
// is relative to the previous point's position; each FXPoint defines
// the relative coordinates. Think LOGO.
void FXDC::drawPointsRel(const FXPoint*,FXuint){ }


// Draw a line
void FXDC::drawLine(FXint,FXint,FXint,FXint){ }



// Draw multiple lines. All points are drawn connected.
// Each point is specified relative to Drawable's origin.
void FXDC::drawLines(const FXPoint*,FXuint){ }



// Draw multiple lines. All points are drawn connected.
// First point's coordinate is relative to drawable's origin, but
// subsequent points' coordinates are relative to previous point.
void FXDC::drawLinesRel(const FXPoint*,FXuint){ }


// Draw unconnected line segments
void FXDC::drawLineSegments(const FXSegment*,FXuint){ }


// Draw unfilled rectangle
void FXDC::drawRectangle(FXint,FXint,FXint,FXint){ }


// Draw unfilled rectangles
void FXDC::drawRectangles(const FXRectangle*,FXuint){ }


// Draw unfilled rounded rectangle
void FXDC::drawRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){ }


// Draw arc
void FXDC::drawArc(FXint,FXint,FXint,FXint,FXint,FXint){ }


// Draw arcs
void FXDC::drawArcs(const FXArc*,FXuint){ }


// Draw ellipse
void FXDC::drawEllipse(FXint,FXint,FXint,FXint){ }


// Filled rectangle
void FXDC::fillRectangle(FXint,FXint,FXint,FXint){ }


// Filled rectangles
void FXDC::fillRectangles(const FXRectangle*,FXuint){ }


// Filled rounded rectangle
void FXDC::fillRoundRectangle(FXint,FXint,FXint,FXint,FXint,FXint){ }


// Fill chord
void FXDC::fillChord(FXint,FXint,FXint,FXint,FXint,FXint){ }


// Fill chords
void FXDC::fillChords(const FXArc*,FXuint){ }


// Fill arc
void FXDC::fillArc(FXint,FXint,FXint,FXint,FXint,FXint){ }


// Fill arcs
void FXDC::fillArcs(const FXArc*,FXuint){ }


// Fill ellipse
void FXDC::fillEllipse(FXint,FXint,FXint,FXint){ }


// Filled simple polygon
void FXDC::fillPolygon(const FXPoint*,FXuint){ }


// Fill concave polygon
void FXDC::fillConcavePolygon(const FXPoint*,FXuint){ }


// Fill complex (self-intersecting) polygon
void FXDC::fillComplexPolygon(const FXPoint*,FXuint){ }


// Filled simple polygon with relative points
void FXDC::fillPolygonRel(const FXPoint*,FXuint){ }


// Fill concave polygon
void FXDC::fillConcavePolygonRel(const FXPoint*,FXuint){ }


// Fill complex (self-intersecting) polygon
void FXDC::fillComplexPolygonRel(const FXPoint*,FXuint){ }


// Fill vertical gradient rectangle
void FXDC::fillVerticalGradient(FXint,FXint,FXint,FXint,FXColor,FXColor){ }


// Fill horizontal gradient rectangle
void FXDC::fillHorizontalGradient(FXint,FXint,FXint,FXint,FXColor,FXColor){ }


// Draw string with base line starting at x, y
void FXDC::drawText(FXint,FXint,const FXchar*,FXuint){ }


// Draw string with base line starting at x, y
void FXDC::drawText(FXint,FXint,const FXString&){ }


// Draw text starting at x, y over filled background
void FXDC::drawImageText(FXint,FXint,const FXchar*,FXuint){ }


// Draw text starting at x, y over filled background
void FXDC::drawImageText(FXint,FXint,const FXString&){ }


// Draw area from source
void FXDC::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint){ }


// Draw area stretched area from source
void FXDC::drawArea(const FXDrawable*,FXint,FXint,FXint,FXint,FXint,FXint,FXint,FXint){ }


// Draw image
void FXDC::drawImage(const FXImage*,FXint,FXint){ }


// Draw bitmap
void FXDC::drawBitmap(const FXBitmap*,FXint,FXint){ }


// Draw icon
void FXDC::drawIcon(const FXIcon*,FXint,FXint){ }


// Draw icon shaded
void FXDC::drawIconShaded(const FXIcon*,FXint,FXint){ }


// Draw icon sunken
void FXDC::drawIconSunken(const FXIcon*,FXint,FXint){ }


// Draw hashed box
void FXDC::drawHashBox(FXint,FXint,FXint,FXint,FXint){ }


// Draw focus rectangle
void FXDC::drawFocusRectangle(FXint,FXint,FXint,FXint){ }


// Set foreground drawing color (brush)
void FXDC::setForeground(FXColor clr){
  fg=clr;
  }


// Set background drawing color (brush)
void FXDC::setBackground(FXColor clr){
  bg=clr;
  }


// Set dash pattern
void FXDC::setDashes(FXuint dashoffset,const FXuchar *dashpattern,FXuint dashlength){
  FXuint len=0;
  if(dashlen<1 || dashlength>32){ fxerror("FXDC::setDashes: bad dashlength parameter.\n"); }
  for(FXuint i=0; i<dashlength; i++){
    dashpat[i]=dashpattern[i];
    len+=dashpattern[i];
    }
  dashlen=dashlength;
  dashoff=dashoffset%len;
  }


// Set line width
void FXDC::setLineWidth(FXuint linewidth){
  width=linewidth;
  }


// Set line cap style
void FXDC::setLineCap(FXCapStyle capstyle){
  cap=capstyle;
  }


// Set line join style
void FXDC::setLineJoin(FXJoinStyle joinstyle){
  join=joinstyle;
  }


// Set line style
void FXDC::setLineStyle(FXLineStyle linestyle){
  style=linestyle;
  }


// Set fill style
void FXDC::setFillStyle(FXFillStyle fillstyle){
  fill=fillstyle;
  }


// Set fill rule
void FXDC::setFillRule(FXFillRule fillrule){
  rule=fillrule;
  }


// Set blit function
void FXDC::setFunction(FXFunction func){
  rop=func;
  }


// Set tile image
void FXDC::setTile(FXImage* image,FXint dx,FXint dy){
  tile=image;
  tx=dx;
  ty=dy;
  }


// Set stipple bitmap
void FXDC::setStipple(FXBitmap* bitmap,FXint dx,FXint dy){
  stipple=bitmap;
  pattern=STIPPLE_NONE;
  tx=dx;
  ty=dy;
  }


// Set stipple pattern
void FXDC::setStipple(FXStipplePattern pat,FXint dx,FXint dy){
  pattern=pat;
  stipple=nullptr;
  tx=dx;
  ty=dy;
  }


// Set clip region
void FXDC::setClipRegion(const FXRegion&){
  }


// Set clip rectangle
void FXDC::setClipRectangle(FXint x,FXint y,FXint w,FXint h){
  clip.x=x;
  clip.y=y;
  clip.w=w;
  clip.h=h;
  }


// Set clip rectangle
void FXDC::setClipRectangle(const FXRectangle& rectangle){
  clip=rectangle;
  }


// Clear clipping
void FXDC::clearClipRectangle(){
  clip.x=0;
  clip.y=0;
  clip.w=32767;
  clip.h=32767;
  }


// Set clip mask
void FXDC::setClipMask(FXBitmap* bitmap,FXint dx,FXint dy){
  mask=bitmap;
  cx=dx;
  cy=dy;
  }


// Clear clip mask
void FXDC::clearClipMask(){
  mask=nullptr;
  cx=0;
  cy=0;
  }


// Set font to draw text with
void FXDC::setFont(FXFont *fnt){
  font=fnt;
  }


// Change clip-against-child windows mode
void FXDC::clipChildren(FXbool){ }


// Clean up
FXDC::~FXDC(){ }

}