OSDN Git Service

最初のコミット
[winaudioj/stedx.git] / win32_graphics.cpp
1 /*
2   win32_graphics.cpp
3   base class of screen driver
4
5   Made by Studio Breeze. 2002
6
7   Permission is hereby granted, free of charge, to any person obtaining a copy
8   of this software and associated documentation files (the "Software"), to deal
9   in the Software without restriction, including without limitation the rights
10   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11   copies of the Software, and to permit persons to whom the Software is
12   furnished to do so, subject to the following conditions:
13
14   The above copyright notice and this permission notice shall be included in
15   all copies or substantial portions of the Software.
16
17   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
20   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23   THE SOFTWARE.
24  */
25 #include "stdafx.h"
26 #include "sted_screen_win32.h"
27
28 // graphics
29
30 // private
31
32 BOOL
33 CSTedScreenWin32::toWindowPos(int in_x, int in_y, int *out_x, int *out_y)
34 {
35   if (out_x) *out_x = fWindowWidth * in_x / fX68WindowWidth;
36   if (out_y) *out_y = fWindowHeight * (in_y%fX68WindowHeight) / fX68WindowHeight;
37   return TRUE;
38 }
39
40 // apis
41
42 void
43 CSTedScreenWin32::TextXBox(int in_x0, int in_y0, int in_x1, int in_y1, int in_page)
44 {
45   int x0, y0, x1, y1;
46   HBRUSH br, mbr;
47   COLORREF c;
48   RECT r;
49
50   c = PageToColor(in_page);
51   if (!toWindowPos(in_x0, in_y0, &x0, &y0)) return;
52   if (!toWindowPos(in_x1, in_y1, &x1, &y1)) return;
53
54   ::SetRect(&r, x0, y0, x1, y1);
55   //zz
56   D2D1_RECT_F r1(D2D1::RectF(x0,y0,x1,y1));
57   D2D1_COLOR_F color = D2D1::ColorF(c);
58   ID2D1SolidColorBrushPtr color_brush;
59
60   text_bitmap_target_->CreateSolidColorBrush(color,&color_brush);
61   {
62     sf::begin_draw<ID2D1BitmapRenderTargetPtr> b(text_bitmap_target_);
63
64     D2D1_ANTIALIAS_MODE backup(text_bitmap_target_->GetAntialiasMode());
65     text_bitmap_target_->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
66
67     if (in_page != 0) 
68     {
69       text_bitmap_target_->DrawRectangle(r1,color_brush);
70             //br = ::CreateSolidBrush(c);
71             //mbr = MASK_ON;
72     } else {
73       text_bitmap_target_->DrawRectangle(r1,brush_text_clear_);
74             //br = fBrushTextClear;
75             //mbr = MASK_OFF;
76     }
77     text_bitmap_target_->SetAntialiasMode(backup);
78     THROW_IF_ERR(b.end_draw());
79   }
80 //  if (!br) return;
81
82 //  ::FrameRect(fTextDC, &r, br);
83 //  ::FrameRect(fTextMaskDC, &r, MASK_ON);
84
85 //  if (in_page!=0)
86 //        ::DeleteObject(br);
87   InvalidateRect(&r);
88 }
89
90 void 
91 CSTedScreenWin32::TextXXLine(int in_page, int in_x, int in_y, int in_w, int in_linestyle)
92 {
93   int x0, x1;
94   int y;
95   HPEN p,mp;
96   HPEN orig, morig;
97
98   if (!toWindowPos(in_x, in_y, &x0, &y)) return;
99   if (!toWindowPos(in_x + in_w, in_y, &x1, &y)) return;
100
101   ID2D1SolidColorBrushPtr brush;
102   
103   
104   sf::begin_draw_bitmap begin(text_bitmap_target_);
105
106   if (in_linestyle != 0 /*&& in_page!=0*/) {
107     text_bitmap_target_->CreateSolidColorBrush(D2D1::ColorF(PageToColor(in_page)),&brush);
108   } else {
109     text_bitmap_target_->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White),&brush);
110   }
111
112   D2D1_ANTIALIAS_MODE backup(text_bitmap_target_->GetAntialiasMode());
113   text_bitmap_target_->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
114   text_bitmap_target_->DrawLine(D2D1::Point2F(x0,y),D2D1::Point2F(x1,y),brush);
115   text_bitmap_target_->SetAntialiasMode(backup);
116
117   //if (in_linestyle != 0 /*&& in_page!=0*/) 
118   //{
119          // p = ::CreatePen(PS_SOLID, 1, PageToColor(in_page));
120          // mp = ::CreatePen(PS_SOLID, 1, RGB(0xff, 0xff, 0xff));
121   //} else {
122          // p = ::CreatePen(PS_SOLID, 1, RGB(0xff, 0xff, 0xff));
123          // mp = ::CreatePen(PS_SOLID, 1, RGB(0x00, 0x00, 0x00));
124   //}
125
126   //if (!p || !mp) 
127   //{
128          // if (p) ::DeleteObject(p);
129          // if (mp) ::DeleteObject(mp);
130          // return;
131   //}
132
133   //orig = (HPEN)::SelectObject(fTextDC, p);
134   //morig = (HPEN)::SelectObject(fTextMaskDC, mp);
135
136   //::MoveToEx(fTextDC, x0,y, NULL);
137   //::LineTo(fTextDC, x1,y);
138   //::MoveToEx(fTextMaskDC, x0,y, NULL);
139   //::LineTo(fTextMaskDC, x1,y);
140
141   //::SelectObject(fTextDC, orig);
142   //::SelectObject(fTextMaskDC, morig);
143   //if (p) ::DeleteObject(p);
144   //if (mp) ::DeleteObject(mp);
145   THROW_IF_ERR(begin.end_draw());
146
147   InvalidateRect(x0,y,x1-x0,1);
148 }
149
150 void
151 CSTedScreenWin32::TextXYLine(int in_page, int in_x, int in_y, int in_h, int in_linestyle)
152 {
153   int x;
154   int y0, y1;
155   HPEN p,mp;
156   HPEN orig, morig;
157
158   if (!toWindowPos(in_x, in_y, &x, &y0)) return;
159   if (!toWindowPos(in_x, in_y+in_h, &x, &y1)) return;
160
161   ID2D1SolidColorBrushPtr brush;
162   sf::begin_draw_bitmap begin(text_bitmap_target_);
163
164   if (in_linestyle != 0 /*&& in_page!=0*/) {
165     text_bitmap_target_->CreateSolidColorBrush(D2D1::ColorF(PageToColor(in_page)),&brush);
166   } else {
167     text_bitmap_target_->CreateSolidColorBrush(D2D1::ColorF(D2D1::ColorF::White),&brush);
168   }
169   D2D1_ANTIALIAS_MODE backup(text_bitmap_target_->GetAntialiasMode());
170   text_bitmap_target_->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
171   text_bitmap_target_->DrawLine(D2D1::Point2F(x,y0),D2D1::Point2F(x,y1),brush);
172   text_bitmap_target_->SetAntialiasMode(backup);
173
174   THROW_IF_ERR(begin.end_draw());
175
176   //if (in_linestyle!=0 /*&& in_page!=0*/) {
177          // p = ::CreatePen(PS_SOLID, 1, PageToColor(in_page));
178          // mp = ::CreatePen(PS_SOLID, 1, RGB(0xff, 0xff, 0xff));
179   //} else {
180          // p = ::CreatePen(PS_SOLID, 1, RGB(0xff, 0xff, 0xff));
181          // mp = ::CreatePen(PS_SOLID, 1, RGB(0x00, 0x00, 0x00));
182   //}
183   //if (!p || !mp) {
184          // if (p) ::DeleteObject(p);
185          // if (mp) ::DeleteObject(mp);
186          // return;
187   //}
188
189   //orig = (HPEN)::SelectObject(fTextDC, p);
190   //morig = (HPEN)::SelectObject(fTextMaskDC, mp);
191
192   //::MoveToEx(fTextDC, x,y0, NULL);
193   //::LineTo(fTextDC, x,y1);
194   //::MoveToEx(fTextMaskDC, x,y0, NULL);
195   //::LineTo(fTextMaskDC, x,y1);
196
197   //::SelectObject(fTextDC, orig);
198   //::SelectObject(fTextMaskDC, morig);
199   //if (p) ::DeleteObject(p);
200   //if (mp) ::DeleteObject(mp);
201
202   //InvalidateRect(x,y0,1,y1-y0);
203 }
204
205 void CSTedScreenWin32::TextReverse(int in_x, int in_y, int in_width, int in_page)
206 {
207   int x,y,w,h;
208   COLORREF c,b;
209   int page;
210
211
212   if (!TextToWindowPos(in_x, in_y, &x, &y)) return;
213   if (!TextToWindowPos(in_width, 0, &w, &h)) return;
214   h = fTextLineHeight;
215
216   switch (in_page) {
217         case 0: page=2;break;
218         case 1: page=0;break;
219         case 2: page=0;break;
220         case 3: page=2;break;
221   }
222
223   {
224     sf::begin_draw_bitmap begin(text_bitmap_target_);
225     {
226       sf::d2_dc_type dc(new sf::d2_dc(text_dc_target_,D2D1_DC_INITIALIZE_MODE_COPY));
227       c = ::SetTextColor(dc, PageToColor(page));
228       b = ::SetBkColor(dc, RGB(0x00, 0x00, 0x00));
229       ::BitBlt(dc, x,y,w,h, dc, x, y, DSTINVERT);
230       ::SetTextColor(dc,c);
231       ::SetBkColor(dc,b);
232     }
233     THROW_IF_ERR(begin.end_draw());
234   }
235   InvalidateRect(x,y,w,h);
236 }
237
238 void
239 CSTedScreenWin32::TextReverseArea(int in_r_ad, int in_r_ln, int in_editscr)
240 {
241   int x0,y0;
242   int w0,h0;
243   int x,y;
244   int w,h;
245   COLORREF b,c;
246
247   x0 = (in_editscr==0) ? 2 : 56;
248   y0 = 6+in_r_ad;
249   w0 = 36;
250   h0 = in_r_ln;
251   if (!TextToWindowPos(x0, y0, &x, &y)) return;
252   if (!TextToWindowPos(w0, h0, &w, &h)) return;
253   {
254     sf::begin_draw_bitmap begin(text_bitmap_target_);
255     {
256       sf::d2_dc_type dc(new sf::d2_dc(text_dc_target_,D2D1_DC_INITIALIZE_MODE_COPY));
257       c = ::SetTextColor(dc, PageToColor(3));
258       b = ::SetBkColor(dc, RGB(0x00, 0x00, 0x00));
259       ::BitBlt(dc, x,y,w,h, dc, x, y, DSTINVERT);
260       ::SetTextColor(dc, c);
261       ::SetBkColor(dc, b);
262     }
263     THROW_IF_ERR(begin.end_draw());
264   }
265
266   /*   
267   c = ::SetTextColor(fTextDC, PageToColor(3));
268   b = ::SetBkColor(fTextDC, RGB(0x00, 0x00, 0x00));
269   ::BitBlt(fTextDC, x,y,w,h, fTextMaskDC, x, y, SRCCOPY);
270   ::SetTextColor(fTextDC, c);
271   ::SetBkColor(fTextDC, b);
272
273   ::BitBlt(fTextMaskDC, x,y,w,h, fTextMaskDC, x, y, DSTINVERT);
274   */
275   InvalidateRect(x,y,w,h); 
276 }
277
278 void
279 CSTedScreenWin32::TextFill(int in_page, int in_x, int in_y, int in_w, int in_h, int in_linestyle)
280 {
281   int x,y,w,h;
282   //COLORREF c;
283   RECT r;
284   HBRUSH br, mbr;
285
286   if (!toWindowPos(in_x, in_y, &x, &y)) return;
287   if (!toWindowPos(in_w, in_h, &w, &h)) return;
288
289   ::SetRect(&r, x, y, x+w, y+h);
290
291   D2D1_RECT_F r1(D2D1::RectF(x,y,x+w,y+h));
292   D2D1_COLOR_F color = D2D1::ColorF(PageToColor(in_page));
293   ID2D1SolidColorBrushPtr color_brush;
294
295   text_bitmap_target_->CreateSolidColorBrush(color,&color_brush);
296   {
297     sf::begin_draw<ID2D1BitmapRenderTargetPtr> b(text_bitmap_target_);
298     D2D1_ANTIALIAS_MODE backup(text_bitmap_target_->GetAntialiasMode());
299     text_bitmap_target_->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
300     if (in_page != 0) 
301     {
302       text_bitmap_target_->FillRectangle(r1,color_brush);
303             //br = ::CreateSolidBrush(c);
304             //mbr = MASK_ON;
305     } else {
306       text_bitmap_target_->PushAxisAlignedClip(r1,text_bitmap_target_->GetAntialiasMode());
307       text_bitmap_target_->Clear();
308       text_bitmap_target_->PopAxisAlignedClip();
309       //text_bitmap_target_->FillRectangle(r1,brush_text_clear_);
310             //br = fBrushTextClear;
311             //mbr = MASK_OFF;
312     }
313     text_bitmap_target_->SetAntialiasMode(backup);
314     THROW_IF_ERR(b.end_draw());
315   }
316  // if (in_linestyle!=0 && in_page!=0) {
317         //  c = PageToColor(in_page);
318         //  br = ::CreateSolidBrush(c);
319         //  mbr = MASK_ON;
320  // } else {
321         //  br = fBrushTextClear;
322         //  mbr = MASK_OFF;
323  // }
324
325  // ::FillRect(fTextDC, &r, br);
326  // ::FillRect(fTextMaskDC, &r, mbr);
327
328  // if (in_linestyle!=0 && in_page!=0)
329         //::DeleteObject(br);
330
331  InvalidateRect(&r);
332 }
333
334 extern int edit_scr;
335
336 void
337 CSTedScreenWin32::TextRasterCopy(int in_dst, int in_src, int in_line, int in_mode)
338 {
339   int sx, lx;
340   int sy, dy, ly;
341   RECT r;
342
343   ly = fWindowHeight * (in_line/4 - 1) / fX68TextHeight;
344   if ((in_src==63*4) || (in_src==30*4)) {
345     sx = 0;
346     lx = fWindowWidth;
347   } else {
348     if (edit_scr==0) {
349       sx = fWindowWidth * 2  / fX68TextWidth;
350       lx = fWindowWidth * 36 / fX68TextWidth;
351     } else {
352       sx = fWindowWidth * 58 / fX68TextWidth;
353       lx = fWindowWidth * 36 / fX68TextWidth;
354     }
355   }
356
357   sf::begin_draw_bitmap begin(text_bitmap_target_);
358   {
359     if (in_mode >= 0x8000) {
360       sf::d2_dc_type dc(new sf::d2_dc(text_dc_target_,D2D1_DC_INITIALIZE_MODE_COPY));
361       sy = fWindowHeight * ((in_src+1)/4) / fX68TextHeight;
362       dy = fWindowHeight * ((in_dst+1)/4) / fX68TextHeight;
363       ::BitBlt(dc, sx, dy-ly, lx, ly, dc, sx, sy-ly, SRCCOPY);
364   //    ::BitBlt(fTextMaskDC, sx, dy-ly, lx, ly, fTextMaskDC, sx, sy-ly, SRCCOPY);
365       InvalidateRect(sx, dy-ly, lx, ly);
366     } else {
367       if (in_src==63*4) {
368         sy = fWindowHeight * in_dst/4 / fX68TextHeight;
369         dy = sy+fTextLineHeight;
370         ::SetRect(&r, sx, sy, sx+lx, dy);
371         D2D1_ANTIALIAS_MODE backup(text_bitmap_target_->GetAntialiasMode());
372         text_bitmap_target_->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
373
374         text_bitmap_target_->FillRectangle(D2D1::RectF(sx,sy,sx+lx,dy),brush_text_clear_);
375 //        ::FillRect(dc, &r, fBrushTextClear);
376   //      ::FillRect(fTextMaskDC, &r, MASK_OFF);
377         text_bitmap_target_->SetAntialiasMode(backup);
378         InvalidateRect(&r);
379       } else {
380         sf::d2_dc_type dc(new sf::d2_dc(text_dc_target_,D2D1_DC_INITIALIZE_MODE_COPY));
381         sy = fWindowHeight * (in_src/4) / fX68TextHeight;
382         dy = fWindowHeight * (in_dst/4) / fX68TextHeight;
383         ::BitBlt(dc, sx, dy, lx, ly, dc, sx, sy, SRCCOPY);
384   //      ::BitBlt(fTextMaskDC, sx, dy, lx, ly, fTextMaskDC, sx, sy, SRCCOPY);
385         InvalidateRect(sx, dy, lx, ly);
386       }
387     }
388   }
389   THROW_IF_ERR(begin.end_draw());
390 }
391
392 void
393 CSTedScreenWin32::TextScroll(int in_x0, int in_y0, int in_xs, int in_ys, int in_x1, int in_y1)
394 {
395   int x0, y0, x1, y1;
396   int w,h;
397   int d;
398
399   if (!TextToWindowPos(in_x0, in_y0, &x0, &d)) return;
400   if (!toWindowPos(in_x0, in_y0, &d, &y0)) return;
401   if (!TextToWindowPos(in_x1, in_y1, &x1, &d)) return;
402   if (!toWindowPos(in_x1, in_y1, &d, &y1)) return;
403   if (!TextToWindowPos(in_xs, in_ys, &w, &d)) return;
404   if (!toWindowPos(in_xs, in_ys, &d, &h)) return;
405
406    sf::begin_draw_bitmap begin(text_bitmap_target_);
407     {
408       sf::d2_dc_type dc(new sf::d2_dc(text_dc_target_,D2D1_DC_INITIALIZE_MODE_COPY));
409       ::BitBlt(dc, x1,y1,w,h, dc, x0, y0, SRCCOPY);
410     }
411     THROW_IF_ERR(begin.end_draw());
412  
413   // ::BitBlt(fTextDC, x1, y1, w, h, fTextDC, x0, y0, SRCCOPY);
414 //  ::BitBlt(fTextMaskDC, x1, y1, w, h, fTextMaskDC, x0, y0, SRCCOPY);
415
416   InvalidateRect(x1, y1, w, h);
417 }
418
419 void 
420 CSTedScreenWin32::GraphicsBox(int in_x0, int in_y0, int in_x1, int in_y1, unsigned int in_color, unsigned int in_linestyle)
421 {
422   int sx, sy, ex,ey;
423   int x,y;
424   int d;
425   int c;
426   RECT r;
427   //HBRUSH br;
428   //HPEN pen, orig;
429
430   if (!toWindowPos(in_x0, in_y0, &sx, &sy)) return;
431   if (!toWindowPos(in_x1, in_y1, &ex, &ey)) return;
432   d = (in_y1 >= fX68WindowHeight) ? 1:0;
433   if (sx>ex) { x=ex; ex=sx; sx=x;}
434   if (sy>ey) { y=ey; ey=sy; sy=y;}
435
436   c = (in_linestyle!=0) ? SetGraphicsColor(in_color) : 0;
437
438   ID2D1SolidColorBrushPtr brush;
439   graphics_bitmap_target_[d]->CreateSolidColorBrush(D2D1::ColorF(c),&brush);
440   sf::begin_draw_bitmap begin(graphics_bitmap_target_[d]);
441   D2D1_ANTIALIAS_MODE backup(graphics_bitmap_target_[d]->GetAntialiasMode());
442   graphics_bitmap_target_[d]->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
443   if (sx==ex || sy==ey) {
444
445           // pen = ::CreatePen(PS_SOLID, 1, c);
446     graphics_bitmap_target_[d]->DrawLine(D2D1::Point2F(sx,sy),D2D1::Point2F(ex,ey),brush);
447
448           //if (pen) {
449
450
451                   //orig = (HPEN)::SelectObject(fGraphicsWindowDC[d], pen);
452                   //::MoveToEx(fGraphicsWindowDC[d], sx, sy, NULL);
453                   //::LineTo(fGraphicsWindowDC[d], ex, ey);
454                   //::SelectObject(fGraphicsWindowDC[d], orig);
455                   //::DeleteObject(pen);
456           /*}*/
457   } else {
458     graphics_bitmap_target_[d]->DrawRectangle(D2D1::RectF(sx,sy,ex,ey),brush);
459          //br = ::CreateSolidBrush(c);
460          // if (br) {
461         ////::FrameRect(fGraphicsWindowDC[d], &r, br);
462                 ////::DeleteObject(br);
463          // }
464   }
465   graphics_bitmap_target_[d]->SetAntialiasMode(backup);
466   // エラーチェック
467   THROW_IF_ERR(begin.end_draw());
468   ::SetRect(&r, sx, sy, ex, ey);
469   InvalidateRect(&r);
470 }
471
472 int
473 CSTedScreenWin32::GraphicsPoint(int in_x, int in_y)
474 {
475   // just ignore
476   return 0;
477 }
478
479 void 
480 CSTedScreenWin32::GraphicsLine(int in_x0, int in_y0, int in_x1, int in_y1, int in_color, int in_linestyle)
481 {
482   int sx, sy, ex,ey;
483   int x,y;
484   int d;
485   int c;
486   //HPEN pen, orig;
487
488   if (!toWindowPos(in_x0, in_y0, &sx, &sy)) return;
489   if (!toWindowPos(in_x1, in_y1, &ex, &ey)) return;
490   d = (in_y1 >= fX68WindowHeight) ? 1:0;
491   if (sx>ex) { x=ex; ex=sx; sx=x;}
492   if (sy>ey) { y=ey; ey=sy; sy=y;}
493
494   c = (in_linestyle!=0) ? SetGraphicsColor(in_color) : 0;
495
496   ID2D1SolidColorBrushPtr brush;
497   graphics_bitmap_target_[d]->CreateSolidColorBrush(D2D1::ColorF(c),&brush);
498
499   {
500     sf::begin_draw_bitmap begin(graphics_bitmap_target_[d]);
501     D2D1_ANTIALIAS_MODE backup(graphics_bitmap_target_[d]->GetAntialiasMode());
502     graphics_bitmap_target_[d]->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
503     graphics_bitmap_target_[d]->DrawLine(D2D1::Point2F(sx,sy),D2D1::Point2F(ex,ey),brush);
504     graphics_bitmap_target_[d]->SetAntialiasMode(backup);
505     // エラーチェック
506     THROW_IF_ERR(begin.end_draw());
507   }
508   //pen = ::CreatePen(PS_SOLID, 1, c);
509   //if (pen) {
510          // orig = (HPEN)::SelectObject(fGraphicsWindowDC[d], pen);
511          // ::MoveToEx(fGraphicsWindowDC[d], sx, sy, NULL);
512          // ::LineTo(fGraphicsWindowDC[d], ex, ey);
513          // ::SelectObject(fGraphicsWindowDC[d], orig);
514          // ::DeleteObject(pen);
515   //}
516   //InvalidateRect(sx, sy, ex-sx, ey-sy);
517 }
518
519 void
520 CSTedScreenWin32::GraphicsFill(int in_x0, int in_y0, int in_x1, int in_y1, int in_color)
521 {
522   int sx, sy, ex,ey;
523   int x,y;
524   int d;
525   int c;
526   RECT r;
527  // HBRUSH br;
528
529   if (!toWindowPos(in_x0, in_y0, &sx, &sy)) return;
530   if (!toWindowPos(in_x1, in_y1, &ex, &ey)) return;
531   d = (in_y1 >= fX68WindowHeight) ? 1:0;
532   if (sx>ex) { x = ex; ex = sx; sx = x;}
533   if (sy>ey) { y = ey; ey = sy; sy = y;}
534
535   c = SetGraphicsColor(in_color);
536
537   ::SetRect(&r, sx, sy, ex, ey);
538   ID2D1SolidColorBrushPtr brush;
539
540   graphics_bitmap_target_[d]->CreateSolidColorBrush(D2D1::ColorF(c),&brush);
541
542   sf::begin_draw_bitmap begin(graphics_bitmap_target_[d]);
543   D2D1_ANTIALIAS_MODE backup(graphics_bitmap_target_[d]->GetAntialiasMode());
544   graphics_bitmap_target_[d]->SetAntialiasMode(D2D1_ANTIALIAS_MODE_ALIASED);
545   graphics_bitmap_target_[d]->FillRectangle(D2D1::RectF(sx,sy,ex,ey),brush);
546   graphics_bitmap_target_[d]->SetAntialiasMode(backup);
547   THROW_IF_ERR(begin.end_draw());
548
549  // br = ::CreateSolidBrush(c);
550  // if (br) {
551  //   ::FillRect(fGraphicsWindowDC[d], &r, br);
552         //::DeleteObject(br);
553   //}
554
555   InvalidateRect(&r);
556 }
557
558 void
559 CSTedScreenWin32::CopyTextToGraphics(int in_editscreen)
560 {
561   int x0, y0, x1, y1;
562   int xt, xl, yt, yl;
563   COLORREF b,c;
564
565   xl = 36;
566   yl = 24;
567   if (in_editscreen==0) {
568     xt = 2;
569     yt = 6;
570   } else {
571     xt = 58;
572     yt = 6;
573   }
574   if (!TextToWindowPos(xt, yt, &x0, &y0)) return;
575   if (!TextToWindowPos(xl, (yt+yl), &x1, &y1)) return;
576
577   //c = ::SetTextColor(fGraphicsWindowDC[1], RGB(0x00, 0x00, 0x00));  
578   //b = ::SetBkColor(fGraphicsWindowDC[1], RGB(0xff, 0xff, 0xff));  
579
580   //::BitBlt(fGraphicsWindowDC[1], x0, y0, x1, y1-y0, fTextMaskDC, x0, y0, SRCPAINT);
581   //::BitBlt(fGraphicsWindowDC[1], x0, y0, x1, y1-y0, fTextDC, x0, y0, SRCAND);
582
583   //::SetTextColor(fGraphicsWindowDC[1], c);  
584   //::SetBkColor(fGraphicsWindowDC[1], b);  
585
586   InvalidateRect(x0, y0, x1, y1-y0);
587 }
588
589 void
590 CSTedScreenWin32::CopyTextToGraphics2(int in_editscreen)
591 {
592   //int x0, y0, x1, y1;
593   //int xt, xl, yt, yl;
594   //COLORREF b,c;
595
596   //xl = 56;
597   //yl = 24;
598   //if (in_editscreen==0) {
599   //  xt = 0;
600   //  yt = 6;
601   //} else {
602   //  xt = 38;
603   //  yt = 6;
604   //}
605   //if (!TextToWindowPos(xt, yt, &x0, &y0)) return;
606   //if (!TextToWindowPos(xl, (yt+yl), &x1, &y1)) return;
607
608   //c = ::SetTextColor(fGraphicsWindowDC[1], RGB(0x00, 0x00, 0x00));  
609   //b = ::SetBkColor(fGraphicsWindowDC[1], RGB(0xff, 0xff, 0xff));  
610
611   //::BitBlt(fGraphicsWindowDC[1], x0, y0, x1, y1-y0, fTextMaskDC, x0, y0, SRCPAINT);
612   //::BitBlt(fGraphicsWindowDC[1], x0, y0, x1, y1-y0, fTextDC, x0, y0, SRCAND);
613
614   //::SetTextColor(fGraphicsWindowDC[1], c);  
615   //::SetBkColor(fGraphicsWindowDC[1], b);  
616
617   //InvalidateRect(x0, y0, x1, y1-y0);
618 }
619
620 void
621 CSTedScreenWin32::GraphicsHome(int in_home)
622 {
623   if (in_home!=0 && in_home!=1) in_home = 0;
624   fCurrentGraphics = in_home;
625   InvalidateRect(NULL);
626 }
627
628 void
629 CSTedScreenWin32::ClsAll(void)
630 {
631   RECT r;
632   ::SetRect(&r, 0, 0, fWindowWidth, fWindowHeight);
633   sf::begin_draw_bitmap begin(text_bitmap_target_);
634   text_bitmap_target_->Clear(D2D1::ColorF(0,0));
635   THROW_IF_ERR(begin.end_draw());
636
637 //  ::FillRect(fTextDC, &r, fBrushTextClear);
638 //  ::FillRect(fTextMaskDC, &r, MASK_OFF);
639   InvalidateRect(&r);
640 }
641
642 void
643 CSTedScreenWin32::GraphicsClear(void)
644 {
645   RECT r;
646   ::SetRect(&r, 0, 0, fWindowWidth, fWindowHeight);
647   sf::begin_draw_bitmap begin(graphics_bitmap_target_[fCurrentGraphics]);
648   graphics_bitmap_target_[fCurrentGraphics]->Clear();
649   THROW_IF_ERR(begin.end_draw());
650   //::FillRect(fGraphicsWindowDC[fCurrentGraphics], &r, fBrushClear);
651   InvalidateRect(&r);
652 }