WinPrinterContext.st
author Stefan Vogel <sv@exept.de>
Wed, 25 Apr 2012 21:46:59 +0200
changeset 3002 a6acab3dbdea
parent 2905 303bf86fa4bb
child 3041 e0211b174c0e
permissions -rw-r--r--
added: #getDefaultFontWithEncoding: changed: #getFontWithFamily:face:style:size:sizeUnit:encoding:
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
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
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
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
    15
	instanceVariableNames:'deviceFonts hatch supportsColor'
2348
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
    16
	classVariableNames:'PostScriptBlackWhite'
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
    17
	poolDictionaries:''
507334e9746f 24 and 32 bits support
fm
parents: 2343
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
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    21
WinPrinterContext subclass:#WinPrinterGraphicContext
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
    22
	instanceVariableNames:'fontScale printPageNumbers pageNumberFormat pageCounter
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
    23
		needsEndOfPage titleFont'
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    24
	classVariableNames:''
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    25
	poolDictionaries:''
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    26
	privateIn:WinPrinterContext
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    27
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
    28
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    29
!WinPrinterContext primitiveDefinitions!
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    30
%{
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    31
#undef INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    32
#define INT WIN_INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    33
#undef Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    34
#define Array WIN_Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    35
#undef Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    36
#define Number WIN_Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    37
#undef Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    38
#define Method WIN_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    39
#undef Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    40
#define Point WIN_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    41
#undef Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    42
/* #define Rectangle WIN_Rectangle */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    43
#undef True
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    44
#define True WIN_True
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    45
#undef False
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    46
#define False WIN_False
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    47
#undef Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    48
#define Block WIN_Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    49
#undef Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    50
#define Context WIN_Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    51
#undef Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    52
#define Date WIN_Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    53
#undef Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    54
#define Time WIN_Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    55
#undef Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    56
#define Delay WIN_Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    57
#undef Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    58
#define Signal WIN_Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    59
#undef Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    60
#define Set WIN_Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    61
#undef Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    62
#define Process WIN_Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    63
#undef Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    64
#define Processor WIN_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    65
#undef Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    66
#define Message WIN_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    67
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    68
#include <stdio.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    69
#include <errno.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    70
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    71
#ifdef __BORLANDC__
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    72
# define NOATOM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    73
# define NOGDICAPMASKS
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    74
# define NOMETAFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    75
# define NOMINMAX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    76
# define NOOPENFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    77
# define NOSOUND
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    78
# define NOWH
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    79
# define NOCOMM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    80
# define NOKANJI
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    81
# define NOCRYPT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    82
# define NOMCX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    83
# define WIN32_LEAN_AND_MEAN
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    84
# include <windows.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    85
# include <shellapi.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    86
# include <sys\timeb.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    87
# include <dir.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    88
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    89
# define _USERENTRY /**/
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    90
# define NOATOM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    91
# define NOGDICAPMASKS
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    92
# define NOMETAFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    93
# define NOMINMAX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    94
# define NOOPENFILE
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    95
# define NOSOUND
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    96
# define NOWH
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    97
# define NOCOMM
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    98
# define NOKANJI
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
    99
# define NOCRYPT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   100
# define NOMCX
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   101
# define WIN32_LEAN_AND_MEAN
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   102
# include <windows.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   103
# include <sys\timeb.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   104
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   105
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   106
#include <process.h>
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   107
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   108
#ifdef __DEF_Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   109
# undef Array
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   110
# define Array __DEF_Array
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_Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   113
# undef Number
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   114
# define Number __DEF_Number
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_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   117
# undef Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   118
# define Method __DEF_Method
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   119
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   120
#ifdef __DEF_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   121
# undef Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   122
# define Point __DEF_Point
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   123
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   124
#ifdef __DEF_Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   125
# undef Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   126
# define Rectangle __DEF_Rectangle
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   127
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   128
# undef Rectangle
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_Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   131
# undef Block
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   132
# define Block __DEF_Block
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_Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   135
# undef Context
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   136
# define Context __DEF_Context
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_Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   139
# undef Date
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   140
# define Date __DEF_Date
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_Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   143
# undef Time
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   144
# define Time __DEF_Time
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_Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   147
#  undef Set
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   148
#  define Set __DEF_Set
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_Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   151
#  undef Signal
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   152
#  define Signal __DEF_Signal
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_Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   155
#  undef Delay
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   156
#  define Delay __DEF_Delay
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_Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   159
#  undef Process
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   160
#  define Process __DEF_Process
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
# ifdef __DEF_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   163
#  undef Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   164
#  define Processor __DEF_Processor
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   165
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   166
# ifdef __DEF_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   167
#  undef Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   168
#  define Message __DEF_Message
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   169
# endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   170
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   171
#undef INT
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   172
#define INT int
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   173
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   174
/*
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   175
 * some defines - tired of typing ...
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   176
 */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   177
#define _HANDLEVal(o)        (HANDLE)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   178
#define _HBITMAPVAL(o)       (HBITMAP)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   179
#define _HWNDVal(o)          (HWND)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   180
#define _HPALETTEVal(o)      (HPALETTE)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   181
#define _HCURSORVal(o)       (HCURSOR)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   182
#define _HGDIOBJVal(o)       (HGDIOBJ)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   183
#define _LOGPALETTEVal(o)    (LOGPALETTE *)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   184
#define _COLORREFVal(o)      (COLORREF)(__MKCP(o))
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   185
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   186
#define WIDECHAR unsigned short
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   187
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   188
#define WIN32PADDING 32
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
#ifdef DEBUG
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
   191
# define DPRINTF(x)              /* printf  x */
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
   192
# define DFPRINTF(x)             /* fprintf x */
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   193
#else
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   194
# define DPRINTF(x)              /* */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   195
# define DFPRINTF(x)             /* */
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   196
#endif
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   197
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   198
typedef int (*intf)(int);
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   199
%}
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   200
! !
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   201
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
!WinPrinterContext class methodsFor:'documentation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   204
copyright
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
 COPYRIGHT (c) 2006 by eXept Software AG
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   207
	      All Rights Reserved
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
 This software is furnished under a license and may be used
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
 only in accordance with the terms of that license and with the
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
 inclusion of the above copyright notice.   This software may not
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
 be provided or otherwise made available to, or used by, any
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
 other person.  No title to or ownership of the software is
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
 hereby transferred.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
