~ubuntu-branches/ubuntu/saucy/fltk1.1/saucy-proposed

« back to all changes in this revision

Viewing changes to src/fl_overlay.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2008-03-29 09:48:46 UTC
  • mto: (2.1.10 intrepid)
  • mto: This revision was merged to the branch mainline in revision 5.
  • Revision ID: james.westby@ubuntu.com-20080329094846-cof1xqv7t0dnv0bc
Tags: upstream-1.1.8
ImportĀ upstreamĀ versionĀ 1.1.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: fl_overlay.cxx 4288 2005-04-16 00:13:17Z mike $"
 
2
// "$Id: fl_overlay.cxx 5614 2007-01-18 15:25:09Z matt $"
3
3
//
4
4
// Overlay support for the Fast Light Tool Kit (FLTK).
5
5
//
36
36
#include <config.h>
37
37
#endif
38
38
 
 
39
//#define USE_XOR
 
40
 
39
41
static int px,py,pw,ph;
40
42
 
 
43
#ifndef USE_XOR
 
44
#include <stdlib.h>
 
45
static uchar *bgN = 0L, *bgS = 0L, *bgE = 0L, *bgW = 0L;
 
46
static int bgx, bgy, bgw, bgh;
 
47
#endif
 
48
 
41
49
static void draw_current_rect() {
42
 
#ifdef WIN32
 
50
#ifdef USE_XOR
 
51
# ifdef WIN32
43
52
  int old = SetROP2(fl_gc, R2_NOT);
44
53
  fl_rect(px, py, pw, ph);
45
54
  SetROP2(fl_gc, old);
46
 
#elif defined(__APPLE_QD__)
 
55
# elif defined(__APPLE_QD__)
47
56
  PenMode( patXor );
48
57
  fl_rect(px, py, pw, ph);
49
58
  PenMode( patCopy );
50
 
#elif defined(__APPLE_QUARTZ__)
 
59
# elif defined(__APPLE_QUARTZ__)
51
60
  // warning: Quartz does not support xor drawing
52
61
  // Use the Fl_Overlay_Window instead.
 
62
  fl_color(FL_WHITE);
53
63
  fl_rect(px, py, pw, ph);
54
 
#else
 
64
# else
55
65
  XSetFunction(fl_display, fl_gc, GXxor);
56
66
  XSetForeground(fl_display, fl_gc, 0xffffffff);
57
67
  XDrawRectangle(fl_display, fl_window, fl_gc, px, py, pw, ph);
58
68
  XSetFunction(fl_display, fl_gc, GXcopy);
 
69
# endif
 
70
#else
 
71
  if (bgN) { free(bgN); bgN = 0L; }
 
72
  if (bgS) { free(bgS); bgS = 0L; }
 
73
  if (bgE) { free(bgE); bgE = 0L; }
 
74
  if (bgW) { free(bgW); bgW = 0L; }
 
75
  if (pw>0 && ph>0) {
 
76
    bgE = fl_read_image(0L, px+pw-1, py, 1, ph);
 
77
    bgW = fl_read_image(0L, px, py, 1, ph);
 
78
    bgS = fl_read_image(0L, px, py+ph-1, pw, 1);
 
79
    bgN = fl_read_image(0L, px, py, pw, 1);
 
80
    bgx = px; bgy = py;
 
81
    bgw = pw; bgh = ph;
 
82
  }
 
83
  fl_color(FL_WHITE);
 
84
  fl_line_style(FL_SOLID);
 
85
  fl_rect(px, py, pw, ph);
 
86
  fl_color(FL_BLACK);
 
87
  fl_line_style(FL_DOT);
 
88
  fl_rect(px, py, pw, ph);
 
89
  fl_line_style(FL_SOLID);
 
90
#endif
 
91
}
 
92
 
 
93
static void erase_current_rect() {
 
94
#ifdef USE_XOR
 
95
# ifdef __APPLE_QUARTZ__
 
96
  fl_rect(px, py, pw, ph);
 
97
# else
 
98
  draw_current_rect();
 
99
# endif
 
100
#else
 
101
  if (bgN) fl_draw_image(bgN, bgx, bgy, bgw, 1);
 
102
  if (bgS) fl_draw_image(bgS, bgx, bgy+bgh-1, bgw, 1);
 
103
  if (bgW) fl_draw_image(bgW, bgx, bgy, 1, bgh);
 
104
  if (bgE) fl_draw_image(bgE, bgx+bgw-1, bgy, 1, bgh);
59
105
#endif
60
106
}
61
107
 
62
108
void fl_overlay_clear() {
63
 
  if (pw > 0) {draw_current_rect(); pw = 0;}
 
109
  if (pw > 0) {erase_current_rect(); pw = 0;}
64
110
}
65
111
 
66
112
void fl_overlay_rect(int x, int y, int w, int h) {
68
114
  if (h < 0) {y += h; h = -h;} else if (!h) h = 1;
69
115
  if (pw > 0) {
70
116
    if (x==px && y==py && w==pw && h==ph) return;
71
 
    draw_current_rect();
 
117
    erase_current_rect();
72
118
  }
73
119
  px = x; py = y; pw = w; ph = h;
74
120
  draw_current_rect();
75
121
}
76
122
 
77
123
//
78
 
// End of "$Id: fl_overlay.cxx 4288 2005-04-16 00:13:17Z mike $".
 
124
// End of "$Id: fl_overlay.cxx 5614 2007-01-18 15:25:09Z matt $".
79
125
//