WinPrinterContext.st
author ca
Tue, 23 Oct 2007 07:08:45 +0200
changeset 2342 78014f6a3c32
parent 2341 cf7b3de4f3ef
child 2343 b7ef200fbfad
permissions -rw-r--r--
bugfixes - round coordinates
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     1
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
 COPYRIGHT (c) 2006 by eXept Software AG
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
     3
	      All Rights Reserved
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
 This software is furnished under a license and may be used
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
 hereby transferred.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
"{ Package: 'stx:libview2' }"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
    14
PrinterContext subclass:#WinPrinterContext
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
    15
	instanceVariableNames:'deviceFonts hatch supportsColor'
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
    16
	classVariableNames:''
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
    17
	poolDictionaries:''
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
    18
	category:'Interface-Printing'
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    21
!WinPrinterContext primitiveDefinitions!
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    22
%{
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    23
#undef INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    24
#define INT WIN_INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    25
#undef Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    26
#define Array WIN_Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    27
#undef Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    28
#define Number WIN_Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    29
#undef Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    30
#define Method WIN_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    31
#undef Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    32
#define Point WIN_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    33
#undef Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    34
/* #define Rectangle WIN_Rectangle */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    35
#undef True
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    36
#define True WIN_True
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    37
#undef False
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    38
#define False WIN_False
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    39
#undef Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    40
#define Block WIN_Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    41
#undef Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    42
#define Context WIN_Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    43
#undef Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    44
#define Date WIN_Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    45
#undef Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    46
#define Time WIN_Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    47
#undef Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    48
#define Delay WIN_Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    49
#undef Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    50
#define Signal WIN_Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    51
#undef Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    52
#define Set WIN_Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    53
#undef Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    54
#define Process WIN_Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    55
#undef Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    56
#define Processor WIN_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    57
#undef Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    58
#define Message WIN_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    59
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    60
#include <stdio.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    61
#include <errno.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    62
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    63
#ifdef __BORLANDC__
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    64
# define NOATOM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    65
# define NOGDICAPMASKS
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    66
# define NOMETAFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    67
# define NOMINMAX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    68
# define NOOPENFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    69
# define NOSOUND
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    70
# define NOWH
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    71
# define NOCOMM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    72
# define NOKANJI
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    73
# define NOCRYPT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    74
# define NOMCX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    75
# define WIN32_LEAN_AND_MEAN
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    76
# include <windows.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    77
# include <shellapi.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    78
# include <sys\timeb.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    79
# include <dir.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    80
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    81
# define _USERENTRY /**/
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    82
# define NOATOM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    83
# define NOGDICAPMASKS
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    84
# define NOMETAFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    85
# define NOMINMAX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    86
# define NOOPENFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    87
# define NOSOUND
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    88
# define NOWH
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    89
# define NOCOMM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    90
# define NOKANJI
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    91
# define NOCRYPT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    92
# define NOMCX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    93
# define WIN32_LEAN_AND_MEAN
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    94
# include <windows.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    95
# include <sys\timeb.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    96
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    97
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    98
#include <process.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    99
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   100
#ifdef __DEF_Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   101
# undef Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   102
# define Array __DEF_Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   103
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   104
#ifdef __DEF_Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   105
# undef Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   106
# define Number __DEF_Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   107
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   108
#ifdef __DEF_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   109
# undef Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   110
# define Method __DEF_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   111
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   112
#ifdef __DEF_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   113
# undef Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   114
# define Point __DEF_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   115
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   116
#ifdef __DEF_Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   117
# undef Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   118
# define Rectangle __DEF_Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   119
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   120
# undef Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   121
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   122
#ifdef __DEF_Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   123
# undef Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   124
# define Block __DEF_Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   125
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   126
#ifdef __DEF_Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   127
# undef Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   128
# define Context __DEF_Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   129
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   130
#ifdef __DEF_Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   131
# undef Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   132
# define Date __DEF_Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   133
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   134
#ifdef __DEF_Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   135
# undef Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   136
# define Time __DEF_Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   137
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   138
# ifdef __DEF_Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   139
#  undef Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   140
#  define Set __DEF_Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   141
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   142
# ifdef __DEF_Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   143
#  undef Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   144
#  define Signal __DEF_Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   145
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   146
# ifdef __DEF_Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   147
#  undef Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   148
#  define Delay __DEF_Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   149
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   150
# ifdef __DEF_Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   151
#  undef Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   152
#  define Process __DEF_Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   153
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   154
# ifdef __DEF_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   155
#  undef Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   156
#  define Processor __DEF_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   157
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   158
# ifdef __DEF_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   159
#  undef Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   160
#  define Message __DEF_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   161
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   162
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   163
#undef INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   164
#define INT int
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   165
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   166
/*
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   167
 * some defines - tired of typing ...
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   168
 */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   169
#define _HANDLEVal(o)        (HANDLE)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   170
#define _HBITMAPVAL(o)       (HBITMAP)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   171
#define _HWNDVal(o)          (HWND)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   172
#define _HPALETTEVal(o)      (HPALETTE)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   173
#define _HCURSORVal(o)       (HCURSOR)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   174
#define _HGDIOBJVal(o)       (HGDIOBJ)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   175
#define _LOGPALETTEVal(o)    (LOGPALETTE *)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   176
#define _COLORREFVal(o)      (COLORREF)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   177
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   178
#define WIDECHAR unsigned short
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   179
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   180
#define WIN32PADDING 32
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   181
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   182
#ifdef DEBUG
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
   183
# define DPRINTF(x)              /* printf  x */
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
   184
# define DFPRINTF(x)             /* fprintf x */
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   185
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   186
# define DPRINTF(x)              /* */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   187
# define DFPRINTF(x)             /* */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   188
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   189
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   190
typedef int (*intf)(int);
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   191
%}
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   192
! !
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   193
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   194
!WinPrinterContext class methodsFor:'documentation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   195
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   196
copyright
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   197
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   198
 COPYRIGHT (c) 2006 by eXept Software AG
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   199
	      All Rights Reserved
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   200
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   201
 This software is furnished under a license and may be used
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
 only in accordance with the terms of that license and with the
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
 inclusion of the above copyright notice.   This software may not
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
 be provided or otherwise made available to, or used by, any
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
 other person.  No title to or ownership of the software is
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
 hereby transferred.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
documentation
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
"
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   212
    I am the mediator between the smalltalk printing protocol
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
    (which is the same as the graphics drawing protocol) and the
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    windows printer.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   215
    When you open a printer, you will typically talk to me.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
    [author:]
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   218
	Felix Madrid (fm@exept.de)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