documentation
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
"
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   220
    I am the mediator between the smalltalk printing protocol
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
    (which is the same as the graphics drawing protocol) and the
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
    windows printer.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   223
    When you open a printer, you will typically talk to me.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
    [author:]
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   226
	Felix Madrid (fm@exept.de)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   229
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   230
!WinPrinterContext class methodsFor:'instance creation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   231
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   232
fromPrinterInfo: aPrinterInfo
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   233
    | printerContext printerDevice hDC|
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
    hDC := aPrinterInfo createDC.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   236
    hDC = 0 ifTrue: [ ^self error: 'Error while opening printer.' ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   237
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   238
    printerContext := self new.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   239
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   240
    printerDevice := printerContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   241
"/    printerDevice := WinPrinter on: aPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   242
"/    printerDevice printerDC:hDC.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   243
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   244
    printerContext printerInfo: aPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   245
    printerContext setDevice:printerDevice id:nil gcId:hDC.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   246
    printerContext initExtent.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   247
    ^printerContext
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   248
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   249
    "Created: / 03-08-2006 / 12:53:52 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   250
    "Modified: / 04-08-2006 / 12:55:01 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   251
    "Modified: / 16-04-2007 / 12:36:26 / cg"
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   252
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   253
2446
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   254
newPrinter
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   255
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   256
    | printer printerInfo|
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   257
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   258
    printerInfo := PrintingDialog getPrinterInfo.
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   259
    printerInfo isNil ifTrue:[^self].
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   260
    printer := WinPrinterContext fromPrinterInfo: printerInfo.
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   261
    ^ printer
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   262
!
c04a44b89cf2 changed #newPrinter
fm
parents: 2399
diff changeset
   263
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   264
openGraphicContext
2621
8eac3ee0603d *** empty log message ***
sr
parents: 2603
diff changeset
   265
    ^ self openGraphicContextWithoutDialog:false
8eac3ee0603d *** empty log message ***
sr
parents: 2603
diff changeset
   266
!
8eac3ee0603d *** empty log message ***
sr
parents: 2603
diff changeset
   267
8eac3ee0603d *** empty log message ***
sr
parents: 2603
diff changeset
   268
openGraphicContextWithoutDialog:withoutDialog
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   269
    |printerInfo gc|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   270
2621
8eac3ee0603d *** empty log message ***
sr
parents: 2603
diff changeset
   271
    printerInfo := PrintingDialog getPrinterInfoWithoutDialog:withoutDialog.
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   272
    printerInfo isNil ifTrue:[^ nil].
2352
b9196fb35b8a bugfix - name of class
ca
parents: 2351
diff changeset
   273
    gc := WinPrinterGraphicContext fromPrinterInfo:printerInfo.
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   274
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   275
    gc notNil ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   276
        gc startPrintJob
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   277
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
   278
    ^ gc
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   279
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   280
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   281
!WinPrinterContext class methodsFor:'accessing'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   282
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   283
getPrinterInformation:printerNameString
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   284
    " 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
   285
      answer the information for the default printer."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   286
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   287
    |h|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   288
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   289
    h := OperatingSystem openPrinter:printerNameString.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   290
    ^ OperatingSystem
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   291
	getDocumentProperties:nil
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   292
	hPrinter:h
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   293
	pDeviceName:printerNameString.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   294
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   295
    "Created: / 27-07-2006 / 10:22:32 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   296
    "Modified: / 01-08-2006 / 16:01:44 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   297
    "Modified: / 10-10-2006 / 18:57:45 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   298
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   299
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   300
getPrinterInformationString: printerNameString
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   301
        " Answer the printer information string from the WIN.INI file
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   302
        for the printer named printerNameString.  If no name is specified,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   303
        answer the information for the default printer. "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   304
    | printerInfo result |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   305
    printerInfo := ( String new: 80 ).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   306
    result := OperatingSystem primGetProfileString: 'windows' 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   307
        keyName:  'device'
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   308
        default: ( printerNameString isNil ifTrue: [ '' ] ifFalse: [ printerNameString ] )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   309
        returnedString: printerInfo
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   310
        size: printerInfo size.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   311
    ^result > 0
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   312
        ifTrue: [printerInfo copyFrom: 1 to: result]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   313
        ifFalse: ['']
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   314
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   315
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   316
named: aName
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   317
    "Answer a new instance of Printer which represents
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   318
     the printer named aName as specified in the host
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   319
     Control Panel."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   320
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   321
    aName isNil ifTrue: [ ^self default ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   322
    ^self new printerInfoWithName: aName
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   323
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   324
    "Created: / 27-07-2006 / 17:51:27 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   325
    "Modified: / 02-08-2006 / 17:26:29 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   326
    "Modified: / 10-10-2006 / 17:33:29 / cg"
2348
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   327
!
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   328
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   329
postScriptBlackWhite
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   330
    "Returns true if the postscript is b&w or returns false if the postscript is color"
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   331
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   332
    ^ PostScriptBlackWhite ? false
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   333
!
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   334
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   335
postScriptBlackWhite: aBoolean
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   336
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
   337
    PostScriptBlackWhite := aBoolean
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   338
! !
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
!WinPrinterContext class methodsFor:'not supported yet'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   341
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   342
printAdvancedLines: pairOfPointsArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   343
    "Opens a print dialog and prints the given lines"
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 printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   346
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   347
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   348
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   349
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   350
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   351
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   352
	printer startPrintJob: 'Advanced Lines'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   353
	printer foreground:Color red background:Color white.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   354
	pairOfPointsArray
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   355
	    do:[:pairOfPointsAndContext |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   356
		 |pairOfPoints|
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   357
		 pairOfPoints := pairOfPointsAndContext at:1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   358
		 printer
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   359
		    lineWidth: (pairOfPointsAndContext at:2);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   360
		    lineStyle: (pairOfPointsAndContext at:3);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   361
		    capStyle: (pairOfPointsAndContext at:4);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   362
		    joinStyle: (pairOfPointsAndContext at:5);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   363
		    foreground: (pairOfPointsAndContext at:6);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   364
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   365
		    displayAdvanceLineFrom: (pairOfPoints at:1)  to: (pairOfPoints at:2).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   366
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   367
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   368
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   369
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   370
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   371
     WinPrinterContext printAdvancedLines:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   372
	(Array with: (Array with: (Array with:10@10 with:1000@5000) with: 3 with:#dashed with: #butt with: #miter with: Color green)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   373
	       with: (Array with: (Array with:10@10 with:3500@2000) with: 2 with:#solid  with: #butt with: #miter with: Color yellow)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   374
	       with: (Array with: (Array with:1000@800 with:6000@5000) with: 8 with:#dashed  with: #butt with: #miter with: Color black)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   375
	       with: (Array with: (Array with:2000@2800 with:2000@5000) with: 1 with:#dashed  with: #butt with: #miter with: Color red)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   376
	)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   377
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   378
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   379
    "Created: / 07-08-2006 / 12:09:48 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   380
    "Modified: / 07-08-2006 / 14:11:17 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   381
    "Modified: / 16-04-2007 / 15:37:41 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   382
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   383
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   384
!WinPrinterContext class methodsFor:'testing'!
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   385
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   386
computeScaleForPrinter:aPrinter
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   387
    ^ Point x:(aPrinter pixelsPerInchOfScreenWidth / Screen current horizontalPixelPerInch)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   388
            y:(aPrinter pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   389
!
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   390
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   391
testPrintingDo:anOneArgBlock
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   392
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   393
    "Opens a print dialog and invokes the action with the printer"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   394
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   395
    | printerInfo printer |
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   396
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   397
    printerInfo := PrintingDialog getPrinterInfo.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   398
    printerInfo isNil ifTrue:[^self].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   399
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   400
    printer := self fromPrinterInfo: printerInfo.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   401
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   402
    printer startPrintJob: 'Testing'.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   403
    anOneArgBlock value:printer.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   404
    printer endPrintJob.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   405
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   406
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   407
"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   408
self testPrintingDo:[:aPrinter| |icon|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   409
    aPrinter scale:(self computeScaleForPrinter:aPrinter).
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   410
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   411
    aPrinter displayLineFrom:10@10   to:100@10.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   412
    aPrinter displayLineFrom:100@10  to:100@100.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   413
    aPrinter displayLineFrom:100@100 to:10@100.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   414
    aPrinter displayLineFrom:10@100  to:10@10.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   415
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   416
    icon := XPToolbarIconLibrary eraseXP28x28Icon.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   417
    icon displayOn:aPrinter x:10 y:10.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   418
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   419
].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   420
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   421
self testPrintingDo:[:aPrinter| |scale|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   422
    scale := self computeScaleForPrinter:aPrinter.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   423
    aPrinter scale:(1 * scale).
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   424
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   425
    aPrinter  font:(Font family:'Arial' face:'medium' size:8).
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   426
    aPrinter displayLineFrom:8@16 to:100@16.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   427
    aPrinter displayLineFrom:8@16 to:8@128.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   428
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   429
    'hallo' displayOn:aPrinter x:8 y:16.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   430
    aPrinter scale:(2 * scale).
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   431
    'hallo' displayOn:aPrinter x:4 y:32.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   432
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   433
    aPrinter scale:(4 * scale).
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   434
    'hallo' displayOn:aPrinter x:2 y:32.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   435
].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   436
"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   437
! !
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
   438
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   439
!WinPrinterContext class methodsFor:'testing & examples'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   440
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   441
fillCircles: arrayOfPointsAndRadiusWithContextArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   442
    "Opens a print dialog and prints the given circles"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   443
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   444
    | printerInfo printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   445
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   446
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   447
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   448
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   449
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   450
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   451
	printer startPrintJob: 'Fill Circles'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   452
	arrayOfPointsAndRadiusWithContextArray
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   453
	    do:[:pointsAndRadiusWithContextArray |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   454
		printer foreground:(pointsAndRadiusWithContextArray at:3).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   455
		printer fillCircle:(pointsAndRadiusWithContextArray at:1)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   456
			radius:(pointsAndRadiusWithContextArray at:2).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   457
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   458
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   459
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   460
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   461
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   462
     WinPrinterContext fillCircles:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   463
	(Array with: (Array with: 800@800 with: 600 with:Color red)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   464
	       with: (Array with: 1500@1500 with: 1000 with:Color blue)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   465
	       with: (Array with: 4000@2500 with: 2000 with:Color gray))
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   466
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   467
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   468
    "Created: / 07-08-2006 / 11:46:52 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   469
    "Modified: / 16-04-2007 / 15:37:34 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   470
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   471
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   472
fillHatchCircles: arrayOfPointsAndRadiusWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   473
    "Opens a print dialog and prints the given circles"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   474
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   475
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   476
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   477
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   478
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   479
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   480
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   481
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   482
        printer startPrintJob: 'Fill Hatch Circles'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   483
        arrayOfPointsAndRadiusWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   484
            do:[:pointsAndRadiusWithContextArray |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   485
                | point radius color hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   486
                point := (pointsAndRadiusWithContextArray at:1).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   487
                radius := (pointsAndRadiusWithContextArray at:2).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   488
                color := (pointsAndRadiusWithContextArray at:3).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   489
                hatch := (pointsAndRadiusWithContextArray at:4).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   490
                printer foreground: color;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   491
                        hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   492
                printer fillCircle:point
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   493
                        radius:radius.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   494
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   495
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   496
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   497
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   498
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   499
     WinPrinterContext fillHatchCircles:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   500
        (Array with: (Array with: 800@800 with: 600 with:Color red with: #diagonalCross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   501
               with: (Array with: 1500@1500 with: 1000 with:Color blue with: #vertical)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   502
               with: (Array with: 4000@2500 with: 2000 with:Color gray with: #bDiagonal))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   503
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   504
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   505
    "Created: / 07-08-2006 / 11:46:52 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   506
    "Modified: / 16-04-2007 / 15:37:34 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   507
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   508
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   509
fillHatchPolygons: polygonsWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   510
    "Opens a print dialog and prints the given polygons"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   511
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   512
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   513
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   514
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   515
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   516
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   517
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   518
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   519
        printer startPrintJob: 'Fill Hatch Polygons'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   520
        polygonsWithContextArray
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   521
            do:[:polygonWithContextArray |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   522
                 |aPolygon color hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   523
                 aPolygon := polygonWithContextArray at: 1.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   524
                 color := (polygonWithContextArray at: 2).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   525
                 hatch := (polygonWithContextArray at: 3).
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   526
                 printer foreground: color;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   527
                         hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   528
                 aPolygon displayFilledOn: printer.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   529
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   530
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   531
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   532
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   533
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   534
     WinPrinterContext fillHatchPolygons:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   535
        (Array with: (Array with: (Polygon vertices:(
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   536
                                Array
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   537
                                    with:100@100
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   538
                                    with:600@1000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   539
                                    with:3500@4000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   540
                                    with:100@4000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   541
                                    with:100@100))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   542
                            with: Color red
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   543
                            with: #cross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   544
                with: (Array with: (Polygon vertices:(
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   545
                                Array
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   546
                                    with:1000@1000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   547
                                    with:1000@2000
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   548
                                    with:2000@1000))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   549
                             with: Color blue
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   550
                             with: #none)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   551
    )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   552
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   553
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   554
    "Created: / 07-08-2006 / 12:09:48 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   555
    "Modified: / 07-08-2006 / 14:11:17 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   556
    "Modified: / 16-04-2007 / 15:37:43 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   557
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   558
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   559
fillHatchRectangles: rectanglesWithHatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   560
    "Opens a print dialog and prints the given rectangles"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   561
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   562
    | printerInfo printer |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   563
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   564
    printerInfo := PrintingDialog getPrinterInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   565
    printerInfo isNil ifTrue:[^self].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   566
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   567
    printer := self fromPrinterInfo: printerInfo.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   568
    [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   569
        printer startPrintJob: 'Fill Hatch Rectangles'.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   570
        printer foreground:Color blue background:Color white.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   571
        rectanglesWithHatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   572
            do:[:rectangleWithHatch |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   573
                |rectangle hatch|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   574
                rectangle := rectangleWithHatch at: 1.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   575
                hatch := rectangleWithHatch at: 2.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   576
                printer hatch: hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   577
                printer fillRectangleX: rectangle origin x
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   578
                        y: rectangle origin y
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   579
                        width: rectangle width
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   580
                        height: rectangle height.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   581
            ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   582
        printer endPrintJob.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   583
    ] forkAt: 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   584
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   585
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   586
     WinPrinterContext fillHatchRectangles:
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   587
        (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
   588
               with: (Array with: (Rectangle left:500 top:700 width:600 height:400) with: #vertical)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   589
               with: (Array with: (Rectangle left:800 top:1000 width:1600 height:2000) with: #cross)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   590
               with: (Array with: (Rectangle left:1040 top:1240 width:3000 height:3000) with: #bDiagonal)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   591
        )
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   592
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   593
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   594
    "Created: / 07-08-2006 / 11:40:48 / fm"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   595
    "Modified: / 16-04-2007 / 15:37:46 / cg"
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   596
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
   597
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   598
fillPolygons: polygonsWithContextArray
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   599
    "Opens a print dialog and prints the given polygons"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   600
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   601
    | printerInfo printer |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   602
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   603
    printerInfo := PrintingDialog getPrinterInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   604
    printerInfo isNil ifTrue:[^self].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   605
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   606
    printer := self fromPrinterInfo: printerInfo.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   607
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   608
	printer startPrintJob: 'Fill Polygons'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   609
	polygonsWithContextArray
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   610
	    do:[:polygonWithContextArray |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   611
		 |aPolygon|
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   612
		 aPolygon := polygonWithContextArray at: 1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   613
		 printer foreground:(polygonWithContextArray at: 2).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   614
		 aPolygon displayFilledOn: printer.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   615
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   616
	printer endPrintJob.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   617
    ] forkAt: 3
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   618
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   619
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   620
     WinPrinterContext fillPolygons:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   621
	(Array with: (Array with: (Polygon vertices:(
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   622
				Array
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   623
				    with:100@100
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   624
				    with:600@1000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   625
				    with:3500@4000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   626
				    with:100@4000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   627
				    with:100@100))
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   628
			    with: Color red)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   629
		with: (Array with: (Polygon vertices:(
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   630
				Array
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   631
				    with:1000@1000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   632
				    with:1000@2000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   633
				    with:2000@1000))
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   634
			     with: Color blue)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   635
    )
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   636
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   637
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   638
    "Created: / 07-08-2006 / 12:09:48 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   639
    "Modified: / 07-08-2006 / 14:11:17 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   640
    "Modified: / 16-04-2007 / 15:37:43 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   641
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   642
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   643
fillRectangles: rectangles
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   644
    "Opens a print dialog and prints the given rectangles"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   645
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   646
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   647
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   648
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   649
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   650
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   651
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   652
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   653
	printer startPrintJob: 'Fill Rectangles'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   654
	printer foreground:Color blue background:Color white.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   655
	rectangles
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   656
	    do:[:rectangle |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   657
		printer fillRectangleX: rectangle origin x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   658
			y: rectangle origin y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   659
			width: rectangle width
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   660
			height: rectangle height.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   661
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   662
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   663
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   664
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   665
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   666
     WinPrinterContext fillRectangles:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   667
	(Array with: (Rectangle left:20 top:20 width:400 height:600)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   668
	       with: (Rectangle left:500 top:700 width:600 height:400)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   669
	       with: (Rectangle left:800 top:1000 width:1600 height:2000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   670
	       with: (Rectangle left:1040 top:1240 width:3000 height:3000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   671
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   672
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   673
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   674
    "Created: / 07-08-2006 / 11:40:48 / fm"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   675
    "Modified: / 16-04-2007 / 15:37:46 / cg"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   676
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   677
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   678
print: aString font: aFont title: aTitle
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   679
    "Open a print dialog to allow printing of the given string
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   680
     using the given title & font."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   681
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   682
    self print: aString font: aFont title: aTitle wordWrap: false
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   683
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   684
   "
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   685
    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
   686
    WinPrinterContext print: (WinPrinterContext class sourceCodeAt:#'print:font:title:wordWrap:') font: nil title: 'Printing Test String'
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
   687
    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
   688
   "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   689
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   690
    "Created: / 27-07-2006 / 17:52:33 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   691
    "Modified: / 03-08-2006 / 18:52:31 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   692
    "Modified: / 16-04-2007 / 13:54:40 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   693
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   694
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   695
print: aString font: aFont title: aTitle wordWrap: wordWrap
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   696
    "Open a print dialog to allow printing of the given string
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   697
     using the given title & font."
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   698
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   699
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   700
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   701
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   702
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   703
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   704
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   705
    [
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   706
        printer
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   707
            print: aString
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   708
            font: aFont
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   709
            title: aTitle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   710
            wordWrap: wordWrap
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   711
            marginsRect: nil
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   712
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   713
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   714
    "
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   715
     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
   716
     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
   717
     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
   718
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   719
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   720
    "Created: / 03-08-2006 / 18:51:53 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   721
    "Modified: / 16-04-2007 / 15:37:31 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   722
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   723
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   724
printCircles: arrayOfPointsAndRadius
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   725
    "Opens a print dialog and prints the given circles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   726
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   727
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   728
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   729
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   730
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   731
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   732
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   733
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   734
	printer startPrintJob: 'Circles'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   735
	printer foreground:Color green background:Color white.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   736
	arrayOfPointsAndRadius
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   737
	    do:[:pointAndRadius |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   738
		printer displayCircle:(pointAndRadius at:1)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   739
			radius:(pointAndRadius at:2).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   740
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   741
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   742
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   743
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   744
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   745
     WinPrinterContext printCircles:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   746
	(Array with: (Array with: 800@800 with: 600)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   747
	       with: (Array with: 1500@1500 with: 1000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   748
	       with: (Array with: 4000@2500 with: 2000))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   749
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   750
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   751
    "Created: / 07-08-2006 / 11:46:52 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   752
    "Modified: / 16-04-2007 / 15:37:34 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   753
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   754
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   755
printCirclesIn: rectangles
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   756
    "Opens a print dialog and prints the given circles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   757
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   758
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   759
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   760
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   761
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   762
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   763
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   764
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   765
	printer startPrintJob: 'Circles In Rectangles'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   766
	rectangles
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   767
	   do:[:rectangle |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   768
	       printer displayCircleIn: rectangle.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   769
	   ].
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   770
       printer endPrintJob.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   771
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   772
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   773
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   774
     WinPrinterContext printCirclesIn:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   775
	(Array with: (Rectangle left:20 top:20 width:400 height:600)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   776
	       with: (Rectangle left:40 top:40 width:600 height:400)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   777
	)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   778
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   779
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   780
    "Created: / 07-08-2006 / 11:48:46 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   781
    "Modified: / 16-04-2007 / 15:37:38 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   782
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   783
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   784
printImage: anImage
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   785
    "Opens a print dialog and prints the given image"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   786
2384
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   787
    self printImage: anImage magnification:1.
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   788
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   789
    "
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   790
     WinPrinterContext printImage: (Image fromFile:'C:\vsw311\pavheadr.gif').
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   791
     WinPrinterContext printImage: XPToolbarIconLibrary help32x32Icon.
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   792
     WinPrinterContext printImage: XPToolbarIconLibrary eraseXP28x28Icon.
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   793
     WinPrinterContext printImage: XPToolbarIconLibrary saveImageBlack22x22Icon.
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   794
     WinPrinterContext printImage: XPToolbarIconLibrary changesBrowser18x22Icon.
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   795
    "
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   796
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   797
    "Created: / 07-08-2006 / 11:46:52 / fm"
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   798
    "Modified: / 16-04-2007 / 15:37:34 / cg"
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   799
!
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   800
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   801
printImage:anImage magnification:factor
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   802
    "Opens a print dialog and prints the given image"
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   803
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   804
    | printerInfo printer |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   805
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   806
    printerInfo := PrintingDialog getPrinterInfo.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   807
    printerInfo isNil ifTrue:[^self].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   808
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   809
    printer := self fromPrinterInfo: printerInfo.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   810
    [
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   811
        printer startPrintJob: 'Image'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   812
        printer background:Color white.
2384
1c53fc6edb39 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2357
diff changeset
   813
        (anImage magnifiedBy:factor) displayOn:printer x:0 y:0.
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   814
        printer endPrintJob.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   815
    ] forkAt: 3
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   816
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   817
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   818
     WinPrinterContext printImage: (Image fromFile:'C:\vsw311\pavheadr.gif').
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   819
     WinPrinterContext printImage: XPToolbarIconLibrary help32x32Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   820
     WinPrinterContext printImage: XPToolbarIconLibrary eraseXP28x28Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   821
     WinPrinterContext printImage: XPToolbarIconLibrary saveImageBlack22x22Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   822
     WinPrinterContext printImage: XPToolbarIconLibrary changesBrowser18x22Icon.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   823
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   824
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   825
    "Created: / 07-08-2006 / 11:46:52 / fm"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   826
    "Modified: / 16-04-2007 / 15:37:34 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   827
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
   828
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   829
printLines: pairOfPointsWithContextArray
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   830
    "Opens a print dialog and prints the given lines"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   831
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   832
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   833
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   834
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   835
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   836
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   837
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   838
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   839
	printer startPrintJob: 'Lines'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   840
	pairOfPointsWithContextArray
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   841
	    do:[:pairOfPointsAndContext |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   842
		 |pairOfPoints|
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   843
		 pairOfPoints := pairOfPointsAndContext at: 1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   844
		 printer
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   845
		    foreground:(pairOfPointsAndContext at:2);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   846
		    lineWidth: (pairOfPointsAndContext at:3);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   847
		    lineStyle: (pairOfPointsAndContext at:4);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   848
		    displayLineFrom: (pairOfPoints at:1)  to: (pairOfPoints at:2).
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   849
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   850
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   851
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   852
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   853
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   854
     WinPrinterContext printLines:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   855
	(Array with: (Array with:(Array with:10@10 with:1000@5000) with: Color red with:4 with: #solid)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   856
	       with: (Array with:(Array with:10@10 with:3500@2000) with: Color blue with:1 with: #dashed)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   857
	       with: (Array with:(Array with:1000@800 with:6000@5000) with: Color black with: 1 with:#dotted)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   858
	       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
   859
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   860
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   861
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   862
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   863
    "Modified: / 16-04-2007 / 15:37:41 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   864
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   865
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   866
printPoints: aCollectionOfPoints
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   867
    "Opens a print dialog and prints the given points"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   868
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   869
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   870
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   871
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   872
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   873
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   874
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   875
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   876
	printer startPrintJob: 'Points'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   877
	aCollectionOfPoints do:[:each |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   878
	    printer displayPointX: each x y: each y.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   879
	].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   880
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   881
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   882
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   883
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   884
     WinPrinterContext printPoints:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   885
	(Array with: (10 @ 10)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   886
	       with: (500 @ 700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   887
	       with: (900 @ 1000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   888
	       with: (1500 @ 1700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   889
	       with: (2100 @ 2000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   890
	       with: (2500 @ 2700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   891
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   892
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   893
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   894
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   895
printPolygons: polygons
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   896
    "Opens a print dialog and prints the given polygons"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   897
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   898
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   899
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   900
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   901
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   902
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   903
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   904
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   905
	printer startPrintJob: 'Polygons'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   906
	printer foreground:Color black background:Color white.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   907
	polygons
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   908
	    do:[:aPolygon |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   909
		 aPolygon displayStrokedOn: printer.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   910
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   911
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   912
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   913
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   914
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   915
     WinPrinterContext printPolygons:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   916
	(Array with: (Polygon vertices:(
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   917
				Array
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   918
				    with:100@100
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   919
				    with:600@1000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   920
				    with:3500@4000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   921
				    with:100@4000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   922
				    with:100@100))
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   923
		with: (Polygon vertices:(
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   924
				Array
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   925
				    with:1000@1000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   926
				    with:1000@2000
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   927
				    with:2000@1000)))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   928
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   929
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   930
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   931
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
   932
    "Modified: / 16-04-2007 / 15:37:43 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   933
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   934
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   935
printPolylines: evenCollectionOfPoints
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   936
    "Opens a print dialog and prints the given rectangles"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   937
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   938
    | printerInfo printer |
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   939
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   940
    printerInfo := PrintingDialog getPrinterInfo.
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   941
    printerInfo isNil ifTrue:[^self].
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   942
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   943
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   944
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   945
	printer startPrintJob: 'Polylines'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   946
	printer displayPolylines:evenCollectionOfPoints.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   947
	printer endPrintJob.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   948
    ] forkAt: 3
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   949
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   950
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   951
     WinPrinterContext printPolylines:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   952
	(Array with: (10 @ 10)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   953
	       with: (500 @ 700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   954
	       with: (900 @ 1000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   955
	       with: (1500 @ 1700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   956
	       with: (2100 @ 2000)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   957
	       with: (2500 @ 2700)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   958
	)
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   959
    "
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   960
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   961
    "Created: / 07-08-2006 / 11:40:48 / fm"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   962
    "Modified: / 16-04-2007 / 15:37:46 / cg"
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   963
!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
   964
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
   965
printRectangles: rectanglesWithContextArray
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   966
    "Opens a print dialog and prints the given rectangles"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   967
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   968
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   969
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   970
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   971
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   972
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   973
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   974
    [
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   975
	printer startPrintJob: 'Rectangles'.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   976
	printer foreground:Color red background:Color white.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   977
	rectanglesWithContextArray do:[:rectangleWithContextArray |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   978
	    |rectangle|
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   979
	    rectangle := rectangleWithContextArray at: 1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   980
	    printer
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   981
		foreground:(rectangleWithContextArray at:2);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   982
		lineWidth: (rectangleWithContextArray at:3);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   983
		lineStyle: (rectangleWithContextArray at:4);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   984
		displayRectangleX: rectangle origin x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   985
			y: rectangle origin y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   986
			width: rectangle width
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   987
			height: rectangle height.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   988
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   989
	printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   990
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   991
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   992
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
   993
     WinPrinterContext printRectangles:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   994
	(Array with: (Array with: (Rectangle left:30 top:10 width:400 height:600) with: Color red with:4 with: #solid)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   995
	       with: (Array with: (Rectangle left:100 top:140 width:700 height:800) with: Color blue with:1 with: #dashed)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   996
	       with: (Array with: (Rectangle left:800 top:1500 width:2600 height:3400) with: Color green with:1 with: #dotted)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   997
	       with: (Array with: (Rectangle left:1000 top:1200 width:1400 height:1600) with: Color gray with:8 with: #dashed)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   998
	       with: (Array with: (Rectangle left:2600 top:1200 width:1400 height:1600) with: Color darkGray with:1 with: #dashDotDot)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
   999
	)
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1000
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1001
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1002
    "Created: / 07-08-2006 / 11:40:48 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
  1003
    "Modified: / 16-04-2007 / 15:37:46 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1004
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1005
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
printStrings: stringAndPositionsArray
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1007
    "Opens a print dialog and prints the given strings"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1008
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1009
    | printerInfo printer |
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1010
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1011
    printerInfo := PrintingDialog getPrinterInfo.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1012
    printerInfo isNil ifTrue:[^self].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1013
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1014
    printer := self fromPrinterInfo: printerInfo.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1015
    [
2482
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1016
        printer startPrintJob: 'Strings with Position'.
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1017
        printer foreground:Color black background:Color white.
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1018
        stringAndPositionsArray
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1019
            do:[:pairOfPointsAndPosition |
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1020
                 printer displayString:(pairOfPointsAndPosition at: 1)
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1021
                            x:(pairOfPointsAndPosition at: 2) x
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1022
                            y:(pairOfPointsAndPosition at: 2) y
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1023
            ].
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1024
        printer endPrintJob.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1025
    ] forkAt: 3
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1026
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1027
    "
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1028
     WinPrinterContext printStrings:
2482
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1029
        (Array with: (Array with:'Testing printing with standard method' with:10@10)
798c34fa1efb standard
Claus Gittinger <cg@exept.de>
parents: 2446
diff changeset
  1030
               with: (Array with:'Another test string to print' with:80@200))
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
    "
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1032
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1033
    "Created: / 07-08-2006 / 12:09:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1034
    "Modified: / 07-08-2006 / 14:11:17 / fm"
2313
a3fa5abef172 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2304
diff changeset
  1035
    "Modified: / 16-04-2007 / 15:37:49 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1036
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
!WinPrinterContext methodsFor:'accessing'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1039
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1040
depth
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1041
    ^ 24
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1042
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1043
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1044
deviceColors
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1045
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1046
    ^#()
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1047
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1048
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1049
deviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1050
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1051
    deviceFonts isNil ifTrue:[deviceFonts := CachingRegistry new cacheSize:10.].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1052
    ^deviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1053
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1054
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1055
getCharHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1056
    "Private - answer the height of the font selected in the receiver's
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1057
     device context."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1058
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1059
    |textMetrics answer|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1060
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1061
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1062
    textMetrics := Win32OperatingSystem::TextMetricsStructure new.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1063
"/    (OperatingSystem getTextMetrics:gcId lpMetrics:textMetrics) ifFalse:[ ^ self error ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1064
"/    Transcript showCR: 'CHAR HEIGHT PRIM ******* ', '   ',  (textMetrics tmHeight + textMetrics tmExternalLeading) printString.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1065
"/    Transcript showCR: 'CHAR HEIGHT DEVICE ***** ', '   ', (self font heightOf:'PQWEXCZ' on:self device) printString.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1066
    answer := (self font heightOf:'PQWEXCZ' on:self device).
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1067
"/    answer := textMetrics tmHeight + textMetrics tmExternalLeading.
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1068
    ^answer
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1069
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1070
    "Created: / 02-08-2006 / 17:47:20 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1071
    "Modified: / 03-08-2006 / 10:09:01 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1072
    "Modified: / 10-10-2006 / 18:15:17 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1073
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1074
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1075
getLogicalPixelSizeX
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1076
    ^ printerInfo printQuality ? 600
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1077
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1078
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1079
getLogicalPixelSizeY
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1080
    ^ printerInfo printQuality ? 600
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1081
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1082
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1083
numberOfColorBitsPerPixel
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1084
    ^ OperatingSystem getDeviceCaps:gcId index:12 "Bitspixel"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1085
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1086
    "Created: / 03-08-2006 / 09:58:18 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1087
    "Modified: / 10-10-2006 / 18:15:40 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1088
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1089
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1090
physicalOffsetX
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1091
    ^ OperatingSystem getDeviceCaps:gcId index:112 "PhysicalOffsetX"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1092
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1093
    "Created: / 01-08-2006 / 16:28:34 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  1094
    "Modified: / 16-04-2007 / 12:52:06 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1095
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1096
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1097
physicalOffsetY
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1098
    ^ OperatingSystem getDeviceCaps:gcId index:113 "PhysicalOffsetY"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1099
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1100
    "Created: / 01-08-2006 / 16:28:34 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  1101
    "Modified: / 16-04-2007 / 12:52:01 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1102
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1103
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1104
pixelsPerInchOfScreenHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
    ^ OperatingSystem getDeviceCaps:gcId index:90 "Logpixelsy"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1107
    "Created: / 01-08-2006 / 16:29:16 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1108
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1110
pixelsPerInchOfScreenWidth
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1111
    ^ OperatingSystem getDeviceCaps:gcId index:88 "Logpixelsx"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1112
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1113
    "Created: / 01-08-2006 / 16:28:34 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1114
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1115
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1116
printerHeightArea
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1117
    ^ (OperatingSystem getDeviceCaps:gcId index:10)
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1119
    "Modified: / 10-10-2006 / 18:18:31 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1120
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1121
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1122
printerPhysicalHeight
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1123
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:111 "PhysicalHeight"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1126
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1127
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1128
printerPhysicalWidth
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1129
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:110 "PhysicalWidth"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1130
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1131
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1132
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1133
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
printerWidthArea
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1135
    ^ OperatingSystem getDeviceCaps:gcId "deviceContext" index:8 "Horzres"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1136
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1137
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1138
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1139
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1140
supportedImageFormats
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1141
    "return an array with supported image formats; each array entry
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1142
     is another array, consisting of depth and bitsPerPixel values."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1143
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1144
    |info|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1145
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1146
    info := IdentityDictionary new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1147
    info at:#depth put:self depth.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1148
    info at:#bitsPerPixel put:self depth.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1149
    info at:#padding put:32.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1150
    ^ Array with:info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1151
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1152
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1153
     Disply supportedImageFormats
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1154
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1155
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1156
    "Modified: / 10.9.1998 / 23:14:05 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1157
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1158
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1159
visualType
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1160
    ^ #TrueColor
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1161
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1162
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1163
!WinPrinterContext methodsFor:'color stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1164
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1165
colorScaledRed:r scaledGreen:g scaledBlue:b
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1166
    "allocate a color with rgb values (0..16rFFFF) - return the color index
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1167
     (i.e. colorID)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1168
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1169
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1170
    int id, ir, ig, ib;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1171
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1172
    if (__bothSmallInteger(r, g) && __isSmallInteger(b)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1173
	ir = (__intVal(r) >> 8) & 0xff;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1174
	ig = (__intVal(g) >> 8) & 0xff;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1175
	ib = (__intVal(b) >> 8) & 0xff;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1176
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1177
	id = RGB( ir, ig, ib);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1178
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1179
	RETURN ( __MKSMALLINT(id) );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1180
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1181
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1182
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1183
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1184
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1185
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1186
setBackground:bgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1187
    "set background color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1188
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1189
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1190
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1191
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1192
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1193
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1194
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1195
	COLORREF bg, oldBg;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1196
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1197
	oldBg = GetBkColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1198
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1199
	bg = __intVal(bgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1200
/*        bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);         */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1201
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1202
	if (bg != oldBg) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1203
	    SetBkColor(hDC, bg);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1204
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1205
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1206
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1207
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1208
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1209
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1210
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1211
setBackgroundColor:color in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1212
    "set background color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1213
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1214
    |colorId deviceColor|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1215
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1216
    (color isOnDevice:self) ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1217
	colorId := color colorId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1218
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1219
	deviceColor := color onDevice:self.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1220
	deviceColor notNil ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1221
	    colorId := deviceColor colorId.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1222
	]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1223
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1224
    colorId isNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1225
	'DeviceWorkstation [warning]: could not set bg color' infoPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1226
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1227
	self setBackground:colorId in:aGCId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1228
    ]
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1229
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1230
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1231
setForeground:fgColorIndex background:bgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1232
    "set foreground and background colors to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1233
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1234
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1235
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1236
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1237
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1238
	COLORREF fg, bg, oldFg, oldBg;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1239
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1240
/*        fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);    */
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1241
	fg = __intVal(fgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1242
/*        bg = (COLORREF)st2RGB(__intVal(bgColorIndex),gcData);    */
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1243
	bg = __intVal(bgColorIndex) & 0xffffff;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1244
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1245
	oldFg = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1246
	oldBg = GetBkColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1247
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1248
	if ((fg != oldFg) || (bg != oldBg)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1249
	    /* Pen only depends upon fg-color */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1250
	    if (fg != oldFg) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1251
		SetTextColor(hDC, fg);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1252
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1253
	    if (bg != oldBg) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1254
		SetBkColor(hDC, bg);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1255
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1256
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1257
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1258
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1259
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1260
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1261
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1262
setForeground:fgColorIndex in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1263
    "set foreground color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1264
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1265
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1266
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1267
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1268
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1269
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1270
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1271
	COLORREF fg, oldFg;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1272
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1273
	oldFg = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1274
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1275
	fg = __intVal(fgColorIndex) & 0xffffff;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1276
/*        fg = (COLORREF)st2RGB(__intVal(fgColorIndex),gcData);         */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1277
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1278
	if (fg != oldFg) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1279
	    SetTextColor(hDC, fg);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1280
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1281
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1282
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1283
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1284
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1285
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1286
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1287
setForegroundColor:color in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1288
    "set the foreground color to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1289
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1290
    |colorId deviceColor|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1291
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1292
    (color isOnDevice:self) ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1293
	colorId := color colorId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1294
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1295
	deviceColor := color onDevice:self.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1296
	deviceColor notNil ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1297
	    colorId := deviceColor colorId.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1298
	]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1299
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1300
    colorId isNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1301
	'DeviceWorkstation [warning]: could not set fg color' infoPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1302
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1303
	self setForeground:colorId in:aGCId.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1304
    ]
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1305
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1306
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1307
!WinPrinterContext methodsFor:'context stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1308
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1309
getPenFor:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1310
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1311
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1312
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1313
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1314
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1315
     && __isSmallInteger(__INST(lineWidth))) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1316
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1317
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1318
	HANDLE hPen, prevPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1319
	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1320
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1321
	lineWidth= __INST(lineWidth);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1322
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1323
	if (__INST(lineStyle) == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1324
	    lineStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1325
	} else if (__INST(lineStyle) == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1326
	    lineStyleInt= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1327
	} else if (__INST(lineStyle) == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1328
	    lineStyleInt= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1329
	} else if (__INST(lineStyle) == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1330
	    lineStyleInt= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1331
	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1332
	    lineStyleInt= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1333
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1334
	    lineStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1335
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1336
	if (__INST(capStyle) == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1337
	    capStyleInt= PS_ENDCAP_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1338
	} else if (__INST(capStyle) == @symbol(square)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1339
	    capStyleInt= PS_ENDCAP_SQUARE;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1340
	} else if (__INST(capStyle) == @symbol(flat)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1341
	    capStyleInt= PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1342
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1343
	    capStyleInt= PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1345
	if (__INST(joinStyle) == @symbol(bevel)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1346
	    joinStyleInt= PS_JOIN_BEVEL;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1347
	} else if (__INST(joinStyle) == @symbol(miter)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1348
	    joinStyleInt= PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1349
	} else if (__INST(joinStyle) == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1350
	    joinStyleInt= PS_JOIN_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1351
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1352
	    joinStyleInt= PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1353
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1354
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1355
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1356
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1357
	hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1358
	prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1359
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1360
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1361
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1362
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1363
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1364
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1365
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1366
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1367
getPenForContext
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1368
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1369
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1370
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1371
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1372
    if (__isExternalAddressLike(__INST(gcId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1373
     && __isSmallInteger(__INST(lineWidth))) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1374
	HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1375
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1376
	HANDLE hPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1377
	int lineStyleInt, capStyleInt, joinStyleInt, lineWidth;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1378
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1379
	lineWidth= __INST(lineWidth);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1380
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1381
	if (__INST(lineStyle) == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1382
	    lineStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1383
	} else if (__INST(lineStyle) == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1384
	    lineStyleInt= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1385
	} else if (__INST(lineStyle) == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1386
	    lineStyleInt= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1387
	} else if (__INST(lineStyle) == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1388
	    lineStyleInt= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1389
	} else if (__INST(lineStyle) == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1390
	    lineStyleInt= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1391
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1392
	    lineStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1393
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1394
	if (__INST(capStyle) == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1395
	    capStyleInt= PS_ENDCAP_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1396
	} else if (__INST(capStyle) == @symbol(square)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1397
	    capStyleInt= PS_ENDCAP_SQUARE;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1398
	} else if (__INST(capStyle) == @symbol(flat)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1399
	    capStyleInt= PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1400
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1401
	    capStyleInt= PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1402
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1403
	if (__INST(joinStyle) == @symbol(bevel)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1404
	    joinStyleInt= PS_JOIN_BEVEL;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1405
	} else if (__INST(joinStyle) == @symbol(miter)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1406
	    joinStyleInt= PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1407
	} else if (__INST(joinStyle) == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1408
	    joinStyleInt= PS_JOIN_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1409
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1410
	    joinStyleInt= PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1411
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1412
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1413
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1414
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1415
	hPen = CreatePen(lineStyleInt | capStyleInt | joinStyleInt, lineWidth, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1416
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1417
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1418
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1419
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1420
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1421
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1422
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1423
hatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1424
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1425
    "The hatch style will define a hatched brush between these patterns:   
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1426
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1427
       #none                                     
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1428
       #horizontal              -----       HS_HORIZONTAL = 0       
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1429
       #vertical                |||||       HS_VERTICAL = 1
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1430
       #fDiagonal               \\\\\       HS_FDIAGONAL = 2
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1431
       #bDiagonal               /////       HS_BDIAGONAL = 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1432
       #cross                   +++++       HS_CROSS = 4
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1433
       #diagonalCross           xxxxx       HS_DIAGCROSS = 5
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1434
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1435
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1436
    hatch isNil ifTrue:[^#none].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1437
    ^ hatch
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1438
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1439
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1440
hatch: aSymbol
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1441
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1442
    "The hatch style will define a hatched brush between these patterns:   
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1443
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1444
       #none                                     
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1445
       #horizontal              -----       HS_HORIZONTAL = 0       
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1446
       #vertical                |||||       HS_VERTICAL = 1
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1447
       #fDiagonal               \\\\\       HS_FDIAGONAL = 2
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1448
       #bDiagonal               /////       HS_BDIAGONAL = 3
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1449
       #cross                   +++++       HS_CROSS = 4
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1450
       #diagonalCross           xxxxx       HS_DIAGCROSS = 5
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1451
    "
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1452
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1453
    hatch := aSymbol
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1454
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  1455
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1456
noClipIn:aWindowId gc:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1457
    "disable clipping rectangle"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1458
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1459
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1460
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1461
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1462
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1463
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1464
	SelectClipRgn(hDC, NULL);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1465
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1466
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1467
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1468
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1469
2399
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  1470
platformName
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  1471
    "used by #fillRoundRectangleX ...."
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  1472
    ^ Smalltalk platformName asUppercase      
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  1473
!
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  1474
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1475
setBitmapMask:aBitmapId in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1476
    "set or clear the drawing mask - a bitmap mask using current fg/bg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1477
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1478
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1479
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1480
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1481
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1482
	HBITMAP oldM;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1483
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1484
/*        oldM = gcData->hMask;
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1485
	if (__isExternalAddress(aBitmapId))
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1486
	    gcData->hMask = _HBITMAPVAL(aBitmapId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1487
	else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1488
	    gcData->hMask = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1489
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1490
	if (oldM != gcData->hMask) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1491
	  FLUSH_CACHED_DC(gcData);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1492
	    CPRINTF(("masks set to %x\n",gcData->hMask));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1493
	}                                                     */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1494
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1495
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1496
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1497
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1498
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1499
setClipX:clipX y:clipY width:clipWidth height:clipHeight in:ignoredDrawableId gc:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1500
    "clip to a rectangle"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1501
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1502
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1503
      p--w---
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1504
      |     |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1505
      h     |  the clipping rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1506
      |     |
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1507
      -------
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1508
	  where p = ( clipX, clipY ), w = clipWidth, h = clipHeight
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1509
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1510
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1511
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1512
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1513
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1514
     && __bothSmallInteger(clipX, clipY)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1515
     && __bothSmallInteger(clipWidth, clipHeight) ) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1516
	HANDLE hDC;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1517
	int cX, cY, cW, cH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1518
	POINT ptOrg;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1519
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1520
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1521
	hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1522
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1523
	GetViewportOrgEx(hDC,&ptOrg);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1524
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1525
	// set the clip rectangle
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1526
	// and offset the rectangle by the viewport origin
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1527
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1528
	cX = __intVal(clipX) + ptOrg.x;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1529
	cY = __intVal(clipY) + ptOrg.y;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1530
	cW = __intVal(clipWidth)+ ptOrg.x;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1531
	cH = __intVal(clipHeight)+ ptOrg.y;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1532
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1533
	{
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1534
	    HRGN region = CreateRectRgn(cX, cY, cX + cW, cY + cH);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1535
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1536
	    if (region == NULL ) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1537
		console_fprintf(stderr, "WinWorkstat [warning]: clipping region creation failed\n");
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1538
	    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1539
		if (SelectClipRgn(hDC, region) == ERROR ) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1540
		    console_fprintf(stderr, "WinWorkstat [warning]: select clipping region failed\n");
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1541
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1542
		DeleteObject(region);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1543
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1544
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1545
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1546
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1547
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1548
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1549
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1550
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1551
setDashes:dashList dashOffset:offset in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1552
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1553
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1554
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1555
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1556
    if (__isExternalAddressLike(aGCId)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1557
	DPRINTF(("WinWorkstat [warning]: dashes not (yet) implemented\n"));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1558
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1559
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1560
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1561
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1562
setLineWidth:aNumber style:lineStyle cap:capStyle join:joinStyle in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1563
    "set line attributes"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1564
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1565
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1566
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1567
    HDC hDC;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1568
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1569
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1570
     && __isSmallInteger(aNumber)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1571
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1572
	int style;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1573
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1574
	if (lineStyle == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1575
	    style = PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1576
	} else if (lineStyle == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1577
	    style= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1578
	} else if (lineStyle == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1579
	    style= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1580
	} else if (lineStyle == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1581
	    style= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1582
	} else if (lineStyle == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1583
	    style= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1584
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1585
	    style= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1586
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1587
	if (capStyle == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1588
	    style = PS_ENDCAP_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1589
	} else if (capStyle == @symbol(square)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1590
	    style = PS_ENDCAP_SQUARE;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1591
	} else if (capStyle == @symbol(flat)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1592
	    style = PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1593
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1594
	    style = PS_ENDCAP_FLAT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1595
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1596
	if (joinStyle == @symbol(bevel)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1597
	    style = PS_JOIN_BEVEL;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1598
	} else if (joinStyle == @symbol(miter)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1599
	    style = PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1600
	} else if (joinStyle == @symbol(round)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1601
	    style = PS_JOIN_ROUND;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1602
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1603
	    style = PS_JOIN_MITER;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1604
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1605
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1606
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1607
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1608
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1609
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1610
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1611
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1612
setMaskOriginX:orgX y:orgY in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1613
    "set the mask origin"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1614
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1615
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1616
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1617
    if (__isExternalAddress(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1618
     && __bothSmallInteger(orgX,orgY)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1619
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1620
	int oX, oY, maskOrgX, maskOrgY;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1621
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1622
	oX = __intVal(orgX);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1623
	oY = __intVal(orgY);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1624
	if ((oX != maskOrgX)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1625
	 || (oY != maskOrgY)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1626
	    maskOrgX = __intVal(orgX);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1627
	    maskOrgY = __intVal(orgY);;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1628
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1629
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1630
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1631
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1632
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1633
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1634
setViewportOrg: aPoint
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1635
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1636
    "Sets the viewport origin (LOGICAL point (0,0)) of the device context"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1637
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1638
    ^ OperatingSystem
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1639
	    setViewportOrg: gcId "deviceContext"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1640
	    x: aPoint x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1641
	    y: aPoint y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1642
	    oldOrigin: nil
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1643
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1644
    "Created: / 01-08-2006 / 16:14:08 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1645
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1646
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1647
!WinPrinterContext methodsFor:'drawing'!
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1648
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1649
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
  1650
    "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
  1651
     The angles may be floats or integer - they are given in degrees."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1652
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1653
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1654
    int __x, __y, w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1655
    float angle1, angle2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1656
    double f;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1657
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1658
    if (__isSmallInteger(startAngle))
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1659
	angle1 = (float)(__intVal(startAngle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1660
    else if (__isFloat(startAngle)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1661
	angle1 = (float) __floatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1662
    } else if (__isShortFloat(startAngle)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1663
	angle1 = __shortFloatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1664
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1665
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1666
    if (__isSmallInteger(angle))
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1667
	angle2 = (float)(__intVal(angle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1668
    else if (__isFloat(angle)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1669
	angle2 = (float) __floatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1670
    } else if (__isShortFloat(angle)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1671
	angle2 = __shortFloatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1672
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1673
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1674
    if (angle2 <= 0) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1675
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1676
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1677
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1678
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1679
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1680
     && __bothSmallInteger(width, height))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1681
     {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1682
	POINT p;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1683
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1684
	DWORD clr = 0 /* 0xFFFFFFFF */;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1685
	HANDLE prevPen, hPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1686
	double xB, yB, xE, yE, xR, yR;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1687
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1688
	int lStyleSymbol, lStyleInt;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1689
	int lw;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1690
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1691
	lw= __intVal(__INST(lineWidth));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1692
	lStyleSymbol= __INST(lineStyle);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1693
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1694
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1695
	    only works with lineWidth = 1  */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1696
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1697
	if (lStyleSymbol == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1698
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1699
	} else if (lStyleSymbol == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1700
	    lStyleInt= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1701
	} else if (lStyleSymbol == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1702
	    lStyleInt= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1703
	} else if (lStyleSymbol == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1704
	    lStyleInt= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1705
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1706
	    lStyleInt= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1707
	} else if (lStyleSymbol == @symbol(insideFrame)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1708
	    lStyleInt= PS_INSIDEFRAME;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1709
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1710
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1711
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1712
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1713
	hPen = CreatePen(lStyleInt, lw, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1714
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1715
	w = __intVal(width);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1716
	h = __intVal(height);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1717
	__x = __intVal(x);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1718
	__y = __intVal(y);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1719
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1720
	    xR = w / 2;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1721
	    yR = h / 2;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1722
	    if (angle2 - angle1 >= 360) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1723
		xB = xE = __x + xR + 0.5;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1724
		yB = yE = __y /*+ yR + 0.5*/;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1725
	    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1726
		double sin(), cos();
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1727
		float rad1, rad2;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1728
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1729
		if (angle1 <= 180)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1730
		  angle1 = 180 - angle1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1731
		else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1732
		  angle1 = 360 + 180 - angle1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1733
		angle2 = angle1 - angle2;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1734
		/* sigh - compute the intersections ... */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1735
		rad1 = (angle1 * 3.14159265359) / 180.0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1736
		rad2 = (angle2 * 3.14159265359) / 180.0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1737
		xB = cos(rad1) * xR;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1738
		yB = sin(rad1) * yR;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1739
		xE = cos(rad2) * xR;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1740
		yE = sin(rad2) * yR;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1741
		xB = __x + xR - xB + 0.5;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1742
		yB = __y + yR - yB + 0.5;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1743
		xE = __x + xR - xE + 0.5;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1744
		yE = __y + yR - yE + 0.5;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1745
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1746
	    prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1747
	    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));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1748
	    Arc(hDC,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1749
		__x, __y,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1750
		__x + w, __y + h,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1751
		(int)xB, (int)yB,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1752
		(int)xE, (int)yE);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1753
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1754
	    SelectObject(hDC, prevPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1755
	    DeleteObject(hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1756
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1757
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1758
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1759
    bad: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1760
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1761
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1762
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1763
    "Created: / 07-08-2006 / 10:40:27 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1764
    "Modified: / 07-08-2006 / 14:44:21 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1765
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1766
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1767
displayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1768
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1769
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1770
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1771
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1772
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1773
     && __bothSmallInteger(x1, y1)) {
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1774
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1775
        COLORREF fgColor;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1776
        HANDLE prevPen, hPen;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1777
        int __x1 = __intVal(x1), __y1 = __intVal(y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1778
        int lStyleSymbol, lStyleInt;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1779
        int lw;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1780
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1781
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1782
                    __intVal(x0), __intVal(y0),
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1783
                    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1784
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1785
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1786
        lw= __intVal(__INST(lineWidth));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1787
        lStyleSymbol= __INST(lineStyle);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1788
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1789
        /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1790
            only works with lineWidth = 1  */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1791
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1792
        if (lStyleSymbol == @symbol(solid)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1793
            lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1794
        } else if (lStyleSymbol == @symbol(dashed)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1795
            lStyleInt= PS_DASH;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1796
        } else if (lStyleSymbol == @symbol(dotted)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1797
            lStyleInt= PS_DOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1798
        } else if (lStyleSymbol == @symbol(dashDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1799
            lStyleInt= PS_DASHDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1800
        } else if (lStyleSymbol == @symbol(dashDotDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1801
            lStyleInt= PS_DASHDOTDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1802
        } else if (lStyleSymbol == @symbol(insideFrame)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1803
            lStyleInt= PS_INSIDEFRAME;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1804
        } else
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1805
            lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1806
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1807
        fgColor = GetTextColor(hDC);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1808
        hPen = CreatePen(lStyleInt, lw, fgColor);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1809
        prevPen = SelectObject(hDC, hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1810
        MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1811
        LineTo(hDC, __x1, __y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1812
        /*
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1813
         * end-point ...
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1814
         */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1815
        // LineTo(hDC, __x1+1, __y1);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1816
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1817
        SelectObject(hDC, prevPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1818
        DeleteObject(hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1819
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  1820
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1821
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1822
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1823
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1824
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1825
displayPointX:px y:py in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1826
    "draw a point. If x/y are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1827
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1828
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1829
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1830
     && __bothSmallInteger(px, py)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1831
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1832
	POINT p;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1833
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1834
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1835
	int __x = __intVal(px), __y = __intVal(py);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1836
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1837
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1838
	SetPixelV(hDC, __x, __y, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1839
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1840
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1841
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1842
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1843
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1844
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1845
displayPolygon:aPolygon in:aDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1846
    "draw a polygon, the argument aPolygon is a Collection of individual points,
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1847
     which define the polygon.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1848
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1849
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1850
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1851
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1852
    numberOfPoints := aPolygon size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1853
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1854
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1855
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1856
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1857
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1858
     /* && __isExternalAddress(aDrawableId) */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1859
     && __isSmallInteger(numberOfPoints)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1860
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1861
	POINT p;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1862
	DWORD clr = 0 /* 0xFFFFFFFF */;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1863
	HANDLE prevPen, hPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1864
	int lw;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1865
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1866
	int lStyleSymbol, lStyleInt;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1867
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1868
	lw= __intVal(__INST(lineWidth));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1869
	lStyleSymbol= __INST(lineStyle);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1870
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1871
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1872
	    only works with lineWidth = 1  */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1873
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1874
	if (lStyleSymbol == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1875
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1876
	} else if (lStyleSymbol == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1877
	    lStyleInt= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1878
	} else if (lStyleSymbol == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1879
	    lStyleInt= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1880
	} else if (lStyleSymbol == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1881
	    lStyleInt= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1882
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1883
	    lStyleInt= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1884
	} else if (lStyleSymbol == @symbol(insideFrame)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1885
	    lStyleInt= PS_INSIDEFRAME;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1886
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1887
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1888
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1889
	num = __intVal(numberOfPoints);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1890
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1891
	for (i=0; i<num; i++) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1892
	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1893
	    if (! __isPoint(point)) goto fail;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1894
	    px = _point_X(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1895
	    py = _point_Y(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1896
	    if (! __bothSmallInteger(px, py)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1897
		goto fail;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1898
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1899
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1900
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1901
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1902
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1903
	hPen = CreatePen(lStyleInt, lw, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1904
	prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1905
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1906
	for (i=0; i<num; i++) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1907
	    point = __AT_(aPolygon, __MKSMALLINT(i+1));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1908
	    px = _point_X(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1909
	    py = _point_Y(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1910
	    p.x = __intVal(px);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1911
	    p.y = __intVal(py);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1912
	    if (i == 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1913
		MoveToEx(hDC, p.x, p.y, NULL);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1914
	    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1915
		if (i == (num-1)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1916
		    PolylineTo(hDC, &p, 1);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1917
		} else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1918
		    LineTo(hDC, p.x, p.y);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1919
#ifdef PRE_04_JUN_04
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1920
		    /*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1921
		     * end-point ...
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1922
		     */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1923
		    LineTo(hDC, p.x+1, p.y);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1924
#endif
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1925
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1926
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1927
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1928
	SelectObject(hDC, prevPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1929
	DeleteObject(hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1930
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1931
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1932
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1933
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1934
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1935
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1936
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1937
    "Created: / 07-08-2006 / 14:46:55 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1938
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1939
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  1940
displayPolylines:arrayOfPoints
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1941
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  1942
    device displayPolylines:arrayOfPoints in:nil with:gcId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1943
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1944
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1945
displayPolylines:aPolyline in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1946
    "draw a polyline, the argument aPolyline is a collection of individual points,
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1947
     which define the lines (p1/p2 pairs); must be even in size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1948
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1949
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1950
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1951
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1952
    numberOfPoints := aPolyline size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1953
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1954
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1955
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1956
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1957
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1958
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1959
     && __isSmallInteger(numberOfPoints)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  1960
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1961
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1962
	POINT p;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1963
	HANDLE prevPen, hPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1964
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1965
	int lw;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1966
	int lStyleSymbol, lStyleInt;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1967
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1968
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1969
	lw= __intVal(__INST(lineWidth));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1970
	lStyleSymbol= __INST(lineStyle);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1971
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1972
	/*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1973
	    only works with lineWidth = 1  */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1974
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1975
	if (lStyleSymbol == @symbol(solid)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1976
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1977
	} else if (lStyleSymbol == @symbol(dashed)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1978
	    lStyleInt= PS_DASH;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1979
	} else if (lStyleSymbol == @symbol(dotted)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1980
	    lStyleInt= PS_DOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1981
	} else if (lStyleSymbol == @symbol(dashDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1982
	    lStyleInt= PS_DASHDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1983
	} else if (lStyleSymbol == @symbol(dashDotDot)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1984
	    lStyleInt= PS_DASHDOTDOT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1985
	} else if (lStyleSymbol == @symbol(insideFrame)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1986
	    lStyleInt= PS_INSIDEFRAME;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1987
	} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1988
	    lStyleInt= PS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1989
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1990
	fgColor = GetTextColor(hDC);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1991
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1992
	num = __intVal(numberOfPoints);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1993
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1994
	for (i=0; i<num; i++) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1995
	    point = __AT_(aPolyline, __MKSMALLINT(i+1));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1996
	    if (! __isPoint(point)) goto fail;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1997
	    px = _point_X(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1998
	    py = _point_Y(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  1999
	    if (! __bothSmallInteger(px, py)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2000
		goto fail;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2001
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2002
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2003
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2004
	hPen = CreatePen(lStyleInt, lw, fgColor);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2005
	prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2006
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2007
	for (i=0; i<num; i++) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2008
	    point = __AT_(aPolyline, __MKSMALLINT(i+1));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2009
	    px = _point_X(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2010
	    py = _point_Y(point);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2011
	    p.x = __intVal(px);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2012
	    p.y = __intVal(py);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2013
	    DPRINTF(("printing point"));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2014
	    DPRINTF(("displayPolygon: no pen\n"));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2015
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2016
	    if ((i & 1) == 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2017
		MoveToEx(hDC, p.x, p.y, NULL);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2018
	    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2019
		LineTo(hDC, p.x, p.y);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2020
		/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2021
		 * end-point ...
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2022
		 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2023
		LineTo(hDC, p.x+1, p.y);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2024
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2025
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2026
	SelectObject(hDC, prevPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2027
	DeleteObject(hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2028
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2029
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2030
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2031
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2032
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2033
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2034
displayRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2035
    "draw a rectangle. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2036
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2037
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2038
    int w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2039
    int xL, yT;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2040
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2041
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2042
     && __bothSmallInteger(width, height)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2043
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2044
        xL = __intVal(x);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2045
        yT = __intVal(y);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2046
        w = __intVal(width);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2047
        h = __intVal(height);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2048
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2049
        DPRINTF(("displayRectangle: %d/%d -> %d/%d\n", xL, yT, w, h));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2050
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2051
        if ((w >= 0) && (h >= 0)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2052
            HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2053
            COLORREF fgColor;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2054
            HANDLE prevPen, hPen;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2055
            int lStyleSymbol, lStyleInt;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2056
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2057
            int lw;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2058
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2059
            lw= __intVal(__INST(lineWidth));
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2060
            lStyleSymbol= __INST(lineStyle);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2061
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2062
            /*  PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2063
                only works with lineWidth = 1  */
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2064
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2065
            if (lStyleSymbol == @symbol(solid)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2066
                lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2067
            } else if (lStyleSymbol == @symbol(dashed)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2068
                lStyleInt= PS_DASH;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2069
            } else if (lStyleSymbol == @symbol(dotted)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2070
                lStyleInt= PS_DOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2071
            } else if (lStyleSymbol == @symbol(dashDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2072
                lStyleInt= PS_DASHDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2073
            } else if (lStyleSymbol == @symbol(dashDotDot)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2074
                lStyleInt= PS_DASHDOTDOT;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2075
            } else if (lStyleSymbol == @symbol(insideFrame)) {
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2076
                lStyleInt= PS_INSIDEFRAME;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2077
            } else
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2078
                lStyleInt= PS_SOLID;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2079
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2080
            fgColor = GetTextColor(hDC);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2081
            hPen = CreatePen(lStyleInt, lw, fgColor);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2082
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2083
            prevPen = SelectObject(hDC, hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2084
            MoveToEx(hDC, xL, yT, NULL);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2085
            LineTo(hDC, xL+w, yT);       // to top-right
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2086
            LineTo(hDC, xL+w, yT+h);     // to bot-right
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2087
            MoveToEx(hDC, xL, yT, NULL); // back to top-left
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2088
            LineTo(hDC, xL, yT+h);       // to bot-left
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2089
            // LineTo(hDC, xL+w+1, yT+h);   // move pen one pixel more
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2090
            LineTo(hDC, xL+w,   yT+h);   // move pen one pixel more
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2091
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2092
            SelectObject(hDC, prevPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2093
            DeleteObject(hPen);
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2094
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2095
        }
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2096
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2097
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2098
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2099
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2100
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2101
    "Created: / 28-07-2006 / 20:18:25 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2102
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2103
2399
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2104
displayRoundRectangleX:left y:top width:width height:height wCorner:wCorn hCorner:hCorn
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2105
    |right bottom wC hC wHalf hHalf|
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2106
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2107
    right := left + width-1.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2108
    bottom := top + height-1.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2109
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2110
    wC := wCorn.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2111
    hC := hCorn.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2112
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2113
    self scale = 1 ifTrue:[
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2114
        wHalf := wC // 2.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2115
        hHalf := hC // 2.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2116
    ] ifFalse:[
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2117
        wHalf := wC / 2.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2118
        hHalf := hC / 2.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2119
    ].
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2120
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2121
    "top left arc"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2122
    self displayArcX:left y:top width:wC height:hC from:90 angle:90.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2123
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2124
    "top right arc"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2125
    self displayArcX:(right - wC) y:top width:wC height:hC from:0 angle:90.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2126
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2127
    "bottom right arc"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2128
    self displayArcX:(right - wC) y:(bottom - hC) width:wC height:hC from:270 angle:90.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2129
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2130
    "bottom left arc"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2131
    self displayArcX:left y:(bottom - hC) width:wC height:hC from:180 angle:90.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2132
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2133
    "top line"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2134
    self displayLineFromX:(left + wHalf) y:top toX:(right - wHalf+1) y:top.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2135
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2136
    "left line"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2137
    self displayLineFromX:left y:(top + hHalf - 1) toX:left y:(bottom - hHalf).
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2138
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2139
    "bottom line"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2140
    self displayLineFromX:(left + wHalf-1) y:bottom
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2141
                      toX:(right - wHalf ) y:bottom.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2142
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2143
    "right line"
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2144
    self displayLineFromX:right y:(top + hHalf) toX:right y:(bottom - hHalf).
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2145
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2146
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2147
    "
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2148
     |v|
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2149
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2150
     (v := View new) extent:200@200; openAndWait.
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2151
     v displayRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2152
    "
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2153
!
1de98d034f71 round rectangles
Michael Beyl <mb@exept.de>
parents: 2384
diff changeset
  2154
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2155
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
  2156
    "draw a sub-string - draw foreground only.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2157
     If the coordinates are not integers, retry with rounded."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2158
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2159
    self
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2160
	displayString:aString
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2161
	from:index1
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2162
	to:index2
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2163
	x:x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2164
	y:y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2165
	in:aDrawableId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2166
	with:aGCId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2167
	opaque:false
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2168
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2169
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2170
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
  2171
    "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
  2172
     foreground and background characters.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2173
     If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2174
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2175
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2176
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2177
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2178
    int  i1, i2, l, n;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2179
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2180
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2181
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2182
     && __isNonNilObject(aString)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2183
     && __bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2184
     && __bothSmallInteger(x, y))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2185
    {
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2186
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2187
        int pX, pY;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2188
        COLORREF fgColor;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2189
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2190
        pX = __intVal(x);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2191
        pY = __intVal(y);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2192
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2193
        if (opaque == true) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2194
            SetBkMode(hDC, OPAQUE);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2195
        } else {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2196
            SetBkMode(hDC, TRANSPARENT);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2197
        }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2198
        fgColor = GetTextColor(hDC);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2199
        SetTextColor(hDC, fgColor);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2200
        SetBkColor(hDC, 0xFFFFFFFF);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2201
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2202
        cls = __qClass(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2203
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2204
        i1 = __intVal(index1) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2205
        if (i1 >= 0) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2206
            i2 = __intVal(index2) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2207
            if (i2 < i1) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2208
                goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2209
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2210
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2211
            cp = _stringVal(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2212
            l = i2 - i1 + 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2213
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2214
            if ((cls == @global(String)) || (cls == @global(Symbol))) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2215
                n = _stringSize(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2216
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2217
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2218
                    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
  2219
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2220
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2221
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2222
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2223
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2224
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2225
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2226
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2227
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2228
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2229
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2230
            nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2231
            cp += nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2232
            n = __byteArraySize(aString) - nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2233
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2234
            if (__isBytes(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2235
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2236
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2237
                    DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2238
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2239
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2240
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2241
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2242
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2243
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2244
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2245
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2246
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2247
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2248
            /* Unicode */
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2249
            if (__isWords(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2250
                n = n / 2;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2251
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2252
                    WIDECHAR *w_cp = (WIDECHAR *)cp;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2253
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2254
                    w_cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2255
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2256
                    if (! TextOutW(hDC, pX, pY, w_cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2257
                        DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2258
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2259
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2260
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2261
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2262
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2263
ret:
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2264
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2265
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2266
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2267
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2268
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2269
    "Created: / 28-07-2006 / 20:35:19 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2270
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2271
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2272
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
  2273
    "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
  2274
     foreground and background characters.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2275
     If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2276
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2277
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2278
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2279
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2280
    int  i1, i2, l, n;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2281
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2282
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2283
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2284
     && __isNonNilObject(aString)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2285
     && __bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2286
     && __bothSmallInteger(x, y))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2287
    {
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2288
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2289
        int pX, pY;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2290
        COLORREF fgColor;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2291
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2292
        pX = __intVal(x);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2293
        pY = __intVal(y);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2294
        pY -= __intVal(fontAscent);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2295
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2296
        if (opaque == true) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2297
            SetBkMode(hDC, OPAQUE);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2298
        } else {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2299
            SetBkMode(hDC, TRANSPARENT);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2300
        }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2301
        fgColor = GetTextColor(hDC);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2302
        SetTextColor(hDC, fgColor);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2303
        SetBkColor(hDC, 0xFFFFFFFF);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2304
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2305
        cls = __qClass(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2306
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2307
        i1 = __intVal(index1) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2308
        if (i1 >= 0) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2309
            i2 = __intVal(index2) - 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2310
            if (i2 < i1) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2311
                goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2312
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2313
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2314
            cp = _stringVal(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2315
            l = i2 - i1 + 1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2316
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2317
            if ((cls == @global(String)) || (cls == @global(Symbol))) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2318
                n = _stringSize(aString);
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2319
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2320
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2321
                    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
  2322
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2323
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2324
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2325
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2326
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2327
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2328
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2329
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2330
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2331
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2332
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2333
            nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2334
            cp += nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2335
            n = __byteArraySize(aString) - nInstBytes;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2336
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2337
            if (__isBytes(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2338
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2339
                    cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2340
                    DPRINTF(("string: %s pos=%d/%d\n", cp, pX, pY));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2341
                    if (l > 32767) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2342
                        l = 32767;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2343
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2344
                    if (! TextOut(hDC, pX, pY, (char *)cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2345
                        DFPRINTF((stderr, "WinPrinter [warning]: Textout failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2346
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2347
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2348
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2349
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2350
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2351
            /* Unicode */
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2352
            if (__isWords(aString)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2353
                n = n / 2;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2354
                if (i2 < n) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2355
                    WIDECHAR *w_cp = (WIDECHAR *)cp;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2356
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2357
                    w_cp += i1;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2358
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2359
                    if (! TextOutW(hDC, pX, pY, w_cp, l)) {
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2360
                        DFPRINTF((stderr, "WinPrinter [warning]: TextoutW failed. %d\n", GetLastError()));
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2361
                    }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2362
                    goto ret;
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2363
                }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2364
            }
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2365
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2366
ret:
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2367
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2368
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2369
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2370
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2371
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2372
    "Created: / 28-07-2006 / 20:35:19 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2373
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2374
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2375
displayString:aString x:x y:y in:aDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2376
    "draw a string - draw foreground only.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2377
     If the coordinates are not integers, retry with rounded."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2378
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2379
    self
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2380
	displayString:aString
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2381
	x:x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2382
	y:y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2383
	in:aDrawableId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2384
	with:aDC
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2385
	opaque:false
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2386
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2387
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2388
displayString:aString x:x y:y in:aDrawableId with:aDC opaque:opaque
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2389
    "draw a string"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2390
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2391
    self displayString:aString
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2392
		  from:1
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2393
		    to:aString size
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2394
		     x:x
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2395
		     y:y
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2396
		     in:aDrawableId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2397
		     with:aDC
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2398
		     opaque:opaque
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2399
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2400
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2401
fillArcX:x y:y width:width height:height from:startAngle angle:angle
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2402
               in:ignoredDrawableId with:aDC
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2403
    "fill an arc. If any coordinate is not integer, an error is triggered.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2404
     The angles may be floats or integer - they are given in degrees."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2405
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2406
    | hatchSymbol |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2407
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2408
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2409
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2410
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2411
    int __x, __y, w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2412
    float angle1, angle2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2413
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2414
    if (__isSmallInteger(startAngle))
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2415
        angle1 = (float)(__intVal(startAngle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2416
    else if (__isFloat(startAngle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2417
        angle1 = __floatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2418
    } else if (__isShortFloat(startAngle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2419
        angle1 = __shortFloatVal(startAngle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2420
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2421
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2422
    if (__isSmallInteger(angle))
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2423
        angle2 = (float)(__intVal(angle));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2424
    else if (__isFloat(angle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2425
        angle2 = __floatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2426
    } else if (__isShortFloat(angle)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2427
        angle2 = __shortFloatVal(angle);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2428
    } else goto bad;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2429
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2430
    if (angle2 <= 0) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2431
        RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2432
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2433
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2434
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2435
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2436
     && __bothSmallInteger(width, height))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2437
     {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2438
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2439
        HBRUSH hBrush, prevBrush;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2440
        HPEN prevPen = 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2441
        COLORREF fgColor;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2442
        int hatch, hasHatch;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2443
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2444
        w = __intVal(width);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2445
        h = __intVal(height);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2446
        __x = __intVal(x);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2447
        __y = __intVal(y);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2448
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2449
        fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2450
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2451
        hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2452
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2453
        if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2454
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2455
        } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2456
            hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2457
        } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2458
            hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2459
        } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2460
            hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2461
        } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2462
            hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2463
        } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2464
            hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2465
        } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2466
            hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2467
        } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2468
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2469
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2470
        if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2471
            hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2472
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2473
            hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2474
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2475
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2476
        prevBrush = SelectObject(hDC, hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2477
        if (hBrush == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2478
            DPRINTF(("fillArc: no brush\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2479
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2480
            HPEN hPen = 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2481
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2482
            if (0 /* __isWinNT */) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2483
                fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2484
                hPen = CreatePen(PS_SOLID, 1, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2485
                prevPen = SelectObject(hDC, hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2486
                if (hPen == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2487
                    DPRINTF(("fillArc: no pen\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2488
                    goto failpen;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2489
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2490
            } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2491
                prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2492
                w++;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2493
                h++;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2494
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2495
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2496
            {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2497
                double xB, yB, xE, yE, xR, yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2498
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2499
                xR = w / 2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2500
                yR = h / 2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2501
                if (angle2 - angle1 >= 360) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2502
                    xB = xE = __x + xR + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2503
                    yB = yE = __y /*+ yR + 0.5*/;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2504
                } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2505
                    double sin(), cos();
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2506
                    float rad1, rad2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2507
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2508
                    if (angle1 <= 180)
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2509
                        angle1 = 180 - angle1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2510
                    else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2511
                        angle1 = 360 + 180 - angle1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2512
                    angle2 = angle1 - angle2;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2513
                    /* sigh - compute the intersections ... */
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2514
                    rad1 = (angle1 * 3.14159265359) / 180.0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2515
                    rad2 = (angle2 * 3.14159265359) / 180.0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2516
                    xB = cos(rad1) * xR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2517
                    yB = sin(rad1) * yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2518
                    xE = cos(rad2) * xR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2519
                    yE = sin(rad2) * yR;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2520
                    xB = __x + xR - xB + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2521
                    yB = __y + yR - yB + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2522
                    xE = __x + xR - xE + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2523
                    yE = __y + yR - yE + 0.5;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2524
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2525
                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
  2526
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2527
                Pie(hDC,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2528
                    __x, __y,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2529
                    __x + w + 1, __y + h + 1,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2530
                    (int)xB, (int)yB,
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2531
                    (int)xE, (int)yE);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2532
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2533
                if (hPen) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2534
                    DeleteObject(hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2535
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2536
            }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2537
failpen:
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2538
            if (prevPen) SelectObject(hDC, prevPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2539
            DeleteObject(hPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2540
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2541
            SelectObject(hDC, prevBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2542
            DeleteObject(hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2543
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2544
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2545
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2546
    bad: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2547
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2548
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2549
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2550
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2551
fillPolygon:aPolygon in:ignoredDrawableId with:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2552
    "fill a polygon given by its points.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2553
     If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2554
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2555
    |numberOfPoints|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2556
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2557
    numberOfPoints := aPolygon size.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2558
    self
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2559
	primFillPolygon:aPolygon n:numberOfPoints
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  2560
	in:ignoredDrawableId with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2561
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2562
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2563
fillRectangleX:x y:y width:width height:height in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2564
    "fill a rectangle. If any coordinate is not integer, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2565
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2566
    |hatchSymbol|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2567
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2568
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2569
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2570
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2571
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2572
    int w, h;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2573
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2574
     && __bothSmallInteger(x, y)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2575
     && __bothSmallInteger(width, height)) {
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2576
        w = __intVal(width);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2577
        h = __intVal(height);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2578
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2579
        if ((w >= 0) && (h >= 0)) {
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2580
            HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2581
            HBRUSH hBrush, prevBrush;
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2582
            RECT rct;
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2583
            COLORREF fgColor;
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2584
            int hatch, hasHatch;
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2585
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2586
            fgColor = GetTextColor(hDC);
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2587
            hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2588
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2589
            if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2590
                hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2591
            } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2592
                hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2593
            } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2594
                hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2595
            } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2596
                hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2597
            } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2598
                hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2599
            } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2600
                hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2601
            } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2602
                hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2603
            } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2604
                hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2605
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2606
            if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2607
                hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2608
            } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2609
                hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2610
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2611
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2612
            rct.left = __intVal(x);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2613
            rct.top  = __intVal(y);
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2614
            rct.right  = rct.left + w; // + 1;
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  2615
            rct.bottom = rct.top  + h; // + 1;
2326
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2616
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2617
           prevBrush = SelectObject(hDC, hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2618
           FillRect(hDC, &rct, hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2619
           SelectObject(hDC, prevBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2620
           DeleteObject(hBrush);
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2621
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2622
        }
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2623
    }
82077cd59898 *** empty log message ***
fm
parents: 2325
diff changeset
  2624
    RETURN ( self );
2327
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2625
32f68e607e13 + displayString supports color
fm
parents: 2326
diff changeset
  2626
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2627
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2628
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2629
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2630
primFillPolygon:aPolygon n:numberOfPoints in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2631
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2632
    |hatchSymbol|
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2633
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2634
    hatchSymbol := self hatch.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2635
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2636
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2637
    OBJ point, px, py;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2638
    int i, num;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2639
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2640
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2641
     && __isSmallInteger(numberOfPoints)) {
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2642
        HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2643
        POINT p;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2644
        HBRUSH hBrush, prevBrush;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2645
        COLORREF fgColor;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2646
        int hatch, hasHatch;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2647
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2648
        num = __intVal(numberOfPoints);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2649
        if (num < 3) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2650
            RETURN ( self );
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2651
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2652
        for (i=0; i<num; i++) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2653
            point = __AT_(aPolygon, __MKSMALLINT(i+1));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2654
            if (! __isPoint(point)) goto fail;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2655
            px = _point_X(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2656
            py = _point_Y(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2657
            if (! __bothSmallInteger(px, py))
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2658
                goto fail;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2659
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2660
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2661
        fgColor = GetTextColor(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2662
        hasHatch= 1;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2663
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2664
        if (hatchSymbol == @symbol(none)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2665
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2666
        } else if (hatchSymbol == @symbol(horizontal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2667
            hatch= HS_HORIZONTAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2668
        } else if (hatchSymbol == @symbol(vertical)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2669
            hatch= HS_VERTICAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2670
        } else if (hatchSymbol == @symbol(cross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2671
            hatch= HS_CROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2672
        } else if (hatchSymbol == @symbol(bDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2673
            hatch= HS_BDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2674
        } else if (hatchSymbol == @symbol(fDiagonal)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2675
            hatch= HS_FDIAGONAL;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2676
        } else if (hatchSymbol == @symbol(diagonalCross)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2677
            hatch= HS_DIAGCROSS;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2678
        } else
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2679
            hasHatch= 0;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2680
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2681
        if (hasHatch) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2682
            hBrush = CreateHatchBrush(hatch, fgColor);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2683
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2684
            hBrush = CreateSolidBrush(fgColor); 
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2685
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2686
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2687
        if (hBrush == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2688
            DPRINTF(("fillPolygon: no brush\n"));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2689
        } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2690
            HPEN prevPen;
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2691
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2692
            prevBrush = SelectObject(hDC, hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2693
            prevPen = SelectObject(hDC, GetStockObject(NULL_PEN));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2694
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2695
            BeginPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2696
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2697
            for (i=0; i<num; i++) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2698
                point = __AT_(aPolygon, __MKSMALLINT(i+1));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2699
                px = _point_X(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2700
                py = _point_Y(point);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2701
                if (i == 0) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2702
                    MoveToEx(hDC, __intVal(px), __intVal(py), NULL);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2703
                } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2704
                    if (i == (num-1)) {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2705
                        p.x = __intVal(px);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2706
                        p.y = __intVal(py);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2707
                        PolylineTo(hDC, &p, 1);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2708
                    } else {
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2709
                        LineTo(hDC, __intVal(px), __intVal(py));
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2710
                    }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2711
                }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2712
            }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2713
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2714
            EndPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2715
            FillPath(hDC);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2716
            SelectObject(hDC, prevPen);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2717
            SelectObject(hDC, prevBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2718
            DeleteObject(hBrush);
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2719
        }
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  2720
        RETURN ( self );
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
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2723
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2724
%}
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2725
!
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2726
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2727
scaleTest_displayString:aString x:x y:y
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2728
    "draw a string at the coordinate x/y - 
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2729
     draw foreground-pixels only (in current paint-color), 
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2730
     leaving background as-is. If the transformation involves scaling, 
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2731
     the fonts point-size is scaled as appropriate."
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2732
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2733
    |id pX pY fontUsed sz s fontsEncoding|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2734
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2735
    "hook for non-strings (i.e. attributed text)"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2736
    (aString isString not
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2737
    or:[aString isText]) ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2738
        ^ aString displayOn:self x:x y:y
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2739
    ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2740
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2741
    gcId isNil ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2742
        self initGC
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2743
    ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2744
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2745
    fontUsed := font.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2746
    transformation notNil ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2747
        pX := transformation applyToX:x.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2748
        pY := transformation applyToY:y.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2749
        transformation noScale ifFalse:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2750
            sz := font size.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2751
            sz isNil ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2752
                "/ oops - not a real font; use original font
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2753
                fontUsed := font
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2754
            ] ifFalse:[ |yS|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2755
                yS := self pixelsPerInchOfScreenHeight / Screen current verticalPixelPerInch.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2756
                yS := self scale y / yS.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2757
                fontUsed := font size:(sz * yS) rounded.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2758
            ]
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2759
        ]
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2760
    ] ifFalse:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2761
        pX := x.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2762
        pY := y.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2763
    ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2764
    pX := pX rounded.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2765
    pY := pY rounded.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2766
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2767
    s := aString.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2768
    fontUsed := fontUsed onDevice:device.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2769
    fontsEncoding := fontUsed encoding.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2770
    (characterEncoding ~~ fontsEncoding) ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2771
        [
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2772
            s := CharacterEncoder encodeString:s from:characterEncoding into:fontsEncoding.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2773
        ] on:CharacterEncoderError do:[:ex|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2774
            "substitute a default value for codes that cannot be represented
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2775
             in the new character set"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2776
            ex proceedWith:ex defaultValue.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2777
        ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2778
    ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2779
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2780
    id := fontUsed fontId.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2781
    id isNil ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2782
        "hook for alien fonts"
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2783
        fontUsed displayString:s x:x y:y in:self
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2784
    ] ifFalse:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2785
        deviceFont ~~ fontUsed ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2786
            device setFont:id in:gcId.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2787
            deviceFont := fontUsed
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2788
        ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2789
        device displayString:s x:pX y:pY in:drawableId with:gcId
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2790
    ]
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2791
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  2792
    "Modified: 1.7.1997 / 17:08:35 / cg"
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2793
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2794
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2795
!WinPrinterContext methodsFor:'drawing bitmaps'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2796
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2797
bitsBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2798
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2799
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2800
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2801
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2802
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2803
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2804
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2805
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2806
     ^Display bitsBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2807
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2808
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2809
bitsGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2810
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2811
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2812
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2813
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2814
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2815
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2816
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2817
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2818
     ^Display bitsGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2819
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2820
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2821
bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2822
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2823
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2824
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2825
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2826
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2827
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2828
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2829
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2830
     ^Display bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2831
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2832
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2833
compressColorMapImage: image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2834
    "calculates a new color map for the image, using only used colors"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2835
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2836
    |depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2837
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2838
    oldImage := image.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2839
    depth := oldImage depth.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2840
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2841
    oldImage photometric ~~ #palette ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2842
        Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2843
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2844
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2845
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2846
    usedColors := oldImage realUsedColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2847
    usedColors size == (1 bitShift:depth) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2848
        Transcript showCR:'Compress colorMap: All colors are used - no compression.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2849
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2850
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2851
    usedColors size == oldImage colorMap size ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2852
        Transcript showCR:'Compress colorMap: Colormap already compressed - no compression.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2853
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2854
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2855
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2856
        "/ translation table
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2857
        oldToNew := ByteArray new:(1 bitShift:depth).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2858
        newColorMap := usedColors asArray.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2859
        newColorMap sort:self sortBlockForColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2860
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2861
        oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2862
            |newPixel|
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2863
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2864
            (usedColors includes:clr) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2865
                newPixel := newColorMap indexOf:clr.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2866
                oldToNew at:oldIdx put:newPixel-1.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2867
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2868
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2869
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2870
        oldBits := oldImage bits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2871
        newBits := ByteArray new:(oldBits size).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2872
        depth ~~ 8 ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2873
            "/ expand/compress can only handle 8bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2874
            tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2875
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2876
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2877
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2878
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2879
                into:tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2880
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2881
            tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2882
                compressPixels:depth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2883
                width:oldImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2884
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2885
                into:newBits 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2886
                mapping:nil
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2887
        ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2888
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2889
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2890
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2891
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2892
                into:newBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2893
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2894
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2895
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2896
        newImage := oldImage species new
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2897
                        width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2898
                        height:oldImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2899
                        depth:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2900
                        fromArray:newBits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2901
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2902
        newImage colorMap:newColorMap.  
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2903
        newImage fileName:oldImage fileName.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2904
        newImage mask:(oldImage mask copy).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2905
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2906
        ^ newImage
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2907
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2908
    "Created: / 28.7.1998 / 20:03:11 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2909
    "Modified: / 15.9.1998 / 17:53:32 / cg"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2910
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2911
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2912
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
  2913
                width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2914
    "do a bit-blt; copy bits from the rectangle defined by
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2915
     srcX/srcY and w/h from the sourceId drawable to the rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2916
     below dstX/dstY in the destId drawable. Trigger an error if any
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2917
     argument is not integer."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2918
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2919
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2920
    int     dstGcOwnerThreadID;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2921
    HWND    dstGcHWIN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2922
    HBITMAP dstGcHBITMAP;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2923
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2924
    if (! __isExternalAddressLike(srcGCId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2925
     || ! __isExternalAddressLike(dstGCId)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2926
        goto fail;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2927
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2928
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2929
    if (__bothSmallInteger(w, h)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2930
     && __bothSmallInteger(srcX, srcY)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2931
     && __bothSmallInteger(dstX, dstY)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2932
        HANDLE srcDC = (HANDLE)(__externalAddressVal(srcGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2933
        HANDLE dstDC = (HANDLE)(__externalAddressVal(dstGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2934
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2935
        int fun, aFunctionSymbol;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2936
        int src_fg, src_bg, dst_fg, dst_bg;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2937
        char buf[5];
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2938
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2939
//          fun = dstGcData->bitbltrop2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2940
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2941
        aFunctionSymbol= __INST(function);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2942
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2943
        if (aFunctionSymbol == @symbol(copy)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2944
            fun = SRCCOPY /* R2_COPYPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2945
/*            bfun = BITBLT_COPY;                                          */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2946
        } else if (aFunctionSymbol == @symbol(copyInverted)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2947
            fun = NOTSRCCOPY /* R2_NOTCOPYPEN */;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2948
/*            bfun = BITBLT_COPYINVERTED;                                  */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2949
        } else if (aFunctionSymbol == @symbol(xor)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2950
            fun = SRCINVERT /* R2_XORPEN */;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2951
/*            bfun = BITBLT_XOR;                                           */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2952
        } else if (aFunctionSymbol == @symbol(and)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2953
            fun = SRCAND /* R2_MASKPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2954
/*            bfun = BITBLT_AND;                                           */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2955
        } else if (aFunctionSymbol == @symbol(or)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2956
            fun = MERGECOPY /* R2_MERGEPEN */ ;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2957
/*            bfun = BITBLT_OR;                                            */
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2958
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2959
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2960
    // convert 123 to string [buf]
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2961
    // itoa(fun, buf, 10);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2962
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  2963
    //        console_printf(" ", buf);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2964
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2965
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2966
#if 0
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2967
        switch (fun) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2968
          case BITBLT_COPY:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2969
            console_printf("BITBLT_COPY\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2970
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2971
          case BITBLT_COPYINVERTED:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2972
            console_printf("BITBLT_COPYINVERTED\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2973
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2974
          case BITBLT_XOR:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2975
            console_printf("BITBLT_XOR\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2976
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2977
          case BITBLT_AND:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2978
            console_printf("BITBLT_AND\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2979
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2980
          case BITBLT_OR:
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2981
            console_printf("BITBLT_OR\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2982
            break;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2983
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2984
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2985
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2986
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2987
//          fun = dstGcData->bitbltrop2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  2988
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2989
        if (0 /* fun == BITBLT_COPY */) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2990
            src_fg = dst_fg = 0xFFFFFF;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2991
            src_bg = dst_bg = 0x000000;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2992
        } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2993
            src_fg = GetTextColor(srcDC) /* srcGcData->fgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2994
            src_bg = GetBkColor(dstDC) /* srcGcData->bgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2995
            dst_fg = GetTextColor(srcDC) /* dstGcData->fgColor */;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  2996
            dst_bg = GetBkColor(dstDC) /* dstGcData->bgColor */;
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
        SetBkColor(dstDC, dst_fg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3000
        SetTextColor(dstDC, dst_bg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3001
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3002
        SetBkColor(srcDC, src_fg);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3003
        SetTextColor(srcDC, src_bg);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3004
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3005
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3006
        CPRINTF(("bitblt src f:%x b:%x",GetTextColor(srcDC),GetBkColor(srcDC)));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3007
        CPRINTF(("dst f:%x b:%x\n",GetTextColor(dstDC),GetBkColor(dstDC)));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3008
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3009
        if (BitBlt(dstDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3010
             __intVal(dstX), __intVal(dstY),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3011
             __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3012
             srcDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3013
             __intVal(srcX), __intVal(srcY),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3014
             fun)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3015
           == 0
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3016
          ) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3017
            console_fprintf(stderr, "WinWorkstation [info]: ERROR in BitBlt\n");
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3018
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3019
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3020
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3021
        if (dstGcData != srcGcData) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3022
            SetBkColor(dstDC, dstGcData->bgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3023
            SetTextColor(dstDC, dstGcData->fgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3024
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3025
        SetBkColor(srcDC, srcGcData->bgColor);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3026
        SetTextColor(srcDC, srcGcData->fgColor);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3027
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3028
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3029
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3030
        if (srcGcData != dstGcData) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3031
            _releaseDC(srcGcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3032
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3033
        _releaseDC(dstGcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3034
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3035
        RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3036
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3037
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3038
 fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3039
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3040
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3041
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3042
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3043
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3044
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
  3045
    "do a bit-blt from a pix- or bitmap.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3046
     Here, fall back into copyFromId:, which should also work.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3047
     Subclasses may redefine this for more performance or if required"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3048
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3049
    ^ 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
  3050
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3051
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3052
copyPlaneFromId:sourceId x:srcX y:srcY gc:srcDCId to:destId x:dstX y:dstY gc:dstDCId
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3053
		width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3054
    "do a bit-blt, but only copy the low-bit plane;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3055
     copy bits from the rectangle defined by
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3056
     srcX/srcY and w/h from the sourceId drawable to the rectangle
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3057
     below dstX/dstY in the destId drawable. Trigger an error if any
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3058
     argument is not integer."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3059
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3060
    ^ self
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3061
	copyFromId:sourceId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3062
		 x:srcX y:srcY gc:srcDCId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3063
		to:destId x:dstX y:dstY gc:dstDCId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3064
	     width:w height:h
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3065
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3066
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3067
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
  3068
    "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
  3069
     Here, fall back into copyPlaneFromId:, which should also work.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3070
     Subclasses may redefine this for more performance or if required"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3071
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3072
    ^ 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
  3073
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3074
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3075
createBitmapFromArray:anArray width:w height:h
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3076
    |bitmapId|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3077
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  3078
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3079
    bitmapId := self primCreateBitmapFromArray:anArray width:w height:h.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3080
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3081
    bitmapId isNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3082
	'WINWORKSTATION: cannot create bitmap' errorPrintCR.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3083
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3084
    ^ bitmapId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3085
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3086
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3087
createPixmapWidth:w height:h depth:d
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3088
    "allocate a pixmap on the Xserver, the contents is undefined
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3089
     (i.e. random). Return a bitmap id or nil"
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3090
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3091
%{
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3092
    HANDLE newBitmapHandle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3093
    HANDLE rootDC = CreateDC("DISPLAY", NULL, NULL, NULL);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3094
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3095
    /*console_printf("CreateBitmap Color\n");*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3096
    if (__bothSmallInteger(w, h) && __isSmallInteger(d) /*&& ISCONNECTED */) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3097
        if (__intVal(d) == 1) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3098
            newBitmapHandle = CreateBitmap(__intVal(w), __intVal(h) , 1, 1, NULL);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3099
        } else {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3100
#if 0
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3101
            if (__intVal(d) != __depth) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3102
                console_printf("invalid depth\n");
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3103
                RETURN (nil);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3104
            }
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3105
#endif
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3106
            newBitmapHandle = CreateCompatibleBitmap(rootDC, __intVal(w), __intVal(h) );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3107
        }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3108
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3109
        if (newBitmapHandle) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3110
            RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3111
        }
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3112
/*
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3113
        DPRINTF(("empty bitmap handle = %x\n", newBitmapHandle));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3114
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3115
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3116
    RETURN (nil);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3117
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3118
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3119
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3120
destroyPixmap:aDrawableId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3121
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3122
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3123
    if (__isExternalAddress(aDrawableId) /* && ISCONNECTED */ ) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3124
	HANDLE bitmapHandle = _HANDLEVal(aDrawableId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3125
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3126
	if (bitmapHandle) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3127
	    DeleteObject(bitmapHandle);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3128
	/*    _DeleteObject(bitmapHandle, __LINE__);    */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3129
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3130
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3131
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3132
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3133
2329
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  3134
displayDeviceForm:aForm x:x y:y
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3135
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3136
    |sortedImage formMask bitsWithTransparency redVector greenVector blueVector|
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3137
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3138
    sortedImage := aForm.
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  3139
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3140
    "Image 16 bits"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3141
    aForm depth = 16 ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3142
        bitsWithTransparency := aForm bits.  
2341
cf7b3de4f3ef *** empty log message ***
fm
parents: 2340
diff changeset
  3143
    ].
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3144
    "Image 24 and 32 bits"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3145
    aForm depth >= 24 ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3146
        |bestFormat|
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3147
        bestFormat := aForm bestSupportedImageFormatFor: Display.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3148
        bitsWithTransparency := aForm rgbImageBitsOn: Display bestFormat: bestFormat.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3149
    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  3150
    "Image up to 8 bits"
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3151
    aForm depth <= 8 ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3152
        aForm depth < 8 ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3153
            sortedImage := aForm asImageWithDepth: 8.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3154
        ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3155
"/        sortedImage := self sortColorMapImage: aForm.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3156
        sortedImage := self compressColorMapImage: sortedImage.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3157
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3158
        formMask := sortedImage mask.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3159
        formMask isNil 
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3160
            ifTrue:[bitsWithTransparency := sortedImage bits ]
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3161
            ifFalse:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3162
                |bitsWithTransparencySize|
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3163
                formMask := formMask asImageWithDepth: sortedImage depth.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3164
                bitsWithTransparency := sortedImage bits copy.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3165
                bitsWithTransparencySize := bitsWithTransparency size.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3166
                formMask bits doWithIndex:[:maskBit :index |
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3167
                    bitsWithTransparencySize >= index ifTrue:[
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3168
                        maskBit == 0 ifTrue:[bitsWithTransparency at: index put: 255 "60" "bitClearAt: index"].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3169
"/                    maskBit == 1 ifTrue:[bitsWithTransparency at: index put: (bitsWithTransparency at: index)].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3170
                    ].
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3171
                ].
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3172
        ].
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3173
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3174
        redVector := sortedImage colorMap redVector.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3175
        greenVector := sortedImage colorMap greenVector.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3176
        blueVector := sortedImage colorMap blueVector.
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3177
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3178
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3179
    self 
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3180
         drawBits: bitsWithTransparency
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3181
        redVector: redVector
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3182
      greenVector: greenVector
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3183
       blueVector: blueVector
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3184
     bitsPerPixel: sortedImage bitsPerPixel
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3185
            depth: sortedImage depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3186
            width: sortedImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3187
           height: sortedImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3188
             into: self id
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3189
                x: x 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3190
                y: y
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3191
            width: sortedImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3192
           height: sortedImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3193
             with: gcId.
2329
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  3194
!
f5a1833995a1 to do #displayDeviceForm:aForm x:x y:y
fm
parents: 2328
diff changeset
  3195
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3196
drawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3197
                          width:imageWidth height:imageHeight
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3198
                              x:srcx y:srcy
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3199
                           into:ignoredDrawableId
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3200
                              x:dstx y:dsty
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3201
                          width:w height:h
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3202
                           with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3203
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3204
    "draw a bitImage which has depth id, width iw and height ih into
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3205
     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
  3206
     Individual source pixels have bitsPerPixel bits, allowing to draw
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3207
     depth and pixel-units to be different.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3208
     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
  3209
     depth - otherwise, primitive failure will be signalled.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3210
     Also it is assumed, that the colormap is setup correctly and the
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3211
     colors are allocated - otherwise the colors may be wrong."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3212
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3213
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3214
     sorry; I had to separate it into 2 methods, since XPutImage needs
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3215
     an unlimited stack, and thus cannot send primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3216
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3217
    (self primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3218
                                        width:imageWidth height:imageHeight
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3219
                                             x:srcx y:srcy
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3220
                                          into:ignoredDrawableId
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3221
                                             x:(dstx rounded) y:(dsty rounded)
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3222
                                         width:w height:h
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3223
                                          with:aGCId)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3224
    ifFalse:[
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3225
        "
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3226
         also happens, if a segmentation violation occurs in the
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3227
         XPutImage ...
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3228
        "
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3229
        self primitiveFailed
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3230
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3231
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3232
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3233
drawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3234
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3235
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3236
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3237
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3238
                               with:aGCId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3239
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3240
    "draw a bitImage which has depth id, width iw and height ih into
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3241
     the drawable. draw a region of w/h pixels from srcx/srcy to dstx/dsty.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3242
     Individual source pixels have bitsPerPixel bits, allowing to draw
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3243
     depth and pixel-units to be different.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3244
     It has to be checked elsewhere, that the server can do it with the given
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3245
     depth - otherwise, primitive failure will be signalled.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3246
     Also it is assumed, that the colormap is setup correctly and the
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3247
     colors are allocated - otherwise the colors may be wrong."
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3248
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3249
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3250
     sorry; I had to separate it into 2 methods, since XPutImage needs
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3251
     an unlimited stack, and thus cannot send primitiveFailed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3252
    "
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3253
    (self primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3254
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3255
                               into:ignoredDrawableId
2342
78014f6a3c32 bugfixes - round coordinates
ca
parents: 2341
diff changeset
  3256
                                  x:(dstx rounded) y:(dsty rounded)
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3257
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3258
                               with:aGCId)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3259
    ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3260
        self primitiveFailed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3261
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3262
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3263
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3264
primCreateBitmapFromArray:anArray width:w height:h
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3265
%{
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3266
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3267
    HBITMAP newBitmapHandle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3268
    int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3269
    int row, col;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3270
    unsigned char *cp, *bPits;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3271
    unsigned char *b_bits = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3272
    int index;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3273
    OBJ num;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3274
    unsigned char *allocatedBits = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3275
    unsigned char fastBits[10000];
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3276
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3277
    if (__bothSmallInteger(w, h)
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3278
     && __isNonNilObject(anArray)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3279
        OBJ cls = __qClass(anArray);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3280
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3281
        b_width = __intVal(w);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3282
        b_height = __intVal(h);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3283
        bytesPerRowST = (b_width + 7) / 8;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3284
        bytesPerRowWN = ((b_width + 15) / 16) * 2;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3285
        padding = bytesPerRowWN - bytesPerRowST;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3286
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3287
        if ((padding == 0) && (cls == @global(ByteArray))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3288
            b_bits = __ByteArrayInstPtr(anArray)->ba_element;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3289
            cp = 0;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3290
        } else {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3291
            int nBytes = b_height * bytesPerRowWN;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3292
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3293
            if (nBytes < sizeof(fastBits)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3294
                cp = b_bits = fastBits;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3295
            } else {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3296
                cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3297
                if (! cp) goto fail;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3298
            }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3299
        }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3300
        if (cp) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3301
            if (__qIsArrayLike(anArray)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3302
                OBJ *op;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3303
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3304
                index = 1;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3305
                op = &(__ArrayInstPtr(anArray)->a_element[index - 1]);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3306
                for (row = b_height; row; row--) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3307
                    for (col = bytesPerRowST; col; col--) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3308
                        num = *op++;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3309
                        if (! __isSmallInteger(num))
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3310
                            goto fail;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3311
                        *cp++ = __intVal(num);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3312
                    }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3313
                    cp += padding;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3314
                }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3315
            } else if (__qIsByteArrayLike(anArray)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3316
                unsigned char *pBits;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3317
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3318
                pBits = __ByteArrayInstPtr(anArray)->ba_element;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3319
                for (row = b_height; row; row--) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3320
                    for (col = bytesPerRowST; col; col--) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3321
                        *cp++ = ( *pBits++ /*^ 0xFF*/ );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3322
                    }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3323
                    cp += padding;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3324
                }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3325
            } else {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3326
                goto fail;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3327
            }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3328
        }
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3329
/*
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3330
        CPRINTF(("create bitmap ...\n"));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3331
*/
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3332
        newBitmapHandle = CreateBitmap(b_width, b_height, 1, 1, b_bits );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3333
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3334
        if (newBitmapHandle ) {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3335
/*
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3336
            DDPRINTF(("returning bitmap %x ...\n", newBitmapHandle));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3337
*/
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3338
            if (allocatedBits) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3339
                free(allocatedBits);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3340
            }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3341
            RETURN ( __MKEXTERNALADDRESS(newBitmapHandle));
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3342
        }
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3343
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3344
fail: ;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3345
/*
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3346
    DDPRINTF(("create bitmap FAILED!!!\n"));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3347
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3348
    if (allocatedBits) {
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3349
/*
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3350
        CPRINTF(("freeing up bitmap bits ...\n"));
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3351
*/
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  3352
        free(allocatedBits);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3353
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3354
/*
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3355
    CPRINTF(("returning nil ...\n"));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3356
*/
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3357
    RETURN ( nil );
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3358
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3359
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3360
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3361
primDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3362
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3363
                                  x:srcx y:srcy
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3364
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3365
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3366
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3367
                               with:aGCId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3368
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3369
    "since XPutImage may allocate huge amount of stack space
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3370
     (some implementations use alloca), this must run with unlimited stack."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3371
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3372
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3373
    unsigned char fastBits[10000];
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3374
    unsigned char *b_bits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3375
    unsigned char *allocatedBits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3376
    unsigned char *__imageBits = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3377
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3378
    if (__isByteArray(imageBits)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3379
        __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3380
    } else if (__isExternalBytesLike(imageBits)) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3381
        __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3382
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3383
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3384
    if (/* ISCONNECTED
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3385
     && */ __isExternalAddressLike(aGCId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3386
     && __bothSmallInteger(srcx, srcy)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3387
     && __bothSmallInteger(dstx, dsty)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3388
     && __bothSmallInteger(w, h)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3389
     && __bothSmallInteger(imageWidth, imageHeight)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3390
     && __bothSmallInteger(imageDepth, bitsPerPixel)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3391
     && __isSmallInteger(padd)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3392
     && __imageBits)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3393
     {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3394
        struct
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3395
        {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3396
          BITMAPINFOHEADER bmiHeader;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3397
          DWORD r;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3398
          DWORD g;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3399
          DWORD b;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3400
        } bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3401
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3402
        HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3403
        HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3404
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3405
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3406
        DDPRINTF(("hDC = %x\n", hDC));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3407
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3408
        if (__intVal(padd) != WIN32PADDING) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3409
            int row, col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3410
            unsigned char *cp;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3411
            unsigned char *pBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3412
            int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3413
            int bi = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3414
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3415
            b_width = __intVal(w);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3416
            b_height = __intVal(h);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3417
            bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3418
            bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3419
            padding = bytesPerRowWN - bytesPerRowST;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3420
            nBytes = b_height * bytesPerRowWN;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3421
            /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3422
            if (padding) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3423
                if (nBytes < sizeof(fastBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3424
                    cp = b_bits = fastBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3425
                } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3426
                    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3427
                }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3428
                if (cp) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3429
                    pBits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3430
                    for (row = b_height; row; row--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3431
                        for (col = bytesPerRowST; col; col--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3432
                            *cp++ = *pBits++;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3433
                        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3434
                        cp += padding;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3435
                    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3436
                } else
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3437
                    goto fail;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3438
            }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3439
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3440
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3441
        if (b_bits == 0) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3442
            b_bits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3443
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3444
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3445
        bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3446
        bitmap.bmiHeader.biPlanes = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3447
        if (__intVal(imageDepth) == 24) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3448
            /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3449
            bitmap.r = 0xff0000;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3450
            bitmap.g = 0x00ff00;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3451
            bitmap.b = 0x0000ff;*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3452
            bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3453
        } else if (__intVal(imageDepth) == 16) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3454
            /*bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3455
            bitmap.bmiHeader.biCompression = BI_BITFIELDS;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3456
            bitmap.b = 0x001f;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3457
            bitmap.g = 0x07e0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3458
            bitmap.r = 0xf800;*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3459
            bitmap.b = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3460
            bitmap.g = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3461
            bitmap.r = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3462
            bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3463
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3464
        bitmap.bmiHeader.biSizeImage = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3465
        bitmap.bmiHeader.biXPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3466
        bitmap.bmiHeader.biYPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3467
        bitmap.bmiHeader.biClrUsed = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3468
        bitmap.bmiHeader.biClrImportant = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3469
        bitmap.bmiHeader.biWidth = __intVal(imageWidth);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3470
        bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3471
        bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3472
        /*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
  3473
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3474
        SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3475
                              __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3476
                              __intVal(srcx), __intVal(srcy),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3477
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3478
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3479
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3480
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3481
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3482
        SetDIBits(hDC,hBitmap,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3483
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3484
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3485
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  3486
*/
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3487
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3488
        StretchDIBits(hDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3489
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3490
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3491
                      __intVal(srcx), __intVal(srcy),           // x & y coord of source upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3492
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3493
                      (void *)b_bits,                           // bitmap bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3494
                      (BITMAPINFO*)&bitmap,                     // bitmap data
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3495
                      DIB_RGB_COLORS,                           // usage options
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3496
                      SRCCOPY                                   // raster operation code
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3497
        );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3498
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3499
        if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3500
            free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3501
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3502
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3503
#ifndef CACHE_LAST_DC
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3504
        _releaseDC(gcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3505
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3506
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3507
        RETURN ( true );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3508
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3509
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3510
fail: ;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3511
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3512
    PRINTF(("create temp bitmap FAILED!!!\n"));
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3513
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3514
    if (allocatedBits) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3515
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3516
        PRINTF(("freeing up temp bitmap bits ...\n"));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3517
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3518
        free(allocatedBits);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3519
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3520
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3521
#ifndef CACHE_LAST_DC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3522
    if (hDC) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3523
        _releaseDC(gcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3524
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3525
#endif
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3526
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3527
%}
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3528
.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3529
    ^ false
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3530
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3531
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3532
primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3533
                              width:imageWidth height:imageHeight
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3534
                               into:ignoredDrawableId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3535
                                  x:dstx y:dsty
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3536
                              width:w height:h
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3537
                               with:aGCId
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3538
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3539
    "since XPutImage may allocate huge amount of stack space
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3540
     (some implementations use alloca), this must run with unlimited stack."
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3541
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3542
%{
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3543
    unsigned char fastBits[10000];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3544
    unsigned char *b_bits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3545
    unsigned char *allocatedBits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3546
    unsigned char *__imageBits = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3547
    unsigned char *__redVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3548
    unsigned char *__greenVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3549
    unsigned char *__blueVector = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3550
    int padd = 8;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3551
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3552
    if (__isByteArray(imageBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3553
        __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3554
    } else if (__isExternalBytesLike(imageBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3555
        __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3556
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3557
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3558
    if (__isByteArray(redVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3559
        __redVector = __ByteArrayInstPtr(redVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3560
    } else if (__isExternalBytesLike(redVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3561
        __redVector = (unsigned char *)(__externalBytesAddress(redVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3562
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3563
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3564
    if (__isByteArray(greenVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3565
        __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3566
    } else if (__isExternalBytesLike(greenVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3567
        __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3568
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3569
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3570
    if (__isByteArray(blueVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3571
        __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3572
    } else if (__isExternalBytesLike(blueVector)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3573
        __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3574
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3575
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3576
    if (/* ISCONNECTED
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3577
     && */ __isExternalAddressLike(aGCId)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3578
//     && __bothSmallInteger(srcx, srcy)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3579
     && __bothSmallInteger(dstx, dsty)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3580
     && __bothSmallInteger(w, h)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3581
     && __bothSmallInteger(imageWidth, imageHeight)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3582
     && __bothSmallInteger(imageDepth, bitsPerPixel)
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3583
     && __imageBits)
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3584
     {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3585
        struct
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3586
        {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3587
          BITMAPINFOHEADER bmiHeader;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3588
          RGBQUAD bmiColors[256];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3589
        } bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3590
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3591
        HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3592
        HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3593
        int col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3594
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3595
        DDPRINTF(("hDC = %x\n", hDC));
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
        if (padd != WIN32PADDING) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3599
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3600
            int row, col;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3601
            unsigned char *cp;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3602
            unsigned char *pBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3603
            int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3604
            int bi = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3605
2340
7aada47a2ec0 changed #primDrawBits:redVector:greenVector:blueVector:bitsPerPixel:depth:width:height:into:x:y:width:height:with:
fm
parents: 2339
diff changeset
  3606
//            console_fprintf(stderr, "Non WIN32PADDING");
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3607
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3608
            b_width = __intVal(w);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3609
            b_height = __intVal(h);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3610
            bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3611
            bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3612
            padding = bytesPerRowWN - bytesPerRowST;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3613
            nBytes = b_height * bytesPerRowWN;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3614
            /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3615
            if (padding) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3616
                if (nBytes < sizeof(fastBits)) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3617
                    cp = b_bits = fastBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3618
                } else {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3619
                    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3620
                }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3621
                if (cp) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3622
                    pBits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3623
                    for (row = b_height; row; row--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3624
                        for (col = bytesPerRowST; col; col--) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3625
                            *cp++ = *pBits++;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3626
                        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3627
                        cp += padding;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3628
                    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3629
                } else
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3630
                    goto fail;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3631
            }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3632
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3633
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3634
        if (b_bits == 0) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3635
            b_bits = __imageBits;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3636
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3637
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3638
        bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3639
        bitmap.bmiHeader.biPlanes = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3640
        bitmap.bmiHeader.biCompression = BI_RGB;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3641
        bitmap.bmiHeader.biSizeImage = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3642
        bitmap.bmiHeader.biXPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3643
        bitmap.bmiHeader.biYPelsPerMeter = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3644
        bitmap.bmiHeader.biClrUsed = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3645
        bitmap.bmiHeader.biClrImportant = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3646
        bitmap.bmiHeader.biWidth = __intVal(imageWidth);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3647
        bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3648
        bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3649
        /*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
  3650
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3651
        if (__intVal(imageDepth) <= 8) {
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3652
            for(col=0;col<256;col++)
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3653
             {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3654
              bitmap.bmiColors[col].rgbBlue = __blueVector[col];    // Microsoft idea: change rgbBlue to rgbRed
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3655
              bitmap.bmiColors[col].rgbGreen = __greenVector[col];
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3656
              bitmap.bmiColors[col].rgbRed = __redVector[col];         // Microsoft idea: change rgbRed to rgbBlue
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3657
              bitmap.bmiColors[col].rgbReserved = 0;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3658
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3659
            }
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3660
        }
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3661
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3662
        bitmap.bmiColors[255].rgbBlue=255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3663
        bitmap.bmiColors[255].rgbGreen=255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3664
        bitmap.bmiColors[255].rgbRed =255;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3665
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3666
        SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3667
                              __intVal(w), __intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3668
                              0, 0, /* __intVal(srcx), __intVal(srcy),    */
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3669
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3670
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3671
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3672
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3673
        SetDIBits(hDC,hBitmap,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3674
                              0,__intVal(h),
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3675
                              (void *)b_bits,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3676
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3677
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3678
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3679
        StretchDIBits(hDC,
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3680
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3681
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3682
                      __intVal(srcx), __intVal(srcy),           // x & y coord of source upper-left corner
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3683
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3684
                      (void *)b_bits,                           // bitmap bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3685
                      (BITMAPINFO*)&bitmap,                     // bitmap data
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3686
                      DIB_RGB_COLORS,                           // usage options
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3687
                      SRCCOPY                                   // raster operation code
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3688
        );
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3689
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3690
        if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3691
            free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3692
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3693
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3694
#ifndef CACHE_LAST_DC
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3695
        _releaseDC(gcData);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3696
#endif
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3697
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3698
        RETURN ( true );
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3699
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3700
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3701
fail: ;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3702
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3703
    PRINTF(("create temp bitmap FAILED!!!\n"));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3704
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3705
    if (allocatedBits) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3706
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3707
        PRINTF(("freeing up temp bitmap bits ...\n"));
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3708
*/
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3709
        free(allocatedBits);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3710
    }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3711
/*
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3712
#ifndef CACHE_LAST_DC
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3713
    if (hDC) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3714
        _releaseDC(gcData);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3715
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3716
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3717
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3718
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3719
.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3720
    ^ false
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3721
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3722
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3723
setFunction:aFunctionSymbol in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3724
    "set alu function to be drawn with"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3725
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3726
    Transcript showCR: aFunctionSymbol printString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3727
    function := aFunctionSymbol.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3728
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3729
"/%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3730
"/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3731
"/    if (__isExternalAddress(aGCId)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3732
"/        struct gcData *gcData = _GCDATA(aGCId);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3733
"/        int fun = -1;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3734
"/        int bfun = -1;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3735
"/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3736
"/        if (aFunctionSymbol == @symbol(copy)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3737
"/            fun = R2_COPYPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3738
"/            bfun = BITBLT_COPY;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3739
"/        } else if (aFunctionSymbol == @symbol(copyInverted)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3740
"/            fun = R2_NOTCOPYPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3741
"/            bfun = BITBLT_COPYINVERTED;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3742
"/        } else if (aFunctionSymbol == @symbol(xor)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3743
"/            fun = R2_XORPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3744
"/            bfun = BITBLT_XOR;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3745
"/        } else if (aFunctionSymbol == @symbol(and)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3746
"/            fun = R2_MASKPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3747
"/            bfun = BITBLT_AND;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3748
"/        } else if (aFunctionSymbol == @symbol(or)) {
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3749
"/            fun = R2_MERGEPEN;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3750
"/            bfun = BITBLT_OR;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3751
"/        }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3752
"/
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  3753
"/        if (fun
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3754
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3755
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3756
setGraphicsExposures:aBoolean in:aGCId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3757
    "set or clear the graphics exposures flag"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3758
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3759
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3760
shiftBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3761
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3762
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3763
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3764
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3765
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3766
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3767
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3768
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3769
     ^Display shiftBlue
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3770
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3771
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3772
shiftGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3773
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3774
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3775
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3776
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3777
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3778
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3779
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3780
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3781
     ^Display shiftGreen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3782
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3783
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3784
shiftRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3785
    "return the number of valid bits in the red component."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3786
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3787
"/    bitsRed isNil ifTrue:[
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3788
"/        "/ not a truecolor display
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3789
"/        ^ bitsPerRGB
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3790
"/    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3791
"/    ^ bitsRed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3792
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  3793
     ^Display shiftRed
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3794
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3795
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3796
sortBlockForColors
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3797
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3798
    ^ [:a :b |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3799
            a redByte == b redByte ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3800
                a greenByte == b greenByte ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3801
                    a blueByte < b blueByte
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3802
                ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3803
                    a greenByte < b greenByte 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3804
                ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3805
            ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3806
                a redByte < b redByte 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3807
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3808
      ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3809
!
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3810
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3811
sortColorMapImage: image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3812
    "calculates a new color map for the image, sorting colors"
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3813
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3814
    |sortBlock depth newColorMap newImage oldImage usedColors oldToNew oldBits newBits tmpBits| 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3815
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3816
    sortBlock := self sortBlockForColors.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3817
    oldImage := image.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3818
    depth := oldImage depth.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3819
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3820
    oldImage photometric ~~ #palette ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3821
        Transcript showCR:'Compress colorMap: Only palette images have colormaps.'.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3822
        ^ image
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3823
    ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3824
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3825
    usedColors := oldImage realColorMap.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3826
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3827
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3828
        "/ translation table
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3829
        oldToNew := ByteArray new:(1 bitShift:depth).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3830
        newColorMap := usedColors asArray.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3831
        newColorMap sort:sortBlock.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3832
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3833
        oldImage colorMap asArray keysAndValuesDo:[:oldIdx :clr |
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3834
            |newPixel|
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3835
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3836
            (usedColors includes:clr) ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3837
                newPixel := newColorMap indexOf:clr.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3838
                oldToNew at:oldIdx put:newPixel-1.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3839
            ]
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3840
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3841
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3842
        oldBits := oldImage bits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3843
        newBits := ByteArray new:(oldBits size).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3844
        depth ~~ 8 ifTrue:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3845
            "/ expand/compress can only handle 8bits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3846
            tmpBits := ByteArray uninitializedNew:(oldImage width*oldImage height).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3847
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3848
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3849
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3850
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3851
                into:tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3852
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3853
            tmpBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3854
                compressPixels:depth 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3855
                width:oldImage width 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3856
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3857
                into:newBits 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3858
                mapping:nil
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3859
        ] ifFalse:[
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3860
            oldBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3861
                expandPixels:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3862
                width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3863
                height:oldImage height 
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3864
                into:newBits
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3865
                mapping:oldToNew.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3866
        ].
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3867
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3868
        newImage := oldImage species new
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3869
                        width:oldImage width
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3870
                        height:oldImage height
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3871
                        depth:depth
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3872
                        fromArray:newBits.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3873
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3874
        newImage colorMap:newColorMap.  
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3875
        newImage fileName:oldImage fileName.
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3876
        newImage mask:(oldImage mask copy).
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3877
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  3878
        ^newImage
2343
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3879
!
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3880
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3881
transparencyTest_primDrawBits:imageBits redVector:redVector greenVector:greenVector blueVector:blueVector bitsPerPixel:bitsPerPixel depth:imageDepth 
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3882
                              width:imageWidth height:imageHeight
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3883
                               into:ignoredDrawableId
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3884
                                  x:dstx y:dsty
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3885
                              width:w height:h
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3886
                               with:aGCId
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3887
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3888
    "since XPutImage may allocate huge amount of stack space
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3889
     (some implementations use alloca), this must run with unlimited stack."
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3890
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3891
%{
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3892
    unsigned char fastBits[10000];
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3893
    unsigned char *b_bits = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3894
    unsigned char *allocatedBits = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3895
    unsigned char *__imageBits = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3896
    unsigned char *__redVector = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3897
    unsigned char *__greenVector = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3898
    unsigned char *__blueVector = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3899
    int padd = 8;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3900
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3901
    if (__isByteArray(imageBits)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3902
        __imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3903
    } else if (__isExternalBytesLike(imageBits)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3904
        __imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3905
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3906
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3907
    if (__isByteArray(redVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3908
        __redVector = __ByteArrayInstPtr(redVector)->ba_element;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3909
    } else if (__isExternalBytesLike(redVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3910
        __redVector = (unsigned char *)(__externalBytesAddress(redVector));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3911
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3912
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3913
    if (__isByteArray(greenVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3914
        __greenVector = __ByteArrayInstPtr(greenVector)->ba_element;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3915
    } else if (__isExternalBytesLike(greenVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3916
        __greenVector = (unsigned char *)(__externalBytesAddress(greenVector));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3917
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3918
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3919
    if (__isByteArray(blueVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3920
        __blueVector = __ByteArrayInstPtr(blueVector)->ba_element;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3921
    } else if (__isExternalBytesLike(blueVector)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3922
        __blueVector = (unsigned char *)(__externalBytesAddress(blueVector));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3923
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3924
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3925
    if (/* ISCONNECTED
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3926
     && */ __isExternalAddressLike(aGCId)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3927
//     && __bothSmallInteger(srcx, srcy)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3928
     && __bothSmallInteger(dstx, dsty)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3929
     && __bothSmallInteger(w, h)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3930
     && __bothSmallInteger(imageWidth, imageHeight)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3931
     && __bothSmallInteger(imageDepth, bitsPerPixel)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3932
     && __imageBits)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3933
     {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3934
        struct
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3935
        {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3936
          BITMAPINFOHEADER bmiHeader;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3937
          RGBQUAD bmiColors[256];
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3938
        } bitmap;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3939
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3940
        HANDLE hDC = (HANDLE)(__externalAddressVal(aGCId));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3941
        HBITMAP hBitmap = _HBITMAPVAL(__INST(drawableId));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3942
        int col;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3943
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3944
        DDPRINTF(("hDC = %x\n", hDC));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3945
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3946
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3947
        if (padd != WIN32PADDING) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3948
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3949
            int row, col;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3950
            unsigned char *cp;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3951
            unsigned char *pBits;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3952
            int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3953
            int bi = __intVal(bitsPerPixel);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3954
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3955
//            console_fprintf(stderr, "Non WIN32PADDING");
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3956
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3957
            b_width = __intVal(w);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3958
            b_height = __intVal(h);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3959
            bytesPerRowST = (b_width * bi + (padd - 1 )) / padd;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3960
            bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3961
            padding = bytesPerRowWN - bytesPerRowST;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3962
            nBytes = b_height * bytesPerRowWN;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3963
            /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3964
            if (padding) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3965
                if (nBytes < sizeof(fastBits)) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3966
                    cp = b_bits = fastBits;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3967
                } else {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3968
                    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3969
                }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3970
                if (cp) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3971
                    pBits = __imageBits;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3972
                    for (row = b_height; row; row--) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3973
                        for (col = bytesPerRowST; col; col--) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3974
                            *cp++ = *pBits++;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3975
                        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3976
                        cp += padding;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3977
                    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3978
                } else
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3979
                    goto fail;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3980
            }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3981
        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3982
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3983
        if (b_bits == 0) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3984
            b_bits = __imageBits;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3985
        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3986
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3987
        bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3988
        bitmap.bmiHeader.biPlanes = 1;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3989
        bitmap.bmiHeader.biCompression = BI_RGB;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3990
        bitmap.bmiHeader.biSizeImage = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3991
        bitmap.bmiHeader.biXPelsPerMeter = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3992
        bitmap.bmiHeader.biYPelsPerMeter = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3993
        bitmap.bmiHeader.biClrUsed = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3994
        bitmap.bmiHeader.biClrImportant = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3995
        bitmap.bmiHeader.biWidth = __intVal(imageWidth);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3996
        bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3997
        bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3998
        /*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);*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  3999
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4000
        if (__intVal(imageDepth) <= 8) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4001
            for(col=0;col<256;col++)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4002
             {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4003
              bitmap.bmiColors[col].rgbBlue = 0;    
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4004
              bitmap.bmiColors[col].rgbGreen = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4005
              bitmap.bmiColors[col].rgbRed = 0;     
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4006
              bitmap.bmiColors[col].rgbReserved = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4007
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4008
            }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4009
        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4010
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4011
        bitmap.bmiColors[255].rgbBlue=255;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4012
        bitmap.bmiColors[255].rgbGreen=255;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4013
        bitmap.bmiColors[255].rgbRed =255;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4014
        bitmap.bmiColors[255].rgbReserved = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4015
        StretchDIBits(hDC,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4016
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4017
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4018
                      0, 0,  /* __intVal(srcx), __intVal(srcy),    */   // x & y coord of source upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4019
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4020
                      (void *)b_bits,                           // bitmap bits
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4021
                      (BITMAPINFO*)&bitmap,                     // bitmap data
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4022
                      DIB_RGB_COLORS,                           // usage options
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4023
                      SRCAND                                   // raster operation code
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4024
        );
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4025
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4026
        if (__intVal(imageDepth) <= 8) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4027
            for(col=0;col<256;col++)
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4028
             {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4029
              bitmap.bmiColors[col].rgbBlue = __blueVector[col];    // Microsoft idea: change rgbBlue to rgbRed
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4030
              bitmap.bmiColors[col].rgbGreen = __greenVector[col];
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4031
              bitmap.bmiColors[col].rgbRed = __redVector[col];         // Microsoft idea: change rgbRed to rgbBlue
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4032
              bitmap.bmiColors[col].rgbReserved = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4033
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4034
            }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4035
        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4036
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4037
        bitmap.bmiColors[255].rgbBlue=0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4038
        bitmap.bmiColors[255].rgbGreen=0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4039
        bitmap.bmiColors[255].rgbRed =0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4040
        bitmap.bmiColors[255].rgbReserved = 0;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4041
        StretchDIBits(hDC,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4042
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4043
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4044
                      0, 0,                                     // x & y coord of source upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4045
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4046
                      (void *)b_bits,                           // bitmap bits
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4047
                      (BITMAPINFO*)&bitmap,                     // bitmap data
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4048
                      DIB_RGB_COLORS,                           // usage options
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4049
                      SRCPAINT                                  // raster operation code
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4050
        );
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4051
 */
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4052
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4053
        SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4054
                              __intVal(w), __intVal(h),
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4055
                              0, 0,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4056
                              0,__intVal(h),
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4057
                              (void *)b_bits,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4058
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4059
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4060
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4061
        SetDIBits(hDC,hBitmap,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4062
                              0,__intVal(h),
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4063
                              (void *)b_bits,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4064
                              (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4065
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4066
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4067
        StretchDIBits(hDC,
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4068
                      __intVal(dstx),(__intVal(dsty)),            //  x & y coord of destination upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4069
                      __intVal(w), __intVal(h),                 // width & height of destination rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4070
                      __intVal(srcx), __intVal(srcy),           // x & y coord of source upper-left corner
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4071
                      __intVal(w), __intVal(h),                 // width & height of source rectangle
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4072
                      (void *)b_bits,                           // bitmap bits
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4073
                      (BITMAPINFO*)&bitmap,                     // bitmap data
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4074
                      DIB_RGB_COLORS,                           // usage options
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4075
                      SRCCOPY                                   // raster operation code
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4076
        );
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4077
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4078
        if (allocatedBits) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4079
            free(allocatedBits);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4080
        }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4081
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4082
#ifndef CACHE_LAST_DC
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4083
        _releaseDC(gcData);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4084
#endif
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4085
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4086
        RETURN ( true );
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4087
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4088
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4089
fail: ;
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4090
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4091
    PRINTF(("create temp bitmap FAILED!!!\n"));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4092
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4093
    if (allocatedBits) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4094
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4095
        PRINTF(("freeing up temp bitmap bits ...\n"));
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4096
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4097
        free(allocatedBits);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4098
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4099
/*
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4100
#ifndef CACHE_LAST_DC
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4101
    if (hDC) {
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4102
        _releaseDC(gcData);
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4103
    }
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4104
#endif
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4105
*/
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4106
%}
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4107
.
b7ef200fbfad *** empty log message ***
fm
parents: 2342
diff changeset
  4108
    ^ false
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4109
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4110
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4111
!WinPrinterContext methodsFor:'font stuff'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4112
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4113
createFontFor:aFontName
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4114
    "a basic method for font allocation; this method allows
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4115
     any font to be aquired (even those not conforming to
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4116
     standard naming conventions, such as cursor, fixed or k14)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4117
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4118
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4119
    HGDIOBJ hFont;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4120
    char *fn;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4121
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4122
    if (__isStringLike(aFontName)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4123
        fn = __stringVal(aFontName);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4124
        if ((strcmp(fn, "fixed") == 0) || (strcmp(fn, "ANSI_FIXED_FONT") == 0)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4125
            hFont = GetStockObject(ANSI_FIXED_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4126
        } else if ((strcmp(fn, "variable") == 0) || (strcmp(fn, "ANSI_VAR_FONT") == 0)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4127
            hFont = GetStockObject(ANSI_VAR_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4128
        } else if ((strcmp(fn, "system") == 0) || (strcmp(fn, "SYSTEM_FONT") == 0)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4129
            hFont = GetStockObject(SYSTEM_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4130
        } else if ((strcmp(fn, "systemFixed") == 0) || (strcmp(fn, "SYSTEM_FIXED_FONT") == 0)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4131
            hFont = GetStockObject(SYSTEM_FIXED_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4132
        } else if ((strcmp(fn, "deviceDefault") == 0) || (strcmp(fn, "DEVICE_DEFAULT_FONT") == 0)) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4133
            hFont = GetStockObject(DEVICE_DEFAULT_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4134
        } else {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4135
            hFont = GetStockObject(ANSI_FIXED_FONT);
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4136
        }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4137
        if (hFont) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4138
            DPRINTF(("createFontFor:%s -> %x\n", fn, hFont));
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4139
            RETURN ( __MKEXTERNALADDRESS(hFont) );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4140
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4141
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4142
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4143
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4144
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4145
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4146
fontMetricsOf:fontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4147
    "return a fonts metrics info object"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4148
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4149
    |rawData info|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4150
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4151
    rawData := Array new:15.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4152
    (self primFontMetricsOf:fontId hdc:gcId intoArray:rawData) isNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4153
	self primitiveFailed.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4154
	^ self
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4155
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4156
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4157
    rawData at:11 put:#'ms-ansi'.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4158
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4159
    info := DeviceWorkstation::DeviceFontMetrics new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4160
    info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4161
      ascent:(rawData at:1)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4162
      descent:(rawData at:2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4163
      maxAscent:(rawData at:3)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4164
      maxDescent:(rawData at:4)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4165
      minWidth:(rawData at:5)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4166
      maxWidth:(rawData at:6)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4167
      avgWidth:(rawData at:7)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4168
      minCode:(rawData at:8)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4169
      maxCode:16rFFFF "(rawData at:9)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4170
      direction:nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4171
      encoding:(rawData at:11).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4172
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4173
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4174
    ^ info
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4175
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4176
3002
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  4177
getDefaultFontWithEncoding:encoding
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4178
    "return a default font id - used when class Font cannot
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4179
     find anything usable"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4180
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4181
     ^ self createFontFor:'fixed'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4182
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4183
2603
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4184
getFontWithFamily:familyString face:faceString style:styleString size:sizeArg encoding:encodingSym
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4185
    "try to get the specified font, return id.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4186
     If not available, try next smaller font.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4187
     If no font fits, return nil"
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4188
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4189
    ^ self 
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4190
        getFontWithFamily:familyString 
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4191
        face:faceString 
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4192
        style:styleString 
2603
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4193
        size:sizeArg  
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4194
        sizeUnit:#pt  
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4195
        encoding:encodingSym
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4196
!
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4197
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4198
getFontWithFamily:familyString face:faceString
2603
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4199
            style:styleArgString size:sizeArgOrNil sizeUnit:sizeUnit encoding:encodingSym
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4200
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4201
    "try to get the specified font, if not available, try the next smaller
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4202
     font."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4203
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4204
    |styleString theName theId xlatedStyle id spacing|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4205
2603
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4206
    self assert:(sizeUnit == #pt).
875d9c41c67d pixelSize stuff
Claus Gittinger <cg@exept.de>
parents: 2602
diff changeset
  4207
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4208
    styleString := styleArgString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4209
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4210
    "special: if face is nil, allow access to X-fonts"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4211
    faceString isNil ifTrue:[
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4212
        sizeArgOrNil notNil ifTrue:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4213
            theName := familyString , '-' , sizeArgOrNil printString
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4214
        ] ifFalse:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4215
            theName := familyString
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4216
        ].
3002
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  4217
        theName notNil ifTrue:[
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  4218
            theId := self createFontFor:theName.
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4219
        ].
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4220
        theId isNil ifTrue:[
3002
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  4221
            theId := self getDefaultFontWithEncoding:encodingSym
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4222
        ].
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4223
        ^ theId
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4224
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4225
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4226
    "/ spacing other than 'normal' is contained as last component
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4227
    "/ in style
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4228
    styleString notNil ifTrue:[
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4229
        ((styleString endsWith:'-narrow')
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4230
         or:[styleString endsWith:'-semicondensed']) ifTrue:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4231
            |i|
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4232
            i := styleString lastIndexOf:$-.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4233
            spacing := styleString copyFrom:(i+1).
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4234
            styleString := styleString copyTo:(i-1).
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4235
        ] ifFalse:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4236
            spacing := 'normal'.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4237
        ].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4238
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4239
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4240
    xlatedStyle := styleString.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4241
    xlatedStyle notNil ifTrue:[
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4242
        xlatedStyle := xlatedStyle first asString
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4243
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4244
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4245
    id := self
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4246
            getFontWithFoundry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4247
            family:familyString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4248
            weight:faceString
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4249
            slant:styleString "/ xlatedStyle
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4250
            spacing:spacing
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4251
            pixelSize:nil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4252
            size:sizeArgOrNil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4253
            registry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4254
            encoding:encodingSym.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4255
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4256
    id isNil ifTrue:[
2602
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4257
        (encodingSym notNil and:[encodingSym ~= '*']) ifTrue:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4258
            "/ too stupid: encodings come in both cases
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4259
            "/
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4260
            id := self
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4261
                    getFontWithFoundry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4262
                    family:familyString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4263
                    weight:faceString
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4264
                    slant:styleString "/ xlatedStyle
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4265
                    spacing:spacing
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4266
                    pixelSize:nil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4267
                    size:sizeArgOrNil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4268
                    registry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4269
                    encoding:encodingSym asUppercase.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4270
            id isNil ifTrue:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4271
                id := self
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4272
                        getFontWithFoundry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4273
                        family:familyString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4274
                        weight:faceString
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4275
                        slant:styleString "/ xlatedStyle
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4276
                        spacing:spacing
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4277
                        pixelSize:nil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4278
                        size:sizeArgOrNil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4279
                        registry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4280
                        encoding:encodingSym asLowercase.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4281
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4282
                id isNil ifTrue:[
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4283
                    id := self
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4284
                            getFontWithFoundry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4285
                            family:familyString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4286
                            weight:faceString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4287
                            slant:styleString asLowercase
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4288
                            spacing:spacing
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4289
                            pixelSize:nil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4290
                            size:sizeArgOrNil
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4291
                            registry:'*'
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4292
                            encoding:encodingSym asLowercase.
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4293
                ]
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4294
            ]
87adcdcddc17 preps for pixelSize fonts
Claus Gittinger <cg@exept.de>
parents: 2482
diff changeset
  4295
        ]
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4296
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4297
    ^ id
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4298
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4299
    "Modified: 24.2.1996 / 22:37:24 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4300
    "Modified: 4.7.1996 / 11:38:47 / stefan"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4301
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4302
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4303
getFontWithFoundry:foundry family:family weight:weight
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4304
              slant:slant spacing:spc pixelSize:pixelSize size:pointSize
2851
fad5f9ba8014 primitives expect a symbol as encoding
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
  4305
              registry:registry encoding:encodingArg
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4306
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4307
    "get the specified font, if not available, return nil.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4308
     For now, this is a poor (incomplete) emulation of the X code ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4309
     Individual attributes can be left empty (i.e. '') or nil to match any.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4310
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4311
     foundry:   'adobe', 'misc', 'dec', 'schumacher' ... usually '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4312
     family:    'helvetica' 'courier' 'times' ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4313
     weight:    'bold' 'medium' 'demi' ...
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4314
     slant:     'r(oman)' 'i(talic)' 'o(blique)'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4315
     spacing:   'narrow' 'normal' semicondensed' ... usually '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4316
     pixelSize: 16,18 ... usually left empty
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4317
     size:      size in point (1/72th of an inch)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4318
     registry:  iso8859, sgi ... '*'
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4319
     encoding:  vendor specific encoding (usually '*')
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4320
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4321
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4322
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4323
     Windows-NT/95 allows the creation of a font with the following parameters
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4324
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4325
        nHeight
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4326
        nWidth
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4327
        nEscapement
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4328
        nOrientation
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4329
        fnWeight        FW_DONTCARE, FW_NORMAL, FW_MEDIUM, FW_BOLD, ...
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4330
        fdwItalic       TRUE or FALSE
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4331
        fdwUnderline    TRUE or FALSE
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4332
        fdwStrikeOut    TRUE or FALSE
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4333
        fdwCharSet      ANSI_CHARSET, UNICODE_, SYMBOL_, SHIFTJIS_,...
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4334
        fdwOutputPrecision      DEFAULT, STRING, CHAR, ...
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4335
        fdwClipPrecision        DEFAULT, CHAR, STROKE, MASK, ...
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4336
        fdwQuality      DEFAULT, DRAFT, or PROOF.
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4337
        fdwPitchAndFamily
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4338
                DEFAULT, FIXED or VARIABLE pitch
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4339
                DECORATIVE, DONTCASE, MODERN, ROMAN, SCRIPT, or SWISS.
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4340
        lpszFace
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4341
                Typeface Name
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4342
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4343
      These two above descriptions will be matched as follows:
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4344
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4345
        foundry   - ignored
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4346
        family    - mapped to type face name.
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4347
        weight    - mapped to fnWeight
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4348
        slant     - used for style
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4349
        spacing   - NOT USED INITIALLY
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4350
        pixelSize - NOT USED INITIALLY
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4351
        size      - mapped to nHeight
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4352
        registry  - NOT USED INITIALLY
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4353
        encoding  - mapped to fdwCharSet
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4354
     "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4355
2851
fad5f9ba8014 primitives expect a symbol as encoding
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
  4356
    |logSize encoding|
fad5f9ba8014 primitives expect a symbol as encoding
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
  4357
fad5f9ba8014 primitives expect a symbol as encoding
Stefan Vogel <sv@exept.de>
parents: 2818
diff changeset
  4358
    encoding := encodingArg asSymbol.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4359
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4360
    pixelSize notNil ifTrue:[
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4361
        logSize := pixelSize
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4362
    ] ifFalse:[
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4363
        logSize := (pointSize * (self getLogicalPixelSizeY) / 72.0) rounded.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4364
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4365
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4366
    HGDIOBJ hFont;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4367
    int  pointSize, nHeight, nWidth, nEscapement, nOrientation;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4368
    char* work;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4369
    char* work2;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4370
    DWORD fnWeight;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4371
    DWORD fdwItalic;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4372
    DWORD fdwUnderline;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4373
    DWORD fdwStrikeOut;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4374
    DWORD fdwCharSet;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4375
    DWORD fdwOutputPrecision;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4376
    DWORD fdwClipPrecision;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4377
    DWORD fdwQuality;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4378
    DWORD fdwPitchAndFamily;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4379
    static char faceName[256];
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4380
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4381
/* INITIALIZE */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4382
    strcpy( faceName, "NULL" );
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4383
    nHeight   = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4384
    nWidth   = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4385
    nEscapement = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4386
    nOrientation = 0;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4387
    fnWeight = FW_NORMAL;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4388
    fdwItalic = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4389
    fdwUnderline = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4390
    fdwStrikeOut = FALSE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4391
    fdwOutputPrecision = OUT_DEFAULT_PRECIS;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4392
    fdwClipPrecision   = CLIP_DEFAULT_PRECIS;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4393
    fdwQuality         = DEFAULT_QUALITY;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4394
    fdwPitchAndFamily  = FF_DONTCARE;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4395
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4396
    fdwCharSet   = ANSI_CHARSET;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4397
    if ((encoding == @symbol('ms-ansi'))) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4398
        fdwCharSet   = ANSI_CHARSET;
2852
9d0ad50e4335 changed: #getFontWithFoundry:family:weight:slant:spacing:pixelSize:size:registry:encoding:
Stefan Vogel <sv@exept.de>
parents: 2851
diff changeset
  4399
    } else if (encoding == @symbol('ms-default')
9d0ad50e4335 changed: #getFontWithFoundry:family:weight:slant:spacing:pixelSize:size:registry:encoding:
Stefan Vogel <sv@exept.de>
parents: 2851
diff changeset
  4400
               || encoding == @symbol(*)) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4401
        fdwCharSet   = DEFAULT_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4402
    } else if ((encoding == @symbol('ms-symbol'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4403
            || (encoding == @symbol('misc-fontspecific'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4404
        fdwCharSet   = SYMBOL_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4405
    } else if ((encoding == @symbol('ms-shiftjis'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4406
            || (encoding == @symbol('jisx0208.1983-0'))){
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4407
        fdwCharSet   = SHIFTJIS_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4408
    } else if ((encoding == @symbol('ms-gb2312'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4409
            || (encoding == @symbol('gb2312.1980-0'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4410
        fdwCharSet   = GB2312_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4411
    } else if ((encoding == @symbol('ms-hangeul'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4412
            || (encoding == @symbol('ksc5601.1987-0'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4413
        fdwCharSet   = HANGEUL_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4414
    } else if ((encoding == @symbol('ms-chinesebig5'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4415
            || (encoding == @symbol('big5'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4416
        fdwCharSet   = CHINESEBIG5_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4417
    } else if (encoding == @symbol('ms-oem')) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4418
        fdwCharSet   = OEM_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4419
    } else if (encoding == @symbol('ms-johab')) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4420
        fdwCharSet   = JOHAB_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4421
    } else if ((encoding == @symbol('ms-hebrew'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4422
            || (encoding == @symbol('ms-cp1255'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4423
        fdwCharSet   = HEBREW_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4424
    } else if ((encoding == @symbol('ms-arabic'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4425
            || (encoding == @symbol('ms-cp1256'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4426
        fdwCharSet   = ARABIC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4427
    } else if ((encoding == @symbol('ms-greek'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4428
            || (encoding == @symbol('ms-cp1253'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4429
        fdwCharSet   = GREEK_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4430
    } else if ((encoding == @symbol('ms-turkish'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4431
            || (encoding == @symbol('ms-cp1254'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4432
        fdwCharSet   = TURKISH_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4433
    } else if ((encoding == @symbol('ms-russian'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4434
            || (encoding == @symbol('ms-cp1251'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4435
        fdwCharSet   = RUSSIAN_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4436
    } else if ((encoding == @symbol('ms-easteurope'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4437
            || (encoding == @symbol('ms-cp1250'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4438
        fdwCharSet   = EASTEUROPE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4439
    } else if ((encoding == @symbol('ms-baltic'))
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4440
            || (encoding == @symbol('ms-cp1257'))) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4441
        fdwCharSet   = BALTIC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4442
    } else if ((encoding == @symbol('ms-vietnamese'))) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4443
        fdwCharSet   = VIETNAMESE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4444
    } else if ((encoding == @symbol('ms-thai'))) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4445
        fdwCharSet   = THAI_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4446
    } else if ((encoding == @symbol('ms-mac'))) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4447
        fdwCharSet   = MAC_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4448
#ifdef UNICODE_CHARSET
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4449
    } else if ((encoding == @symbol('ms-unicode'))) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4450
        fdwCharSet   = UNICODE_CHARSET;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4451
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4452
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4453
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4454
    if ( __isString( family ) ) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4455
        work = __stringVal( family );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4456
        if (strcmp( work, "nil" ) != 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4457
            strncpy( faceName, work, sizeof(faceName)-1 );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4458
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4459
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4460
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4461
    /* 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
  4462
    if( __isString( weight ) ) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4463
        work = __stringVal( weight );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4464
        if (strcmp( work, "bold" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4465
            fnWeight = FW_BOLD;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4466
        } else if (strcmp( work, "medium" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4467
            fnWeight = FW_MEDIUM;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4468
        } else if (strcmp( work, "normal" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4469
            fnWeight = FW_NORMAL;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4470
        } else if (strcmp( work, "light" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4471
            fnWeight = FW_LIGHT;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4472
        } else if (strcmp( work, "demi" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4473
            fnWeight = FW_LIGHT;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4474
        } else if (strcmp( work, "heavy" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4475
            fnWeight = FW_HEAVY;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4476
        } else if (strcmp( work, "extraBold" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4477
            fnWeight = FW_EXTRABOLD;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4478
        } else if (strcmp( work, "semiBold" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4479
            fnWeight = FW_SEMIBOLD;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4480
        } else if (strcmp( work, "thin" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4481
            fnWeight = FW_THIN;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4482
        } else if (strcmp( work, "extraLight" ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4483
            fnWeight = FW_EXTRALIGHT;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4484
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4485
    } else if (__isSmallInteger(weight)) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4486
        fnWeight = __intVal(weight);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4487
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4488
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4489
    if(__isSmallInteger( logSize )) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4490
        nHeight = __intVal( logSize );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4491
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4492
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4493
    if (__isString(slant)) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4494
        work2 = __stringVal( slant );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4495
        work  = __stringVal( slant );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4496
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4497
        if (strncmp(work2, "italic", 6) == 0)  {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4498
            fdwItalic = TRUE;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4499
            if ( work2[6] == '-' )
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4500
                strncpy( work, &work2[7], ( strlen( work2) - 7) );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4501
        } else {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4502
            if (strncmp(work2, "oblique", 7) == 0)  {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4503
                fdwItalic = TRUE;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4504
                if ( work2[7] == '-' )
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4505
                    strncpy( work, &work2[8], ( strlen( work2) - 8) );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4506
            }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4507
        }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4508
        if (strncmp( work, "underline", 9 ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4509
            fdwUnderline = TRUE;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4510
            if( work[10] == '-' )
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4511
                strncpy( work2, &work[11], ( strlen( work ) - 10 ) );
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4512
        }
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4513
        if (strncmp( work2, "strikeOut", 9 ) == 0 ) {
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4514
            fdwStrikeOut = TRUE;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4515
        }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4516
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4517
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4518
    DPRINTF(("CreateFont face:%s h=%d w=%d wght=%d\n",
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4519
                faceName, nHeight, nWidth, fnWeight));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4520
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4521
    hFont = CreateFont( -nHeight,   /* character height - not cell height */
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4522
                        nWidth,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4523
                        nEscapement,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4524
                        nOrientation,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4525
                        fnWeight,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4526
                        fdwItalic,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4527
                        fdwUnderline,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4528
                        fdwStrikeOut,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4529
                        fdwCharSet,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4530
                        fdwOutputPrecision,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4531
                        fdwClipPrecision,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4532
                        fdwQuality,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4533
                        fdwPitchAndFamily,
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4534
                        faceName );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4535
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4536
    if (hFont != NULL) {
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4537
        DPRINTF(("createFont: %x\n", hFont));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4538
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4539
    #ifdef COUNT_RESOURCES
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4540
        __cnt_font++;
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4541
        RES1PRINTF(("CreateFont %d\n", __cnt_font));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4542
    #endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4543
*/
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4544
        RETURN ( __MKEXTERNALADDRESS(hFont) );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4545
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4546
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4547
    DPRINTF(("***** ERROR createFontWithFoundry failed ERROR *****\n" ));
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4548
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4549
    ^ nil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4550
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4551
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4552
     Display getFontWithFoundry:'*'
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4553
                         family:'courier'
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4554
                         weight:'medium'
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4555
                          slant:'r'
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4556
                        spacing:nil
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4557
                      pixelSize:nil
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4558
                           size:13
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4559
                       registry:'iso8859'
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  4560
                       encoding:'*'
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4561
    "
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4562
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4563
    "new NT Version: 20.2.1997 / 22:33:29 / dq"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4564
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4565
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4566
primFontMetricsOf:fontId hdc:aDC intoArray:rawData
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4567
    "evaluate aBlock, passing a fonts metrics as arguments.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4568
     fill passed array as:
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4569
      ascent     -> (data at:1)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4570
      descent    -> (data at:2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4571
      maxAscent  -> (data at:3)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4572
      maxDescent -> (data at:4)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4573
      minWidth   -> (data at:5)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4574
      maxWidth   -> (data at:6)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4575
      avgWidth   -> (data at:7).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4576
      minChar    -> (data at:8).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4577
      maxChar    -> (data at:9).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4578
      defaultChar-> (data at:10).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4579
      charSet    -> (data at:11).
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4580
"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4581
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4582
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4583
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4584
    if (__isExternalAddress(fontId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4585
     && __isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4586
     && __isArray(rawData)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4587
     && (__arraySize(rawData) >= 11)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4588
	SIZE size;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4589
	int avgWidth;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4590
	HGDIOBJ hFont;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4591
	HGDIOBJ prevFont;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4592
	TEXTMETRIC tmet;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4593
	static char *s = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4594
	static int len;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4595
	OBJ t;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4596
	HANDLE hDC;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4597
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4598
	hFont = _HGDIOBJVal(fontId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4599
	hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4600
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4601
	/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4602
	 * temporarily set this font in the tmpDC (root-) context
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4603
	 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4604
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4605
	prevFont = SelectObject(hDC, hFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4606
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4607
	GetTextMetricsW(hDC, &tmet);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4608
	if (len == 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4609
	    len = strlen(s);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4610
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4611
#if 0
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4612
	GetTextExtentPoint32(hDC, s, len, &size);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4613
	avgWidth = (size.cx / (len / 2) + 1) / 2;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4614
#else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4615
	avgWidth = tmet.tmAveCharWidth;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4616
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4617
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4618
	__ArrayInstPtr(rawData)->a_element[0] = __MKSMALLINT(tmet.tmAscent);        /* ascent     -> (data at:1) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4619
	__ArrayInstPtr(rawData)->a_element[1] = __MKSMALLINT(tmet.tmDescent);       /* descent    -> (data at:2) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4620
	__ArrayInstPtr(rawData)->a_element[2] = __MKSMALLINT(tmet.tmAscent);        /* maxAscent  -> (data at:3) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4621
	__ArrayInstPtr(rawData)->a_element[3] = __MKSMALLINT(tmet.tmDescent);       /* maxDescent -> (data at:4) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4622
	__ArrayInstPtr(rawData)->a_element[4] = __MKSMALLINT(avgWidth);             /* minWidth   -> (data at:5) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4623
	__ArrayInstPtr(rawData)->a_element[5] = __MKSMALLINT(tmet.tmMaxCharWidth);  /* maxWidth   -> (data at:6) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4624
	__ArrayInstPtr(rawData)->a_element[6] = __MKSMALLINT(avgWidth);             /* avgWidth   -> (data at:7) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4625
	__ArrayInstPtr(rawData)->a_element[7] = __MKSMALLINT(tmet.tmFirstChar);     /* min        -> (data at:8) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4626
	__ArrayInstPtr(rawData)->a_element[8] = __MKSMALLINT(tmet.tmLastChar);      /* max        -> (data at:9) */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4627
	__ArrayInstPtr(rawData)->a_element[9] = __MKSMALLINT(tmet.tmDefaultChar);   /* default    -> (data at:10) */
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4628
#if 0
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4629
	t = __charSetSymbolFor(tmet.tmCharSet);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4630
	__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
  4631
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4632
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4633
	DPRINTF(("textMetrics h=%x  avgAsc=%d avgDesc=%d minW=%d maxW=%d avgW=%d\n",
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4634
		    hFont, tmet.tmAscent, tmet.tmDescent, avgWidth, tmet.tmMaxCharWidth,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4635
		    tmet.tmAveCharWidth));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4636
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4637
	SelectObject(hDC, prevFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4638
	RETURN (self);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4639
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4640
    RETURN (nil);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4641
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4642
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4643
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4644
releaseFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4645
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4646
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4647
    if (__isExternalAddress(aFontId)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4648
	HGDIOBJ hFont = _HGDIOBJVal(aFontId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4649
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4650
	if (hFont) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4651
	   DPRINTF(("ReleaseFont: %x\n", hFont));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4652
	   DeleteObject(hFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4653
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4654
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4655
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4656
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4657
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4658
setFont:aFontId in:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4659
    "set font to be drawn in"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4660
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4661
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4662
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4663
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4664
     && __isExternalAddress(aFontId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4665
    {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4666
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4667
	HGDIOBJ prevFont, hFont;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4668
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4669
	hFont = _HGDIOBJVal(aFontId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4670
	prevFont = SelectObject(hDC, hFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4671
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4672
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4673
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4674
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4675
    self primitiveFailed
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4676
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4677
    "Created: / 04-08-2006 / 12:32:53 / fm"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4678
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4679
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4680
widthOf:aString from:index1 to:index2 inFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4681
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4682
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4683
    unsigned char *cp;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4684
    int len, n, i1, i2, l;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4685
    OBJ cls;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4686
    int nInstBytes;
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4687
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4688
    if (__bothSmallInteger(index1, index2)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4689
     && __isExternalAddress(aFontId)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4690
     && __isExternalAddressLike(__INST(gcId))
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4691
     && __isNonNilObject(aString)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4692
	HGDIOBJ hFont,prevFont;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4693
	HANDLE hDC;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4694
	SIZE tsize;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4695
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4696
#ifndef PRE_22_FEP_2007
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4697
#       define N_QUICK_CHARS    1024
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4698
	unsigned short quickWchars[N_QUICK_CHARS];
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4699
	unsigned short *wcharPtr;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4700
	int mustFree = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4701
	int i;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4702
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4703
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4704
	hFont = _HGDIOBJVal(aFontId);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4705
	hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4706
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4707
	prevFont = SelectObject(hDC, hFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4708
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4709
	i1 = __intVal(index1) - 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4710
	cls = __qClass(aString);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4711
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4712
	if (i1 >= 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4713
	    i2 = __intVal(index2) - 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4714
	    if (i2 < i1) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4715
		RETURN ( __MKSMALLINT( 0 ) );
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4716
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4717
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4718
	    cp = (char *) _stringVal(aString);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4719
	    l = i2 - i1 + 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4720
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4721
	    if ((cls == @global(String)) || (cls == @global(Symbol))) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4722
		n = _stringSize(aString);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4723
    commonWidthChars:
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4724
		if (i2 < n) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4725
		    cp += i1;
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4726
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4727
#ifdef PRE_22_FEP_2007
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4728
		    GetTextExtentPoint32(hDC, cp, l, &tsize);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4729
#else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4730
		    if (l <= N_QUICK_CHARS) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4731
			wcharPtr = quickWchars;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4732
			mustFree = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4733
		    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4734
			wcharPtr = malloc(sizeof(short)*l);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4735
			if (! wcharPtr) RETURN (__MKSMALLINT(0));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4736
			mustFree = 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4737
		    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4738
		    for (i=0; i<l; i++) wcharPtr[i] = ((unsigned char *)cp)[i];
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4739
		    GetTextExtentPoint32W(hDC, wcharPtr, l, &tsize);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4740
		    if (mustFree) free(wcharPtr);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4741
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4742
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4743
#ifdef SUPERDEBUG
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4744
		    if (__debug__) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4745
			char buf[80];
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4746
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4747
			GetTextFace(hDC,80,buf);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4748
			console_printf("font1 %x %s >%s< l=%d dx=%d\n",hFont,buf,cp,l,tsize.cx);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4749
		    }
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4750
#endif
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4751
		    SelectObject(hDC, prevFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4752
		    RETURN ( __MKSMALLINT(tsize.cx) );
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4753
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4754
		RETURN (__MKSMALLINT(0));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4755
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4756
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4757
	    nInstBytes = __OBJS2BYTES__(__intVal(__ClassInstPtr(cls)->c_ninstvars));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4758
	    cp += nInstBytes;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4759
	    n = __byteArraySize(aString) - nInstBytes;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4760
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4761
	    if (__isBytes(aString)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4762
		goto commonWidthChars;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4763
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4764
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4765
	    /* Unicode */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4766
	    if (__isWords(aString)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4767
		n = n / 2;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4768
		if (i2 < n) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4769
		    WIDECHAR *w_cp = (WIDECHAR *)cp;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4770
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4771
		    w_cp += i1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4772
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4773
		    GetTextExtentPoint32W(hDC, w_cp, l, &tsize);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4774
		    SelectObject(hDC, prevFont);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4775
		    RETURN ( __MKSMALLINT(tsize.cx) );
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4776
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4777
		RETURN (__MKSMALLINT(0));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4778
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4779
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4780
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4781
%}.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4782
    self primitiveFailed.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4783
    ^ 0
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4784
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4785
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4786
widthOf:aString inFont:aFontId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4787
    "return the width in pixels of a string in a specific font"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4788
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4789
    ^ self widthOf:aString from:1 to:(aString size) inFont:aFontId
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4790
! !
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4791
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4792
!WinPrinterContext methodsFor:'initialization & release'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4793
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4794
createDC
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4795
    "Private - Create a device context for the receiver"
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  4796
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4797
    gcId := printerInfo createDC
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4798
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4799
    "Created: / 27-07-2006 / 10:21:05 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4800
    "Modified: / 02-08-2006 / 17:30:47 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4801
    "Modified: / 10-10-2006 / 18:14:28 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4802
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4803
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4804
deleteDC
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4805
    "Private - Delete a device context for the receiver"
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4806
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4807
    OperatingSystem deletePrinterDC: gcId.
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4808
!
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4809
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4810
destroy
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4811
    "Destroy the GC."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4812
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4813
    |id|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4814
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4815
    id := gcId.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4816
    id notNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4817
	gcId := nil.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4818
	self deleteDC.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4819
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4820
"/    Lobby unregister:self.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4821
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4822
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4823
destroyGC:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4824
%{
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4825
    if (__isExternalAddressLike(aDC)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4826
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4827
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4828
	DeleteDC(hDC);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4829
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4830
/*
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4831
#ifdef CACHE_LAST_DC
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4832
	if (lastGcData == gcData) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4833
	    _releaseDC(gcData);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4834
	}
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4835
#endif
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4836
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4837
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4838
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4839
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4840
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4841
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4842
executor
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4843
    |aCopy|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4844
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4845
    aCopy := WinWorkstation::PrinterDeviceContextHandle basicNew.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4846
    aCopy setDevice:device id:nil gcId:gcId.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4847
    ^ aCopy
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4848
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  4849
    "Created: / 16-04-2007 / 12:39:02 / cg"
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4850
!
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4851
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4852
initialize
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4853
    super initialize.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4854
"/    deviceForms := Registry new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4855
"/    deviceColors := Registry new.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4856
    deviceFonts := CachingRegistry new cacheSize:10.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4857
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4858
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4859
releaseDC
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4860
    "Private - Delete and clear the device context of the receiver."
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4861
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  4862
    self deleteDC.
2316
1660bcf17d63 *** empty log message ***
fm
parents: 2315
diff changeset
  4863
"/    device close.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4864
    gcId := nil.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4865
    self releaseDeviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4866
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4867
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4868
releaseDeviceFonts
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4869
    deviceFonts isEmptyOrNil ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4870
	deviceFonts do:[:afont |
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4871
	    afont releaseFromDevice.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4872
	].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4873
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4874
    deviceFonts := CachingRegistry new cacheSize:10.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4875
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4876
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4877
!WinPrinterContext methodsFor:'non standard methods'!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4878
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4879
stringWidthOf:aString at:index
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4880
    "Return the width of aString up to index
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4881
     when written using the current font; expand tabs out
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4882
     to 4 spaces for calculations"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4883
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4884
    |answer str size spaceWidth|
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4885
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4886
    index <= 0 ifTrue:[ ^ 0 ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4887
    str := index >= aString size ifTrue:[ aString ] ifFalse:[ aString copyFrom:1 to:index ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4888
    true "self font isNil" ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4889
	"if font not set yet, calculate based on default font"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4890
	"/            extString := str asExternalString.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4891
	size := Win32OperatingSystem::WinPointStructure new.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4892
	(OperatingSystem
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4893
	    getTextExtentPoint:gcId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4894
	    string:str
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4895
	    size:size) ifFalse:[ ^ self error ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4896
	answer := size x.
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4897
"/        Transcript showCR: 'FROM PRIM ******* ', str, '   ',  answer printString.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4898
"/        Transcript showCR: 'FROM DEVICE ***** ', str, '   ',(self font widthOf:str on:self device) printString.
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4899
	#TODO.
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4900
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4901
	answer := self font widthOf:str on:self device
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4902
    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4903
    index > aString size ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4904
	spaceWidth := self font widthOf:Character space on:self device.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4905
	answer := answer + ((index - aString size) * spaceWidth)
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4906
    ].
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4907
    ^ answer.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4908
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4909
    "Created: / 03-08-2006 / 10:27:20 / fm"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4910
    "Modified: / 04-08-2006 / 12:27:26 / fm"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4911
    "Modified: / 10-10-2006 / 18:20:43 / cg"
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4912
! !
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  4913
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4914
!WinPrinterContext methodsFor:'not supported yet'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4915
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4916
displayAdvanceLineFrom:point1 to:point2
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4917
    "draw a line"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4918
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4919
    self displayAdvanceLineFromX:(point1 x) y:(point1 y)
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4920
		      toX:(point2 x) y:(point2 y)
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4921
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4922
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4923
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4924
    "draw a line (with current paint-color); apply transformation if nonNil"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4925
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4926
    |pX0 pY0 pX1 pY1 easy fgId bgId|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4927
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4928
    gcId isNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4929
	self initGC
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4930
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4931
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4932
    lineStyle == #doubleDashed ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4933
	"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4934
	 if bgPaint or paint is not a real color, we have to do it the hard way ...
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4935
	"
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4936
	easy := true.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4937
	paint isColor ifFalse:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4938
	    easy := false
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4939
	] ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4940
	    fgId := paint colorId.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4941
	    fgId isNil ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4942
		easy := false
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4943
	    ]
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4944
	].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4945
	bgPaint isColor ifFalse:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4946
	    easy := false
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4947
	] ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4948
	    bgId := bgPaint colorId.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4949
	    bgId isNil ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4950
		easy := false
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4951
	    ]
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4952
	].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4953
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4954
	easy ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4955
	    ((foreground ~~ paint) or:[background ~~ bgPaint]) ifTrue:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4956
		device setForeground:fgId background:bgId in:gcId.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4957
		foreground := paint.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4958
		background := bgPaint.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4959
	    ].
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4960
	] ifFalse:[
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4961
	    'DeviceGraphicsContext [warning]: cannot draw dashes with dithered colors' errorPrintCR
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4962
	].
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4963
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4964
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4965
    transformation notNil ifTrue:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4966
	pX0 := transformation applyToX:x0.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4967
	pY0 := transformation applyToY:y0.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4968
	pX1 := transformation applyToX:x1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4969
	pY1 := transformation applyToY:y1.
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4970
    ] ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4971
	pX0 := x0.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4972
	pY0 := y0.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4973
	pX1 := x1.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4974
	pY1 := y1
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4975
    ].
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4976
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4977
    pX0 := pX0 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4978
    pY0 := pY0 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4979
    pX1 := pX1 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4980
    pY1 := pY1 rounded.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4981
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4982
    device displayAdvanceLineFromX:pX0 y:pY0 toX:pX1 y:pY1 in:drawableId with:gcId
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4983
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4984
    "Modified: 10.1.1997 / 17:46:32 / cg"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4985
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4986
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4987
displayAdvanceLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4988
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4989
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4990
    self getPenForMyContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4991
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4992
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4993
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4994
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4995
     && __bothSmallInteger(x1, y1)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4996
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4997
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  4998
	int __x1 = __intVal(x1), __y1 = __intVal(y1);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  4999
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5000
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5001
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5002
		    __intVal(x0), __intVal(y0),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5003
		    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5004
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5005
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5006
/*        fgColor = GetTextColor(hDC);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5007
 *        hPen = CreatePen(PS_SOLID, 1, fgColor);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5008
 */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5009
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5010
	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5011
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5012
	LineTo(hDC, __x1, __y1);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5013
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5014
	/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5015
	 * end-point ...
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5016
	 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5017
	LineTo(hDC, __x1+1, __y1);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5018
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5019
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5020
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5021
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5022
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5023
%}
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5024
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5025
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5026
gcForBitmap:aDrawableId
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5027
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5028
%{  /* NOCONTEXT */
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5029
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5030
    if (__isExternalAddress(aDrawableId)){
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5031
        BITMAP bitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5032
        HBITMAP hBitmap = _HBITMAPVAL(aDrawableId);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5033
        HBITMAP memBM;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5034
        HANDLE compatibleDC, rootDC, hdcScreen;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5035
   //     HANDLE printerDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5036
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5037
        if (! hBitmap) {
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5038
            RETURN (nil);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5039
        }
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5040
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5041
        if (GetObject(hBitmap, sizeof(bitmap), &bitmap)) {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5042
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5043
            DDPRINTF(("bitmap info:%d\n", bitmap.bmBitsPixel));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5044
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5045
        } else {
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5046
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5047
            DPRINTF(("noinfo returned for bitmap\n"));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5048
*/
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5049
            /* mhmh - can this happen ? */
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5050
            bitmap.bmBitsPixel = 1;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5051
        }
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5052
/*
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5053
        gcData->hBitmap = hBitmap;
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5054
        gcData->bitmapColorBitCount = bitmap.bmBitsPixel;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5055
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5056
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5057
        rootDC  = CreateDC("DISPLAY", NULL, NULL, NULL);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5058
        compatibleDC = CreateCompatibleDC(rootDC);
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5059
        SelectObject(compatibleDC, hBitmap);
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5060
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5061
   //     hdcScreen= CreateDC("NULL", NULL, NULL, NULL);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5062
   //       compatibleDC =  rootDC;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5063
   //     compatibleDC = CreateCompatibleDC(printerDC);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5064
   //     compatibleDC = CreateCompatibleDC(0);
2338
d170c690a945 drawing bitmaps
fm
parents: 2330
diff changeset
  5065
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5066
   //     memBM = CreateCompatibleBitmap ( compatibleDC, bitmap.bmWidth, bitmap.bmHeight );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5067
   //     SelectObject ( compatibleDC, memBM );
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5068
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  5069
        RETURN (__MKEXTERNALADDRESS(compatibleDC));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5070
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5071
/*
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  5072
        RETURN ( __MKEXTERNALADDRESS(gcData) );
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5073
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5074
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5075
    RETURN (nil);
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5076
%}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5077
!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5078
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5079
getPenForMyContext
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5080
    "Get a pen for my context"
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5081
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5082
    |maskOriginX maskOriginY|
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5083
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5084
    self maskOrigin isNil ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5085
	maskOriginX := self maskOrigin x.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5086
	maskOriginY := self maskOrigin y.
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5087
    ].
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5088
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  5089
%{
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5090
    HPEN hPen = 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5091
    HPEN prevPen;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5092
    LOGBRUSH Brush;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5093
    COLORREF fgColor;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5094
    HANDLE hDC = (HANDLE)(__externalAddressVal(__INST(gcId)));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5095
    int lStyle, bkMode, hMask, maskOrgX, maskOrgY;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5096
    int style, lineStyle, capStyle, joinStyle;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5097
    int lw;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5098
    int BK_TRANSPARENT;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5099
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5100
    BK_TRANSPARENT = 1;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5101
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5102
    lw= __INST(lineWidth);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5103
/*    fgColor = __intVal(__INST(foreground)) & 0xffffff;     */
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5104
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  5105
    fgColor = GetTextColor(hDC);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5106
    lineStyle=__INST(lineStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5107
    capStyle=__INST(capStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5108
    joinStyle=__INST(joinStyle);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5109
    hMask= __INST(mask);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5110
    maskOrgX=__intVal(maskOriginX);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5111
    maskOrgY=__intVal(maskOriginY);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5112
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5113
    if (lineStyle == @symbol(solid)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5114
	style = PS_SOLID;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5115
    } else if (lineStyle == @symbol(dashed)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5116
	style= PS_DASH;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5117
    } else if (lineStyle == @symbol(dotted)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5118
	style= PS_DOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5119
    } else if (lineStyle == @symbol(dashDot)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5120
	style= PS_DASHDOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5121
    } else if (lineStyle == @symbol(dashDotDot)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5122
	style= PS_DASHDOTDOT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5123
    } else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5124
	style= PS_SOLID;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5125
    lStyle &= ~PS_STYLE_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5126
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5127
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5128
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5129
    if (capStyle == @symbol(round)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5130
	style = PS_ENDCAP_ROUND;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5131
    } else if (capStyle == @symbol(square)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5132
	style = PS_ENDCAP_SQUARE;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5133
    } else if (capStyle == @symbol(flat)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5134
	style = PS_ENDCAP_FLAT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5135
    } else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5136
	style = PS_ENDCAP_FLAT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5137
    lStyle &= ~PS_ENDCAP_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5138
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5139
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5140
    if (joinStyle == @symbol(bevel)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5141
	style = PS_JOIN_BEVEL;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5142
    } else if (joinStyle == @symbol(miter)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5143
	style = PS_JOIN_MITER;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5144
    } else if (joinStyle == @symbol(round)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5145
	style = PS_JOIN_ROUND;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5146
    } else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5147
	style = PS_JOIN_MITER;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5148
    lStyle &= ~PS_JOIN_MASK;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5149
    lStyle |= style;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5150
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5151
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5152
    if (((lStyle & PS_STYLE_MASK) == PS_SOLID)
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5153
     && (hMask == 0)
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5154
     && (lw /* lineWidth */ <= 1)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5155
	if (fgColor == 0 /* BlackPixel */ ) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5156
	    hPen = GetStockObject(BLACK_PEN);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5157
	    prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5158
	    RETURN( hPen );
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5159
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5160
	if (fgColor == 1 /* WhitePixel */) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5161
	    hPen = GetStockObject(WHITE_PEN);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5162
	    prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5163
	    RETURN( hPen );
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5164
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5165
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5166
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5167
    hPen = (HPEN) 0;
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5168
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5169
    if (0 /* __isWinNT */) {
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5170
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5171
	if (lw == 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5172
	    lw = 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5173
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5174
	/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5175
	 * NT supports masked drawing with any lineStyle,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5176
	 * and also non-solid lines with any lineWidth.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5177
	 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5178
	if (hMask) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5179
	    Brush.lbStyle = BS_PATTERN;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5180
	    Brush.lbHatch = (DWORD)hMask;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5181
	    Brush.lbColor = fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5182
	} else {
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5183
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5184
#ifndef PRE_07_APR_04
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5185
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5186
	    hPen = CreatePen((lStyle & PS_STYLE_MASK), lw, fgColor);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5187
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5188
/*            RESPRINTF(("CreatePen %x %d(%d) %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5189
 *                       lStyle,
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5190
 *                       lw, __INST(lineWidth),
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5191
 *                       fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5192
 */
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5193
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5194
	    SetBkMode(hDC, TRANSPARENT);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5195
	    bkMode = BK_TRANSPARENT;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5196
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5197
#else
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5198
	    Brush.lbStyle = BS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5199
	    Brush.lbHatch = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5200
	    Brush.lbColor = fgColor;
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5201
#endif
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5202
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5203
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5204
	if (! hPen)
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5205
	{
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5206
	    hPen = ExtCreatePen(PS_GEOMETRIC | lStyle,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5207
			    lw, /* lineWidth, */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5208
			    &Brush,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5209
			    0, 0);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5210
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5211
/*            RESPRINTF(("ExtCreatePen1 %x %d(%d) %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5212
 *                       lStyle,
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5213
 *                       lw, __INST(lineWidth),
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5214
 *                       fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5215
 */
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5216
	    if (hMask) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5217
		SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5218
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5219
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5220
    } else {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5221
	/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5222
	 * W95 only supports masked drawing with SOLID lines
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5223
	 * also, we should use COSMETIC pens if possible
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5224
	 * with non-solid lineStyles.
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5225
	 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5226
	if ((lStyle & PS_STYLE_MASK) == PS_SOLID) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5227
	    int ps = PS_GEOMETRIC;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5228
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5229
	    if (hMask) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5230
		Brush.lbStyle = BS_PATTERN;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5231
		Brush.lbHatch = (DWORD)hMask;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5232
		Brush.lbColor = fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5233
	    } else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5234
		Brush.lbStyle = BS_SOLID;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5235
		Brush.lbHatch = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5236
		Brush.lbColor = fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5237
		if (lw /* lineWidth */ <= 1) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5238
		    ps = PS_COSMETIC;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5239
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5240
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5241
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5242
	    hPen = ExtCreatePen(ps | lStyle,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5243
				lw, /* lineWidth */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5244
				&Brush,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5245
				0, 0);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5246
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5247
/*            RESPRINTF(("ExtCreatePen1 %x %d %x %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5248
 *                           lStyle,
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  5249
 *                           lw,
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5250
 *                           fgColor, hMask));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5251
 */
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5252
	    if (hMask) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5253
		SetBrushOrgEx(hDC, maskOrgX, maskOrgY, 0);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5254
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5255
	} else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5256
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5257
	    if (lw == 1) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5258
		lw = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5259
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5260
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5261
	    /*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5262
	     * dashes only supported with lineWidth 0
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5263
	     */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5264
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5265
	    hPen = CreatePen((lStyle & PS_STYLE_MASK),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5266
			     lw,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5267
			     fgColor);
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5268
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5269
/*            RESPRINTF(("CreatePen %x %d %x\n",
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5270
 *                               (lStyle & PS_STYLE_MASK),
2325
634b74929d2d *** empty log message ***
fm
parents: 2324
diff changeset
  5271
 *                               lw,
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5272
 *                               fgColor));
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5273
 */
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5274
	    //
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5275
	    // CG: wrong; must set to opaque, if doubleDashed
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5276
	    //
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5277
	    SetBkMode(hDC, TRANSPARENT);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5278
	    bkMode = BK_TRANSPARENT;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5279
	}
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5280
    }
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5281
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5282
    prevPen = SelectObject(hDC, hPen);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5283
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5284
    RETURN (hPen);
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5285
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5286
%}
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5287
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5288
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5289
xprimDrawBits:imageBits bitsPerPixel:bitsPerPixel depth:imageDepth padding:padd width:imageWidth height:imageHeight
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5290
				  x:srcx y:srcy
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5291
			       into:ignoredDrawableId
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5292
				  x:dstx y:dsty
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5293
			      width:w height:h
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5294
			       with:aDC
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5295
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5296
    "since XPutImage may allocate huge amount of stack space
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5297
     (some implementations use alloca), this must run with unlimited stack."
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5298
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5299
%{
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5300
    unsigned char fastBits[10000];
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5301
    unsigned char *b_bits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5302
    unsigned char *allocatedBits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5303
    unsigned char *__imageBits = 0;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5304
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5305
    if (__isByteArray(imageBits)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5306
	__imageBits = __ByteArrayInstPtr(imageBits)->ba_element;
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5307
    } else if (__isExternalBytesLike(imageBits)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5308
	__imageBits = (unsigned char *)(__externalBytesAddress(imageBits));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5309
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5310
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5311
    if (/* ISCONNECTED
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5312
     && */  __isExternalAddressLike(aDC)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5313
     && __bothSmallInteger(srcx, srcy)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5314
     && __bothSmallInteger(dstx, dsty)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5315
     && __bothSmallInteger(w, h)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5316
     && __bothSmallInteger(imageWidth, imageHeight)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5317
     && __bothSmallInteger(imageDepth, bitsPerPixel)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5318
     && __isSmallInteger(padd)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5319
     && __imageBits)
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5320
     {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5321
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5322
	struct
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5323
	{
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5324
	  BITMAPINFOHEADER bmiHeader;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5325
	  DWORD r;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5326
	  DWORD g;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5327
	  DWORD b;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5328
	} bitmap;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5329
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5330
	if (__intVal(padd) != WIN32PADDING) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5331
	    int row, col;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5332
	    unsigned char *cp;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5333
	    unsigned char *pBits;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5334
	    int b_width, b_height, bytesPerRowST, bytesPerRowWN, padding, nBytes;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5335
	    int bi = __intVal(bitsPerPixel);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5336
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5337
	    b_width = __intVal(w);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5338
	    b_height = __intVal(h);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5339
	    bytesPerRowST = (b_width * bi + (__intVal(padd)-1)) / __intVal(padd);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5340
	    bytesPerRowWN = (b_width * bi + (WIN32PADDING-1)) / WIN32PADDING * (WIN32PADDING/8);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5341
	    padding = bytesPerRowWN - bytesPerRowST;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5342
	    nBytes = b_height * bytesPerRowWN;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5343
	    /*console_printf("padd %d bs %d bw %d p %d\n",__intVal(padd),bytesPerRowST,bytesPerRowWN,padding);*/
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5344
	    if (padding) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5345
		if (nBytes < sizeof(fastBits)) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5346
		    cp = b_bits = fastBits;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5347
		} else {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5348
		    cp = b_bits = allocatedBits = (unsigned char *) malloc(nBytes);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5349
		}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5350
		if (cp) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5351
		    pBits = __imageBits;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5352
		    for (row = b_height; row; row--) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5353
			for (col = bytesPerRowST; col; col--) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5354
			    *cp++ = *pBits++;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5355
			}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5356
			cp += padding;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5357
		    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5358
		} else
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5359
		    goto fail;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5360
	    }
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5361
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5362
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5363
	if (b_bits == 0) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5364
	    b_bits = __imageBits;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5365
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5366
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5367
	bitmap.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5368
	bitmap.bmiHeader.biPlanes = 1;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5369
	if (__intVal(imageDepth) == 24) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5370
	    /*bitmap.bmiHeader.biCompression = BI_BITFIELDS;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5371
	    bitmap.r = 0xff0000;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5372
	    bitmap.g = 0x00ff00;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5373
	    bitmap.b = 0x0000ff;*/
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5374
	    bitmap.bmiHeader.biCompression = BI_RGB;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5375
	} else if (__intVal(imageDepth) == 16) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5376
	    /*bitmap.bmiHeader.biCompression = BI_RGB;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5377
	    bitmap.bmiHeader.biCompression = BI_BITFIELDS;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5378
	    bitmap.b = 0x001f;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5379
	    bitmap.g = 0x07e0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5380
	    bitmap.r = 0xf800;*/
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5381
	    bitmap.b = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5382
	    bitmap.g = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5383
	    bitmap.r = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5384
	    bitmap.bmiHeader.biCompression = BI_RGB;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5385
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5386
	bitmap.bmiHeader.biSizeImage = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5387
	bitmap.bmiHeader.biXPelsPerMeter = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5388
	bitmap.bmiHeader.biYPelsPerMeter = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5389
	bitmap.bmiHeader.biClrUsed = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5390
	bitmap.bmiHeader.biClrImportant = 0;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5391
	bitmap.bmiHeader.biWidth = __intVal(imageWidth);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5392
	bitmap.bmiHeader.biHeight = -(__intVal(imageHeight));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5393
	bitmap.bmiHeader.biBitCount = __intVal(bitsPerPixel);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5394
	/*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);*/
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5395
	SetDIBitsToDevice(hDC,__intVal(dstx),__intVal(dsty),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5396
			      __intVal(w), __intVal(h),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5397
			      __intVal(srcx), __intVal(srcy),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5398
			      0,__intVal(h),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5399
			      (void *)b_bits,
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5400
			      (BITMAPINFO*)&bitmap,DIB_RGB_COLORS);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5401
	if (allocatedBits) {
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5402
	    free(allocatedBits);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5403
	}
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5404
	RETURN ( true );
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5405
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5406
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5407
fail: ;
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5408
/*
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5409
    PRINTF(("create temp bitmap FAILED!!!\n"));
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5410
*/
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5411
    if (allocatedBits) {
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5412
/*
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5413
	PRINTF(("freeing up temp bitmap bits ...\n"));
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5414
*/
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5415
	free(allocatedBits);
2328
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5416
    }
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5417
%}
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5418
.
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5419
    ^ false
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5420
!
90f481d446bc + displayString supports color
fm
parents: 2327
diff changeset
  5421
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5422
xxxdisplayLineFromX:x0 y:y0 toX:x1 y:y1 in:ignoredDrawableId with:aDC
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5423
    "draw a line. If the coordinates are not integers, an error is triggered."
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5424
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5425
    |penHandle|
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5426
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5427
    penHandle := ExternalBytes address: self getPenForMyContext.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5428
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5429
%{  /* NOCONTEXT */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5430
    if (__isExternalAddressLike(aDC)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5431
     && __isExternalAddressLike(penHandle)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5432
     && __bothSmallInteger(x0, y0)
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5433
     && __bothSmallInteger(x1, y1)) {
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5434
	HANDLE hDC = (HANDLE)(__externalAddressVal(aDC));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5435
	HANDLE hPen = (HANDLE)(__externalAddressVal(penHandle));
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5436
	COLORREF fgColor;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5437
	HANDLE prevPen;
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5438
	int __x1 = __intVal(x1), __y1 = __intVal(y1);
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5439
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5440
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5441
/*      DPRINTF(("displayLine: %d/%d -> %d/%d\n",
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5442
		    __intVal(x0), __intVal(y0),
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5443
		    __x1, __y1));
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5444
*/
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5445
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5446
/*        fgColor = GetTextColor(hDC);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5447
 *        hPen = CreatePen(PS_SOLID, 1, fgColor);
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5448
 */
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5449
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5450
	prevPen = SelectObject(hDC, hPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5451
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5452
	MoveToEx(hDC, __intVal(x0), __intVal(y0), NULL);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5453
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5454
	LineTo(hDC, __x1, __y1);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5455
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5456
	/*
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5457
	 * end-point ...
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5458
	 */
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5459
	LineTo(hDC, __x1+1, __y1);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5460
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5461
	SelectObject(hDC, prevPen);
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5462
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5463
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5464
	RETURN ( self );
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5465
    }
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5466
%}
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5467
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5468
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5469
!WinPrinterContext methodsFor:'printing process'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5470
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5471
endPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5472
    "Informs device that we are finished writing to a page."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5473
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5474
    (OperatingSystem endPage:gcId) > 0 ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5475
	self error
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5476
    ]
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5477
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5478
    "Created: / 27-07-2006 / 18:20:48 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5479
    "Modified: / 01-08-2006 / 16:01:34 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5480
    "Modified: / 10-10-2006 / 18:14:44 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5481
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5482
2315
026d4d8cfb1b changed #endPrintJob
fm
parents: 2313
diff changeset
  5483
endPrintJobWithoutRelease
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5484
    "End the print job.  Everything drawn between startPrintJob
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5485
     and endPrintJob will become one entry in the print queue."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5486
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5487
    |result|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5488
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5489
    self endPage.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5490
    result := OperatingSystem endDoc:gcId.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5491
    jobid := nil.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5492
    result >= 0 ifFalse:[ self error ]
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5493
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5494
    "Created: / 27-07-2006 / 18:21:04 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5495
    "Modified: / 01-08-2006 / 16:01:38 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5496
    "Modified: / 10-10-2006 / 18:50:43 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5497
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5498
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5499
getSupportsColor
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5500
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5501
    | retVal info |
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5502
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5503
    info := (self class getPrinterInformationString: self name) asUppercase.
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5504
    (info includesSubString: ',PSCRIPT,')
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5505
        ifTrue: [
2348
ab36aad361f6 supportsColor
fm
parents: 2347
diff changeset
  5506
            retVal := self class postScriptBlackWhite not.
2347
e5b1c5c1ad88 supportsColor
fm
parents: 2344
diff changeset
  5507
"/            retVal := (DAPASX::DapasSystemInfo getYesNoInfoApp: 'Printer' profile: 'PostScriptBlackWhite') not.
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5508
        ]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5509
        ifFalse: [
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5510
            retVal := (info includesSubString: 'PDF')
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5511
                ifTrue: [true]
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5512
                ifFalse: [self numberOfColorBitsPerPixel > 1].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5513
    ].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5514
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5515
    ^retVal
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5516
!
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5517
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5518
startPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5519
    "Starts a page."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5520
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5521
    (OperatingSystem startPage:gcId) > 0 ifFalse:[
2344
507334e9746f 24 and 32 bits support
fm
parents: 2343
diff changeset
  5522
	^ self error
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5523
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5524
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5525
    "Created: / 27-07-2006 / 18:25:55 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5526
    "Modified: / 28-07-2006 / 18:19:04 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5527
    "Modified: / 10-10-2006 / 18:19:02 / cg"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5528
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5529
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5530
startPrintJob:aString fileName:aFileName
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5531
    "Start a print job, using aString as the job title; everything
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5532
     drawn between startPrintJob and endPrintJob will become
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5533
     one entry in the print queue."
2317
c9bf3bf3c014 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2316
diff changeset
  5534
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5535
    |docInfoStruct nameAddress title fileNameAddress|
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5536
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5537
    gcId isNil ifTrue:[
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5538
        self buildPrinter
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5539
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5540
    abort := false.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5541
    title := aString ? 'Smalltalk/X'.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5542
    nameAddress := title asExternalBytes unprotectFromGC.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5543
    aFileName isNil ifFalse:[
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5544
        fileNameAddress := aFileName pathName asExternalBytes unprotectFromGC
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5545
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5546
    docInfoStruct := Win32OperatingSystem::DocInfoStructure new.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5547
    docInfoStruct
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5548
        cbSize:docInfoStruct sizeInBytes;
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5549
        lpszDocName:nameAddress address.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5550
    fileNameAddress isNil ifFalse:[
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5551
        docInfoStruct lpszOutput:fileNameAddress address
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5552
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5553
    jobid := OperatingSystem startDoc:gcId docInfo:docInfoStruct.
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5554
    jobid > 0 ifFalse:[
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5555
        jobid = -1 ifTrue:[
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5556
            abort := true.
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5557
            ^ nil
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5558
        ].
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5559
"/        ^ self error
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5560
        OpenError raiseErrorString:'Cannot create printer job'.
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5561
    ].
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5562
    self startPage
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5563
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5564
    "Created: / 27-07-2006 / 18:19:31 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5565
    "Modified: / 03-08-2006 / 15:11:19 / fm"
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5566
    "Modified: / 10-10-2006 / 18:20:01 / cg"
2905
303bf86fa4bb changed: #startPrintJob:fileName:
sr
parents: 2852
diff changeset
  5567
    "Modified: / 07-04-2011 / 12:03:50 / sr"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5568
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5569
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5570
!WinPrinterContext methodsFor:'queries'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5571
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5572
hasGrayscales
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5573
    "return true, if this workstation supports grayscales
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5574
     (also true for color displays)"
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5575
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5576
    ^ true
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5577
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5578
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5579
isOpen
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5580
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5581
    ^ gcId notNil
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5582
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5583
2324
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5584
isPersistentInSnapshot
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5585
    "return true, if resources on this device are to be made
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5586
     persistent in a snapshot image."
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5587
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5588
    ^ false
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5589
!
5065edb4f5bd *** empty log message ***
fm
parents: 2323
diff changeset
  5590
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5591
supportsColor
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5592
2330
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5593
    supportsColor isNil ifTrue:[supportsColor := self getSupportsColor].
5f3b78d00a18 fill with hatch brush
fm
parents: 2329
diff changeset
  5594
    ^supportsColor
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5595
!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5596
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5597
supportsGraphics
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  5598
    ^(OperatingSystem getDeviceCaps: gcId index: 2 "Technology") ~= 4
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5599
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5600
    "Created: / 03-08-2006 / 10:07:43 / fm"
2301
135f21a3d127 refactorred OS-independent stuff
Claus Gittinger <cg@exept.de>
parents: 2299
diff changeset
  5601
    "Modified: / 16-04-2007 / 12:44:03 / cg"
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5602
! !
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  5603
2323
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5604
!WinPrinterContext methodsFor:'registration'!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5605
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5606
registerFont:aFont
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5607
    deviceFonts register:aFont.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5608
!
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5609
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5610
unregisterFont:aFont
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5611
    deviceFonts unregister:aFont.
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5612
! !
c038faba10bf printing in context (without device)
fm
parents: 2317
diff changeset
  5613
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5614
!WinPrinterContext::WinPrinterGraphicContext class methodsFor:'documentation'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5615
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5616
documentation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5617
"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5618
    The class is simular to the PSGraphicsContext. It implements a
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5619
    'what you see is what you get' interface - all is scaled dependent
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5620
    on the current screen resolution
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5621
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5622
    supports margin, clipping ...
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5623
"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5624
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5625
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5626
examples
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5627
"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5628
                                                                                [exBegin]
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5629
    |gc font|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5630
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5631
    gc := WinPrinterContext openGraphicContext.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5632
    gc isNil ifTrue:[^ self ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5633
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5634
    [
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5635
        gc startPrintJob:'Test'.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5636
        gc paint:(Color black).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5637
        gc displayLineFromX:10 y:40 toX:100 y:40.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5638
        font := (Font family:'helvetica' face:'roman' style:'bold' size:16) onDevice:(gc device).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5639
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5640
        gc font:font.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5641
        gc paint:(Color red).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5642
        gc displayString:'hallo' x:10 y:(40 + font ascent).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5643
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5644
        gc paint:(Color black).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5645
        gc displayLineFromX:10 y:(40 + font height) toX:100 y:(40 + font height).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5646
    ] ensure:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5647
        gc close.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5648
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5649
                                                                                [exEnd]
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5650
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5651
"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5652
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5653
2353
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5654
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing dimensions'!
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5655
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5656
bottomMargin
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5657
    "return the papers bottom margin measured in pixels"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5658
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5659
    ^ 50
2353
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5660
!
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5661
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5662
leftMargin
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5663
    "return the papers left margin measured in pixels"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5664
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5665
    ^ 50
2353
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5666
!
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5667
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5668
rightMargin
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5669
    "return the papers right margin measured in pixels"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5670
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5671
    ^ 50
2353
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5672
!
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5673
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5674
topMargin
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5675
    "return the papers top margin measured in pixels"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5676
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5677
    ^ 50
2353
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5678
! !
d8d1a7094c63 margins - added but not yet supported
ca
parents: 2352
diff changeset
  5679
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5680
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing-hooks'!
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5681
2357
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5682
pageCounter
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5683
    "answer the current page number"
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5684
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5685
    pageCounter ~~ 0 ifTrue:[^ pageCounter].
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5686
    ^ 1
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5687
!
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5688
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5689
pageNumberFormat:aFormatString
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5690
    "set the pageNumber format - the default is 'page %1'"
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5691
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5692
    pageNumberFormat := aFormatString ? ''
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5693
!
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5694
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5695
printPageNumbers:aBoolean
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5696
    "enable/disable printing of page numbers - the default is on"
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5697
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5698
    printPageNumbers := aBoolean.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5699
! !
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5700
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5701
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'accessing-transformation'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5702
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5703
clippingRectangle:aRectangle
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5704
    |tranlate extent lft rgt top bot|
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5705
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5706
    tranlate := self translation negated asPoint.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5707
    extent   := self extent.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5708
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5709
    lft := tranlate x.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5710
    top := tranlate y.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5711
    rgt := lft + extent x.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5712
    bot := top + extent y.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5713
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5714
    aRectangle notNil ifTrue:[
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5715
        lft := lft max:aRectangle left.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5716
        top := top max:aRectangle top.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5717
        rgt := rgt min:aRectangle right.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5718
        bot := bot min:aRectangle bottom.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5719
    ].
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5720
    super clippingRectangle:(Rectangle left:lft top:top right:rgt bottom:bot).
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5721
!
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5722
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5723
scale
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5724
    "answer the scale excluding the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5725
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5726
    ^ super scale / fontScale
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5727
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5728
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5729
scale:aScale
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5730
    "set the scale and add the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5731
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5732
    super scale:(fontScale * (aScale ? 1.0)).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5733
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5734
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5735
transformation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5736
    "answer the transformation excluding the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5737
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5738
    ^ WindowingTransformation scale:(self scale)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5739
                        translation:(self translation).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5740
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5741
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5742
transformation:aTransformation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5743
    "set the transformation and add the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5744
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5745
    |s t|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5746
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5747
    aTransformation notNil ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5748
        s := aTransformation scale.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5749
        t := aTransformation translation.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5750
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5751
    self scale:s.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5752
    self translation:t.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5753
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5754
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5755
translateBy:aTranslation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5756
    "set the translation and add the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5757
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5758
    aTranslation isNil ifTrue:[^ self].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5759
    self translation:( self translation + (self scale * aTranslation)).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5760
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5761
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5762
translation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5763
    "answer the translation excluding the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5764
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5765
    |margin trans|
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5766
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5767
    margin := Point x:(self leftMargin) y:(self topMargin).
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5768
    trans  := (super translation / fontScale) rounded.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5769
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5770
    ^ trans - margin
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5771
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5772
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5773
translation:aTranslation
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5774
    "set the translation and add the fontScale factor"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5775
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5776
    |trans|
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5777
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5778
    trans := Point x:(self leftMargin) y:(self topMargin).
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5779
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5780
    aTranslation notNil ifTrue:[
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5781
        trans := trans + aTranslation.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5782
    ].
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5783
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5784
    super translation:((trans * fontScale) rounded).
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5785
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5786
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5787
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'drawing strings'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5788
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5789
displayOpaqueString:aString from:index1 to:index2 x:x y:y
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5790
    self displayString:aString from:index1 to:index2 x:x y:y.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5791
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5792
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5793
displayOpaqueString:aString x:x y:y
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5794
    |end|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5795
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5796
    end := aString size.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5797
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5798
    end ~~ 0 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5799
        self displayOpaqueString:aString from:1 to:end x:x y:y.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5800
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5801
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5802
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5803
displayString:aString from:index1 to:index2 x:x y:y
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5804
    "setup the special scale for strings before drawing"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5805
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5806
    |tscale fscale yFont xFont|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5807
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5808
    index2 < index1 ifTrue:[^ self].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5809
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5810
    transformation isNil ifTrue:[
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5811
        self initTransformation.
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5812
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5813
    tscale := transformation scale.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5814
    fscale := tscale / fontScale.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5815
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5816
    xFont := x * fontScale x.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5817
    yFont := (y - font ascent) * fontScale y.    "/ MM_TEXT - Ursprung liegt oben links
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5818
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5819
    transformation scale:fscale.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5820
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5821
    super displayString:aString from:index1 to:index2
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5822
                x:xFont truncated
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5823
                y:yFont truncated.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5824
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5825
    transformation scale:tscale.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5826
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5827
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5828
displayString:aString x:x y:y
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5829
    |end|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5830
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5831
    end := aString size.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5832
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5833
    end ~~ 0 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5834
        self displayString:aString from:1 to:end x:x y:y.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5835
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5836
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5837
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5838
displayString:aString x:x y:y angle:drawAngle opaque:opaque
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5839
    "angles other than 0 is not yet supported"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5840
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5841
    |angle|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5842
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5843
    angle := drawAngle.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5844
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5845
    angle >= 360 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5846
        angle := angle - (((angle // 360)) * 360)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5847
    ] ifFalse:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5848
        angle < 0 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5849
            angle := angle - (((angle // 360)) * 360).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5850
            angle := angle + 360.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5851
            angle >= 360 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5852
                angle := angle - (((angle // 360)) * 360)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5853
            ]
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5854
        ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5855
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5856
    angle == 0 ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5857
        super displayString:aString x:x y:y angle:drawAngle opaque:opaque.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5858
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5859
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5860
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5861
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'font stuff'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5862
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5863
fontMetricsOf:fontId
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5864
    "after retrieving the metrics, we have to scale the information"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5865
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5866
    |metrics|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5867
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5868
    metrics := super fontMetricsOf:fontId.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5869
    metrics isNil ifTrue:[^ nil ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5870
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5871
    metrics ascent:((metrics ascent / fontScale y) rounded)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5872
            descent:((metrics descent / fontScale y) rounded + 1)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5873
            maxAscent:((metrics maxAscent / fontScale y) rounded)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5874
            maxDescent:((metrics maxDescent / fontScale y) rounded + 1)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5875
            minWidth:((metrics minWidth / fontScale x) rounded)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5876
            maxWidth:((metrics maxWidth / fontScale x) rounded)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5877
            avgWidth:((metrics averageWidth / fontScale x) rounded).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5878
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5879
    ^ metrics
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5880
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5881
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5882
getFontWithFoundry:foundry family:family weight:weight
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5883
              slant:slant spacing:spc pixelSize:pixelSize size:pointSize
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5884
              registry:registry encoding:encoding
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5885
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5886
    "compute the pixels dependent on the Screen current resolution"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5887
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5888
    |psize|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5889
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5890
    psize := pixelSize.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5891
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5892
    psize isNil ifTrue:[ 
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5893
        psize := (pointSize * (self getLogicalPixelSizeY) / (Screen current getLogicalPixelSizeY)) rounded.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5894
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5895
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5896
    ^ super getFontWithFoundry:foundry family:family weight:weight
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5897
              slant:slant spacing:spc pixelSize:psize size:pointSize
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5898
              registry:registry encoding:encoding
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5899
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5900
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5901
titleFont
2357
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5902
    "answer the font used for displaying page numbers..."
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5903
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5904
    titleFont isNil ifTrue:[
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5905
        titleFont := Font family:'helvetica' face:'medium' style:'roman' size:10.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5906
        titleFont := titleFont onDevice:(self device).
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5907
    ].
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5908
    ^ titleFont
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5909
!
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5910
2357
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5911
titleFont:aFont
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5912
    "set the font used for displaying page numbers..."
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5913
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5914
    (aFont notNil and:[aFont ~= titleFont]) ifTrue:[
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5915
        titleFont := aFont onDevice:(self device).
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5916
    ].
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5917
!
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5918
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5919
widthOf:aString from:index1 to:index2 inFont:aFontId
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5920
    "after retrieving the width, we have to scale the width"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5921
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5922
    |w|
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5923
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5924
    w := super widthOf:aString from:index1 to:index2 inFont:aFontId.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5925
    w := (w / fontScale x) rounded.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5926
    ^ w
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5927
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5928
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5929
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'initialization & release'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5930
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5931
close
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5932
    "compatible with PSGraphicsContext"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5933
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5934
    self endPrintJob.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5935
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5936
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5937
initExtent
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5938
    "scale the extent"
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5939
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5940
    fontScale := self resolution / Screen current resolution.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5941
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5942
    width  := (self printerWidthArea / fontScale x) rounded.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5943
    width  := width - self leftMargin - self rightMargin.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5944
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5945
    height := (self printerHeightArea / fontScale y) rounded.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5946
    height := height - self topMargin - self bottomMargin.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5947
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5948
    self initTransformation.
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5949
!
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5950
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5951
initTransformation
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5952
    |margin|
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5953
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5954
    transformation isNil ifTrue:[
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5955
        margin := Point x:(self leftMargin) y:(self topMargin).
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5956
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5957
        transformation := WindowingTransformation scale:fontScale
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5958
                                            translation:(margin * fontScale).
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5959
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5960
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5961
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5962
initialize
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5963
    super initialize.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5964
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5965
    pageCounter    := 0.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5966
    needsEndOfPage := false.
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5967
    printPageNumbers := true.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5968
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5969
    Language == #de ifTrue:[ pageNumberFormat := 'Seite %1' ]
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5970
                   ifFalse:[ pageNumberFormat := 'page %1'  ].
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5971
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5972
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5973
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'printing process'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5974
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5975
displayTitleDo:aNoneArgAction
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5976
    
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5977
    |oldClip oldTrans oldFont|
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5978
2357
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5979
    oldClip := clipRect.
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5980
    oldClip notNil ifTrue:[ self deviceClippingRectangle:nil ].
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5981
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5982
    oldTrans := self translation.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5983
    oldFont  := font.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5984
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5985
    self  font:(self titleFont).
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5986
    self  translation:0.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5987
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5988
    aNoneArgAction value.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5989
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5990
    self translation:oldTrans.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5991
    oldFont notNil ifTrue:[ self font:oldFont ].
2357
918859a27b27 accessing pageCounter and titleFont used for pageNumbers...
ca
parents: 2356
diff changeset
  5992
    oldClip notNil ifTrue:[ self deviceClippingRectangle:oldClip ].
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5993
!
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5994
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  5995
endPage
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5996
    "ends the current page
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5997
     if the current page is already closed by endPage, the request will be ignored"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  5998
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  5999
    |s|
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6000
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6001
    needsEndOfPage ifFalse:[
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6002
        ^ self
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6003
    ].
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6004
    needsEndOfPage := false.
2356
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6005
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6006
    printPageNumbers == true ifTrue:[
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6007
        self displayTitleDo:[
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6008
            s := pageNumberFormat bindWith:pageCounter.
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6009
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6010
            self displayString:s
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6011
                             x:(self extent x - (font widthOf:s))
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6012
                             y:(self extent y + (font ascent)).
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6013
        ]
a4128a41b721 support printPageNumbers pageNumberFormat
ca
parents: 2354
diff changeset
  6014
    ].
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6015
    super endPage.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6016
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6017
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6018
startPage
2354
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  6019
    "starts a new page
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  6020
     if the current page is not closed by endPage, a endPage is forward to the device"
8bfd1f8d2e08 support margins
ca
parents: 2353
diff changeset
  6021
2351
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6022
    needsEndOfPage ifTrue:[
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6023
        self endPage.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6024
    ].
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6025
    super startPage.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6026
    needsEndOfPage := true.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6027
    pageCounter := pageCounter + 1.
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6028
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6029
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6030
!WinPrinterContext::WinPrinterGraphicContext methodsFor:'queries'!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6031
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6032
pixelPerInch
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6033
    ^ Point x:(self pixelsPerInchOfScreenWidth)
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6034
            y:(self pixelsPerInchOfScreenHeight).
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6035
!
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6036
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6037
resolution
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6038
    ^ self pixelPerInch
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6039
! !
4b133b41221a what you see is w3hat you get...
ca
parents: 2348
diff changeset
  6040
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6041
!WinPrinterContext class methodsFor:'documentation'!
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6042
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6043
version
3002
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  6044
    ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.42 2012-04-25 19:46:59 stefan Exp $'
2818
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  6045
!
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  6046
37b97e4ebb01 Use __isArrayLike() and __isByteArrayLike()
Stefan Vogel <sv@exept.de>
parents: 2621
diff changeset
  6047
version_CVS
3002
a6acab3dbdea added: #getDefaultFontWithEncoding:
Stefan Vogel <sv@exept.de>
parents: 2905
diff changeset
  6048
    ^ '$Header: /cvs/stx/stx/libview2/WinPrinterContext.st,v 1.42 2012-04-25 19:46:59 stefan Exp $'
2299
b0576a106d03 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  6049
! !