!WinPrinterContext class methodsFor:'instance creation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
fromPrinterInfo: aPrinterInfo
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   225
    | printerContext printerDevice hDC|
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
    hDC := aPrinterInfo createDC.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
    hDC = 0 ifTrue: [ ^self error: 'Error while opening printer.' ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   230
    printerContext := self new.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   231
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   232
    printerDevice := printerContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   233
"/    printerDevice := WinPrinter on: aPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   234
"/    printerDevice printerDC:hDC.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   235
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   236
    printerContext printerInfo: aPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   237
    printerContext setDevice:printerDevice id:nil gcId:hDC.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   238
    printerContext initExtent.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   239
    ^printerContext
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   240
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   241
    "Created: / 03-08-2006 / 12:53:52 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   242
    "Modified: / 04-08-2006 / 12:55:01 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   243
    "Modified: / 16-04-2007 / 12:36:26 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   244
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   245
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   246
!WinPrinterContext class methodsFor:'accessing'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   247
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   248
getPrinterInformation:printerNameString
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    " Answer the printer information for the printer named printerNameString.  If no name is specified,
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
      answer the information for the default printer."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   251
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   252
    |h|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   253
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   254
    h := OperatingSystem openPrinter:printerNameString.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   255
    ^ OperatingSystem
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   256
	getDocumentProperties:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   257
	hPrinter:h
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   258
	pDeviceName:printerNameString.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   259
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   260
    "Created: / 27-07-2006 / 10:22:32 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   261
    "Modified: / 01-08-2006 / 16:01:44 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   262
    "Modified: / 10-10-2006 / 18:57:45 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   263
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   264
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   265
getPrinterInformationString: printerNameString
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   266
        " Answer the printer information string from the WIN.INI file
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   267
        for the printer named printerNameString.  If no name is specified,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   268
        answer the information for the default printer. "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   269
    | printerInfo result |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   270
    printerInfo := ( String new: 80 ).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   271
    result := OperatingSystem primGetProfileString: 'windows' 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   272
        keyName:  'device'
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   273
        default: ( printerNameString isNil ifTrue: [ '' ] ifFalse: [ printerNameString ] )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   274
        returnedString: printerInfo
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   275
        size: printerInfo size.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   276
    ^result > 0
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   277
        ifTrue: [printerInfo copyFrom: 1 to: result]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   278
        ifFalse: ['']
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   279
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   280
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
named: aName
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
    "Answer a new instance of Printer which represents
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   283
     the printer named aName as specified in the host
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
     Control Panel."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   285
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   286
    aName isNil ifTrue: [ ^self default ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    ^self new printerInfoWithName: aName
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    "Created: / 27-07-2006 / 17:51:27 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   290
    "Modified: / 02-08-2006 / 17:26:29 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   291
    "Modified: / 10-10-2006 / 17:33:29 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   292
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   293
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   294
!WinPrinterContext class methodsFor:'not supported yet'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   295
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   296
printAdvancedLines: pairOfPointsArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   297
    "Opens a print dialog and prints the given lines"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   298
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   299
    | printerInfo printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   300
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   301
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   302
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   303
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   304
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   305
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   306
	printer startPrintJob: 'Advanced Lines'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   307
	printer foreground:Color red background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   308
	pairOfPointsArray
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   309
	    do:[:pairOfPointsAndContext |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   310
		 |pairOfPoints|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   311
		 pairOfPoints := pairOfPointsAndContext at:1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   312
		 printer
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   313
		    lineWidth: (pairOfPointsAndContext at:2);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   314
		    lineStyle: (pairOfPointsAndContext at:3);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   315
		    capStyle: (pairOfPointsAndContext at:4);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   316
		    joinStyle: (pairOfPointsAndContext at:5);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   317
		    foreground: (pairOfPointsAndContext at:6);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   318
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   319
		    displayAdvanceLineFrom: (pairOfPoints at:1)  to: (pairOfPoints at:2).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   320
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   321
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   322
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   324
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   325
     WinPrinterContext printAdvancedLines:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   326
	(Array with: (Array with: (Array with:10@10 with:1000@5000) with: 3 with:#dashed with: #butt with: #miter with: Color green)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   327
	       with: (Array with: (Array with:10@10 with:3500@2000) with: 2 with:#solid  with: #butt with: #miter with: Color yellow)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   328
	       with: (Array with: (Array with:1000@800 with:6000@5000) with: 8 with:#dashed  with: #butt with: #miter with: Color black)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   329
	       with: (Array with: (Array with:2000@2800 with:2000@5000) with: 1 with:#dashed  with: #butt with: #miter with: Color red)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   330
	)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   331
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   332
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   333
    "Created: / 07-08-2006 / 12:09:48 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   334
    "Modified: / 07-08-2006 / 14:11:17 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   335
    "Modified: / 16-04-2007 / 15:37:41 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   336
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   337
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
!WinPrinterContext class methodsFor:'testing & examples'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   339
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   340
fillCircles: arrayOfPointsAndRadiusWithContextArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   341
    "Opens a print dialog and prints the given circles"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   342
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   343
    | printerInfo printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   344
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   345
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   346
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   347
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   348
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   349
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   350
	printer startPrintJob: 'Fill Circles'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   351
	arrayOfPointsAndRadiusWithContextArray
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   352
	    do:[:pointsAndRadiusWithContextArray |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   353
		printer foreground:(pointsAndRadiusWithContextArray at:3).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   354
		printer fillCircle:(pointsAndRadiusWithContextArray at:1)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   355
			radius:(pointsAndRadiusWithContextArray at:2).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   356
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   357
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   358
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   359
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   360
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   361
     WinPrinterContext fillCircles:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   362
	(Array with: (Array with: 800@800 with: 600 with:Color red)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   363
	       with: (Array with: 1500@1500 with: 1000 with:Color blue)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   364
	       with: (Array with: 4000@2500 with: 2000 with:Color gray))
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   365
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   366
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   367
    "Created: / 07-08-2006 / 11:46:52 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   368
    "Modified: / 16-04-2007 / 15:37:34 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   369
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   370
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   371
fillHatchCircles: arrayOfPointsAndRadiusWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   372
    "Opens a print dialog and prints the given circles"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   373
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   374
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   375
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   376
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   377
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   378
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   379
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   380
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   381
        printer startPrintJob: 'Fill Hatch Circles'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   382
        arrayOfPointsAndRadiusWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   383
            do:[:pointsAndRadiusWithContextArray |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   384
                | point radius color hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   385
                point := (pointsAndRadiusWithContextArray at:1).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   386
                radius := (pointsAndRadiusWithContextArray at:2).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   387
                color := (pointsAndRadiusWithContextArray at:3).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   388
                hatch := (pointsAndRadiusWithContextArray at:4).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   389
                printer foreground: color;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   390
                        hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   391
                printer fillCircle:point
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   392
                        radius:radius.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   393
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   394
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   395
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   396
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   397
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   398
     WinPrinterContext fillHatchCircles:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   399
        (Array with: (Array with: 800@800 with: 600 with:Color red with: #diagonalCross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   400
               with: (Array with: 1500@1500 with: 1000 with:Color blue with: #vertical)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   401
               with: (Array with: 4000@2500 with: 2000 with:Color gray with: #bDiagonal))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   402
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   403
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   404
    "Created: / 07-08-2006 / 11:46:52 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   405
    "Modified: / 16-04-2007 / 15:37:34 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   406
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   407
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   408
fillHatchPolygons: polygonsWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   409
    "Opens a print dialog and prints the given polygons"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   410
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   411
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   412
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   413
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   414
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   415
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   416
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   417
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   418
        printer startPrintJob: 'Fill Hatch Polygons'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   419
        polygonsWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   420
            do:[:polygonWithContextArray |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   421
                 |aPolygon color hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   422
                 aPolygon := polygonWithContextArray at: 1.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   423
                 color := (polygonWithContextArray at: 2).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   424
                 hatch := (polygonWithContextArray at: 3).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   425
                 printer foreground: color;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   426
                         hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   427
                 aPolygon displayFilledOn: printer.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   428
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   429
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   430
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   431
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   432
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   433
     WinPrinterContext fillHatchPolygons:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   434
        (Array with: (Array with: (Polygon vertices:(
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   435
                                Array
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   436
                                    with:100@100
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   437
                                    with:600@1000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   438
                                    with:3500@4000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   439
                                    with:100@4000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   440
                                    with:100@100))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   441
                            with: Color red
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   442
                            with: #cross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   443
                with: (Array with: (Polygon vertices:(
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   444
                                Array
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   445
                                    with:1000@1000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   446
                                    with:1000@2000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   447
                                    with:2000@1000))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   448
                             with: Color blue
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   449
                             with: #none)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   450
    )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   451
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   452
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   453
    "Created: / 07-08-2006 / 12:09:48 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   454
    "Modified: / 07-08-2006 / 14:11:17 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   455
    "Modified: / 16-04-2007 / 15:37:43 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   456
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   457
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   458
fillHatchRectangles: rectanglesWithHatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   459
    "Opens a print dialog and prints the given rectangles"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   460
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   461
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   462
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   463
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   464
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   465
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   466
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   467
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   468
        printer startPrintJob: 'Fill Hatch Rectangles'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   469
        printer foreground:Color blue background:Color white.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   470
        rectanglesWithHatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   471
            do:[:rectangleWithHatch |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   472
                |rectangle hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   473
                rectangle := rectangleWithHatch at: 1.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   474
                hatch := rectangleWithHatch at: 2.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   475
                printer hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   476
                printer fillRectangleX: rectangle origin x
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   477
                        y: rectangle origin y
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   478
                        width: rectangle width
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   479
                        height: rectangle height.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   480
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   481
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   482
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   483
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   484
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   485
     WinPrinterContext fillHatchRectangles:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   486
        (Array with: (Array with: (Rectangle left:20 top:20 width:400 height:600) with: #horizontal)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   487
               with: (Array with: (Rectangle left:500 top:700 width:600 height:400) with: #vertical)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   488
               with: (Array with: (Rectangle left:800 top:1000 width:1600 height:2000) with: #cross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   489
               with: (Array with: (Rectangle left:1040 top:1240 width:3000 height:3000) with: #bDiagonal)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   490
        )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   491
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   492
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   493
    "Created: / 07-08-2006 / 11:40:48 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   494
    "Modified: / 16-04-2007 / 15:37:46 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   495
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   496
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   497
fillPolygons: polygonsWithContextArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   498
    "Opens a print dialog and prints the given polygons"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   499
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   500
    | printerInfo printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   501
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   502
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   503
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   504
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   505
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   506
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   507
	printer startPrintJob: 'Fill Polygons'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   508
	polygonsWithContextArray
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   509
	    do:[:polygonWithContextArray |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   510
		 |aPolygon|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   511
		 aPolygon := polygonWithContextArray at: 1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   512
		 printer foreground:(polygonWithContextArray at: 2).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   513
		 aPolygon displayFilledOn: printer.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   514
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   515
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   516
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   517
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   518
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   519
     WinPrinterContext fillPolygons:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   520
	(Array with: (Array with: (Polygon vertices:(
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   521
				Array
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   522
				    with:100@100
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   523
				    with:600@1000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   524
				    with:3500@4000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   525
				    with:100@4000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   526
				    with:100@100))
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   527
			    with: Color red)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   528
		with: (Array with: (Polygon vertices:(
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   529
				Array
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   530
				    with:1000@1000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   531
				    with:1000@2000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   532
				    with:2000@1000))
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   533
			     with: Color blue)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   534
    )
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   535
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   536
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   537
    "Created: / 07-08-2006 / 12:09:48 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   538
    "Modified: / 07-08-2006 / 14:11:17 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   539
    "Modified: / 16-04-2007 / 15:37:43 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   540
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   541
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   542
fillRectangles: rectangles
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   543
    "Opens a print dialog and prints the given rectangles"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   544
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   545
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   546
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   547
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   548
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   549
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   550
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   551
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   552
	printer startPrintJob: 'Fill Rectangles'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   553
	printer foreground:Color blue background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   554
	rectangles
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   555
	    do:[:rectangle |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   556
		printer fillRectangleX: rectangle origin x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   557
			y: rectangle origin y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   558
			width: rectangle width
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   559
			height: rectangle height.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   560
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   561
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   562
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   563
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   564
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   565
     WinPrinterContext fillRectangles:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   566
	(Array with: (Rectangle left:20 top:20 width:400 height:600)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   567
	       with: (Rectangle left:500 top:700 width:600 height:400)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   568
	       with: (Rectangle left:800 top:1000 width:1600 height:2000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   569
	       with: (Rectangle left:1040 top:1240 width:3000 height:3000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   570
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   571
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   572
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   573
    "Created: / 07-08-2006 / 11:40:48 / fm"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   574
    "Modified: / 16-04-2007 / 15:37:46 / cg"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   575
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   576
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   577
print: aString font: aFont title: aTitle
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   578
    "Open a print dialog to allow printing of the given string
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   579
     using the given title & font."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   580
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   581
    self print: aString font: aFont title: aTitle wordWrap: false
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   582
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   583
   "
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   584
    WinPrinterContext print: 'Holaaaa!! (from:  WinPrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test'
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
   585
    WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: nil title: 'Printing Test String'
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
   586
    WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String'
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   587
   "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   588
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   589
    "Created: / 27-07-2006 / 17:52:33 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   590
    "Modified: / 03-08-2006 / 18:52:31 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   591
    "Modified: / 16-04-2007 / 13:54:40 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   592
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   593
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   594
print: aString font: aFont title: aTitle wordWrap: wordWrap
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   595
    "Open a print dialog to allow printing of the given string
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   596
     using the given title & font."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   597
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   598
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   599
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   600
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   601
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   602
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   603
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   604
    [
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   605
        printer
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   606
            print: aString
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   607
            font: aFont
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   608
            title: aTitle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   609
            wordWrap: wordWrap
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   610
            marginsRect: nil
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   611
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   612
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   613
    "
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   614
     WinPrinterContext print: 'Holaaaa!! (from:  PrinterContext>>print:aString font:aFont title:aTitle)' font: nil title: 'Printing Test' wordWrap: true
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
   615
     WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font:nil title:'Printing Test String' wordWrap:true
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
   616
     WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: (Font family:'Arial' face:'medium' size:8) title: 'Printing Test String' wordWrap: true
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   617
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   618
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   619
    "Created: / 03-08-2006 / 18:51:53 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   620
    "Modified: / 16-04-2007 / 15:37:31 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   621
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   622
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   623
printCircles: arrayOfPointsAndRadius
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   624
    "Opens a print dialog and prints the given circles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   625
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   626
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   627
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   628
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   629
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   630
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   631
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   632
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   633
	printer startPrintJob: 'Circles'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   634
	printer foreground:Color green background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   635
	arrayOfPointsAndRadius
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   636
	    do:[:pointAndRadius |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   637
		printer displayCircle:(pointAndRadius at:1)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   638
			radius:(pointAndRadius at:2).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   639
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   640
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   641
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   642
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   643
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   644
     WinPrinterContext printCircles:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   645
	(Array with: (Array with: 800@800 with: 600)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   646
	       with: (Array with: 1500@1500 with: 1000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   647
	       with: (Array with: 4000@2500 with: 2000))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   648
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   649
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   650
    "Created: / 07-08-2006 / 11:46:52 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   651
    "Modified: / 16-04-2007 / 15:37:34 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   652
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   653
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   654
printCirclesIn: rectangles
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   655
    "Opens a print dialog and prints the given circles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   656
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   657
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   658
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   659
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   660
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   661
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   662
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   663
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   664
	printer startPrintJob: 'Circles In Rectangles'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   665
	rectangles
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   666
	   do:[:rectangle |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   667
	       printer displayCircleIn: rectangle.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   668
	   ].
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   669
       printer endPrintJob.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   670
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   671
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   672
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   673
     WinPrinterContext printCirclesIn:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   674
	(Array with: (Rectangle left:20 top:20 width:400 height:600)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   675
	       with: (Rectangle left:40 top:40 width:600 height:400)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   676
	)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   677
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
    "Created: / 07-08-2006 / 11:48:46 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   680
    "Modified: / 16-04-2007 / 15:37:38 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   682
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   683
printImage: anImage
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   684
    "Opens a print dialog and prints the given image"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   685
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   686
    | printerInfo printer |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   687
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   688
    printerInfo := PrintingDialog getPrinterInfo.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   689
    printerInfo isNil ifTrue:[^self].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   690
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   691
    printer := self fromPrinterInfo: printerInfo.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   692
    [
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   693
        printer startPrintJob: 'Image'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   694
        printer background:Color white.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   695
        anImage displayOn:printer x:1000 y:1000.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   696
        printer endPrintJob.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   697
    ] forkAt: 3
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   698
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   699
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   700
     WinPrinterContext printImage: (Image fromFile:'C:\vsw311\pavheadr.gif').
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   701
     WinPrinterContext printImage: XPToolbarIconLibrary help32x32Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   702
     WinPrinterContext printImage: XPToolbarIconLibrary eraseXP28x28Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   703
     WinPrinterContext printImage: XPToolbarIconLibrary saveImageBlack22x22Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   704
     WinPrinterContext printImage: XPToolbarIconLibrary changesBrowser18x22Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   705
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   706
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   707
    "Created: / 07-08-2006 / 11:46:52 / fm"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   708
    "Modified: / 16-04-2007 / 15:37:34 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   709
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   710
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   711
printLines: pairOfPointsWithContextArray
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    "Opens a print dialog and prints the given lines"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   715
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   716
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   717
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   718
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   720
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   721
	printer startPrintJob: 'Lines'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   722
	pairOfPointsWithContextArray
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   723
	    do:[:pairOfPointsAndContext |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   724
		 |pairOfPoints|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   725
		 pairOfPoints := pairOfPointsAndContext at: 1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   726
		 printer
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   727
		    foreground:(pairOfPointsAndContext at:2);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   728
		    lineWidth: (pairOfPointsAndContext at:3);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   729
		    lineStyle: (pairOfPointsAndContext at:4);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   730
		    displayLineFrom: (pairOfPoints at:1)  to: (pairOfPoints at:2).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   731
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   732
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   733
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   734
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   735
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   736
     WinPrinterContext printLines:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   737
	(Array with: (Array with:(Array with:10@10 with:1000@5000) with: Color red with:4 with: #solid)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   738
	       with: (Array with:(Array with:10@10 with:3500@2000) with: Color blue with:1 with: #dashed)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   739
	       with: (Array with:(Array with:1000@800 with:6000@5000) with: Color black with: 1 with:#dotted)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   740
	       with: (Array with: (Array with:2000@2800 with:2000@5000) with: Color green with:8 with: nil))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   741
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   745
    "Modified: / 16-04-2007 / 15:37:41 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   746
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   747
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   748
printPoints: aCollectionOfPoints
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   749
    "Opens a print dialog and prints the given points"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   750
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   751
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   752
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   753
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   754
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   755
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   756
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   757
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   758
	printer startPrintJob: 'Points'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   759
	aCollectionOfPoints do:[:each |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   760
	    printer displayPointX: each x y: each y.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   761
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   762
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   763
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   764
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   765
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   766
     WinPrinterContext printPoints:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   767
	(Array with: (10 @ 10)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   768
	       with: (500 @ 700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   769
	       with: (900 @ 1000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   770
	       with: (1500 @ 1700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   771
	       with: (2100 @ 2000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   772
	       with: (2500 @ 2700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   773
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   774
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   775
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   776
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   777
printPolygons: polygons
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    "Opens a print dialog and prints the given polygons"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   781
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   784
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   785
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   786
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   787
	printer startPrintJob: 'Polygons'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   788
	printer foreground:Color black background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   789
	polygons
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   790
	    do:[:aPolygon |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   791
		 aPolygon displayStrokedOn: printer.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   792
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   793
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   794
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   795
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   796
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   797
     WinPrinterContext printPolygons:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   798
	(Array with: (Polygon vertices:(
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   799
				Array
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   800
				    with:100@100
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   801
				    with:600@1000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   802
				    with:3500@4000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   803
				    with:100@4000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   804
				    with:100@100))
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   805
		with: (Polygon vertices:(
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   806
				Array
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   807
				    with:1000@1000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   808
				    with:1000@2000
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   809
				    with:2000@1000)))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   810
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   811
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   812
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   813
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   814
    "Modified: / 16-04-2007 / 15:37:43 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   815
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   816
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   817
printPolylines: evenCollectionOfPoints
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   818
    "Opens a print dialog and prints the given rectangles"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   819
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   820
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   821
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   822
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   823
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   824
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   825
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   826
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   827
	printer startPrintJob: 'Polylines'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   828
	printer displayPolylines:evenCollectionOfPoints.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   829
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   830
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   831
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   832
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   833
     WinPrinterContext printPolylines:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   834
	(Array with: (10 @ 10)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   835
	       with: (500 @ 700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   836
	       with: (900 @ 1000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   837
	       with: (1500 @ 1700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   838
	       with: (2100 @ 2000)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   839
	       with: (2500 @ 2700)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   840
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   841
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   842
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   843
    "Created: / 07-08-2006 / 11:40:48 / fm"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   844
    "Modified: / 16-04-2007 / 15:37:46 / cg"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   845
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   846
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   847
printRectangles: rectanglesWithContextArray
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   848
    "Opens a print dialog and prints the given rectangles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   849
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   850
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   854
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   855
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   856
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   857
	printer startPrintJob: 'Rectangles'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   858
	printer foreground:Color red background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   859
	rectanglesWithContextArray do:[:rectangleWithContextArray |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   860
	    |rectangle|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   861
	    rectangle := rectangleWithContextArray at: 1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   862
	    printer
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   863
		foreground:(rectangleWithContextArray at:2);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   864
		lineWidth: (rectangleWithContextArray at:3);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   865
		lineStyle: (rectangleWithContextArray at:4);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   866
		displayRectangleX: rectangle origin x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   867
			y: rectangle origin y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   868
			width: rectangle width
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   869
			height: rectangle height.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   870
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   871
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   872
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   873
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   874
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   875
     WinPrinterContext printRectangles:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   876
	(Array with: (Array with: (Rectangle left:30 top:10 width:400 height:600) with: Color red with:4 with: #solid)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   877
	       with: (Array with: (Rectangle left:100 top:140 width:700 height:800) with: Color blue with:1 with: #dashed)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   878
	       with: (Array with: (Rectangle left:800 top:1500 width:2600 height:3400) with: Color green with:1 with: #dotted)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   879
	       with: (Array with: (Rectangle left:1000 top:1200 width:1400 height:1600) with: Color gray with:8 with: #dashed)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   880
	       with: (Array with: (Rectangle left:2600 top:1200 width:1400 height:1600) with: Color darkGray with:1 with: #dashDotDot)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   881
	)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   882
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   883
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   884
    "Created: / 07-08-2006 / 11:40:48 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   885
    "Modified: / 16-04-2007 / 15:37:46 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   886
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   887
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   888
printStrings: stringAndPositionsArray
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   889
    "Opens a print dialog and prints the given strings"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   890
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   891
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   892
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   893
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   894
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   897
    [
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   898
	printer startPrintJob: 'Strings with Position'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   899
	printer foreground:Color black background:Color white.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   900
	stringAndPositionsArray
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   901
	    do:[:pairOfPointsAndPosition |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   902
		 printer displayString:(pairOfPointsAndPosition at: 1)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   903
			    x:(pairOfPointsAndPosition at: 2) x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   904
			    y:(pairOfPointsAndPosition at: 2) y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   905
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   906
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   907
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   908
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   909
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   910
     WinPrinterContext printStrings:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   911
	(Array with: (Array with:'Testing printing with standart method' with:10@10)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
   912
	       with: (Array with:'Another test string to print' with:80@200))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   915
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   916
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   917
    "Modified: / 16-04-2007 / 15:37:49 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   918
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   919
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   920
!WinPrinterContext methodsFor:'accessing'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   921
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   922
depth
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   923
    ^ 24
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   924
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   925
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   926
deviceColors
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   927
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   928
    ^#()
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   929
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   930
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   931
deviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   932
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   933
    deviceFonts isNil ifTrue:[deviceFonts := CachingRegistry new cacheSize:10.].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   934
    ^deviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   935
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   936
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   937
getCharHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   938
    "Private - answer the height of the font selected in the receiver's
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   939
     device context."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   940
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   941
    |textMetrics answer|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   942
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   943
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   944
    textMetrics := Win32OperatingSystem::TextMetricsStructure new.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   945
"/    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   946
"/    Transcript showCR: 'CHAR HEIGHT PRIM ******* ', '   ',  (textMetrics tmHeight + textMetrics tmExternalLeading) printString.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   947
"/    Transcript showCR: 'CHAR HEIGHT DEVICE ***** ', '   ', (self font heightOf:'PQWEXCZ' on:self device) printString.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   948
    answer := (self font heightOf:'PQWEXCZ' on:self device).
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   949
"/    answer := textMetrics tmHeight + textMetrics tmExternalLeading.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   950
    ^answer
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   951
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   952
    "Created: / 02-08-2006 / 17:47:20 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   953
    "Modified: / 03-08-2006 / 10:09:01 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   954
    "Modified: / 10-10-2006 / 18:15:17 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   955
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   956
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   957
getLogicalPixelSizeX
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   958
    ^ printerInfo printQuality ? 600
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   959
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   960
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   961
getLogicalPixelSizeY
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   962
    ^ printerInfo printQuality ? 600
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   963
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   964
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   965
numberOfColorBitsPerPixel
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    "Created: / 03-08-2006 / 09:58:18 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
    "Modified: / 10-10-2006 / 18:15:40 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
physicalOffsetX
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
    ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   974
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   975
    "Created: / 01-08-2006 / 16:28:34 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
   976
    "Modified: / 16-04-2007 / 12:52:06 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   977
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   978
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   979
physicalOffsetY
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   980
    ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   981
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   982
    "Created: / 01-08-2006 / 16:28:34 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
   983
    "Modified: / 16-04-2007 / 12:52:01 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   984
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   985
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   986
pixelsPerInchOfScreenHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   987
    ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   988
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   989
    "Created: / 01-08-2006 / 16:29:16 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
pixelsPerInchOfScreenWidth
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   993
    ^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   994
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   995
    "Created: / 01-08-2006 / 16:28:34 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   996
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   997
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   998
printerHeightArea
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   999
    ^ (OperatingSystem getDeviceCaps:gcId index:10)
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
    "Modified: / 10-10-2006 / 18:18:31 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1003
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
printerPhysicalHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
printerPhysicalWidth
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1016
printerWidthArea
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1017
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1018
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1019
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1020
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1022
supportedImageFormats
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1023
    "return an array with supported image formats; each array entry
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1024
     is another array, consisting of depth and bitsPerPixel values."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1025
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1026
    |info|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1027
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1028
    info := IdentityDictionary new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1029
    info at:#depth put:self depth.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1030
    info at:#bitsPerPixel put:self depth.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1031
    info at:#padding put:32.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1032
    ^ Array with:info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1033
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1034
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1035
     Disply supportedImageFormats
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1036
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1037
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1038
    "Modified: / 10.9.1998 / 23:14:05 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1039
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1040
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1041
visualType
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1042
    ^ #TrueColor
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1043
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1044
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1045
!WinPrinterContext methodsFor:'color stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1046
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1047
colorScaledRed:r scaledGreen:g scaledBlue:b
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1048
    "allocate a color with rgb values (0..16rFFFF) - return the color index
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1049
     (i.e. colorID)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1050
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1051
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1052
    int id, ir, ig, ib;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1053
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1054
    if (__bothSmallInteger(r, g) && __isSmallInteger(b)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1055
	ir = (__intVal(r) >> 8) & 0xff;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1056
	ig = (__intVal(g) >> 8) & 0xff;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1057
	ib = (__intVal(b) >> 8) & 0xff;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1058
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1059
	id = RGB( ir, ig, ib);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1060
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1061
	RETURN ( __MKSMALLINT(id) );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1062
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1063
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1064
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1065
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1066
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1067
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1068
setBackground:bgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1069
    "set background color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1070
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1071
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1072
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1073
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1074
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1075
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1076
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1077
	COLORREF bg, oldBg;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1078
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1079
	oldBg = GetBkColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1080
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1081
	bg = __intVal(bgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1082
/*        bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);         */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1083
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1084
	if (bg != oldBg) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1085
	    SetBkColor(hDC, bg);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1086
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1087
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1088
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1089
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1090
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1091
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1092
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1093
setBackgroundColor:color in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1094
    "set background color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1095
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1096
    |colorId deviceColor|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1097
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1098
    (color isOnDevice:self) ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1099
	colorId := color colorId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1100
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1101
	deviceColor := color onDevice:self.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1102
	deviceColor notNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1103
	    colorId := deviceColor colorId.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1104
	]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1105
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1106
    colorId isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1107
	'DeviceWorkstation [warning]: could not set bg color' infoPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1108
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1109
	self setBackground:colorId in:aGCId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1110
    ]
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1111
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1112
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1113
setForeground:fgColorIndex background:bgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1114
    "set foreground and background colors to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1115
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1116
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1117
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1118
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1119
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1120
	COLORREF fg, bg, oldFg, oldBg;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1121
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1122
/*        fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);    */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1123
	fg = __intVal(fgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1124
/*        bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);    */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1125
	bg = __intVal(bgColorIndex) & 0xffffff;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1126
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1127
	oldFg = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1128
	oldBg = GetBkColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1129
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1130
	if ((fg != oldFg) || (bg != oldBg)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1131
	    /* Pen only depends upon fg-color */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1132
	    if (fg != oldFg) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1133
		SetTextColor(hDC, fg);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1134
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1135
	    if (bg != oldBg) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1136
		SetBkColor(hDC, bg);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1137
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1138
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1139
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1140
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1141
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1142
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1143
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1144
setForeground:fgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1145
    "set foreground color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1146
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1147
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1148
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1149
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1150
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1151
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1152
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1153
	COLORREF fg, oldFg;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1154
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1155
	oldFg = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1156
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1157
	fg = __intVal(fgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1158
/*        fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);         */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1159
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1160
	if (fg != oldFg) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1161
	    SetTextColor(hDC, fg);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1162
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1163
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1164
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1165
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1166
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1167
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1168
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1169
setForegroundColor:color in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1170
    "set the foreground color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1171
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1172
    |colorId deviceColor|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1173
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1174
    (color isOnDevice:self) ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1175
	colorId := color colorId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1176
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1177
	deviceColor := color onDevice:self.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1178
	deviceColor notNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1179
	    colorId := deviceColor colorId.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1180
	]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1181
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1182
    colorId isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1183
	'DeviceWorkstation [warning]: could not set fg color' infoPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1184
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1185
	self setForeground:colorId in:aGCId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1186
    ]
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1187
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1188
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1189
!WinPrinterContext methodsFor:'context stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1190
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1191
getPenFor:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1192
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1193
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1194
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1195
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1196
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1197
     && __isSmallInteger(__INST(lineWidth))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1198
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1199
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1200
	HANDLE hPen, prevPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1201
	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1202
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1203
	lineWidth= __INST(lineWidth);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1204
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1205
	if (__INST(lineStyle) == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1206
	    lineStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1207
	} else if (__INST(lineStyle) == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1208
	    lineStyleInt= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1209
	} else if (__INST(lineStyle) == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1210
	    lineStyleInt= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1211
	} else if (__INST(lineStyle) == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1212
	    lineStyleInt= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1213
	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1214
	    lineStyleInt= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1215
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1216
	    lineStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1217
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1218
	if (__INST(capStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1219
	    capStyleInt= PS_ENDCAP_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1220
	} else if (__INST(capStyle) == @symbol(square)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1221
	    capStyleInt= PS_ENDCAP_SQUARE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1222
	} else if (__INST(capStyle) == @symbol(flat)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1223
	    capStyleInt= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1224
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1225
	    capStyleInt= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1226
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1227
	if (__INST(joinStyle) == @symbol(bevel)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1228
	    joinStyleInt= PS_JOIN_BEVEL;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1229
	} else if (__INST(joinStyle) == @symbol(miter)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1230
	    joinStyleInt= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1231
	} else if (__INST(joinStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1232
	    joinStyleInt= PS_JOIN_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1233
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1234
	    joinStyleInt= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1235
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1236
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1237
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1238
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1239
	hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1240
	prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1241
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1242
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1243
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1244
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1245
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1246
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1247
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1248
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1249
getPenForContext
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1250
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1251
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1252
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1253
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1254
    if (__isExternalAddressLike(__INST(gcId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1255
     && __isSmallInteger(__INST(lineWidth))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1256
	HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1257
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1258
	HANDLE hPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1259
	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1260
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1261
	lineWidth= __INST(lineWidth);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1262
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1263
	if (__INST(lineStyle) == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1264
	    lineStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1265
	} else if (__INST(lineStyle) == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1266
	    lineStyleInt= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1267
	} else if (__INST(lineStyle) == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1268
	    lineStyleInt= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1269
	} else if (__INST(lineStyle) == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1270
	    lineStyleInt= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1271
	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1272
	    lineStyleInt= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1273
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1274
	    lineStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1275
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1276
	if (__INST(capStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1277
	    capStyleInt= PS_ENDCAP_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1278
	} else if (__INST(capStyle) == @symbol(square)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1279
	    capStyleInt= PS_ENDCAP_SQUARE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1280
	} else if (__INST(capStyle) == @symbol(flat)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1281
	    capStyleInt= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1282
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1283
	    capStyleInt= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1284
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1285
	if (__INST(joinStyle) == @symbol(bevel)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1286
	    joinStyleInt= PS_JOIN_BEVEL;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1287
	} else if (__INST(joinStyle) == @symbol(miter)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1288
	    joinStyleInt= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1289
	} else if (__INST(joinStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1290
	    joinStyleInt= PS_JOIN_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1291
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1292
	    joinStyleInt= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1293
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1294
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1295
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1296
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1297
	hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1298
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1299
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1300
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1301
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1302
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1303
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1304
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1305
hatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1306
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1307
    "The hatch style will define a hatched brush between these patterns:   
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1308
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1309
       #none                                     
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1310
       #horizontal              -----       HS_HORIZONTAL = 0       
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1311
       #vertical                |||||       HS_VERTICAL = 1
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1312
       #fDiagonal               \\\\\       HS_FDIAGONAL = 2
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1313
       #bDiagonal               /////       HS_BDIAGONAL = 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1314
       #cross                   +++++       HS_CROSS = 4
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1315
       #diagonalCross           xxxxx       HS_DIAGCROSS = 5
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1316
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1317
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1318
    hatch isNil ifTrue:[^#none].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1319
    ^ hatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1320
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1321
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1322
hatch: aSymbol
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1323
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1324
    "The hatch style will define a hatched brush between these patterns:   
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1325
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1326
       #none                                     
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1327
       #horizontal              -----       HS_HORIZONTAL = 0       
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1328
       #vertical                |||||       HS_VERTICAL = 1
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1329
       #fDiagonal               \\\\\       HS_FDIAGONAL = 2
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1330
       #bDiagonal               /////       HS_BDIAGONAL = 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1331
       #cross                   +++++       HS_CROSS = 4
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1332
       #diagonalCross           xxxxx       HS_DIAGCROSS = 5
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1333
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1334
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1335
    hatch := aSymbol
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1336
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1337
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1338
noClipIn:aWindowId gc:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1339
    "disable clipping rectangle"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1340
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1341
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1342
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1343
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1344
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1345
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1346
	SelectClipRgn(hDC, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1347
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1348
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1349
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1350
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1351
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1352
setBitmapMask:aBitmapId in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1353
    "set or clear the drawing mask - a bitmap mask using current fg/bg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1354
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1355
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1356
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1357
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1358
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1359
	HBITMAP oldM;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1360
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1361
/*        oldM = gcData->hMask;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1362
	if (__isExternalAddress(aBitmapId))
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1363
	    gcData->hMask = _HBITMAPVAL(aBitmapId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1364
	else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1365
	    gcData->hMask = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1366
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1367
	if (oldM != gcData->hMask) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1368
	  FLUSH_CACHED_DC(gcData);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1369
	    CPRINTF(("masks set to %x\n",gcData->hMask));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1370
	}                                                     */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1371
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1372
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1373
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1374
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1375
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1376
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:ignoredDrawableId gc:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1377
    "clip to a rectangle"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1378
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1379
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1380
      p--w---
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1381
      |     |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1382
      h     |  the clipping rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1383
      |     |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1384
      -------
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1385
	  where p = ( clipX, clipY ), w = clipWidth, h = clipHeight
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1386
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1387
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1388
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1389
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1390
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1391
     && __bothSmallInteger(clipX, clipY)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1392
     && __bothSmallInteger(clipWidth, clipHeight) ) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1393
	HANDLE hDC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1394
	int cX, cY, cW, cH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1395
	POINT ptOrg;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1396
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1397
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1398
	hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1399
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1400
	GetViewportOrgEx(hDC,&ptOrg);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1401
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1402
	// set the clip rectangle
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1403
	// and offset the rectangle by the viewport origin
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1404
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1405
	cX = __intVal(clipX) + ptOrg.x;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1406
	cY = __intVal(clipY) + ptOrg.y;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1407
	cW = __intVal(clipWidth)+ ptOrg.x;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1408
	cH = __intVal(clipHeight)+ ptOrg.y;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1409
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1410
	{
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1411
	    HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1412
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1413
	    if (region == NULL ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1414
		console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1415
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1416
		if (SelectClipRgn(hDC, region) == ERROR ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1417
		    console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1418
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1419
		DeleteObject(region);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1420
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1421
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1422
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1423
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1424
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1425
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1426
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1427
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1428
setDashes:dashList dashOffset:offset in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1429
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1430
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1431
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1432
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1433
    if (__isExternalAddressLike(aGCId)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1434
	DPRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1435
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1436
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1437
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1438
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1439
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1440
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1441
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1442
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1443
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1444
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1445
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1446
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1447
     && __isSmallInteger(aNumber)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1448
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1449
	int style;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1450
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1451
	if (lineStyle == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1452
	    style = PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1453
	} else if (lineStyle == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1454
	    style= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1455
	} else if (lineStyle == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1456
	    style= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1457
	} else if (lineStyle == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1458
	    style= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1459
	} else if (lineStyle == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1460
	    style= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1461
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1462
	    style= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1463
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1464
	if (capStyle == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1465
	    style = PS_ENDCAP_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1466
	} else if (capStyle == @symbol(square)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1467
	    style = PS_ENDCAP_SQUARE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1468
	} else if (capStyle == @symbol(flat)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1469
	    style = PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1470
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1471
	    style = PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1472
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1473
	if (joinStyle == @symbol(bevel)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1474
	    style = PS_JOIN_BEVEL;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1475
	} else if (joinStyle == @symbol(miter)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1476
	    style = PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1477
	} else if (joinStyle == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1478
	    style = PS_JOIN_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1479
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1480
	    style = PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1481
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1482
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1483
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1484
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1485
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1486
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1487
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1488
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1489
setMaskOriginX:orgX y:orgY in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1490
    "set the mask origin"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1491
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1492
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1493
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1494
    if (__isExternalAddress(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1495
     && __bothSmallInteger(orgX,orgY)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1496
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1497
	int oX, oY, maskOrgX, maskOrgY;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1498
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1499
	oX = __intVal(orgX);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1500
	oY = __intVal(orgY);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1501
	if ((oX != maskOrgX)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1502
	 || (oY != maskOrgY)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1503
	    maskOrgX = __intVal(orgX);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1504
	    maskOrgY = __intVal(orgY);;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1505
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1506
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1507
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1508
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1509
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1510
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1511
setViewportOrg: aPoint
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1512
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1513
    "Sets the viewport origin (LOGICAL point (0,0)) of the device context"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1514
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1515
    ^ OperatingSystem
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1516
	    setViewportOrg: gcId "deviceContext"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1517
	    x: aPoint x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1518
	    y: aPoint y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1519
	    oldOrigin: nil
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1520
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1521
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1522
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1523
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1524
!WinPrinterContext methodsFor:'drawing'!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1525
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1526
displayArcX:x y:y width:width height:height from:startAngle angle:angle in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1527
    "draw an arc. If any of x,y, w or h is not an integer, an error is triggered.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1528
     The angles may be floats or integer - they are given in degrees."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1529
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1530
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1531
    int __x, __y, w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1532
    float angle1, angle2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1533
    double f;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1534
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1535
    if (__isSmallInteger(startAngle))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1536
	angle1 = (float)(__intVal(startAngle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1537
    else if (__isFloat(startAngle)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1538
	angle1 = (float) __floatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1539
    } else if (__isShortFloat(startAngle)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1540
	angle1 = __shortFloatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1541
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1542
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1543
    if (__isSmallInteger(angle))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1544
	angle2 = (float)(__intVal(angle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1545
    else if (__isFloat(angle)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1546
	angle2 = (float) __floatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1547
    } else if (__isShortFloat(angle)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1548
	angle2 = __shortFloatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1549
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1550
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1551
    if (angle2 <= 0) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1552
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1553
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1554
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1555
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1556
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1557
     && __bothSmallInteger(width, height))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1558
     {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1559
	POINT p;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1560
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1561
	DWORD clr = 0 /* 0xFFFFFFFF */;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1562
	HANDLE prevPen, hPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1563
	double xB, yB, xE, yE, xR, yR;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1564
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1565
	int lStyleSymbol, lStyleInt;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1566
	int lw;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1567
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1568
	lw= __intVal(__INST(lineWidth));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1569
	lStyleSymbol= __INST(lineStyle);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1570
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1571
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1572
	    only works with lineWidth = 1  */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1573
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1574
	if (lStyleSymbol == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1575
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1576
	} else if (lStyleSymbol == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1577
	    lStyleInt= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1578
	} else if (lStyleSymbol == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1579
	    lStyleInt= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1580
	} else if (lStyleSymbol == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1581
	    lStyleInt= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1582
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1583
	    lStyleInt= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1584
	} else if (lStyleSymbol == @symbol(insideFrame)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1585
	    lStyleInt= PS_INSIDEFRAME;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1586
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1587
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1588
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1589
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1590
	hPen = CreatePen(lStyleInt, lw, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1591
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1592
	w = __intVal(width);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1593
	h = __intVal(height);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1594
	__x = __intVal(x);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1595
	__y = __intVal(y);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1596
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1597
	    xR = w / 2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1598
	    yR = h / 2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1599
	    if (angle2 - angle1 >= 360) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1600
		xB = xE = __x + xR + 0.5;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1601
		yB = yE = __y /*+ yR + 0.5*/;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1602
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1603
		double sin(), cos();
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1604
		float rad1, rad2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1605
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1606
		if (angle1 <= 180)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1607
		  angle1 = 180 - angle1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1608
		else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1609
		  angle1 = 360 + 180 - angle1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1610
		angle2 = angle1 - angle2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1611
		/* sigh - compute the intersections ... */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1612
		rad1 = (angle1 * 3.14159265359) / 180.0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1613
		rad2 = (angle2 * 3.14159265359) / 180.0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1614
		xB = cos(rad1) * xR;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1615
		yB = sin(rad1) * yR;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1616
		xE = cos(rad2) * xR;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1617
		yE = sin(rad2) * yR;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1618
		xB = __x + xR - xB + 0.5;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1619
		yB = __y + yR - yB + 0.5;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1620
		xE = __x + xR - xE + 0.5;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1621
		yE = __y + yR - yE + 0.5;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1622
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1623
	    prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1624
	    DPRINTF(("Arc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1625
	    Arc(hDC,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1626
		__x, __y,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1627
		__x + w, __y + h,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1628
		(int)xB, (int)yB,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1629
		(int)xE, (int)yE);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1630
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1631
	    SelectObject(hDC, prevPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1632
	    DeleteObject(hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1633
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1634
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1635
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1636
    bad: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1637
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1638
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1639
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1640
    "Created: / 07-08-2006 / 10:40:27 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1641
    "Modified: / 07-08-2006 / 14:44:21 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1642
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1643
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1644
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1645
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1646
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1647
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1648
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1649
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1650
     && __bothSmallInteger(x1, y1)) {
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1651
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1652
        COLORREF fgColor;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1653
        HANDLE prevPen, hPen;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1654
        int __x1 = __intVal(x1), __y1 = __intVal(y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1655
        int lStyleSymbol, lStyleInt;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1656
        int lw;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1657
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1658
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1659
                    __intVal(x0), __intVal(y0),
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1660
                    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1661
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1662
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1663
        lw= __intVal(__INST(lineWidth));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1664
        lStyleSymbol= __INST(lineStyle);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1665
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1666
        /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1667
            only works with lineWidth = 1  */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1668
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1669
        if (lStyleSymbol == @symbol(solid)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1670
            lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1671
        } else if (lStyleSymbol == @symbol(dashed)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1672
            lStyleInt= PS_DASH;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1673
        } else if (lStyleSymbol == @symbol(dotted)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1674
            lStyleInt= PS_DOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1675
        } else if (lStyleSymbol == @symbol(dashDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1676
            lStyleInt= PS_DASHDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1677
        } else if (lStyleSymbol == @symbol(dashDotDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1678
            lStyleInt= PS_DASHDOTDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1679
        } else if (lStyleSymbol == @symbol(insideFrame)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1680
            lStyleInt= PS_INSIDEFRAME;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1681
        } else
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1682
            lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1683
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1684
        fgColor = GetTextColor(hDC);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1685
        hPen = CreatePen(lStyleInt, lw, fgColor);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1686
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1687
        prevPen = SelectObject(hDC, hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1688
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1689
        MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1690
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1691
        LineTo(hDC, __x1, __y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1692
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1693
        /*
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1694
         * end-point ...
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1695
         */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1696
        // LineTo(hDC, __x1+1, __y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1697
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1698
        SelectObject(hDC, prevPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1699
        DeleteObject(hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1700
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1701
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1702
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1703
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1704
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1705
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1706
displayPointX:px y:py in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1707
    "draw a point. If x/y are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1708
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1709
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1710
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1711
     && __bothSmallInteger(px, py)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1712
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1713
	POINT p;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1714
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1715
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1716
	int __x = __intVal(px), __y = __intVal(py);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1717
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1718
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1719
	SetPixelV(hDC, __x, __y, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1720
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1721
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1722
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1723
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1724
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1725
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1726
displayPolygon:aPolygon in:aDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1727
    "draw a polygon, the argument aPolygon is a Collection of individual points,
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1728
     which define the polygon.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1729
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1730
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1731
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1732
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1733
    numberOfPoints := aPolygon size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1734
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1735
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1736
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1737
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1738
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1739
     /* && __isExternalAddress(aDrawableId) */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1740
     && __isSmallInteger(numberOfPoints)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1741
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1742
	POINT p;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1743
	DWORD clr = 0 /* 0xFFFFFFFF */;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1744
	HANDLE prevPen, hPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1745
	int lw;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1746
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1747
	int lStyleSymbol, lStyleInt;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1748
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1749
	lw= __intVal(__INST(lineWidth));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1750
	lStyleSymbol= __INST(lineStyle);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1751
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1752
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1753
	    only works with lineWidth = 1  */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1754
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1755
	if (lStyleSymbol == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1756
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1757
	} else if (lStyleSymbol == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1758
	    lStyleInt= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1759
	} else if (lStyleSymbol == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1760
	    lStyleInt= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1761
	} else if (lStyleSymbol == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1762
	    lStyleInt= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1763
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1764
	    lStyleInt= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1765
	} else if (lStyleSymbol == @symbol(insideFrame)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1766
	    lStyleInt= PS_INSIDEFRAME;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1767
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1768
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1769
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1770
	num = __intVal(numberOfPoints);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1771
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1772
	for (i=0; i<num; i++) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1773
	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1774
	    if (! __isPoint(point)) goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1775
	    px = _point_X(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1776
	    py = _point_Y(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1777
	    if (! __bothSmallInteger(px, py)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1778
		goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1779
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1780
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1781
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1782
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1783
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1784
	hPen = CreatePen(lStyleInt, lw, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1785
	prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1786
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1787
	for (i=0; i<num; i++) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1788
	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1789
	    px = _point_X(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1790
	    py = _point_Y(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1791
	    p.x = __intVal(px);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1792
	    p.y = __intVal(py);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1793
	    if (i == 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1794
		MoveToEx(hDC, p.x, p.y, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1795
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1796
		if (i == (num-1)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1797
		    PolylineTo(hDC, &p, 1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1798
		} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1799
		    LineTo(hDC, p.x, p.y);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1800
#ifdef PRE_04_JUN_04
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1801
		    /*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1802
		     * end-point ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1803
		     */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1804
		    LineTo(hDC, p.x+1, p.y);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1805
#endif
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1806
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1807
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1808
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1809
	SelectObject(hDC, prevPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1810
	DeleteObject(hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1811
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1812
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1813
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1814
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1815
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1816
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1817
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1818
    "Created: / 07-08-2006 / 14:46:55 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1819
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1820
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1821
displayPolylines:arrayOfPoints
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1822
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1823
    device displayPolylines:arrayOfPoints in:nil with:gcId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1824
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1825
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1826
displayPolylines:aPolyline in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1827
    "draw a polyline, the argument aPolyline is a collection of individual points,
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1828
     which define the lines (p1/p2 pairs); must be even in size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1829
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1830
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1831
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1832
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1833
    numberOfPoints := aPolyline size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1834
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1835
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1836
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1837
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1838
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1839
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1840
     && __isSmallInteger(numberOfPoints)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1841
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1842
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1843
	POINT p;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1844
	HANDLE prevPen, hPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1845
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1846
	int lw;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1847
	int lStyleSymbol, lStyleInt;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1848
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1849
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1850
	lw= __intVal(__INST(lineWidth));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1851
	lStyleSymbol= __INST(lineStyle);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1852
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1853
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1854
	    only works with lineWidth = 1  */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1855
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1856
	if (lStyleSymbol == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1857
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1858
	} else if (lStyleSymbol == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1859
	    lStyleInt= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1860
	} else if (lStyleSymbol == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1861
	    lStyleInt= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1862
	} else if (lStyleSymbol == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1863
	    lStyleInt= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1864
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1865
	    lStyleInt= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1866
	} else if (lStyleSymbol == @symbol(insideFrame)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1867
	    lStyleInt= PS_INSIDEFRAME;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1868
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1869
	    lStyleInt= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1870
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1871
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1872
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1873
	num = __intVal(numberOfPoints);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1874
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1875
	for (i=0; i<num; i++) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1876
	    point = __AT_(aPolyline, __MKSMALLINT(i+1));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1877
	    if (! __isPoint(point)) goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1878
	    px = _point_X(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1879
	    py = _point_Y(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1880
	    if (! __bothSmallInteger(px, py)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1881
		goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1882
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1883
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1884
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1885
	hPen = CreatePen(lStyleInt, lw, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1886
	prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1887
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1888
	for (i=0; i<num; i++) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1889
	    point = __AT_(aPolyline, __MKSMALLINT(i+1));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1890
	    px = _point_X(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1891
	    py = _point_Y(point);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1892
	    p.x = __intVal(px);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1893
	    p.y = __intVal(py);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1894
	    DPRINTF(("printing point"));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1895
	    DPRINTF(("displayPolygon: no pen\n"));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1896
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1897
	    if ((i & 1) == 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1898
		MoveToEx(hDC, p.x, p.y, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1899
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1900
		LineTo(hDC, p.x, p.y);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1901
		/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1902
		 * end-point ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1903
		 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1904
		LineTo(hDC, p.x+1, p.y);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1905
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1906
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1907
	SelectObject(hDC, prevPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1908
	DeleteObject(hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1909
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1910
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1911
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1912
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1913
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1914
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1915
displayRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1916
    "draw a rectangle. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1917
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1918
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1919
    int w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1920
    int xL, yT;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1921
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1922
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1923
     && __bothSmallInteger(width, height)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1924
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1925
        xL = __intVal(x);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1926
        yT = __intVal(y);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1927
        w = __intVal(width);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1928
        h = __intVal(height);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1929
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1930
        DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1931
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1932
        if ((w >= 0) && (h >= 0)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1933
            HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1934
            COLORREF fgColor;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1935
            HANDLE prevPen, hPen;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1936
            int lStyleSymbol, lStyleInt;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1937
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1938
            int lw;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1939
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1940
            lw= __intVal(__INST(lineWidth));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1941
            lStyleSymbol= __INST(lineStyle);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1942
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1943
            /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1944
                only works with lineWidth = 1  */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1945
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1946
            if (lStyleSymbol == @symbol(solid)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1947
                lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1948
            } else if (lStyleSymbol == @symbol(dashed)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1949
                lStyleInt= PS_DASH;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1950
            } else if (lStyleSymbol == @symbol(dotted)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1951
                lStyleInt= PS_DOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1952
            } else if (lStyleSymbol == @symbol(dashDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1953
                lStyleInt= PS_DASHDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1954
            } else if (lStyleSymbol == @symbol(dashDotDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1955
                lStyleInt= PS_DASHDOTDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1956
            } else if (lStyleSymbol == @symbol(insideFrame)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1957
                lStyleInt= PS_INSIDEFRAME;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1958
            } else
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1959
                lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1960
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1961
            fgColor = GetTextColor(hDC);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1962
            hPen = CreatePen(lStyleInt, lw, fgColor);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1963
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1964
            prevPen = SelectObject(hDC, hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1965
            MoveToEx(hDC, xL, yT, NULL);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1966
            LineTo(hDC, xL+w, yT);       // to top-right
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1967
            LineTo(hDC, xL+w, yT+h);     // to bot-right
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1968
            MoveToEx(hDC, xL, yT, NULL); // back to top-left
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1969
            LineTo(hDC, xL, yT+h);       // to bot-left
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1970
            // LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1971
            LineTo(hDC, xL+w,   yT+h);   // move pen one pixel more
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1972
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1973
            SelectObject(hDC, prevPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1974
            DeleteObject(hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1975
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1976
        }
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1977
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1978
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1979
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1980
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1981
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1982
    "Created: / 28-07-2006 / 20:18:25 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1983
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1984
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1985
displayString:aString from:index1 to:index2 x:x y:y in:aDrawableId with:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1986
    "draw a sub-string - draw foreground only.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1987
     If the coordinates are not integers, retry with rounded."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1988
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1989
    self
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1990
	displayString:aString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1991
	from:index1
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1992
	to:index2
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1993
	x:x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1994
	y:y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1995
	in:aDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1996
	with:aGCId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  1997
	opaque:false
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1998
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1999
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2000
displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aDC opaque:opaque
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2001
    "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2002
     foreground and background characters.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2003
     If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2004
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2005
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2006
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2007
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2008
    int  i1, i2, l, n;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2009
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2010
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2011
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2012
     && __isNonNilObject(aString)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2013
     && __bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2014
     && __bothSmallInteger(x, y))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2015
    {
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2016
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2017
        int pX, pY;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2018
        COLORREF fgColor;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2019
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2020
        pX = __intVal(x);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2021
        pY = __intVal(y);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2022
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2023
        if (opaque == true) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2024
            SetBkMode(hDC, OPAQUE);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2025
        } else {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2026
            SetBkMode(hDC, TRANSPARENT);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2027
        }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2028
        fgColor = GetTextColor(hDC);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2029
        SetTextColor(hDC, fgColor);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2030
        SetBkColor(hDC, 0xFFFFFFFF);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2031
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2032
        cls = __qClass(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2033
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2034
        i1 = __intVal(index1) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2035
        if (i1 >= 0) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2036
            i2 = __intVal(index2) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2037
            if (i2 < i1) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2038
                goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2039
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2040
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2041
            cp = _stringVal(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2042
            l = i2 - i1 + 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2043
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2044
            if ((cls == @global(String)) || (cls == @global(Symbol))) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2045
                n = _stringSize(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2046
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2047
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2048
                    DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2049
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2050
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2051
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2052
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2053
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2054
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2055
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2056
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2057
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2058
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2059
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2060
            nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2061
            cp += nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2062
            n = __byteArraySize(aString) - nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2063
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2064
            if (__isBytes(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2065
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2066
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2067
                    DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2068
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2069
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2070
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2071
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2072
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2073
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2074
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2075
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2076
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2077
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2078
            /* Unicode */
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2079
            if (__isWords(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2080
                n = n / 2;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2081
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2082
                    WIDECHAR *w_cp = (WIDECHAR *)cp;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2083
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2084
                    w_cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2085
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2086
                    if (! TextOutW(hDC, pX, pY, w_cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2087
                        DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2088
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2089
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2090
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2091
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2092
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2093
ret:
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2094
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2095
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2096
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2097
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2098
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2099
    "Created: / 28-07-2006 / 20:35:19 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2100
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2101
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2102
displayString:aString from:index1 to:index2 x:x y:y in:ignoredDrawableId with:aDC opaque:opaque fontAscent:fontAscent
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2103
    "draw a sub-string - if opaque is false, draw foreground only; otherwise, draw both
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2104
     foreground and background characters.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2105
     If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2106
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2107
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2108
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2109
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2110
    int  i1, i2, l, n;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2111
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2112
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2113
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2114
     && __isNonNilObject(aString)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2115
     && __bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2116
     && __bothSmallInteger(x, y))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2117
    {
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2118
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2119
        int pX, pY;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2120
        COLORREF fgColor;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2121
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2122
        pX = __intVal(x);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2123
        pY = __intVal(y);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2124
        pY -= __intVal(fontAscent);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2125
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2126
        if (opaque == true) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2127
            SetBkMode(hDC, OPAQUE);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2128
        } else {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2129
            SetBkMode(hDC, TRANSPARENT);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2130
        }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2131
        fgColor = GetTextColor(hDC);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2132
        SetTextColor(hDC, fgColor);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2133
        SetBkColor(hDC, 0xFFFFFFFF);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2134
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2135
        cls = __qClass(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2136
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2137
        i1 = __intVal(index1) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2138
        if (i1 >= 0) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2139
            i2 = __intVal(index2) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2140
            if (i2 < i1) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2141
                goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2142
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2143
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2144
            cp = _stringVal(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2145
            l = i2 - i1 + 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2146
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2147
            if ((cls == @global(String)) || (cls == @global(Symbol))) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2148
                n = _stringSize(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2149
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2150
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2151
                    DPRINTF(("string1: %s pos=%d/%d l=%d hDC=%x\n", cp, pX, pY,l,hDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2152
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2153
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2154
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2155
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2156
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2157
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2158
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2159
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2160
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2161
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2162
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2163
            nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2164
            cp += nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2165
            n = __byteArraySize(aString) - nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2166
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2167
            if (__isBytes(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2168
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2169
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2170
                    DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2171
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2172
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2173
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2174
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2175
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2176
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2177
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2178
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2179
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2180
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2181
            /* Unicode */
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2182
            if (__isWords(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2183
                n = n / 2;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2184
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2185
                    WIDECHAR *w_cp = (WIDECHAR *)cp;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2186
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2187
                    w_cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2188
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2189
                    if (! TextOutW(hDC, pX, pY, w_cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2190
                        DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2191
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2192
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2193
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2194
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2195
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2196
ret:
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2197
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2198
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2199
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2200
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2201
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2202
    "Created: / 28-07-2006 / 20:35:19 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2203
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2204
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2205
displayString:aString x:x y:y in:aDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2206
    "draw a string - draw foreground only.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2207
     If the coordinates are not integers, retry with rounded."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2208
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2209
    self
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2210
	displayString:aString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2211
	x:x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2212
	y:y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2213
	in:aDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2214
	with:aDC
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2215
	opaque:false
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2216
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2217
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2218
displayString:aString x:x y:y in:aDrawableId with:aDC opaque:opaque
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2219
    "draw a string"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2220
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2221
    self displayString:aString
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2222
		  from:1
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2223
		    to:aString size
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2224
		     x:x
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2225
		     y:y
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2226
		     in:aDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2227
		     with:aDC
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2228
		     opaque:opaque
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2229
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2230
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2231
fillArcX:x y:y width:width height:height from:startAngle angle:angle
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2232
               in:ignoredDrawableId with:aDC
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2233
    "fill an arc. If any coordinate is not integer, an error is triggered.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2234
     The angles may be floats or integer - they are given in degrees."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2235
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2236
    | hatchSymbol |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2237
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2238
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2239
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2240
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2241
    int __x, __y, w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2242
    float angle1, angle2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2243
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2244
    if (__isSmallInteger(startAngle))
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2245
        angle1 = (float)(__intVal(startAngle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2246
    else if (__isFloat(startAngle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2247
        angle1 = __floatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2248
    } else if (__isShortFloat(startAngle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2249
        angle1 = __shortFloatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2250
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2251
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2252
    if (__isSmallInteger(angle))
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2253
        angle2 = (float)(__intVal(angle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2254
    else if (__isFloat(angle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2255
        angle2 = __floatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2256
    } else if (__isShortFloat(angle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2257
        angle2 = __shortFloatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2258
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2259
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2260
    if (angle2 <= 0) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2261
        RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2262
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2263
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2264
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2265
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2266
     && __bothSmallInteger(width, height))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2267
     {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2268
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2269
        HBRUSH hBrush, prevBrush;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2270
        HPEN prevPen = 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2271
        COLORREF fgColor;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2272
        int hatch, hasHatch;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2273
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2274
        w = __intVal(width);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2275
        h = __intVal(height);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2276
        __x = __intVal(x);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2277
        __y = __intVal(y);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2278
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2279
        fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2280
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2281
        hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2282
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2283
        if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2284
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2285
        } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2286
            hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2287
        } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2288
            hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2289
        } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2290
            hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2291
        } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2292
            hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2293
        } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2294
            hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2295
        } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2296
            hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2297
        } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2298
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2299
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2300
        if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2301
            hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2302
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2303
            hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2304
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2305
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2306
        prevBrush = SelectObject(hDC, hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2307
        if (hBrush == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2308
            DPRINTF(("fillArc: no brush\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2309
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2310
            HPEN hPen = 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2311
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2312
            if (0 /* __isWinNT */) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2313
                fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2314
                hPen = CreatePen(PS_SOLID, 1, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2315
                prevPen = SelectObject(hDC, hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2316
                if (hPen == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2317
                    DPRINTF(("fillArc: no pen\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2318
                    goto failpen;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2319
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2320
            } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2321
                prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2322
                w++;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2323
                h++;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2324
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2325
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2326
            {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2327
                double xB, yB, xE, yE, xR, yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2328
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2329
                xR = w / 2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2330
                yR = h / 2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2331
                if (angle2 - angle1 >= 360) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2332
                    xB = xE = __x + xR + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2333
                    yB = yE = __y /*+ yR + 0.5*/;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2334
                } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2335
                    double sin(), cos();
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2336
                    float rad1, rad2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2337
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2338
                    if (angle1 <= 180)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2339
                        angle1 = 180 - angle1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2340
                    else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2341
                        angle1 = 360 + 180 - angle1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2342
                    angle2 = angle1 - angle2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2343
                    /* sigh - compute the intersections ... */
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2344
                    rad1 = (angle1 * 3.14159265359) / 180.0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2345
                    rad2 = (angle2 * 3.14159265359) / 180.0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2346
                    xB = cos(rad1) * xR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2347
                    yB = sin(rad1) * yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2348
                    xE = cos(rad2) * xR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2349
                    yE = sin(rad2) * yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2350
                    xB = __x + xR - xB + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2351
                    yB = __y + yR - yB + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2352
                    xE = __x + xR - xE + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2353
                    yE = __y + yR - yE + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2354
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2355
                DPRINTF(("fillArc x=%d y=%d w=%d h=%d xB=%d xE=%d yB=%d yE=%d a1=%f a2=%f\n",__x,__y,w,h,(int)xB,(int)xE,(int)yB,(int)yE,angle1,angle2));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2356
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2357
                Pie(hDC,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2358
                    __x, __y,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2359
                    __x + w + 1, __y + h + 1,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2360
                    (int)xB, (int)yB,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2361
                    (int)xE, (int)yE);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2362
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2363
                if (hPen) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2364
                    DeleteObject(hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2365
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2366
            }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2367
failpen:
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2368
            if (prevPen) SelectObject(hDC, prevPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2369
            DeleteObject(hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2370
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2371
            SelectObject(hDC, prevBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2372
            DeleteObject(hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2373
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2374
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2375
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2376
    bad: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2377
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2378
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2379
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2380
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2381
fillPolygon:aPolygon in:ignoredDrawableId with:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2382
    "fill a polygon given by its points.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2383
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2384
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2385
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2386
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2387
    numberOfPoints := aPolygon size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2388
    self
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2389
	primFillPolygon:aPolygon n:numberOfPoints
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2390
	in:ignoredDrawableId with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2391
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2392
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2393
fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2394
    "fill a rectangle. If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2395
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2396
    |hatchSymbol|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2397
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2398
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2399
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2400
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2401
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2402
    int w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2403
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2404
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2405
     && __bothSmallInteger(width, height)) {
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2406
        w = __intVal(width);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2407
        h = __intVal(height);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2408
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2409
        if ((w >= 0) && (h >= 0)) {
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2410
            HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2411
            HBRUSH hBrush, prevBrush;
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2412
            RECT rct;
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2413
            COLORREF fgColor;
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2414
            int hatch, hasHatch;
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2415
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2416
            fgColor = GetTextColor(hDC);
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2417
            hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2418
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2419
            if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2420
                hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2421
            } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2422
                hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2423
            } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2424
                hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2425
            } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2426
                hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2427
            } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2428
                hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2429
            } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2430
                hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2431
            } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2432
                hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2433
            } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2434
                hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2435
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2436
            if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2437
                hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2438
            } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2439
                hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2440
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2441
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2442
            rct.left = __intVal(x);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2443
            rct.top  = __intVal(y);
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2444
            rct.right  = rct.left + w; // + 1;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2445
            rct.bottom = rct.top  + h; // + 1;
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2446
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2447
           prevBrush = SelectObject(hDC, hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2448
           FillRect(hDC, &rct, hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2449
           SelectObject(hDC, prevBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2450
           DeleteObject(hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2451
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2452
        }
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2453
    }
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2454
    RETURN ( self );
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2455
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2456
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2457
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2458
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2459
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2460
primFillPolygon:aPolygon n:numberOfPoints in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2461
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2462
    |hatchSymbol|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2463
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2464
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2465
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2466
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2467
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2468
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2469
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2470
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2471
     && __isSmallInteger(numberOfPoints)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2472
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2473
        POINT p;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2474
        HBRUSH hBrush, prevBrush;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2475
        COLORREF fgColor;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2476
        int hatch, hasHatch;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2477
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2478
        num = __intVal(numberOfPoints);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2479
        if (num < 3) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2480
            RETURN ( self );
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2481
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2482
        for (i=0; i<num; i++) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2483
            point = __AT_(aPolygon, __MKSMALLINT(i+1));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2484
            if (! __isPoint(point)) goto fail;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2485
            px = _point_X(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2486
            py = _point_Y(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2487
            if (! __bothSmallInteger(px, py))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2488
                goto fail;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2489
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2490
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2491
        fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2492
        hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2493
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2494
        if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2495
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2496
        } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2497
            hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2498
        } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2499
            hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2500
        } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2501
            hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2502
        } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2503
            hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2504
        } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2505
            hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2506
        } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2507
            hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2508
        } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2509
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2510
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2511
        if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2512
            hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2513
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2514
            hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2515
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2516
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2517
        if (hBrush == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2518
            DPRINTF(("fillPolygon: no brush\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2519
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2520
            HPEN prevPen;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2521
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2522
            prevBrush = SelectObject(hDC, hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2523
            prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2524
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2525
            BeginPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2526
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2527
            for (i=0; i<num; i++) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2528
                point = __AT_(aPolygon, __MKSMALLINT(i+1));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2529
                px = _point_X(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2530
                py = _point_Y(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2531
                if (i == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2532
                    MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2533
                } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2534
                    if (i == (num-1)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2535
                        p.x = __intVal(px);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2536
                        p.y = __intVal(py);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2537
                        PolylineTo(hDC, &p, 1);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2538
                    } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2539
                        LineTo(hDC, __intVal(px), __intVal(py));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2540
                    }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2541
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2542
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2543
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2544
            EndPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2545
            FillPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2546
            SelectObject(hDC, prevPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2547
            SelectObject(hDC, prevBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2548
            DeleteObject(hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2549
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2550
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2551
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2552
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2553
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2554
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2555
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2556
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2557
!WinPrinterContext methodsFor:'drawing bitmaps'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2558
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2559
bitsBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2560
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2561
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2562
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2563
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2564
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2565
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2566
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2567
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2568
     ^Display bitsBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2569
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2570
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2571
bitsGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2572
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2573
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2574
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2575
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2576
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2577
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2578
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2579
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2580
     ^Display bitsGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2581
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2582
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2583
bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2584
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2585
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2586
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2587
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2588
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2589
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2590
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2591
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2592
     ^Display bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2593
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2594
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2595
compressColorMapImage: image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2596
    "calculates a new color map for the image, using only used colors"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2597
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2598
    |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2599
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2600
    oldImage := image.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2601
    depth := oldImage depth.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2602
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2603
    oldImage photometric ~~ #palette ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2604
        Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2605
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2606
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2607
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2608
    usedColors := oldImage realUsedColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2609
    usedColors size == (1 bitShift:depth) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2610
        Transcript showCR:'Compress colorMap: All colors are used - no compression.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2611
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2612
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2613
    usedColors size == oldImage colorMap size ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2614
        Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2615
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2616
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2617
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2618
        "/ translation table
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2619
        oldToNew := ByteArray new:(1 bitShift:depth).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2620
        newColorMap := usedColors asArray.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2621
        newColorMap sort:self sortBlockForColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2622
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2623
        oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2624
            |newPixel|
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2625
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2626
            (usedColors includes:clr) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2627
                newPixel := newColorMap indexOf:clr.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2628
                oldToNew at:oldIdx put:newPixel-1.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2629
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2630
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2631
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2632
        oldBits := oldImage bits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2633
        newBits := ByteArray new:(oldBits size).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2634
        depth ~~ 8 ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2635
            "/ expand/compress can only handle 8bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2636
            tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2637
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2638
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2639
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2640
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2641
                into:tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2642
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2643
            tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2644
                compressPixels:depth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2645
                width:oldImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2646
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2647
                into:newBits 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2648
                mapping:nil
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2649
        ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2650
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2651
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2652
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2653
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2654
                into:newBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2655
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2656
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2657
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2658
        newImage := oldImage species new
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2659
                        width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2660
                        height:oldImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2661
                        depth:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2662
                        fromArray:newBits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2663
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2664
        newImage colorMap:newColorMap.  
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2665
        newImage fileName:oldImage fileName.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2666
        newImage mask:(oldImage mask copy).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2667
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2668
        ^ newImage
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2669
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2670
    "Created: / 28.7.1998 / 20:03:11 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2671
    "Modified: / 15.9.1998 / 17:53:32 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2672
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2673
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2674
copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2675
                width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2676
    "do a bit-blt; copy bits from the rectangle defined by
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2677
     srcX/srcY and w/h from the sourceId drawable to the rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2678
     below dstX/dstY in the destId drawable. Trigger an error if any
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2679
     argument is not integer."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2680
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2681
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2682
    int     dstGcOwnerThreadID;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2683
    HWND    dstGcHWIN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2684
    HBITMAP dstGcHBITMAP;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2685
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2686
    if (! __isExternalAddressLike(srcGCId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2687
     || ! __isExternalAddressLike(dstGCId)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2688
        goto fail;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2689
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2690
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2691
    if (__bothSmallInteger(w, h)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2692
     && __bothSmallInteger(srcX, srcY)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2693
     && __bothSmallInteger(dstX, dstY)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2694
        HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2695
        HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2696
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2697
        int fun, aFunctionSymbol;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2698
        int src_fg, src_bg, dst_fg, dst_bg;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2699
        char buf[5];
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2700
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2701
//          fun = dstGcData->bitbltrop2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2702
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2703
        aFunctionSymbol= __INST(function);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2704
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2705
        if (aFunctionSymbol == @symbol(copy)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2706
            fun = SRCCOPY /* R2_COPYPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2707
/*            bfun = BITBLT_COPY;                                          */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2708
        } else if (aFunctionSymbol == @symbol(copyInverted)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2709
            fun = NOTSRCCOPY /* R2_NOTCOPYPEN */;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2710
/*            bfun = BITBLT_COPYINVERTED;                                  */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2711
        } else if (aFunctionSymbol == @symbol(xor)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2712
            fun = SRCINVERT /* R2_XORPEN */;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2713
/*            bfun = BITBLT_XOR;                                           */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2714
        } else if (aFunctionSymbol == @symbol(and)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2715
            fun = SRCAND /* R2_MASKPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2716
/*            bfun = BITBLT_AND;                                           */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2717
        } else if (aFunctionSymbol == @symbol(or)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2718
            fun = MERGECOPY /* R2_MERGEPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2719
/*            bfun = BITBLT_OR;                                            */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2720
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2721
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2722
    // convert 123 to string [buf]
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2723
    // itoa(fun, buf, 10);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2724
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2725
    //        console_printf(" ", buf);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2726
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2727
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2728
#if 0
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2729
        switch (fun) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2730
          case BITBLT_COPY:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2731
            console_printf("BITBLT_COPY\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2732
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2733
          case BITBLT_COPYINVERTED:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2734
            console_printf("BITBLT_COPYINVERTED\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2735
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2736
          case BITBLT_XOR:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2737
            console_printf("BITBLT_XOR\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2738
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2739
          case BITBLT_AND:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2740
            console_printf("BITBLT_AND\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2741
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2742
          case BITBLT_OR:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2743
            console_printf("BITBLT_OR\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2744
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2745
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2746
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2747
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2748
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2749
//          fun = dstGcData->bitbltrop2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2750
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2751
        if (0 /* fun == BITBLT_COPY */) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2752
            src_fg = dst_fg = 0xFFFFFF;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2753
            src_bg = dst_bg = 0x000000;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2754
        } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2755
            src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2756
            src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2757
            dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2758
            dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2759
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2760
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2761
        SetBkColor(dstDC, dst_fg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2762
        SetTextColor(dstDC, dst_bg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2763
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2764
        SetBkColor(srcDC, src_fg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2765
        SetTextColor(srcDC, src_bg);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2766
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2767
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2768
        CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2769
        CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2770
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2771
        if (BitBlt(dstDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2772
             __intVal(dstX), __intVal(dstY),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2773
             __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2774
             srcDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2775
             __intVal(srcX), __intVal(srcY),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2776
             fun)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2777
           == 0
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2778
          ) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2779
            console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2780
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2781
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2782
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2783
        if (dstGcData != srcGcData) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2784
            SetBkColor(dstDC, dstGcData->bgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2785
            SetTextColor(dstDC, dstGcData->fgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2786
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2787
        SetBkColor(srcDC, srcGcData->bgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2788
        SetTextColor(srcDC, srcGcData->fgColor);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2789
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2790
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2791
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2792
        if (srcGcData != dstGcData) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2793
            _releaseDC(srcGcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2794
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2795
        _releaseDC(dstGcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2796
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2797
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2798
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2799
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2800
 fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2801
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2802
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2803
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2804
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2805
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2806
copyFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2807
    "do a bit-blt from a pix- or bitmap.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2808
     Here, fall back into copyFromId:, which should also work.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2809
     Subclasses may redefine this for more performance or if required"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2810
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2811
    ^ self copyFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2812
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2813
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2814
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2815
		width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2816
    "do a bit-blt, but only copy the low-bit plane;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2817
     copy bits from the rectangle defined by
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2818
     srcX/srcY and w/h from the sourceId drawable to the rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2819
     below dstX/dstY in the destId drawable. Trigger an error if any
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2820
     argument is not integer."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2821
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2822
    ^ self
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2823
	copyFromId:sourceId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2824
		 x:srcX y:srcY gc:srcDCId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2825
		to:destId x:dstX y:dstY gc:dstDCId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2826
	     width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2827
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2828
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2829
copyPlaneFromPixmapId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2830
    "do a bit-blt from a pix- or bitmap, using the low-bit plane of the source only.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2831
     Here, fall back into copyPlaneFromId:, which should also work.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2832
     Subclasses may redefine this for more performance or if required"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2833
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2834
    ^ self copyPlaneFromId:sourceId x:srcX y:srcY gc:srcGCId to:destId x:dstX y:dstY gc:dstGCId width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2835
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2836
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2837
createBitmapFromArray:anArray width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2838
    |bitmapId|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2839
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  2840
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2841
    bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2842
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2843
    bitmapId isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2844
	'WINWORKSTATION: cannot create bitmap' errorPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2845
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2846
    ^ bitmapId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2847
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2848
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2849
createPixmapWidth:w height:h depth:d
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2850
    "allocate a pixmap on the Xserver, the contents is undefined
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2851
     (i.e. random). Return a bitmap id or nil"
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2852
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2853
%{
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2854
    HANDLE newBitmapHandle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2855
    HANDLE rootDC = CreateDC("DISPLAY", NULL, NULL, NULL);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2856
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2857
    /*console_printf("CreateBitmap Color\n");*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2858
    if (__bothSmallInteger(w, h) && __isSmallInteger(d) /*&& ISCONNECTED */) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2859
	if (__intVal(d) == 1) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2860
	    newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2861
	} else {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2862
#if 0
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2863
	    if (__intVal(d) != __depth) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2864
		console_printf("invalid depth\n");
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2865
		RETURN (nil);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2866
	    }
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2867
#endif
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2868
	    newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2869
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2870
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2871
	if (newBitmapHandle) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2872
	    RETURN ( __MKOBJ(newBitmapHandle));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2873
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2874
/*
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2875
	DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2876
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2877
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2878
    RETURN (nil);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2879
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2880
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2881
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2882
destroyPixmap:aDrawableId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2883
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2884
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2885
    if (__isExternalAddress(aDrawableId) /* && ISCONNECTED */ ) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2886
	HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2887
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2888
	if (bitmapHandle) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2889
	    DeleteObject(bitmapHandle);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2890
	/*    _DeleteObject(bitmapHandle, __LINE__);    */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  2891
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2892
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2893
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2894
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2895
2329
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  2896
displayDeviceForm:aForm x:x y:y
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2897
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2898
    |sortedImage formMask bitsWithTransparency|
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2899
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2900
    sortedImage := aForm.
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2901
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2902
    aForm depth ~~ 8 ifTrue:[
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2903
        sortedImage := aForm asImageWithDepth: 8.
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2904
    ].
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2905
"/    sortedImage := self sortColorMapImage: aForm.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2906
    sortedImage := self compressColorMapImage: sortedImage.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2907
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2908
    formMask := sortedImage mask.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2909
    formMask isNil 
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2910
        ifTrue:[bitsWithTransparency := sortedImage bits ]
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2911
        ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2912
            |bitsWithTransparencySize|
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  2913
            formMask := formMask asImageWithDepth: sortedImage depth.
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2914
            bitsWithTransparency := sortedImage bits copy.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2915
            bitsWithTransparencySize := bitsWithTransparency size.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2916
            formMask bits doWithIndex:[:maskBit :index |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2917
                bitsWithTransparencySize >= index ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2918
                    maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2919
"/                maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2920
                ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2921
            ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2922
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2923
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2924
"/    sortedImage colorMap redVector at:255 put: 255.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2925
"/    sortedImage colorMap greenVector at:255 put: 255.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2926
"/    sortedImage colorMap blueVector at:255 put: 255.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2927
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2928
    self 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2929
         drawBits: bitsWithTransparency ? sortedImage bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2930
        redVector: sortedImage colorMap redVector
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2931
      greenVector: sortedImage colorMap greenVector
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2932
       blueVector: sortedImage colorMap blueVector
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2933
     bitsPerPixel: sortedImage bitsPerPixel
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2934
            depth: sortedImage depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2935
            width: sortedImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2936
           height: sortedImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2937
             into: self id
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2938
                x: x 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2939
                y: y
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2940
            width: sortedImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2941
           height: sortedImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2942
             with: gcId.
2329
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  2943
!
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  2944
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2945
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2946
                          width:imageWidth height:imageHeight
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2947
                              x:srcx y:srcy
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2948
                           into:ignoredDrawableId
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2949
                              x:dstx y:dsty
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2950
                          width:w height:h
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2951
                           with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2952
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2953
    "draw a bitImage which has depth id, width iw and height ih into
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2954
     the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2955
     Individual source pixels have bitsPerPixel bits, allowing to draw
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2956
     depth and pixel-units to be different.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2957
     It has to be checked elsewhere, that the server can do it with the given
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2958
     depth - otherwise, primitive failure will be signalled.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2959
     Also it is assumed, that the colormap is setup correctly and the
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2960
     colors are allocated - otherwise the colors may be wrong."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2961
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2962
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2963
     sorry; I had to separate it into 2 methods, since XPutImage needs
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2964
     an unlimited stack, and thus cannot send primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2965
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2966
    (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2967
                                        width:imageWidth height:imageHeight
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2968
                                             x:srcx y:srcy
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2969
                                          into:ignoredDrawableId
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2970
                                             x:(dstx rounded) y:(dsty rounded)
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2971
                                         width:w height:h
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2972
                                          with:aGCId)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2973
    ifFalse:[
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2974
        "
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2975
         also happens, if a segmentation violation occurs in the
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2976
         XPutImage ...
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2977
        "
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2978
        self primitiveFailed
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2979
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2980
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2981
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2982
drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2983
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2984
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2985
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2986
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2987
                               with:aGCId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2988
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2989
    "draw a bitImage which has depth id, width iw and height ih into
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2990
     the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2991
     Individual source pixels have bitsPerPixel bits, allowing to draw
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2992
     depth and pixel-units to be different.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2993
     It has to be checked elsewhere, that the server can do it with the given
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2994
     depth - otherwise, primitive failure will be signalled.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2995
     Also it is assumed, that the colormap is setup correctly and the
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2996
     colors are allocated - otherwise the colors may be wrong."
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2997
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2998
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2999
     sorry; I had to separate it into 2 methods, since XPutImage needs
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3000
     an unlimited stack, and thus cannot send primitiveFailed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3001
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3002
    (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3003
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3004
                               into:ignoredDrawableId
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3005
                                  x:(dstx rounded) y:(dsty rounded)
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3006
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3007
                               with:aGCId)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3008
    ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3009
        "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3010
         also happens, if a segmentation violation occurs in the
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3011
         XPutImage ...
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3012
        "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3013
        self primitiveFailed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3014
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3015
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3016
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3017
primCreateBitmapFromArray:anArray width:w height:h
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3018
%{
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3019
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3020
    HBITMAP newBitmapHandle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3021
    int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3022
    int row, col;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3023
    unsigned char *cp, *bPits;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3024
    unsigned char *b_bits = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3025
    int index;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3026
    OBJ num;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3027
    unsigned char *allocatedBits = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3028
    unsigned char fastBits[10000];
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3029
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3030
    if (__bothSmallInteger(w, h)
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3031
     && _isNonNilObject(anArray)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3032
	OBJ cls = __qClass(anArray);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3033
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3034
	b_width = __intVal(w);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3035
	b_height = __intVal(h);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3036
	bytesPerRowST = (b_width + 7) / 8;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3037
	bytesPerRowWN = ((b_width + 15) / 16) * 2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3038
	padding = bytesPerRowWN - bytesPerRowST;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3039
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3040
	if ((padding == 0) && (cls == @global(ByteArray))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3041
	    b_bits = __ByteArrayInstPtr(anArray)->ba_element;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3042
	    cp = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3043
	} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3044
	    int nBytes = b_height * bytesPerRowWN;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3045
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3046
	    if (nBytes < sizeof(fastBits)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3047
		cp = b_bits = fastBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3048
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3049
		cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3050
		if (! cp) goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3051
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3052
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3053
	if (cp) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3054
	    if (cls == @global(Array)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3055
		OBJ *op;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3056
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3057
		index = 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3058
		op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3059
		for (row = b_height; row; row--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3060
		    for (col = bytesPerRowST; col; col--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3061
			num = *op++;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3062
			if (! __isSmallInteger(num))
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3063
			    goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3064
			*cp++ = __intVal(num);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3065
		    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3066
		    cp += padding;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3067
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3068
	    } else if (cls == @global(ByteArray)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3069
		unsigned char *pBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3070
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3071
		pBits = __ByteArrayInstPtr(anArray)->ba_element;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3072
		for (row = b_height; row; row--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3073
		    for (col = bytesPerRowST; col; col--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3074
			*cp++ = ( *pBits++ /*^ 0xFF*/ );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3075
		    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3076
		    cp += padding;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3077
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3078
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3079
		goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3080
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3081
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3082
/*
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3083
	CPRINTF(("create bitmap ...\n"));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3084
*/
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3085
	newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3086
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3087
	if (newBitmapHandle ) {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3088
/*
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3089
	    DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3090
*/
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3091
	    if (allocatedBits) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3092
		free(allocatedBits);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3093
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3094
	    RETURN ( __MKOBJ(newBitmapHandle));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3095
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3096
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3097
fail: ;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3098
/*
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3099
    DDPRINTF(("create bitmap FAILED!!!\n"));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3100
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3101
    if (allocatedBits) {
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3102
/*
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3103
	CPRINTF(("freeing up bitmap bits ...\n"));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3104
*/
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3105
	free(allocatedBits);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3106
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3107
/*
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3108
    CPRINTF(("returning nil ...\n"));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3109
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3110
    RETURN ( nil );
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3111
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3112
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3113
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3114
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3115
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3116
                                  x:srcx y:srcy
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3117
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3118
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3119
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3120
                               with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3121
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3122
    "since XPutImage may allocate huge amount of stack space
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3123
     (some implementations use alloca), this must run with unlimited stack."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3124
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3125
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3126
    unsigned char fastBits[10000];
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3127
    unsigned char *b_bits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3128
    unsigned char *allocatedBits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3129
    unsigned char *__imageBits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3130
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3131
    if (__isByteArray(imageBits)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3132
        __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3133
    } else if (__isExternalBytesLike(imageBits)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3134
        __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3135
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3136
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3137
    if (/* ISCONNECTED
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3138
     && */ __isExternalAddressLike(aGCId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3139
     && __bothSmallInteger(srcx, srcy)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3140
     && __bothSmallInteger(dstx, dsty)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3141
     && __bothSmallInteger(w, h)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3142
     && __bothSmallInteger(imageWidth, imageHeight)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3143
     && __bothSmallInteger(imageDepth, bitsPerPixel)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3144
     && __isSmallInteger(padd)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3145
     && __imageBits)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3146
     {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3147
        struct
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3148
        {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3149
          BITMAPINFOHEADER bmiHeader;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3150
          DWORD r;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3151
          DWORD g;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3152
          DWORD b;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3153
        } bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3154
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3155
        HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3156
        HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3157
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3158
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3159
        DDPRINTF(("hDC = %x\n", hDC));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3160
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3161
        if (__intVal(padd) != WIN32PADDING) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3162
            int row, col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3163
            unsigned char *cp;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3164
            unsigned char *pBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3165
            int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3166
            int bi = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3167
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3168
            b_width = __intVal(w);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3169
            b_height = __intVal(h);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3170
            bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3171
            bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3172
            padding = bytesPerRowWN - bytesPerRowST;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3173
            nBytes = b_height * bytesPerRowWN;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3174
            /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3175
            if (padding) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3176
                if (nBytes < sizeof(fastBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3177
                    cp = b_bits = fastBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3178
                } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3179
                    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3180
                }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3181
                if (cp) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3182
                    pBits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3183
                    for (row = b_height; row; row--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3184
                        for (col = bytesPerRowST; col; col--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3185
                            *cp++ = *pBits++;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3186
                        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3187
                        cp += padding;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3188
                    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3189
                } else
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3190
                    goto fail;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3191
            }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3192
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3193
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3194
        if (b_bits == 0) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3195
            b_bits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3196
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3197
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3198
        bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3199
        bitmap.bmiHeader.biPlanes = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3200
        if (__intVal(imageDepth) == 24) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3201
            /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3202
            bitmap.r = 0xff0000;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3203
            bitmap.g = 0x00ff00;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3204
            bitmap.b = 0x0000ff;*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3205
            bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3206
        } else if (__intVal(imageDepth) == 16) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3207
            /*bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3208
            bitmap.bmiHeader.biCompression = BI_BITFIELDS;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3209
            bitmap.b = 0x001f;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3210
            bitmap.g = 0x07e0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3211
            bitmap.r = 0xf800;*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3212
            bitmap.b = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3213
            bitmap.g = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3214
            bitmap.r = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3215
            bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3216
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3217
        bitmap.bmiHeader.biSizeImage = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3218
        bitmap.bmiHeader.biXPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3219
        bitmap.bmiHeader.biYPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3220
        bitmap.bmiHeader.biClrUsed = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3221
        bitmap.bmiHeader.biClrImportant = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3222
        bitmap.bmiHeader.biWidth = __intVal(imageWidth);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3223
        bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3224
        bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3225
        /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3226
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3227
        SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3228
                              __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3229
                              __intVal(srcx), __intVal(srcy),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3230
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3231
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3232
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3233
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3234
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3235
        SetDIBits(hDC,hBitmap,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3236
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3237
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3238
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3239
*/
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3240
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3241
        StretchDIBits(hDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3242
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3243
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3244
                      __intVal(srcx), __intVal(srcy),           // x & y coord of source upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3245
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3246
                      (void *)b_bits,                           // bitmap bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3247
                      (BITMAPINFO*)&bitmap,                     // bitmap data
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3248
                      DIB_RGB_COLORS,                           // usage options
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3249
                      SRCCOPY                                   // raster operation code
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3250
        );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3251
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3252
        if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3253
            free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3254
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3255
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3256
#ifndef CACHE_LAST_DC
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3257
        _releaseDC(gcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3258
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3259
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3260
        RETURN ( true );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3261
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3262
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3263
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3264
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3265
    PRINTF(("create temp bitmap FAILED!!!\n"));
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3266
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3267
    if (allocatedBits) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3268
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3269
        PRINTF(("freeing up temp bitmap bits ...\n"));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3270
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3271
        free(allocatedBits);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3272
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3273
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3274
#ifndef CACHE_LAST_DC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3275
    if (hDC) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3276
        _releaseDC(gcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3277
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3278
#endif
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3279
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3280
%}
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3281
.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3282
    ^ false
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3283
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3284
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3285
primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3286
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3287
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3288
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3289
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3290
                               with:aGCId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3291
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3292
    "since XPutImage may allocate huge amount of stack space
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3293
     (some implementations use alloca), this must run with unlimited stack."
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3294
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3295
%{
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3296
    unsigned char fastBits[10000];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3297
    unsigned char *b_bits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3298
    unsigned char *allocatedBits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3299
    unsigned char *__imageBits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3300
    unsigned char *__redVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3301
    unsigned char *__greenVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3302
    unsigned char *__blueVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3303
    int padd = 8;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3304
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3305
    if (__isByteArray(imageBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3306
        __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3307
    } else if (__isExternalBytesLike(imageBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3308
        __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3309
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3310
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3311
    if (__isByteArray(redVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3312
        __redVector = __ByteArrayInstPtr(redVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3313
    } else if (__isExternalBytesLike(redVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3314
        __redVector = (unsigned char *)(__externalBytesAddress(redVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3315
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3316
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3317
    if (__isByteArray(greenVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3318
        __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3319
    } else if (__isExternalBytesLike(greenVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3320
        __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3321
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3322
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3323
    if (__isByteArray(blueVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3324
        __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3325
    } else if (__isExternalBytesLike(blueVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3326
        __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3327
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3328
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3329
    if (/* ISCONNECTED
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3330
     && */ __isExternalAddressLike(aGCId)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3331
//     && __bothSmallInteger(srcx, srcy)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3332
     && __bothSmallInteger(dstx, dsty)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3333
     && __bothSmallInteger(w, h)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3334
     && __bothSmallInteger(imageWidth, imageHeight)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3335
     && __bothSmallInteger(imageDepth, bitsPerPixel)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3336
     && __imageBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3337
     && __redVector
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3338
     && __greenVector
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3339
     && __blueVector)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3340
     {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3341
        struct
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3342
        {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3343
          BITMAPINFOHEADER bmiHeader;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3344
          RGBQUAD bmiColors[256];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3345
        } bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3346
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3347
        HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3348
        HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3349
        int col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3350
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3351
        DDPRINTF(("hDC = %x\n", hDC));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3352
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3353
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3354
        if (padd != WIN32PADDING) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3355
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3356
            int row, col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3357
            unsigned char *cp;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3358
            unsigned char *pBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3359
            int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3360
            int bi = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3361
2340
7aada47a2ec0 changed #primDrawBits:redVector:greenVector:blueVector:bitsPerPixel:depth:width:height:into:x:y:width:height:with:
fm
parents: 2339
diff changeset
  3362
//            console_fprintf(stderr, "Non WIN32PADDING");
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3363
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3364
            b_width = __intVal(w);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3365
            b_height = __intVal(h);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3366
            bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3367
            bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3368
            padding = bytesPerRowWN - bytesPerRowST;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3369
            nBytes = b_height * bytesPerRowWN;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3370
            /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3371
            if (padding) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3372
                if (nBytes < sizeof(fastBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3373
                    cp = b_bits = fastBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3374
                } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3375
                    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3376
                }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3377
                if (cp) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3378
                    pBits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3379
                    for (row = b_height; row; row--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3380
                        for (col = bytesPerRowST; col; col--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3381
                            *cp++ = *pBits++;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3382
                        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3383
                        cp += padding;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3384
                    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3385
                } else
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3386
                    goto fail;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3387
            }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3388
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3389
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3390
        if (b_bits == 0) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3391
            b_bits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3392
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3393
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3394
        bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3395
        bitmap.bmiHeader.biPlanes = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3396
        bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3397
        bitmap.bmiHeader.biSizeImage = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3398
        bitmap.bmiHeader.biXPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3399
        bitmap.bmiHeader.biYPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3400
        bitmap.bmiHeader.biClrUsed = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3401
        bitmap.bmiHeader.biClrImportant = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3402
        bitmap.bmiHeader.biWidth = __intVal(imageWidth);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3403
        bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3404
        bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3405
        /*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3406
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  3407
 //       if (__intVal(imageDepth) == 8) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3408
            for(col=0;col<256;col++)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3409
             {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3410
              bitmap.bmiColors[col].rgbBlue = __blueVector[col];    // Microsoft idea: change rgbBlue to rgbRed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3411
              bitmap.bmiColors[col].rgbGreen = __greenVector[col];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3412
              bitmap.bmiColors[col].rgbRed = __redVector[col];         // Microsoft idea: change rgbRed to rgbBlue
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3413
              bitmap.bmiColors[col].rgbReserved = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3414
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3415
            }
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  3416
 //       }
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3417
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3418
        bitmap.bmiColors[255].rgbBlue=255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3419
        bitmap.bmiColors[255].rgbGreen=255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3420
        bitmap.bmiColors[255].rgbRed =255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3421
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3422
        SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3423
                              __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3424
                              0, 0, /* __intVal(srcx), __intVal(srcy),    */
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3425
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3426
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3427
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3428
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3429
        SetDIBits(hDC,hBitmap,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3430
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3431
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3432
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3433
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3434
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3435
        StretchDIBits(hDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3436
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3437
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3438
                      __intVal(srcx), __intVal(srcy),           // x & y coord of source upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3439
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3440
                      (void *)b_bits,                           // bitmap bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3441
                      (BITMAPINFO*)&bitmap,                     // bitmap data
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3442
                      DIB_RGB_COLORS,                           // usage options
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3443
                      SRCCOPY                                   // raster operation code
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3444
        );
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3445
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3446
        if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3447
            free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3448
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3449
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3450
#ifndef CACHE_LAST_DC
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3451
        _releaseDC(gcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3452
#endif
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3453
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3454
        RETURN ( true );
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3455
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3456
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3457
fail: ;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3458
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3459
    PRINTF(("create temp bitmap FAILED!!!\n"));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3460
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3461
    if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3462
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3463
        PRINTF(("freeing up temp bitmap bits ...\n"));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3464
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3465
        free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3466
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3467
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3468
#ifndef CACHE_LAST_DC
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3469
    if (hDC) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3470
        _releaseDC(gcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3471
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3472
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3473
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3474
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3475
.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3476
    ^ false
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3477
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3478
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3479
setFunction:aFunctionSymbol in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3480
    "set alu function to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3481
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3482
    Transcript showCR: aFunctionSymbol printString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3483
    function := aFunctionSymbol.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3484
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3485
"/%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3486
"/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3487
"/    if (__isExternalAddress(aGCId)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3488
"/        struct gcData *gcData = _GCDATA(aGCId);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3489
"/        int fun = -1;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3490
"/        int bfun = -1;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3491
"/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3492
"/        if (aFunctionSymbol == @symbol(copy)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3493
"/            fun = R2_COPYPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3494
"/            bfun = BITBLT_COPY;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3495
"/        } else if (aFunctionSymbol == @symbol(copyInverted)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3496
"/            fun = R2_NOTCOPYPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3497
"/            bfun = BITBLT_COPYINVERTED;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3498
"/        } else if (aFunctionSymbol == @symbol(xor)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3499
"/            fun = R2_XORPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3500
"/            bfun = BITBLT_XOR;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3501
"/        } else if (aFunctionSymbol == @symbol(and)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3502
"/            fun = R2_MASKPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3503
"/            bfun = BITBLT_AND;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3504
"/        } else if (aFunctionSymbol == @symbol(or)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3505
"/            fun = R2_MERGEPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3506
"/            bfun = BITBLT_OR;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3507
"/        }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3508
"/
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  3509
"/        if (fun
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3510
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3511
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3512
setGraphicsExposures:aBoolean in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3513
    "set or clear the graphics exposures flag"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3514
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3515
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3516
shiftBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3517
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3518
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3519
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3520
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3521
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3522
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3523
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3524
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3525
     ^Display shiftBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3526
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3527
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3528
shiftGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3529
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3530
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3531
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3532
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3533
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3534
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3535
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3536
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3537
     ^Display shiftGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3538
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3539
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3540
shiftRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3541
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3542
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3543
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3544
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3545
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3546
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3547
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3548
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3549
     ^Display shiftRed
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3550
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3551
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3552
sortBlockForColors
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3553
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3554
    ^ [:a :b |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3555
            a redByte == b redByte ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3556
                a greenByte == b greenByte ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3557
                    a blueByte < b blueByte
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3558
                ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3559
                    a greenByte < b greenByte 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3560
                ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3561
            ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3562
                a redByte < b redByte 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3563
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3564
      ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3565
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3566
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3567
sortColorMapImage: image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3568
    "calculates a new color map for the image, sorting colors"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3569
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3570
    |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3571
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3572
    sortBlock := self sortBlockForColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3573
    oldImage := image.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3574
    depth := oldImage depth.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3575
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3576
    oldImage photometric ~~ #palette ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3577
        Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3578
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3579
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3580
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3581
    usedColors := oldImage realColorMap.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3582
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3583
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3584
        "/ translation table
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3585
        oldToNew := ByteArray new:(1 bitShift:depth).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3586
        newColorMap := usedColors asArray.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3587
        newColorMap sort:sortBlock.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3588
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3589
        oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3590
            |newPixel|
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3591
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3592
            (usedColors includes:clr) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3593
                newPixel := newColorMap indexOf:clr.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3594
                oldToNew at:oldIdx put:newPixel-1.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3595
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3596
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3597
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3598
        oldBits := oldImage bits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3599
        newBits := ByteArray new:(oldBits size).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3600
        depth ~~ 8 ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3601
            "/ expand/compress can only handle 8bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3602
            tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3603
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3604
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3605
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3606
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3607
                into:tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3608
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3609
            tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3610
                compressPixels:depth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3611
                width:oldImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3612
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3613
                into:newBits 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3614
                mapping:nil
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3615
        ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3616
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3617
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3618
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3619
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3620
                into:newBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3621
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3622
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3623
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3624
        newImage := oldImage species new
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3625
                        width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3626
                        height:oldImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3627
                        depth:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3628
                        fromArray:newBits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3629
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3630
        newImage colorMap:newColorMap.  
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3631
        newImage fileName:oldImage fileName.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3632
        newImage mask:(oldImage mask copy).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3633
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3634
        ^newImage
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3635
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3636
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3637
!WinPrinterContext methodsFor:'font stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3638
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3639
createFontFor:aFontName
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3640
    "a basic method for font allocation; this method allows
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3641
     any font to be aquired (even those not conforming to
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3642
     standard naming conventions, such as cursor, fixed or k14)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3643
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3644
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3645
    HGDIOBJ hFont;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3646
    char *fn;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3647
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3648
    if (__isString(aFontName) || __isSymbol(aFontName)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3649
	fn = __stringVal(aFontName);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3650
	if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3651
	    hFont = GetStockObject(ANSI_FIXED_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3652
	} else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3653
	    hFont = GetStockObject(ANSI_VAR_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3654
	} else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3655
	    hFont = GetStockObject(SYSTEM_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3656
	} else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3657
	    hFont = GetStockObject(SYSTEM_FIXED_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3658
	} else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3659
	    hFont = GetStockObject(DEVICE_DEFAULT_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3660
	} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3661
	    hFont = GetStockObject(ANSI_FIXED_FONT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3662
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3663
	if (hFont) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3664
	    DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3665
	    RETURN ( __MKOBJ(hFont) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3666
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3667
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3668
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3669
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3670
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3671
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3672
fontMetricsOf:fontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3673
    "return a fonts metrics info object"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3674
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3675
    |rawData info|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3676
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3677
    rawData := Array new:15.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3678
    (self primFontMetricsOf:fontId hdc:gcId intoArray:rawData) isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3679
	self primitiveFailed.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3680
	^ self
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3681
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3682
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3683
    rawData at:11 put:#'ms-ansi'.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3684
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3685
    info := DeviceWorkstation::DeviceFontMetrics new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3686
    info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3687
      ascent:(rawData at:1)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3688
      descent:(rawData at:2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3689
      maxAscent:(rawData at:3)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3690
      maxDescent:(rawData at:4)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3691
      minWidth:(rawData at:5)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3692
      maxWidth:(rawData at:6)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3693
      avgWidth:(rawData at:7)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3694
      minCode:(rawData at:8)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3695
      maxCode:16rFFFF "(rawData at:9)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3696
      direction:nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3697
      encoding:(rawData at:11).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3698
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3699
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3700
    ^ info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3701
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3702
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3703
getDefaultFont
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3704
    "return a default font id - used when class Font cannot
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3705
     find anything usable"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3706
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3707
     ^ self createFontFor:'fixed'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3708
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3709
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3710
getFontWithFamily:familyString face:faceString
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3711
	    style:styleArgString size:sizeArg encoding:encodingSym
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3712
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3713
    "try to get the specified font, if not available, try the next smaller
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3714
     font."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3715
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3716
    |styleString theName theId xlatedStyle id spacing|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3717
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3718
    styleString := styleArgString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3719
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3720
    "special: if face is nil, allow access to X-fonts"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3721
    faceString isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3722
	sizeArg notNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3723
	    theName := familyString , '-' , sizeArg printString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3724
	] ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3725
	    theName := familyString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3726
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3727
	theName isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3728
	    "
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3729
	     mhmh - fall back to the default font
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3730
	    "
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3731
	    theName := 'fixed'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3732
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3733
	theId := self createFontFor:theName.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3734
	theId isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3735
	    theId := self getDefaultFont
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3736
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3737
	^ theId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3738
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3739
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3740
    "/ spacing other than 'normal' is contained as last component
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3741
    "/ in style
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3742
    styleString notNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3743
	((styleString endsWith:'-narrow')
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3744
	 or:[styleString endsWith:'-semicondensed']) ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3745
	    |i|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3746
	    i := styleString lastIndexOf:$-.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3747
	    spacing := styleString copyFrom:(i+1).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3748
	    styleString := styleString copyTo:(i-1).
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3749
	] ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3750
	    spacing := 'normal'.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3751
	].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3752
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3753
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3754
    xlatedStyle := styleString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3755
    xlatedStyle notNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3756
	xlatedStyle := xlatedStyle first asString
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3757
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3758
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3759
    id := self
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3760
	    getFontWithFoundry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3761
	    family:familyString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3762
	    weight:faceString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3763
	    slant:styleString "/ xlatedStyle
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3764
	    spacing:spacing
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3765
	    pixelSize:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3766
	    size:sizeArg
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3767
	    registry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3768
	    encoding:encodingSym.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3769
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3770
    id isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3771
	(encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3772
	    "/ too stupid: encodings come in both cases
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3773
	    "/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3774
	    id := self
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3775
		    getFontWithFoundry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3776
		    family:familyString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3777
		    weight:faceString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3778
		    slant:styleString "/ xlatedStyle
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3779
		    spacing:spacing
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3780
		    pixelSize:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3781
		    size:sizeArg
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3782
		    registry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3783
		    encoding:encodingSym asUppercase.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3784
	    id isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3785
		id := self
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3786
			getFontWithFoundry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3787
			family:familyString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3788
			weight:faceString
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3789
			slant:styleString "/ xlatedStyle
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3790
			spacing:spacing
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3791
			pixelSize:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3792
			size:sizeArg
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3793
			registry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3794
			encoding:encodingSym asLowercase.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3795
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3796
		id isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3797
		    id := self
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3798
			    getFontWithFoundry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3799
			    family:familyString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3800
			    weight:faceString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3801
			    slant:styleString asLowercase
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3802
			    spacing:spacing
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3803
			    pixelSize:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3804
			    size:sizeArg
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3805
			    registry:'*'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3806
			    encoding:encodingSym asLowercase.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3807
		]
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3808
	    ]
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3809
	]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3810
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3811
    ^ id
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3812
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3813
    "Modified: 24.2.1996 / 22:37:24 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3814
    "Modified: 4.7.1996 / 11:38:47 / stefan"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3815
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3816
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3817
getFontWithFoundry:foundry family:family weight:weight
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3818
	      slant:slant spacing:spc pixelSize:pixelSize size:pointSize
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3819
	      registry:registry encoding:encoding
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3820
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3821
    "get the specified font, if not available, return nil.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3822
     For now, this is a poor (incomplete) emulation of the X code ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3823
     Individual attributes can be left empty (i.e. '') or nil to match any.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3824
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3825
     foundry:   'adobe', 'misc', 'dec', 'schumacher' ... usually '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3826
     family:    'helvetica' 'courier' 'times' ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3827
     weight:    'bold' 'medium' 'demi' ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3828
     slant:     'r(oman)' 'i(talic)' 'o(blique)'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3829
     spacing:   'narrow' 'normal' semicondensed' ... usually '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3830
     pixelSize: 16,18 ... usually left empty
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3831
     size:      size in point (1/72th of an inch)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3832
     registry:  iso8859, sgi ... '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3833
     encoding:  vendor specific encoding (usually '*')
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3834
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3835
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3836
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3837
     Windows-NT/95 allows the creation of a font with the following parameters
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3838
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3839
	nHeight
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3840
	nWidth
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3841
	nEscapement
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3842
	nOrientation
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3843
	fnWeight        FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3844
	fdwItalic       TRUE or FALSE
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3845
	fdwUnderline    TRUE or FALSE
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3846
	fdwStrikeOut    TRUE or FALSE
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3847
	fdwCharSet      ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3848
	fdwOutputPrecision      DEFAULT, STRING, CHAR, ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3849
	fdwClipPrecision        DEFAULT, CHAR, STROKE, MASK, ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3850
	fdwQuality      DEFAULT, DRAFT, or PROOF.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3851
	fdwPitchAndFamily
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3852
		DEFAULT, FIXED or VARIABLE pitch
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3853
		DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3854
	lpszFace
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3855
		Typeface Name
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3856
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3857
      These two above descriptions will be matched as follows:
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3858
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3859
	foundry   - ignored
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3860
	family    - mapped to type face name.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3861
	weight    - mapped to fnWeight
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3862
	slant     - used for style
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3863
	spacing   - NOT USED INITIALLY
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3864
	pixelSize - NOT USED INITIALLY
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3865
	size      - mapped to nHeight
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3866
	registry  - NOT USED INITIALLY
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3867
	encoding  - mapped to fdwCharSet
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3868
     "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3869
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3870
    |logSize|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3871
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3872
    pixelSize notNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3873
	logSize := pixelSize
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3874
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3875
	logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3876
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3877
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3878
    HGDIOBJ hFont;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3879
    int  pointSize, nHeight, nWidth, nEscapement, nOrientation;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3880
    char* work;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3881
    char* work2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3882
    DWORD fnWeight;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3883
    DWORD fdwItalic;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3884
    DWORD fdwUnderline;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3885
    DWORD fdwStrikeOut;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3886
    DWORD fdwCharSet;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3887
    DWORD fdwOutputPrecision;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3888
    DWORD fdwClipPrecision;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3889
    DWORD fdwQuality;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3890
    DWORD fdwPitchAndFamily;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3891
    static char faceName[256];
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3892
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3893
/* INITIALIZE */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3894
    strcpy( faceName, "NULL" );
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3895
    nHeight   = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3896
    nWidth   = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3897
    nEscapement = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3898
    nOrientation = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3899
    fnWeight = FW_NORMAL;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3900
    fdwItalic = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3901
    fdwUnderline = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3902
    fdwStrikeOut = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3903
    fdwOutputPrecision = OUT_DEFAULT_PRECIS;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3904
    fdwClipPrecision   = CLIP_DEFAULT_PRECIS;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3905
    fdwQuality         = DEFAULT_QUALITY;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3906
    fdwPitchAndFamily  = FF_DONTCARE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3907
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3908
    fdwCharSet   = ANSI_CHARSET;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3909
    if ((encoding == @symbol('ms-ansi'))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3910
	fdwCharSet   = ANSI_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3911
    } else if (encoding == @symbol('ms-default')) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3912
	fdwCharSet   = DEFAULT_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3913
    } else if ((encoding == @symbol('ms-symbol'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3914
	    || (encoding == @symbol('misc-fontspecific'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3915
	fdwCharSet   = SYMBOL_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3916
    } else if ((encoding == @symbol('ms-shiftjis'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3917
	    || (encoding == @symbol('jisx0208.1983-0'))){
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3918
	fdwCharSet   = SHIFTJIS_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3919
    } else if ((encoding == @symbol('ms-gb2312'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3920
	    || (encoding == @symbol('gb2312.1980-0'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3921
	fdwCharSet   = GB2312_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3922
    } else if ((encoding == @symbol('ms-hangeul'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3923
	    || (encoding == @symbol('ksc5601.1987-0'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3924
	fdwCharSet   = HANGEUL_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3925
    } else if ((encoding == @symbol('ms-chinesebig5'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3926
	    || (encoding == @symbol('big5'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3927
	fdwCharSet   = CHINESEBIG5_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3928
    } else if (encoding == @symbol('ms-oem')) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3929
	fdwCharSet   = OEM_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3930
    } else if (encoding == @symbol('ms-johab')) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3931
	fdwCharSet   = JOHAB_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3932
    } else if ((encoding == @symbol('ms-hebrew'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3933
	    || (encoding == @symbol('ms-cp1255'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3934
	fdwCharSet   = HEBREW_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3935
    } else if ((encoding == @symbol('ms-arabic'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3936
	    || (encoding == @symbol('ms-cp1256'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3937
	fdwCharSet   = ARABIC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3938
    } else if ((encoding == @symbol('ms-greek'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3939
	    || (encoding == @symbol('ms-cp1253'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3940
	fdwCharSet   = GREEK_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3941
    } else if ((encoding == @symbol('ms-turkish'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3942
	    || (encoding == @symbol('ms-cp1254'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3943
	fdwCharSet   = TURKISH_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3944
    } else if ((encoding == @symbol('ms-russian'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3945
	    || (encoding == @symbol('ms-cp1251'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3946
	fdwCharSet   = RUSSIAN_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3947
    } else if ((encoding == @symbol('ms-easteurope'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3948
	    || (encoding == @symbol('ms-cp1250'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3949
	fdwCharSet   = EASTEUROPE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3950
    } else if ((encoding == @symbol('ms-baltic'))
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3951
	    || (encoding == @symbol('ms-cp1257'))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3952
	fdwCharSet   = BALTIC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3953
    } else if ((encoding == @symbol('ms-vietnamese'))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3954
	fdwCharSet   = VIETNAMESE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3955
    } else if ((encoding == @symbol('ms-thai'))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3956
	fdwCharSet   = THAI_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3957
    } else if ((encoding == @symbol('ms-mac'))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3958
	fdwCharSet   = MAC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3959
#ifdef UNICODE_CHARSET
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3960
    } else if ((encoding == @symbol('ms-unicode'))) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3961
	fdwCharSet   = UNICODE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3962
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3963
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3964
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3965
    if ( __isString( family ) ) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3966
	work = __stringVal( family );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3967
	if (strcmp( work, "nil" ) != 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3968
	    strncpy( faceName, work, sizeof(faceName)-1 );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3969
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3970
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3971
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3972
    /* Q: should we allow those ? (they make ST/X programs less portable to X */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3973
    if( __isString( weight ) ) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3974
	work = __stringVal( weight );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3975
	if (strcmp( work, "bold" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3976
	    fnWeight = FW_BOLD;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3977
	} else if (strcmp( work, "medium" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3978
	    fnWeight = FW_MEDIUM;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3979
	} else if (strcmp( work, "normal" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3980
	    fnWeight = FW_NORMAL;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3981
	} else if (strcmp( work, "light" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3982
	    fnWeight = FW_LIGHT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3983
	} else if (strcmp( work, "demi" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3984
	    fnWeight = FW_LIGHT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3985
	} else if (strcmp( work, "heavy" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3986
	    fnWeight = FW_HEAVY;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3987
	} else if (strcmp( work, "extraBold" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3988
	    fnWeight = FW_EXTRABOLD;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3989
	} else if (strcmp( work, "semiBold" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3990
	    fnWeight = FW_SEMIBOLD;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3991
	} else if (strcmp( work, "thin" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3992
	    fnWeight = FW_THIN;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3993
	} else if (strcmp( work, "extraLight" ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3994
	    fnWeight = FW_EXTRALIGHT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3995
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3996
    } else if (__isSmallInteger(weight)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  3997
	fnWeight = __intVal(weight);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3998
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3999
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4000
    if(__isSmallInteger( logSize )) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4001
	nHeight = __intVal( logSize );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4002
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4003
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4004
    if (__isString(slant)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4005
	work2 = __stringVal( slant );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4006
	work  = __stringVal( slant );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4007
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4008
	if (strncmp(work2, "italic", 6) == 0)  {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4009
	    fdwItalic = TRUE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4010
	    if ( work2[6] == '-' )
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4011
		strncpy( work, &work2[7], ( strlen( work2) - 7) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4012
	} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4013
	    if (strncmp(work2, "oblique", 7) == 0)  {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4014
		fdwItalic = TRUE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4015
		if ( work2[7] == '-' )
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4016
		    strncpy( work, &work2[8], ( strlen( work2) - 8) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4017
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4018
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4019
	if (strncmp( work, "underline", 9 ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4020
	    fdwUnderline = TRUE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4021
	    if( work[10] == '-' )
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4022
		strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4023
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4024
	if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4025
	    fdwStrikeOut = TRUE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4026
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4027
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4028
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4029
    DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n",
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4030
		faceName, nHeight, nWidth, fnWeight));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4031
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4032
    hFont = CreateFont( -nHeight,   /* character height - not cell height */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4033
			nWidth,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4034
			nEscapement,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4035
			nOrientation,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4036
			fnWeight,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4037
			fdwItalic,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4038
			fdwUnderline,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4039
			fdwStrikeOut,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4040
			fdwCharSet,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4041
			fdwOutputPrecision,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4042
			fdwClipPrecision,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4043
			fdwQuality,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4044
			fdwPitchAndFamily,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4045
			faceName );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4046
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4047
    if (hFont != NULL) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4048
	DPRINTF(("createFont: %x\n", hFont));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4049
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4050
    #ifdef COUNT_RESOURCES
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4051
	__cnt_font++;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4052
	RES1PRINTF(("CreateFont %d\n", __cnt_font));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4053
    #endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4054
*/
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4055
	RETURN ( __MKOBJ(hFont) );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4056
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4057
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4058
    DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4059
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4060
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4061
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4062
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4063
     Display getFontWithFoundry:'*'
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4064
			 family:'courier'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4065
			 weight:'medium'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4066
			  slant:'r'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4067
			spacing:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4068
		      pixelSize:nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4069
			   size:13
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4070
		       registry:'iso8859'
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4071
		       encoding:'*'
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4072
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4073
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4074
    "new NT Version: 20.2.1997 / 22:33:29 / dq"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4075
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4076
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4077
primFontMetricsOf:fontId hdc:aDC intoArray:rawData
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4078
    "evaluate aBlock, passing a fonts metrics as arguments.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4079
     fill passed array as:
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4080
      ascent     -> (data at:1)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4081
      descent    -> (data at:2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4082
      maxAscent  -> (data at:3)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4083
      maxDescent -> (data at:4)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4084
      minWidth   -> (data at:5)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4085
      maxWidth   -> (data at:6)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4086
      avgWidth   -> (data at:7).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4087
      minChar    -> (data at:8).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4088
      maxChar    -> (data at:9).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4089
      defaultChar-> (data at:10).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4090
      charSet    -> (data at:11).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4091
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4092
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4093
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4094
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4095
    if (__isExternalAddress(fontId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4096
     && __isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4097
     && __isArray(rawData)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4098
     && (__arraySize(rawData) >= 11)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4099
	SIZE size;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4100
	int avgWidth;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4101
	HGDIOBJ hFont;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4102
	HGDIOBJ prevFont;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4103
	TEXTMETRIC tmet;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4104
	static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4105
	static int len;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4106
	OBJ t;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4107
	HANDLE hDC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4108
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4109
	hFont = _HGDIOBJVal(fontId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4110
	hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4111
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4112
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4113
	 * temporarily set this font in the tmpDC (root-) context
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4114
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4115
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4116
	prevFont = SelectObject(hDC, hFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4117
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4118
	GetTextMetricsW(hDC, &tmet);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4119
	if (len == 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4120
	    len = strlen(s);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4121
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4122
#if 0
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4123
	GetTextExtentPoint32(hDC, s, len, &size);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4124
	avgWidth = (size.cx / (len / 2) + 1) / 2;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4125
#else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4126
	avgWidth = tmet.tmAveCharWidth;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4127
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4128
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4129
	__ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent);        /* ascent     -> (data at:1) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4130
	__ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent);       /* descent    -> (data at:2) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4131
	__ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent);        /* maxAscent  -> (data at:3) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4132
	__ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent);       /* maxDescent -> (data at:4) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4133
	__ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth);             /* minWidth   -> (data at:5) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4134
	__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4135
	__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4136
	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4137
	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4138
	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4139
#if 0
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4140
	t = __charSetSymbolFor(tmet.tmCharSet);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4141
	__ArrayInstPtr(rawData)->a_element[10]= t; __STORE(rawData, t);             /* charSet    -> (data at:11) */
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4142
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4143
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4144
	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4145
		    hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4146
		    tmet.tmAveCharWidth));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4147
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4148
	SelectObject(hDC, prevFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4149
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4150
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4151
    RETURN (nil);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4152
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4153
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4154
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4155
releaseFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4156
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4157
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4158
    if (__isExternalAddress(aFontId)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4159
	HGDIOBJ hFont = _HGDIOBJVal(aFontId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4160
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4161
	if (hFont) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4162
	   DPRINTF(("ReleaseFont: %x\n", hFont));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4163
	   DeleteObject(hFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4164
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4165
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4166
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4167
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4168
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4169
setFont:aFontId in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4170
    "set font to be drawn in"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4171
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4172
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4173
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4174
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4175
     && __isExternalAddress(aFontId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4176
    {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4177
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4178
	HGDIOBJ prevFont, hFont;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4179
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4180
	hFont = _HGDIOBJVal(aFontId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4181
	prevFont = SelectObject(hDC, hFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4182
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4183
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4184
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4185
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4186
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4187
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4188
    "Created: / 04-08-2006 / 12:32:53 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4189
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4190
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4191
widthOf:aString from:index1 to:index2 inFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4192
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4193
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4194
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4195
    int len, n, i1, i2, l;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4196
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4197
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4198
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4199
    if (__bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4200
     && __isExternalAddress(aFontId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4201
     && __isExternalAddressLike(__INST(gcId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4202
     && __isNonNilObject(aString)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4203
	HGDIOBJ hFont,prevFont;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4204
	HANDLE hDC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4205
	SIZE tsize;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4206
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4207
#ifndef PRE_22_FEP_2007
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4208
#       define N_QUICK_CHARS    1024
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4209
	unsigned short quickWchars[N_QUICK_CHARS];
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4210
	unsigned short *wcharPtr;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4211
	int mustFree = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4212
	int i;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4213
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4214
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4215
	hFont = _HGDIOBJVal(aFontId);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4216
	hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4217
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4218
	prevFont = SelectObject(hDC, hFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4219
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4220
	i1 = __intVal(index1) - 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4221
	cls = __qClass(aString);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4222
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4223
	if (i1 >= 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4224
	    i2 = __intVal(index2) - 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4225
	    if (i2 < i1) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4226
		RETURN ( __MKSMALLINT( 0 ) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4227
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4228
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4229
	    cp = (char *) _stringVal(aString);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4230
	    l = i2 - i1 + 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4231
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4232
	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4233
		n = _stringSize(aString);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4234
    commonWidthChars:
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4235
		if (i2 < n) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4236
		    cp += i1;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4237
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4238
#ifdef PRE_22_FEP_2007
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4239
		    GetTextExtentPoint32(hDC, cp, l, &tsize);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4240
#else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4241
		    if (l <= N_QUICK_CHARS) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4242
			wcharPtr = quickWchars;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4243
			mustFree = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4244
		    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4245
			wcharPtr = malloc(sizeof(short)*l);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4246
			if (! wcharPtr) RETURN (__MKSMALLINT(0));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4247
			mustFree = 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4248
		    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4249
		    for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4250
		    GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4251
		    if (mustFree) free(wcharPtr);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4252
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4253
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4254
#ifdef SUPERDEBUG
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4255
		    if (__debug__) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4256
			char buf[80];
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4257
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4258
			GetTextFace(hDC,80,buf);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4259
			console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4260
		    }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4261
#endif
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4262
		    SelectObject(hDC, prevFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4263
		    RETURN ( __MKSMALLINT(tsize.cx) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4264
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4265
		RETURN (__MKSMALLINT(0));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4266
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4267
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4268
	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4269
	    cp += nInstBytes;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4270
	    n = __byteArraySize(aString) - nInstBytes;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4271
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4272
	    if (__isBytes(aString)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4273
		goto commonWidthChars;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4274
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4275
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4276
	    /* Unicode */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4277
	    if (__isWords(aString)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4278
		n = n / 2;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4279
		if (i2 < n) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4280
		    WIDECHAR *w_cp = (WIDECHAR *)cp;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4281
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4282
		    w_cp += i1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4283
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4284
		    GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4285
		    SelectObject(hDC, prevFont);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4286
		    RETURN ( __MKSMALLINT(tsize.cx) );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4287
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4288
		RETURN (__MKSMALLINT(0));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4289
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4290
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4291
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4292
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4293
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4294
    ^ 0
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4295
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4296
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4297
widthOf:aString inFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4298
    "return the width in pixels of a string in a specific font"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4299
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4300
    ^ self widthOf:aString from:1 to:(aString size) inFont:aFontId
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4301
! !
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4302
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4303
!WinPrinterContext methodsFor:'initialization & release'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4304
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4305
createDC
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4306
    "Private - Create a device context for the receiver"
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  4307
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4308
    gcId := printerInfo createDC
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4309
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4310
    "Created: / 27-07-2006 / 10:21:05 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4311
    "Modified: / 02-08-2006 / 17:30:47 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4312
    "Modified: / 10-10-2006 / 18:14:28 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4313
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4314
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4315
deleteDC
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4316
    "Private - Delete a device context for the receiver"
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4317
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4318
    OperatingSystem deletePrinterDC: gcId.
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4319
!
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4320
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4321
destroy
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4322
    "Destroy the GC."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4324
    |id|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4325
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4326
    id := gcId.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4327
    id notNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4328
	gcId := nil.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4329
	self deleteDC.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4330
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4331
"/    Lobby unregister:self.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4332
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4333
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4334
destroyGC:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4335
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4336
    if (__isExternalAddressLike(aDC)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4337
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4338
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4339
	DeleteDC(hDC);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4340
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4341
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4342
#ifdef CACHE_LAST_DC
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4343
	if (lastGcData == gcData) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4344
	    _releaseDC(gcData);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4345
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4346
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4347
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4348
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4349
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4350
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4351
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4352
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4353
executor
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4354
    |aCopy|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4355
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4356
    aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4357
    aCopy setDevice:device id:nil gcId:gcId.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4358
    ^ aCopy
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4359
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4360
    "Created: / 16-04-2007 / 12:39:02 / cg"
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4361
!
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4362
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4363
initialize
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4364
    super initialize.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4365
"/    deviceForms := Registry new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4366
"/    deviceColors := Registry new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4367
    deviceFonts := CachingRegistry new cacheSize:10.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4368
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4369
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4370
releaseDC
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4371
    "Private - Delete and clear the device context of the receiver."
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4372
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4373
    self deleteDC.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4374
"/    device close.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4375
    gcId := nil.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4376
    self releaseDeviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4377
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4378
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4379
releaseDeviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4380
    deviceFonts isEmptyOrNil ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4381
	deviceFonts do:[:afont |
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4382
	    afont releaseFromDevice.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4383
	].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4384
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4385
    deviceFonts := CachingRegistry new cacheSize:10.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4386
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4387
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4388
!WinPrinterContext methodsFor:'non standard methods'!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4389
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4390
stringWidthOf:aString at:index
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4391
    "Return the width of aString up to index
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4392
     when written using the current font; expand tabs out
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4393
     to 4 spaces for calculations"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4394
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4395
    |answer str size spaceWidth|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4396
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4397
    index <= 0 ifTrue:[ ^ 0 ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4398
    str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4399
    true "self font isNil" ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4400
	"if font not set yet, calculate based on default font"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4401
	"/            extString := str asExternalString.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4402
	size := Win32OperatingSystem::WinPointStructure new.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4403
	(OperatingSystem
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4404
	    getTextExtentPoint:gcId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4405
	    string:str
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4406
	    size:size) ifFalse:[ ^ self error ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4407
	answer := size x.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4408
"/        Transcript showCR: 'FROM PRIM ******* ', str, '   ',  answer printString.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4409
"/        Transcript showCR: 'FROM DEVICE ***** ', str, '   ',(self font widthOf:str on:self device) printString.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4410
	#TODO.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4411
    ] ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4412
	answer := self font widthOf:str on:self device
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4413
    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4414
    index > aString size ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4415
	spaceWidth := self font widthOf:Character space on:self device.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4416
	answer := answer + ((index - aString size) * spaceWidth)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4417
    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4418
    ^ answer.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4419
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4420
    "Created: / 03-08-2006 / 10:27:20 / fm"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4421
    "Modified: / 04-08-2006 / 12:27:26 / fm"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4422
    "Modified: / 10-10-2006 / 18:20:43 / cg"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4423
! !
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4424
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4425
!WinPrinterContext methodsFor:'not supported yet'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4426
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4427
displayAdvanceLineFrom:point1 to:point2
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4428
    "draw a line"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4429
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4430
    self displayAdvanceLineFromX:(point1 x) y:(point1 y)
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4431
		      toX:(point2 x) y:(point2 y)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4432
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4433
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4434
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4435
    "draw a line (with current paint-color); apply transformation if nonNil"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4436
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4437
    |pX0 pY0 pX1 pY1 easy fgId bgId|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4438
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4439
    gcId isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4440
	self initGC
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4441
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4442
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4443
    lineStyle == #doubleDashed ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4444
	"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4445
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4446
	"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4447
	easy := true.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4448
	paint isColor ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4449
	    easy := false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4450
	] ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4451
	    fgId := paint colorId.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4452
	    fgId isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4453
		easy := false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4454
	    ]
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4455
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4456
	bgPaint isColor ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4457
	    easy := false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4458
	] ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4459
	    bgId := bgPaint colorId.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4460
	    bgId isNil ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4461
		easy := false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4462
	    ]
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4463
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4464
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4465
	easy ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4466
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4467
		device setForeground:fgId background:bgId in:gcId.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4468
		foreground := paint.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4469
		background := bgPaint.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4470
	    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4471
	] ifFalse:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4472
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4473
	].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4474
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4475
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4476
    transformation notNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4477
	pX0 := transformation applyToX:x0.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4478
	pY0 := transformation applyToY:y0.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4479
	pX1 := transformation applyToX:x1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4480
	pY1 := transformation applyToY:y1.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4481
    ] ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4482
	pX0 := x0.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4483
	pY0 := y0.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4484
	pX1 := x1.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4485
	pY1 := y1
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4486
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4487
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4488
    pX0 := pX0 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4489
    pY0 := pY0 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4490
    pX1 := pX1 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4491
    pY1 := pY1 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4492
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4493
    device displayAdvanceLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4494
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4495
    "Modified: 10.1.1997 / 17:46:32 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4496
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4497
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4498
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4499
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4500
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4501
    self getPenForMyContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4502
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4503
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4504
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4505
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4506
     && __bothSmallInteger(x1, y1)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4507
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4508
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4509
	int __x1 = __intVal(x1), __y1 = __intVal(y1);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4510
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4511
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4512
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4513
		    __intVal(x0), __intVal(y0),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4514
		    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4515
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4516
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4517
/*        fgColor = GetTextColor(hDC);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4518
 *        hPen = CreatePen(PS_SOLID, 1, fgColor);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4519
 */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4520
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4521
	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4522
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4523
	LineTo(hDC, __x1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4524
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4525
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4526
	 * end-point ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4527
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4528
	LineTo(hDC, __x1+1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4529
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4530
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4531
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4532
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4533
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4534
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4535
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4536
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4537
gcForBitmap:aDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4538
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4539
%{  /* NOCONTEXT */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4540
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4541
    if (__isExternalAddress(aDrawableId)){
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4542
        BITMAP bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4543
        HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4544
        HBITMAP memBM;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4545
        HANDLE compatibleDC, rootDC, hdcScreen;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4546
   //     HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4547
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4548
        if (! hBitmap) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4549
            RETURN (nil);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4550
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4551
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4552
        if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4553
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4554
            DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4555
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4556
        } else {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4557
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4558
            DPRINTF(("noinfo returned for bitmap\n"));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4559
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4560
            /* mhmh - can this happen ? */
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4561
            bitmap.bmBitsPixel = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4562
        }
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4563
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4564
        gcData->hBitmap = hBitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4565
        gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4566
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4567
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4568
        rootDC  = CreateDC("DISPLAY", NULL, NULL, NULL);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4569
        compatibleDC = CreateCompatibleDC(rootDC);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4570
        SelectObject(compatibleDC, hBitmap);
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4571
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4572
   //     hdcScreen= CreateDC("NULL", NULL, NULL, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4573
   //       compatibleDC =  rootDC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4574
   //     compatibleDC = CreateCompatibleDC(printerDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4575
   //     compatibleDC = CreateCompatibleDC(0);
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4576
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4577
   //     memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4578
   //     SelectObject ( compatibleDC, memBM );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4579
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4580
        RETURN (__MKOBJ(compatibleDC));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4581
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4582
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  4583
        RETURN ( __MKOBJ(gcData) );
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4584
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4585
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4586
    RETURN (nil);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4587
%}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4588
!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4589
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4590
getPenForMyContext
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4591
    "Get a pen for my context"
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4592
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4593
    |maskOriginX maskOriginY|
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4594
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4595
    self maskOrigin isNil ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4596
	maskOriginX := self maskOrigin x.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4597
	maskOriginY := self maskOrigin y.
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4598
    ].
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4599
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  4600
%{
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4601
    HPEN hPen = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4602
    HPEN prevPen;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4603
    LOGBRUSH Brush;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4604
    COLORREF fgColor;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4605
    HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4606
    int lStyle, bkMode, hMask, maskOrgX, maskOrgY;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4607
    int style, lineStyle, capStyle, joinStyle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4608
    int lw;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4609
    int BK_TRANSPARENT;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4610
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4611
    BK_TRANSPARENT = 1;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4612
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4613
    lw= __INST(lineWidth);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4614
/*    fgColor = __intVal(__INST(foreground)) & 0xffffff;     */
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4615
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  4616
    fgColor = GetTextColor(hDC);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4617
    lineStyle=__INST(lineStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4618
    capStyle=__INST(capStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4619
    joinStyle=__INST(joinStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4620
    hMask= __INST(mask);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4621
    maskOrgX=__intVal(maskOriginX);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4622
    maskOrgY=__intVal(maskOriginY);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4623
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4624
    if (lineStyle == @symbol(solid)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4625
	style = PS_SOLID;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4626
    } else if (lineStyle == @symbol(dashed)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4627
	style= PS_DASH;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4628
    } else if (lineStyle == @symbol(dotted)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4629
	style= PS_DOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4630
    } else if (lineStyle == @symbol(dashDot)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4631
	style= PS_DASHDOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4632
    } else if (lineStyle == @symbol(dashDotDot)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4633
	style= PS_DASHDOTDOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4634
    } else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4635
	style= PS_SOLID;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4636
    lStyle &= ~PS_STYLE_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4637
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4638
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4639
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4640
    if (capStyle == @symbol(round)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4641
	style = PS_ENDCAP_ROUND;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4642
    } else if (capStyle == @symbol(square)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4643
	style = PS_ENDCAP_SQUARE;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4644
    } else if (capStyle == @symbol(flat)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4645
	style = PS_ENDCAP_FLAT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4646
    } else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4647
	style = PS_ENDCAP_FLAT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4648
    lStyle &= ~PS_ENDCAP_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4649
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4650
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4651
    if (joinStyle == @symbol(bevel)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4652
	style = PS_JOIN_BEVEL;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4653
    } else if (joinStyle == @symbol(miter)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4654
	style = PS_JOIN_MITER;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4655
    } else if (joinStyle == @symbol(round)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4656
	style = PS_JOIN_ROUND;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4657
    } else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4658
	style = PS_JOIN_MITER;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4659
    lStyle &= ~PS_JOIN_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4660
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4661
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4662
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4663
    if (((lStyle & PS_STYLE_MASK) == PS_SOLID)
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4664
     && (hMask == 0)
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4665
     && (lw /* lineWidth */ <= 1)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4666
	if (fgColor == 0 /* BlackPixel */ ) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4667
	    hPen = GetStockObject(BLACK_PEN);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4668
	    prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4669
	    RETURN( hPen );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4670
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4671
	if (fgColor == 1 /* WhitePixel */) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4672
	    hPen = GetStockObject(WHITE_PEN);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4673
	    prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4674
	    RETURN( hPen );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4675
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4676
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4677
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4678
    hPen = (HPEN) 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4679
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4680
    if (0 /* __isWinNT */) {
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4681
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4682
	if (lw == 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4683
	    lw = 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4684
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4685
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4686
	 * NT supports masked drawing with any lineStyle,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4687
	 * and also non-solid lines with any lineWidth.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4688
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4689
	if (hMask) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4690
	    Brush.lbStyle = BS_PATTERN;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4691
	    Brush.lbHatch = (DWORD)hMask;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4692
	    Brush.lbColor = fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4693
	} else {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4694
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4695
#ifndef PRE_07_APR_04
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4696
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4697
	    hPen = CreatePen((lStyle & PS_STYLE_MASK), lw, fgColor);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4698
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4699
/*            RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4700
 *                       lStyle,
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4701
 *                       lw, __INST(lineWidth),
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4702
 *                       fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4703
 */
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4704
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4705
	    SetBkMode(hDC, TRANSPARENT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4706
	    bkMode = BK_TRANSPARENT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4707
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4708
#else
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4709
	    Brush.lbStyle = BS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4710
	    Brush.lbHatch = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4711
	    Brush.lbColor = fgColor;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4712
#endif
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4713
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4714
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4715
	if (! hPen)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4716
	{
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4717
	    hPen = ExtCreatePen(PS_GEOMETRIC | lStyle,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4718
			    lw, /* lineWidth, */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4719
			    &Brush,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4720
			    0, 0);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4721
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4722
/*            RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4723
 *                       lStyle,
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4724
 *                       lw, __INST(lineWidth),
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4725
 *                       fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4726
 */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4727
	    if (hMask) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4728
		SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4729
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4730
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4731
    } else {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4732
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4733
	 * W95 only supports masked drawing with SOLID lines
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4734
	 * also, we should use COSMETIC pens if possible
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4735
	 * with non-solid lineStyles.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4736
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4737
	if ((lStyle & PS_STYLE_MASK) == PS_SOLID) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4738
	    int ps = PS_GEOMETRIC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4739
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4740
	    if (hMask) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4741
		Brush.lbStyle = BS_PATTERN;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4742
		Brush.lbHatch = (DWORD)hMask;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4743
		Brush.lbColor = fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4744
	    } else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4745
		Brush.lbStyle = BS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4746
		Brush.lbHatch = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4747
		Brush.lbColor = fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4748
		if (lw /* lineWidth */ <= 1) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4749
		    ps = PS_COSMETIC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4750
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4751
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4752
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4753
	    hPen = ExtCreatePen(ps | lStyle,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4754
				lw, /* lineWidth */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4755
				&Brush,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4756
				0, 0);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4757
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4758
/*            RESPRINTF(("ExtCreatePen1 %x %d %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4759
 *                           lStyle,
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  4760
 *                           lw,
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4761
 *                           fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4762
 */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4763
	    if (hMask) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4764
		SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4765
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4766
	} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4767
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4768
	    if (lw == 1) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4769
		lw = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4770
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4771
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4772
	    /*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4773
	     * dashes only supported with lineWidth 0
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4774
	     */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4775
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4776
	    hPen = CreatePen((lStyle & PS_STYLE_MASK),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4777
			     lw,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4778
			     fgColor);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4779
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4780
/*            RESPRINTF(("CreatePen %x %d %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4781
 *                               (lStyle & PS_STYLE_MASK),
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  4782
 *                               lw,
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4783
 *                               fgColor));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4784
 */
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4785
	    //
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4786
	    // CG: wrong; must set to opaque, if doubleDashed
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4787
	    //
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4788
	    SetBkMode(hDC, TRANSPARENT);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4789
	    bkMode = BK_TRANSPARENT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4790
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4791
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4792
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4793
    prevPen = SelectObject(hDC, hPen);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4794
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4795
    RETURN (hPen);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4796
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4797
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4798
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  4799
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4800
xprimDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd width:imageWidth height:imageHeight
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4801
				  x:srcx y:srcy
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4802
			       into:ignoredDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4803
				  x:dstx y:dsty
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4804
			      width:w height:h
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4805
			       with:aDC
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4806
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4807
    "since XPutImage may allocate huge amount of stack space
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4808
     (some implementations use alloca), this must run with unlimited stack."
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4809
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4810
%{
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4811
    unsigned char fastBits[10000];
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4812
    unsigned char *b_bits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4813
    unsigned char *allocatedBits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4814
    unsigned char *__imageBits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4815
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4816
    if (__isByteArray(imageBits)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4817
	__imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4818
    } else if (__isExternalBytesLike(imageBits)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4819
	__imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4820
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4821
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4822
    if (/* ISCONNECTED
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4823
     && */  __isExternalAddressLike(aDC)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4824
     && __bothSmallInteger(srcx, srcy)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4825
     && __bothSmallInteger(dstx, dsty)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4826
     && __bothSmallInteger(w, h)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4827
     && __bothSmallInteger(imageWidth, imageHeight)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4828
     && __bothSmallInteger(imageDepth, bitsPerPixel)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4829
     && __isSmallInteger(padd)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4830
     && __imageBits)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4831
     {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4832
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4833
	struct
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4834
	{
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4835
	  BITMAPINFOHEADER bmiHeader;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4836
	  DWORD r;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4837
	  DWORD g;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4838
	  DWORD b;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4839
	} bitmap;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4840
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4841
	if (__intVal(padd) != WIN32PADDING) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4842
	    int row, col;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4843
	    unsigned char *cp;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4844
	    unsigned char *pBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4845
	    int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4846
	    int bi = __intVal(bitsPerPixel);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4847
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4848
	    b_width = __intVal(w);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4849
	    b_height = __intVal(h);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4850
	    bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4851
	    bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4852
	    padding = bytesPerRowWN - bytesPerRowST;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4853
	    nBytes = b_height * bytesPerRowWN;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4854
	    /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4855
	    if (padding) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4856
		if (nBytes < sizeof(fastBits)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4857
		    cp = b_bits = fastBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4858
		} else {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4859
		    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4860
		}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4861
		if (cp) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4862
		    pBits = __imageBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4863
		    for (row = b_height; row; row--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4864
			for (col = bytesPerRowST; col; col--) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4865
			    *cp++ = *pBits++;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4866
			}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4867
			cp += padding;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4868
		    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4869
		} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4870
		    goto fail;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4871
	    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4872
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4873
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4874
	if (b_bits == 0) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4875
	    b_bits = __imageBits;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4876
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4877
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4878
	bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4879
	bitmap.bmiHeader.biPlanes = 1;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4880
	if (__intVal(imageDepth) == 24) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4881
	    /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4882
	    bitmap.r = 0xff0000;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4883
	    bitmap.g = 0x00ff00;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4884
	    bitmap.b = 0x0000ff;*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4885
	    bitmap.bmiHeader.biCompression = BI_RGB;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4886
	} else if (__intVal(imageDepth) == 16) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4887
	    /*bitmap.bmiHeader.biCompression = BI_RGB;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4888
	    bitmap.bmiHeader.biCompression = BI_BITFIELDS;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4889
	    bitmap.b = 0x001f;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4890
	    bitmap.g = 0x07e0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4891
	    bitmap.r = 0xf800;*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4892
	    bitmap.b = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4893
	    bitmap.g = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4894
	    bitmap.r = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4895
	    bitmap.bmiHeader.biCompression = BI_RGB;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4896
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4897
	bitmap.bmiHeader.biSizeImage = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4898
	bitmap.bmiHeader.biXPelsPerMeter = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4899
	bitmap.bmiHeader.biYPelsPerMeter = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4900
	bitmap.bmiHeader.biClrUsed = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4901
	bitmap.bmiHeader.biClrImportant = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4902
	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4903
	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4904
	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4905
	/*console_printf("drawBits depth:%d bitsPerPixel:%d IW%d W:%d H:%d\n",__intVal(imageDepth),bitmap.bmiHeader.biBitCount,bitmap.bmiHeader.biWidth,__intVal(w),bitmap.bmiHeader.biHeight);*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4906
	SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4907
			      __intVal(w), __intVal(h),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4908
			      __intVal(srcx), __intVal(srcy),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4909
			      0,__intVal(h),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4910
			      (void *)b_bits,
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4911
			      (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4912
	if (allocatedBits) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4913
	    free(allocatedBits);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4914
	}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4915
	RETURN ( true );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4916
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4917
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4918
fail: ;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4919
/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4920
    PRINTF(("create temp bitmap FAILED!!!\n"));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4921
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4922
    if (allocatedBits) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4923
/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4924
	PRINTF(("freeing up temp bitmap bits ...\n"));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4925
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4926
	free(allocatedBits);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4927
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4928
%}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4929
.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4930
    ^ false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4931
!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4932
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4933
xxdisplayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4934
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4935
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4936
    |pen|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4937
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4938
    pen := self getPenForMyContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4939
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4940
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4941
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4942
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4943
     && __bothSmallInteger(x1, y1)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4944
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4945
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4946
	HANDLE prevPen, hPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4947
	int __x1 = __intVal(x1), __y1 = __intVal(y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4948
									  /*  Obtaining Pen  */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4949
	int style, styleInt, lineWidth;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4950
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4951
	lineWidth= __INST(lineWidth);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4952
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4953
	if (__INST(lineStyle) == @symbol(solid)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4954
	    style= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4955
	} else if (__INST(lineStyle) == @symbol(dashed)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4956
	    style= PS_DASH;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4957
	} else if (__INST(lineStyle) == @symbol(dotted)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4958
	    style= PS_DOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4959
	} else if (__INST(lineStyle) == @symbol(dashDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4960
	    style= PS_DASHDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4961
	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4962
	    style= PS_DASHDOTDOT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4963
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4964
	    style= PS_SOLID;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4965
	styleInt &= ~PS_STYLE_MASK;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4966
	styleInt |= style;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4967
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4968
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4969
	if (__INST(capStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4970
	    style= PS_ENDCAP_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4971
	} else if (__INST(capStyle) == @symbol(square)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4972
	    style= PS_ENDCAP_SQUARE;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4973
	} else if (__INST(capStyle) == @symbol(flat)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4974
	    style= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4975
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4976
	    style= PS_ENDCAP_FLAT;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4977
	styleInt &= ~PS_ENDCAP_MASK;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4978
	styleInt |= style;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4979
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4980
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4981
	if (__INST(joinStyle) == @symbol(bevel)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4982
	    style= PS_JOIN_BEVEL;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4983
	} else if (__INST(joinStyle) == @symbol(miter)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4984
	    style= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4985
	} else if (__INST(joinStyle) == @symbol(round)) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4986
	    style= PS_JOIN_ROUND;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4987
	} else
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4988
	    style= PS_JOIN_MITER;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4989
	styleInt &= ~PS_JOIN_MASK;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4990
	styleInt |= style;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4991
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4992
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4993
	fgColor = GetTextColor(hDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4994
	hPen = CreatePen((styleInt & PS_STYLE_MASK), lineWidth, fgColor);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4995
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4996
									     /*  Finish Obtaining Pen  */
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4997
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4998
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4999
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5000
		    __intVal(x0), __intVal(y0),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5001
		    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5002
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5003
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5004
	prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5005
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5006
	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5007
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5008
	LineTo(hDC, __x1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5009
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5010
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5011
	 * end-point ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5012
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5013
	LineTo(hDC, __x1+1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5014
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5015
	SelectObject(hDC, prevPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5016
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5017
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5018
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5019
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5020
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5021
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5022
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5023
xxxdisplayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5024
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5025
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5026
    |penHandle|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5027
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5028
    penHandle := ExternalBytes address: self getPenForMyContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5029
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5030
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5031
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5032
     && __isExternalAddressLike(penHandle)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5033
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5034
     && __bothSmallInteger(x1, y1)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5035
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5036
	HANDLE hPen = (HANDLE)(__externalAddressVal(penHandle));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5037
	COLORREF fgColor;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5038
	HANDLE prevPen;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5039
	int __x1 = __intVal(x1), __y1 = __intVal(y1);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5040
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5041
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5042
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5043
		    __intVal(x0), __intVal(y0),
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5044
		    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5045
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5046
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5047
/*        fgColor = GetTextColor(hDC);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5048
 *        hPen = CreatePen(PS_SOLID, 1, fgColor);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5049
 */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5050
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5051
	prevPen = SelectObject(hDC, hPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5052
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5053
	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5054
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5055
	LineTo(hDC, __x1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5056
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5057
	/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5058
	 * end-point ...
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5059
	 */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5060
	LineTo(hDC, __x1+1, __y1);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5061
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5062
	SelectObject(hDC, prevPen);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5063
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5064
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5065
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5066
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5067
%}
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5068
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5069
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5070
!WinPrinterContext methodsFor:'printing process'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5071
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5072
endPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5073
    "Informs device that we are finished writing to a page."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5074
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5075
    (OperatingSystem endPage:gcId) > 0 ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5076
	self error
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5077
    ]
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5078
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5079
    "Created: / 27-07-2006 / 18:20:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5080
    "Modified: / 01-08-2006 / 16:01:34 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5081
    "Modified: / 10-10-2006 / 18:14:44 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5082
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5083
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  5084
endPrintJobWithoutRelease
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5085
    "End the print job.  Everything drawn between startPrintJob
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5086
     and endPrintJob will become one entry in the print queue."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5087
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5088
    |result|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5089
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5090
    self endPage.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5091
    result := OperatingSystem endDoc:gcId.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5092
    jobid := nil.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5093
    result >= 0 ifFalse:[ self error ]
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5094
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5095
    "Created: / 27-07-2006 / 18:21:04 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5096
    "Modified: / 01-08-2006 / 16:01:38 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5097
    "Modified: / 10-10-2006 / 18:50:43 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5098
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5099
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5100
getSupportsColor
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5101
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5102
    | retVal info |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5103
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5104
    info := (self class getPrinterInformationString: self name) asUppercase.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5105
    (info includesSubString: ',PSCRIPT,')
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5106
        ifTrue: [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5107
            retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5108
        ]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5109
        ifFalse: [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5110
            retVal := (info includesSubString: 'PDF')
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5111
                ifTrue: [true]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5112
                ifFalse: [self numberOfColorBitsPerPixel > 1].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5113
    ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5114
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5115
    ^retVal
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5116
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5117
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5118
startPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5119
    "Starts a page."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5120
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5121
    (OperatingSystem startPage:gcId) > 0 ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5122
	^ self error
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5123
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5124
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5125
    "Created: / 27-07-2006 / 18:25:55 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5126
    "Modified: / 28-07-2006 / 18:19:04 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5127
    "Modified: / 10-10-2006 / 18:19:02 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5128
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5129
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5130
startPrintJob:aString fileName:aFileName
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5131
    "Start a print job, using aString as the job title; everything
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5132
     drawn between startPrintJob and endPrintJob will become
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5133
     one entry in the print queue."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5134
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5135
    |docInfoStruct nameAddress title fileNameAddress|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5136
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5137
    gcId isNil ifTrue:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5138
	self buildPrinter
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5139
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5140
    abort := false.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5141
    title := aString ? 'Smalltalk/X'.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5142
    nameAddress := title asExternalBytes unprotectFromGC.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5143
    aFileName isNil ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5144
	fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5145
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5146
    docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5147
    docInfoStruct
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5148
	cbSize:docInfoStruct sizeInBytes;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5149
	lpszDocName:nameAddress address.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5150
    fileNameAddress isNil ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5151
	docInfoStruct lpszOutput:fileNameAddress address
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5152
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5153
    jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5154
    jobid > 0 ifFalse:[
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5155
	jobid = -1 ifTrue:[
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5156
	    abort := true.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5157
	    ^ nil
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5158
	].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5159
	^ self error
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5160
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5161
    self startPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5162
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5163
    "Created: / 27-07-2006 / 18:19:31 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5164
    "Modified: / 03-08-2006 / 15:11:19 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5165
    "Modified: / 10-10-2006 / 18:20:01 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5166
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5167
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5168
!WinPrinterContext methodsFor:'queries'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5169
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5170
hasGrayscales
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5171
    "return true, if this workstation supports grayscales
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5172
     (also true for color displays)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5173
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5174
    ^ true
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5175
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5176
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5177
isOpen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5178
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5179
    ^ gcId notNil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5180
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5181
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5182
isPersistentInSnapshot
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5183
    "return true, if resources on this device are to be made
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5184
     persistent in a snapshot image."
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5185
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5186
    ^ false
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5187
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5188
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5189
supportsColor
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5190
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5191
    supportsColor isNil ifTrue:[supportsColor := self getSupportsColor].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5192
    ^supportsColor
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5193
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5194
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5195
supportsGraphics
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  5196
    ^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5197
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5198
    "Created: / 03-08-2006 / 10:07:43 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  5199
    "Modified: / 16-04-2007 / 12:44:03 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5200
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5201
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5202
!WinPrinterContext methodsFor:'registration'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5203
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5204
registerFont:aFont
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5205
    deviceFonts register:aFont.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5206
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5207
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5208
unregisterFont:aFont
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5209
    deviceFonts unregister:aFont.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5210
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5211
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5212
!WinPrinterContext class methodsFor:'documentation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5213
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5214
version
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  5215
    ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.20 2007-10-23 05:08:45 ca Exp $'
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5216
! !