| 1 |
/* Tera Term
|
| 2 |
Copyright(C) 1994-1998 T. Teranishi
|
| 3 |
All rights reserved. */
|
| 4 |
|
| 5 |
/* TERATERM.EXE, VT terminal display routines */
|
| 6 |
#include "teraterm.h"
|
| 7 |
#include "tttypes.h"
|
| 8 |
#include "string.h"
|
| 9 |
|
| 10 |
#include "ttwinman.h"
|
| 11 |
#include "ttime.h"
|
| 12 |
#include "ttdialog.h"
|
| 13 |
#include "ttcommon.h"
|
| 14 |
|
| 15 |
#include "vtdisp.h"
|
| 16 |
|
| 17 |
#include <locale.h>
|
| 18 |
|
| 19 |
#define CurWidth 2
|
| 20 |
|
| 21 |
int WinWidth, WinHeight;
|
| 22 |
static BOOL Active = FALSE;
|
| 23 |
static BOOL CompletelyVisible;
|
| 24 |
HFONT VTFont[AttrFontMask+1];
|
| 25 |
int FontHeight, FontWidth, ScreenWidth, ScreenHeight;
|
| 26 |
BOOL AdjustSize;
|
| 27 |
BOOL DontChangeSize=FALSE;
|
| 28 |
#ifdef ALPHABLEND_TYPE2
|
| 29 |
static int CRTWidth, CRTHeight;
|
| 30 |
#endif
|
| 31 |
int CursorX, CursorY;
|
| 32 |
/* Virtual screen region */
|
| 33 |
RECT VirtualScreen;
|
| 34 |
|
| 35 |
// --- scrolling status flags
|
| 36 |
int WinOrgX, WinOrgY, NewOrgX, NewOrgY;
|
| 37 |
|
| 38 |
int NumOfLines, NumOfColumns;
|
| 39 |
int PageStart, BuffEnd;
|
| 40 |
|
| 41 |
static BOOL CursorOnDBCS = FALSE;
|
| 42 |
static LOGFONT VTlf;
|
| 43 |
static BOOL SaveWinSize = FALSE;
|
| 44 |
static int WinWidthOld, WinHeightOld;
|
| 45 |
static HBRUSH Background;
|
| 46 |
static COLORREF ANSIColor[256];
|
| 47 |
static int Dx[256];
|
| 48 |
|
| 49 |
// caret variables
|
| 50 |
static int CaretStatus;
|
| 51 |
static BOOL CaretEnabled = TRUE;
|
| 52 |
|
| 53 |
// ---- device context and status flags
|
| 54 |
static HDC VTDC = NULL; /* Device context for VT window */
|
| 55 |
static TCharAttr DCAttr;
|
| 56 |
static TCharAttr CurCharAttr;
|
| 57 |
static BOOL DCReverse;
|
| 58 |
static HFONT DCPrevFont;
|
| 59 |
|
| 60 |
TCharAttr DefCharAttr = {
|
| 61 |
AttrDefault,
|
| 62 |
AttrDefault,
|
| 63 |
AttrDefaultFG,
|
| 64 |
AttrDefaultBG
|
| 65 |
};
|
| 66 |
|
| 67 |
// scrolling
|
| 68 |
static int ScrollCount = 0;
|
| 69 |
static int dScroll = 0;
|
| 70 |
static int SRegionTop;
|
| 71 |
static int SRegionBottom;
|
| 72 |
|
| 73 |
#ifdef ALPHABLEND_TYPE2
|
| 74 |
//<!--by AKASI
|
| 75 |
#include "ttlib.h"
|
| 76 |
#include <stdio.h>
|
| 77 |
#include <time.h>
|
| 78 |
|
| 79 |
#define BG_SECTION "BG"
|
| 80 |
|
| 81 |
typedef enum _BG_TYPE {BG_COLOR = 0,BG_PICTURE,BG_WALLPAPER} BG_TYPE;
|
| 82 |
typedef enum _BG_PATTERN {BG_STRETCH = 0,BG_TILE,BG_CENTER,BG_FIT_WIDTH,BG_FIT_HEIGHT,BG_AUTOFIT} BG_PATTERN;
|
| 83 |
|
| 84 |
typedef struct _BGSrc
|
| 85 |
{
|
| 86 |
HDC hdc;
|
| 87 |
BG_TYPE type;
|
| 88 |
BG_PATTERN pattern;
|
| 89 |
BOOL antiAlias;
|
| 90 |
COLORREF color;
|
| 91 |
int alpha;
|
| 92 |
int width;
|
| 93 |
int height;
|
| 94 |
char file[MAX_PATH];
|
| 95 |
char fileTmp[MAX_PATH];
|
| 96 |
}BGSrc;
|
| 97 |
|
| 98 |
BGSrc BGDest;
|
| 99 |
BGSrc BGSrc1;
|
| 100 |
BGSrc BGSrc2;
|
| 101 |
|
| 102 |
int BGEnable;
|
| 103 |
int BGReverseTextAlpha;
|
| 104 |
int BGUseAlphaBlendAPI;
|
| 105 |
BOOL BGNoFrame;
|
| 106 |
BOOL BGFastSizeMove;
|
| 107 |
|
| 108 |
char BGSPIPath[MAX_PATH];
|
| 109 |
|
| 110 |
COLORREF BGVTColor[2];
|
| 111 |
COLORREF BGVTBoldColor[2];
|
| 112 |
COLORREF BGVTBlinkColor[2];
|
| 113 |
COLORREF BGVTReverseColor[2];
|
| 114 |
/* begin - ishizaki */
|
| 115 |
COLORREF BGURLColor[2];
|
| 116 |
/* end - ishizaki */
|
| 117 |
|
| 118 |
RECT BGPrevRect;
|
| 119 |
BOOL BGReverseText;
|
| 120 |
|
| 121 |
BOOL BGNoCopyBits;
|
| 122 |
BOOL BGInSizeMove;
|
| 123 |
HBRUSH BGBrushInSizeMove;
|
| 124 |
|
| 125 |
HDC hdcBGWork;
|
| 126 |
HDC hdcBGBuffer;
|
| 127 |
HDC hdcBG;
|
| 128 |
|
| 129 |
typedef struct tagWallpaperInfo
|
| 130 |
{
|
| 131 |
char filename[MAX_PATH];
|
| 132 |
int pattern;
|
| 133 |
}WallpaperInfo;
|
| 134 |
|
| 135 |
typedef struct _BGBLENDFUNCTION
|
| 136 |
{
|
| 137 |
BYTE BlendOp;
|
| 138 |
BYTE BlendFlags;
|
| 139 |
BYTE SourceConstantAlpha;
|
| 140 |
BYTE AlphaFormat;
|
| 141 |
}BGBLENDFUNCTION;
|
| 142 |
|
| 143 |
BOOL (FAR WINAPI *BGAlphaBlend)(HDC,int,int,int,int,HDC,int,int,int,int,BGBLENDFUNCTION);
|
| 144 |
BOOL (FAR WINAPI *BGEnumDisplayMonitors)(HDC,LPCRECT,MONITORENUMPROC,LPARAM);
|
| 145 |
|
| 146 |
|
| 147 |
//便利関数☆
|
| 148 |
|
| 149 |
void dprintf(char *format, ...)
|
| 150 |
{
|
| 151 |
va_list args;
|
| 152 |
char buffer[1024];
|
| 153 |
|
| 154 |
va_start(args,format);
|
| 155 |
|
| 156 |
_vsnprintf_s(buffer,sizeof(buffer),_TRUNCATE,format,args);
|
| 157 |
strncat_s(buffer,sizeof(buffer),"\n",_TRUNCATE);
|
| 158 |
|
| 159 |
OutputDebugString(buffer);
|
| 160 |
}
|
| 161 |
|
| 162 |
HBITMAP CreateScreenCompatibleBitmap(int width,int height)
|
| 163 |
{
|
| 164 |
HDC hdc;
|
| 165 |
HBITMAP hbm;
|
| 166 |
|
| 167 |
#ifdef _DEBUG
|
| 168 |
dprintf("CreateScreenCompatibleBitmap : width = %d height = %d",width,height);
|
| 169 |
#endif
|
| 170 |
|
| 171 |
hdc = GetDC(NULL);
|
| 172 |
|
| 173 |
hbm = CreateCompatibleBitmap(hdc,width,height);
|
| 174 |
|
| 175 |
ReleaseDC(NULL,hdc);
|
| 176 |
|
| 177 |
#ifdef _DEBUG
|
| 178 |
if(!hbm)
|
| 179 |
dprintf("CreateScreenCompatibleBitmap : fail in CreateCompatibleBitmap");
|
| 180 |
#endif
|
| 181 |
|
| 182 |
return hbm;
|
| 183 |
}
|
| 184 |
|
| 185 |
HBITMAP CreateDIB24BPP(int width,int height,unsigned char **buf,int *lenBuf)
|
| 186 |
{
|
| 187 |
HDC hdc;
|
| 188 |
HBITMAP hbm;
|
| 189 |
BITMAPINFO bmi;
|
| 190 |
|
| 191 |
#ifdef _DEBUG
|
| 192 |
dprintf("CreateDIB24BPP : width = %d height = %d",width,height);
|
| 193 |
#endif
|
| 194 |
|
| 195 |
if(!width || !height)
|
| 196 |
return NULL;
|
| 197 |
|
| 198 |
ZeroMemory(&bmi,sizeof(bmi));
|
| 199 |
|
| 200 |
*lenBuf = ((width * 3 + 3) & ~3) * height;
|
| 201 |
|
| 202 |
bmi.bmiHeader.biSize = sizeof(bmi.bmiHeader);
|
| 203 |
bmi.bmiHeader.biWidth = width;
|
| 204 |
bmi.bmiHeader.biHeight = height;
|
| 205 |
bmi.bmiHeader.biPlanes = 1;
|
| 206 |
bmi.bmiHeader.biBitCount = 24;
|
| 207 |
bmi.bmiHeader.biSizeImage = *lenBuf;
|
| 208 |
bmi.bmiHeader.biCompression = BI_RGB;
|
| 209 |
|
| 210 |
hdc = GetDC(NULL);
|
| 211 |
|
| 212 |
hbm = CreateDIBSection(hdc,&bmi,DIB_RGB_COLORS,(void**)buf,NULL,0);
|
| 213 |
|
| 214 |
ReleaseDC(NULL,hdc);
|
| 215 |
|
| 216 |
return hbm;
|
| 217 |
}
|
| 218 |
|
| 219 |
HDC CreateBitmapDC(HBITMAP hbm)
|
| 220 |
{
|
| 221 |
HDC hdc;
|
| 222 |
|
| 223 |
#ifdef _DEBUG
|
| 224 |
dprintf("CreateBitmapDC : hbm = %x",hbm);
|
| 225 |
#endif
|
| 226 |
|
| 227 |
hdc = CreateCompatibleDC(NULL);
|
| 228 |
|
| 229 |
SaveDC(hdc);
|
| 230 |
SelectObject(hdc,hbm);
|
| 231 |
|
| 232 |
return hdc;
|
| 233 |
}
|
| 234 |
|
| 235 |
void DeleteBitmapDC(HDC *hdc)
|
| 236 |
{
|
| 237 |
HBITMAP hbm;
|
| 238 |
|
| 239 |
#ifdef _DEBUG
|
| 240 |
dprintf("DeleteBitmapDC : *hdc = %x",hdc);
|
| 241 |
#endif
|
| 242 |
|
| 243 |
if(!hdc)
|
| 244 |
return;
|
| 245 |
|
| 246 |
if(!(*hdc))
|
| 247 |
return;
|
| 248 |
|
| 249 |
hbm = GetCurrentObject(*hdc,OBJ_BITMAP);
|
| 250 |
|
| 251 |
RestoreDC(*hdc,-1);
|
| 252 |
DeleteObject(hbm);
|
| 253 |
DeleteDC(*hdc);
|
| 254 |
|
| 255 |
*hdc = 0;
|
| 256 |
}
|
| 257 |
|
| 258 |
void FillBitmapDC(HDC hdc,COLORREF color)
|
| 259 |
{
|
| 260 |
HBITMAP hbm;
|
| 261 |
BITMAP bm;
|
| 262 |
RECT rect;
|
| 263 |
HBRUSH hBrush;
|
| 264 |
|
| 265 |
#ifdef _DEBUG
|
| 266 |
dprintf("FillBitmapDC : hdc = %x color = %x",hdc,color);
|
| 267 |
#endif
|
| 268 |
|
| 269 |
if(!hdc)
|
| 270 |
return;
|
| 271 |
|
| 272 |
hbm = GetCurrentObject(hdc,OBJ_BITMAP);
|
| 273 |
GetObject(hbm,sizeof(bm),&bm);
|
| 274 |
|
| 275 |
SetRect(&rect,0,0,bm.bmWidth,bm.bmHeight);
|
| 276 |
hBrush = CreateSolidBrush(color);
|
| 277 |
FillRect(hdc,&rect,hBrush);
|
| 278 |
DeleteObject(hBrush);
|
| 279 |
}
|
| 280 |
|
| 281 |
FARPROC GetProcAddressWithDllName(char *dllName,char *procName)
|
| 282 |
{
|
| 283 |
HINSTANCE hDll;
|
| 284 |
|
| 285 |
hDll = LoadLibrary(dllName);
|
| 286 |
|
| 287 |
if(hDll)
|
| 288 |
return GetProcAddress(hDll,procName);
|
| 289 |
else
|
| 290 |
return 0;
|
| 291 |
}
|
| 292 |
|
| 293 |
void RandomFile(char *filespec,char *filename, int destlen)
|
| 294 |
{
|
| 295 |
int i;
|
| 296 |
int file_num;
|
| 297 |
char fullpath[MAX_PATH];
|
| 298 |
char *filePart;
|
| 299 |
|
| 300 |
HANDLE hFind;
|
| 301 |
WIN32_FIND_DATA fd;
|
| 302 |
|
| 303 |
//絶対パスに変換
|
| 304 |
if(!GetFullPathName(filespec,MAX_PATH,fullpath,&filePart))
|
| 305 |
return;
|
| 306 |
|
| 307 |
//ファイルを数える
|
| 308 |
hFind = FindFirstFile(fullpath,&fd);
|
| 309 |
|
| 310 |
file_num = 0;
|
| 311 |
|
| 312 |
if(hFind != INVALID_HANDLE_VALUE && filePart)
|
| 313 |
{
|
| 314 |
|
| 315 |
do{
|
| 316 |
|
| 317 |
if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
| 318 |
file_num ++;
|
| 319 |
|
| 320 |
}while(FindNextFile(hFind,&fd));
|
| 321 |
|
| 322 |
}
|
| 323 |
|
| 324 |
if(!file_num)
|
| 325 |
return;
|
| 326 |
|
| 327 |
FindClose(hFind);
|
| 328 |
|
| 329 |
//何番目のファイルにするか決める。
|
| 330 |
file_num = rand()%file_num + 1;
|
| 331 |
|
| 332 |
hFind = FindFirstFile(fullpath,&fd);
|
| 333 |
|
| 334 |
if(hFind != INVALID_HANDLE_VALUE)
|
| 335 |
{
|
| 336 |
i = 0;
|
| 337 |
|
| 338 |
do{
|
| 339 |
|
| 340 |
if(!(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
|
| 341 |
i ++;
|
| 342 |
|
| 343 |
}while(i < file_num && FindNextFile(hFind,&fd));
|
| 344 |
|
| 345 |
}else{
|
| 346 |
return;
|
| 347 |
}
|
| 348 |
|
| 349 |
FindClose(hFind);
|
| 350 |
|
| 351 |
//ディレクトリ取得
|
| 352 |
ZeroMemory(filename,destlen);
|
| 353 |
{
|
| 354 |
int tmplen;
|
| 355 |
char *tmp;
|
| 356 |
tmplen = filePart - fullpath + 1;
|
| 357 |
tmp = (char *)_alloca(tmplen);
|
| 358 |
strncpy_s(tmp,tmplen,fullpath,filePart - fullpath);
|
| 359 |
strncpy_s(filename,destlen,tmp,_TRUNCATE);
|
| 360 |
}
|
| 361 |
strncat_s(filename,destlen,fd.cFileName,_TRUNCATE);
|
| 362 |
}
|
| 363 |
|
| 364 |
BOOL LoadPictureWithSPI(char *nameSPI,char *nameFile,unsigned char *bufFile,long sizeFile,HLOCAL *hbuf,HLOCAL *hbmi)
|
| 365 |
{
|
| 366 |
HINSTANCE hSPI;
|
| 367 |
char spiVersion[8];
|
| 368 |
int (FAR PASCAL *SPI_IsSupported)(LPSTR,DWORD);
|
| 369 |
int (FAR PASCAL *SPI_GetPicture)(LPSTR,long,unsigned int,HANDLE *,HANDLE *,FARPROC,long);
|
| 370 |
int (FAR PASCAL *SPI_GetPluginInfo)(int,LPSTR,int);
|
| 371 |
int ret;
|
| 372 |
|
| 373 |
ret = FALSE;
|
| 374 |
hSPI = NULL;
|
| 375 |
|
| 376 |
//SPI をロード
|
| 377 |
hSPI = LoadLibrary(nameSPI);
|
| 378 |
|
| 379 |
if(!hSPI)
|
| 380 |
goto error;
|
| 381 |
|
| 382 |
(FARPROC)SPI_GetPluginInfo = GetProcAddress(hSPI,"GetPluginInfo");
|
| 383 |
(FARPROC)SPI_IsSupported = GetProcAddress(hSPI,"IsSupported");
|
| 384 |
(FARPROC)SPI_GetPicture = GetProcAddress(hSPI,"GetPicture");
|
| 385 |
|
| 386 |
if(!SPI_GetPluginInfo || !SPI_IsSupported || !SPI_GetPicture)
|
| 387 |
goto error;
|
| 388 |
|
| 389 |
//バージョンチェック
|
| 390 |
SPI_GetPluginInfo(0,spiVersion,8);
|
| 391 |
|
| 392 |
if(spiVersion[2] != 'I' || spiVersion[3] != 'N')
|
| 393 |
goto error;
|
| 394 |
|
| 395 |
if(!(SPI_IsSupported)(nameFile,(unsigned long)bufFile))
|
| 396 |
goto error;
|
| 397 |
|
| 398 |
if((SPI_GetPicture)(bufFile,sizeFile,1,hbmi,hbuf,NULL,0))
|
| 399 |
goto error;
|
| 400 |
|
| 401 |
ret = TRUE;
|
| 402 |
|
| 403 |
error :
|
| 404 |
|
| 405 |
if(hSPI)
|
| 406 |
FreeLibrary(hSPI);
|
| 407 |
|
| 408 |
return ret;
|
| 409 |
}
|
| 410 |
|
| 411 |
BOOL SaveBitmapFile(char *nameFile,unsigned char *pbuf,BITMAPINFO *pbmi)
|
| 412 |
{
|
| 413 |
int bmiSize;
|
| 414 |
DWORD writtenByte;
|
| 415 |
HANDLE hFile;
|
| 416 |
BITMAPFILEHEADER bfh;
|
| 417 |
|
| 418 |
hFile = CreateFile(nameFile,GENERIC_WRITE,0,NULL,CREATE_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
|
| 419 |
|
| 420 |
if(hFile == INVALID_HANDLE_VALUE)
|
| 421 |
return FALSE;
|
| 422 |
|
| 423 |
bmiSize = pbmi->bmiHeader.biSize;
|
| 424 |
|
| 425 |
switch(pbmi->bmiHeader.biBitCount)
|
| 426 |
{
|
| 427 |
case 1:
|
| 428 |
bmiSize += pbmi->bmiHeader.biClrUsed ? sizeof(RGBQUAD) * 2 : 0;
|
| 429 |
break;
|
| 430 |
|
| 431 |
case 2 :
|
| 432 |
bmiSize += sizeof(RGBQUAD) * 4;
|
| 433 |
break;
|
| 434 |
|
| 435 |
case 4 :
|
| 436 |
bmiSize += sizeof(RGBQUAD) * 16;
|
| 437 |
break;
|
| 438 |
|
| 439 |
case 8 :
|
| 440 |
bmiSize += sizeof(RGBQUAD) * 256;
|
| 441 |
break;
|
| 442 |
}
|
| 443 |
|
| 444 |
ZeroMemory(&bfh,sizeof(bfh));
|
| 445 |
bfh.bfType = MAKEWORD('B','M');
|
| 446 |
bfh.bfOffBits = sizeof(bfh) + bmiSize;
|
| 447 |
bfh.bfSize = bfh.bfOffBits + pbmi->bmiHeader.biSizeImage;
|
| 448 |
|
| 449 |
WriteFile(hFile,&bfh,sizeof(bfh) ,&writtenByte,0);
|
| 450 |
WriteFile(hFile,pbmi,bmiSize ,&writtenByte,0);
|
| 451 |
WriteFile(hFile,pbuf,pbmi->bmiHeader.biSizeImage,&writtenByte,0);
|
| 452 |
|
| 453 |
CloseHandle(hFile);
|
| 454 |
|
| 455 |
return TRUE;
|
| 456 |
}
|
| 457 |
|
| 458 |
BOOL FAR WINAPI AlphaBlendWithoutAPI(HDC hdcDest,int dx,int dy,int width,int height,HDC hdcSrc,int sx,int sy,int sw,int sh,BGBLENDFUNCTION bf)
|
| 459 |
{
|
| 460 |
HDC hdcDestWork,hdcSrcWork;
|
| 461 |
int i,invAlpha,alpha;
|
| 462 |
int lenBuf;
|
| 463 |
unsigned char *bufDest;
|
| 464 |
unsigned char *bufSrc;
|
| 465 |
|
| 466 |
if(dx != 0 || dy != 0 || sx != 0 || sy != 0 || width != sw || height != sh)
|
| 467 |
return FALSE;
|
| 468 |
|
| 469 |
hdcDestWork = CreateBitmapDC(CreateDIB24BPP(width,height,&bufDest,&lenBuf));
|
| 470 |
hdcSrcWork = CreateBitmapDC(CreateDIB24BPP(width,height,&bufSrc ,&lenBuf));
|
| 471 |
|
| 472 |
if(!bufDest || !bufSrc)
|
| 473 |
return FALSE;
|
| 474 |
|
| 475 |
BitBlt(hdcDestWork,0,0,width,height,hdcDest,0,0,SRCCOPY);
|
| 476 |
BitBlt(hdcSrcWork ,0,0,width,height,hdcSrc ,0,0,SRCCOPY);
|
| 477 |
|
| 478 |
alpha = bf.SourceConstantAlpha;
|
| 479 |
invAlpha = 255 - alpha;
|
| 480 |
|
| 481 |
for(i = 0;i < lenBuf;i++,bufDest++,bufSrc++)
|
| 482 |
*bufDest = (*bufDest * invAlpha + *bufSrc * alpha)>>8;
|
| 483 |
|
| 484 |
BitBlt(hdcDest,0,0,width,height,hdcDestWork,0,0,SRCCOPY);
|
| 485 |
|
| 486 |
DeleteBitmapDC(&hdcDestWork);
|
| 487 |
DeleteBitmapDC(&hdcSrcWork);
|
| 488 |
|
| 489 |
return TRUE;
|
| 490 |
}
|
| 491 |
|
| 492 |
// 画像読み込み関係
|
| 493 |
|
| 494 |
void BGPreloadPicture(BGSrc *src)
|
| 495 |
{
|
| 496 |
char spiPath[MAX_PATH];
|
| 497 |
char filespec[MAX_PATH];
|
| 498 |
char *filePart;
|
| 499 |
int fileSize;
|
| 500 |
int readByte;
|
| 501 |
unsigned char *fileBuf;
|
| 502 |
|
| 503 |
HBITMAP hbm;
|
| 504 |
HANDLE hPictureFile;
|
| 505 |
HANDLE hFind;
|
| 506 |
WIN32_FIND_DATA fd;
|
| 507 |
|
| 508 |
#ifdef _DEBUG
|
| 509 |
dprintf("Preload Picture : %s",src->file);
|
| 510 |
#endif
|
| 511 |
|
| 512 |
//ファイルを読み込む
|
| 513 |
hPictureFile = CreateFile(src->file,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
|
| 514 |
|
| 515 |
if(hPictureFile == INVALID_HANDLE_VALUE)
|
| 516 |
return;
|
| 517 |
|
| 518 |
fileSize = GetFileSize(hPictureFile,0);
|
| 519 |
|
| 520 |
//最低 2kb は確保 (Susie plugin の仕様より)
|
| 521 |
fileBuf = GlobalAlloc(GPTR,fileSize + 2048);
|
| 522 |
|
| 523 |
//頭の 2kb は0で初期化
|
| 524 |
ZeroMemory(fileBuf,2048);
|
| 525 |
|
| 526 |
ReadFile(hPictureFile,fileBuf,fileSize,&readByte,0);
|
| 527 |
|
| 528 |
CloseHandle(hPictureFile);
|
| 529 |
|
| 530 |
// SPIPath を絶対パスに変換
|
| 531 |
if(!GetFullPathName(BGSPIPath,MAX_PATH,filespec,&filePart))
|
| 532 |
return;
|
| 533 |
|
| 534 |
//プラグインを当たっていく
|
| 535 |
hFind = FindFirstFile(filespec,&fd);
|
| 536 |
|
| 537 |
if(hFind != INVALID_HANDLE_VALUE && filePart)
|
| 538 |
{
|
| 539 |
//ディレクトリ取得
|
| 540 |
ExtractDirName(filespec, spiPath);
|
| 541 |
AppendSlash(spiPath, sizeof(spiPath));
|
| 542 |
|
| 543 |
do{
|
| 544 |
HLOCAL hbuf,hbmi;
|
| 545 |
BITMAPINFO *pbmi;
|
| 546 |
char *pbuf;
|
| 547 |
char spiFileName[MAX_PATH];
|
| 548 |
|
| 549 |
if(fd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
| 550 |
continue;
|
| 551 |
|
| 552 |
strncpy_s(spiFileName, sizeof(spiFileName), spiPath, _TRUNCATE);
|
| 553 |
strncat_s(spiFileName, sizeof(spiFileName), fd.cFileName, _TRUNCATE);
|
| 554 |
|
| 555 |
if(LoadPictureWithSPI(spiFileName,src->file,fileBuf,fileSize,&hbuf,&hbmi))
|
| 556 |
{
|
| 557 |
pbuf = LocalLock(hbuf);
|
| 558 |
pbmi = LocalLock(hbmi);
|
| 559 |
|
| 560 |
SaveBitmapFile(src->fileTmp,pbuf,pbmi);
|
| 561 |
|
| 562 |
LocalUnlock(hbmi);
|
| 563 |
LocalUnlock(hbuf);
|
| 564 |
|
| 565 |
LocalFree(hbmi);
|
| 566 |
LocalFree(hbuf);
|
| 567 |
|
| 568 |
strncpy_s(src->file, sizeof(src->file),src->fileTmp, _TRUNCATE);
|
| 569 |
|
| 570 |
break;
|
| 571 |
}
|
| 572 |
}while(FindNextFile(hFind,&fd));
|
| 573 |
|
| 574 |
FindClose(hFind);
|
| 575 |
}
|
| 576 |
|
| 577 |
GlobalFree(fileBuf);
|
| 578 |
|
| 579 |
//画像をビットマップとして読み込み
|
| 580 |
|
| 581 |
hbm = LoadImage(0,src->file,IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
|
| 582 |
|
| 583 |
if(hbm)
|
| 584 |
{
|
| 585 |
BITMAP bm;
|
| 586 |
|
| 587 |
GetObject(hbm,sizeof(bm),&bm);
|
| 588 |
|
| 589 |
src->hdc = CreateBitmapDC(hbm);
|
| 590 |
src->width = bm.bmWidth;
|
| 591 |
src->height = bm.bmHeight;
|
| 592 |
}else{
|
| 593 |
src->type = BG_COLOR;
|
| 594 |
}
|
| 595 |
}
|
| 596 |
|
| 597 |
void BGGetWallpaperInfo(WallpaperInfo *wi)
|
| 598 |
{
|
| 599 |
int length;
|
| 600 |
int tile;
|
| 601 |
char str[256];
|
| 602 |
HKEY hKey;
|
| 603 |
|
| 604 |
wi->pattern = BG_CENTER;
|
| 605 |
strncpy_s(wi->filename, sizeof(wi->filename),"", _TRUNCATE);
|
| 606 |
|
| 607 |
//レジストリキーのオープン
|
| 608 |
if(RegOpenKeyEx(HKEY_CURRENT_USER, "Control Panel\\Desktop", 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
| 609 |
return;
|
| 610 |
|
| 611 |
//壁紙名ゲット
|
| 612 |
length = MAX_PATH;
|
| 613 |
RegQueryValueEx(hKey,"Wallpaper" ,NULL,NULL,(BYTE*)(wi->filename),&length);
|
| 614 |
|
| 615 |
//壁紙スタイルゲット
|
| 616 |
length = 256;
|
| 617 |
RegQueryValueEx(hKey,"WallpaperStyle",NULL,NULL,(BYTE*)str,&length);
|
| 618 |
wi->pattern = atoi(str);
|
| 619 |
|
| 620 |
//壁紙スタイルゲット
|
| 621 |
length = 256;
|
| 622 |
RegQueryValueEx(hKey,"TileWallpaper" ,NULL,NULL,(BYTE*)str,&length);
|
| 623 |
tile = atoi(str);
|
| 624 |
|
| 625 |
//これでいいの?
|
| 626 |
if(tile)
|
| 627 |
wi->pattern = BG_TILE;
|
| 628 |
else
|
| 629 |
if(wi->pattern == 0)
|
| 630 |
wi->pattern = BG_CENTER;
|
| 631 |
else
|
| 632 |
if(wi->pattern == 2)
|
| 633 |
wi->pattern = BG_STRETCH;
|
| 634 |
|
| 635 |
//レジストリキーのクローズ
|
| 636 |
RegCloseKey(hKey);
|
| 637 |
}
|
| 638 |
|
| 639 |
void BGPreloadWallpaper(BGSrc *src)
|
| 640 |
{
|
| 641 |
HBITMAP hbm;
|
| 642 |
WallpaperInfo wi;
|
| 643 |
|
| 644 |
BGGetWallpaperInfo(&wi);
|
| 645 |
|
| 646 |
//壁紙を読み込み
|
| 647 |
//LR_CREATEDIBSECTION を指定するのがコツ
|
| 648 |
if(wi.pattern == BG_STRETCH)
|
| 649 |
hbm = LoadImage(0,wi.filename,IMAGE_BITMAP,CRTWidth,CRTHeight,LR_LOADFROMFILE | LR_CREATEDIBSECTION);
|
| 650 |
else
|
| 651 |
hbm = LoadImage(0,wi.filename,IMAGE_BITMAP, 0, 0,LR_LOADFROMFILE);
|
| 652 |
|
| 653 |
//壁紙DCを作る
|
| 654 |
if(hbm)
|
| 655 |
{
|
| 656 |
BITMAP bm;
|
| 657 |
|
| 658 |
GetObject(hbm,sizeof(bm),&bm);
|
| 659 |
|
| 660 |
src->hdc = CreateBitmapDC(hbm);
|
| 661 |
src->width = bm.bmWidth;
|
| 662 |
src->height = bm.bmHeight;
|
| 663 |
src->pattern = wi.pattern;
|
| 664 |
}else{
|
| 665 |
src->hdc = NULL;
|
| 666 |
}
|
| 667 |
|
| 668 |
src->color = GetSysColor(COLOR_DESKTOP);
|
| 669 |
}
|
| 670 |
|
| 671 |
void BGPreloadSrc(BGSrc *src)
|
| 672 |
{
|
| 673 |
DeleteBitmapDC(&(src->hdc));
|
| 674 |
|
| 675 |
switch(src->type)
|
| 676 |
{
|
| 677 |
case BG_COLOR :
|
| 678 |
break;
|
| 679 |
|
| 680 |
case BG_WALLPAPER :
|
| 681 |
BGPreloadWallpaper(src);
|
| 682 |
break;
|
| 683 |
|
| 684 |
case BG_PICTURE :
|
| 685 |
BGPreloadPicture(src);
|
| 686 |
break;
|
| 687 |
}
|
| 688 |
}
|
| 689 |
|
| 690 |
void BGStretchPicture(HDC hdcDest,BGSrc *src,int x,int y,int width,int height,BOOL bAntiAlias)
|
| 691 |
{
|
| 692 |
if(!hdcDest || !src)
|
| 693 |
return;
|
| 694 |
|
| 695 |
if(bAntiAlias)
|
| 696 |
{
|
| 697 |
if(src->width != width || src->height != height)
|
| 698 |
{
|
| 699 |
HBITMAP hbm;
|
| 700 |
|
| 701 |
hbm = LoadImage(0,src->file,IMAGE_BITMAP,width,height,LR_LOADFROMFILE);
|
| 702 |
|
| 703 |
if(!hbm)
|
| 704 |
return;
|
| 705 |
|
| 706 |
DeleteBitmapDC(&(src->hdc));
|
| 707 |
src->hdc = CreateBitmapDC(hbm);
|
| 708 |
src->width = width;
|
| 709 |
src->height = height;
|
| 710 |
}
|
| 711 |
|
| 712 |
BitBlt(hdcDest,x,y,width,height,src->hdc,0,0,SRCCOPY);
|
| 713 |
}else{
|
| 714 |
SetStretchBltMode(src->hdc,COLORONCOLOR);
|
| 715 |
StretchBlt(hdcDest,x,y,width,height,src->hdc,0,0,src->width,src->height,SRCCOPY);
|
| 716 |
}
|
| 717 |
}
|
| 718 |
|
| 719 |
void BGLoadPicture(HDC hdcDest,BGSrc *src)
|
| 720 |
{
|
| 721 |
int x,y,width,height,pattern;
|
| 722 |
HDC hdc = NULL;
|
| 723 |
|
| 724 |
FillBitmapDC(hdcDest,src->color);
|
| 725 |
|
| 726 |
if(!src->height || !src->width)
|
| 727 |
return;
|
| 728 |
|
| 729 |
if(src->pattern == BG_AUTOFIT){
|
| 730 |
if((src->height * ScreenWidth) > (ScreenHeight * src->width))
|
| 731 |
pattern = BG_FIT_WIDTH;
|
| 732 |
else
|
| 733 |
pattern = BG_FIT_HEIGHT;
|
| 734 |
}else{
|
| 735 |
pattern = src->pattern;
|
| 736 |
}
|
| 737 |
|
| 738 |
switch(pattern)
|
| 739 |
{
|
| 740 |
case BG_STRETCH :
|
| 741 |
BGStretchPicture(hdcDest,src,0,0,ScreenWidth,ScreenHeight,src->antiAlias);
|
| 742 |
break;
|
| 743 |
|
| 744 |
case BG_FIT_WIDTH :
|
| 745 |
|
| 746 |
height = (src->height * ScreenWidth) / src->width;
|
| 747 |
y = (ScreenHeight - height) / 2;
|
| 748 |
|
| 749 |
BGStretchPicture(hdcDest,src,0,y,ScreenWidth,height,src->antiAlias);
|
| 750 |
break;
|
| 751 |
|
| 752 |
case BG_FIT_HEIGHT :
|
| 753 |
|
| 754 |
width = (src->width * ScreenHeight) / src->height;
|
| 755 |
x = (ScreenWidth - width) / 2;
|
| 756 |
|
| 757 |
BGStretchPicture(hdcDest,src,x,0,width,ScreenHeight,src->antiAlias);
|
| 758 |
break;
|
| 759 |
|
| 760 |
case BG_TILE :
|
| 761 |
for(x = 0;x < ScreenWidth ;x += src->width )
|
| 762 |
for(y = 0;y < ScreenHeight;y += src->height)
|
| 763 |
BitBlt(hdcDest,x,y,src->width,src->height,src->hdc,0,0,SRCCOPY);
|
| 764 |
break;
|
| 765 |
|
| 766 |
case BG_CENTER :
|
| 767 |
x = (ScreenWidth - src->width) / 2;
|
| 768 |
y = (ScreenHeight - src->height) / 2;
|
| 769 |
|
| 770 |
BitBlt(hdcDest,x,y,src->width,src->height,src->hdc,0,0,SRCCOPY);
|
| 771 |
break;
|
| 772 |
}
|
| 773 |
}
|
| 774 |
|
| 775 |
typedef struct tagLoadWallpaperStruct
|
| 776 |
{
|
| 777 |
RECT *rectClient;
|
| 778 |
HDC hdcDest;
|
| 779 |
BGSrc *src;
|
| 780 |
}LoadWallpaperStruct;
|
| 781 |
|
| 782 |
BOOL CALLBACK BGLoadWallpaperEnumFunc(HMONITOR hMonitor,HDC hdcMonitor,LPRECT lprcMonitor,LPARAM dwData)
|
| 783 |
{
|
| 784 |
RECT rectDest;
|
| 785 |
RECT rectRgn;
|
| 786 |
int monitorWidth;
|
| 787 |
int monitorHeight;
|
| 788 |
int destWidth;
|
| 789 |
int destHeight;
|
| 790 |
HRGN hRgn;
|
| 791 |
int x;
|
| 792 |
int y;
|
| 793 |
|
| 794 |
LoadWallpaperStruct *lws = (LoadWallpaperStruct*)dwData;
|
| 795 |
|
| 796 |
if(!IntersectRect(&rectDest,lprcMonitor,lws->rectClient))
|
| 797 |
return TRUE;
|
| 798 |
|
| 799 |
//モニターにかかってる部分をマスク
|
| 800 |
SaveDC(lws->hdcDest);
|
| 801 |
CopyRect(&rectRgn,&rectDest);
|
| 802 |
OffsetRect(&rectRgn,- lws->rectClient->left,- lws->rectClient->top);
|
| 803 |
hRgn = CreateRectRgnIndirect(&rectRgn);
|
| 804 |
SelectObject(lws->hdcDest,hRgn);
|
| 805 |
|
| 806 |
//モニターの大きさ
|
| 807 |
monitorWidth = lprcMonitor->right - lprcMonitor->left;
|
| 808 |
monitorHeight = lprcMonitor->bottom - lprcMonitor->top;
|
| 809 |
|
| 810 |
destWidth = rectDest.right - rectDest.left;
|
| 811 |
destHeight = rectDest.bottom - rectDest.top;
|
| 812 |
|
| 813 |
switch(lws->src->pattern)
|
| 814 |
{
|
| 815 |
case BG_CENTER :
|
| 816 |
case BG_STRETCH :
|
| 817 |
|
| 818 |
SetWindowOrgEx(lws->src->hdc,
|
| 819 |
lprcMonitor->left + (monitorWidth - lws->src->width )/2,
|
| 820 |
lprcMonitor->top + (monitorHeight - lws->src->height)/2,NULL);
|
| 821 |
BitBlt(lws->hdcDest ,rectDest.left,rectDest.top,destWidth,destHeight,
|
| 822 |
lws->src->hdc,rectDest.left,rectDest.top,SRCCOPY);
|
| 823 |
|
| 824 |
break;
|
| 825 |
case BG_TILE :
|
| 826 |
|
| 827 |
SetWindowOrgEx(lws->src->hdc,0,0,NULL);
|
| 828 |
|
| 829 |
for(x = rectDest.left - (rectDest.left % lws->src->width ) - lws->src->width ;
|
| 830 |
x < rectDest.right ;x += lws->src->width )
|
| 831 |
for(y = rectDest.top - (rectDest.top % lws->src->height) - lws->src->height;
|
| 832 |
y < rectDest.bottom;y += lws->src->height)
|
| 833 |
BitBlt(lws->hdcDest,x,y,lws->src->width,lws->src->height,lws->src->hdc,0,0,SRCCOPY);
|
| 834 |
break;
|
| 835 |
}
|
| 836 |
|
| 837 |
//リージョンを破棄
|
| 838 |
RestoreDC(lws->hdcDest,-1);
|
| 839 |
DeleteObject(hRgn);
|
| 840 |
|
| 841 |
return TRUE;
|
| 842 |
}
|
| 843 |
|
| 844 |
void BGLoadWallpaper(HDC hdcDest,BGSrc *src)
|
| 845 |
{
|
| 846 |
RECT rectClient;
|
| 847 |
POINT point;
|
| 848 |
LoadWallpaperStruct lws;
|
| 849 |
|
| 850 |
//取りあえずデスクトップ色で塗りつぶす
|
| 851 |
FillBitmapDC(hdcDest,src->color);
|
| 852 |
|
| 853 |
//壁紙が設定されていない
|
| 854 |
if(!src->hdc)
|
| 855 |
return;
|
| 856 |
|
| 857 |
//hdcDestの座標系を仮想スクリーンに合わせる
|
| 858 |
point.x = 0;
|
| 859 |
point.y = 0;
|
| 860 |
ClientToScreen(HVTWin,&point);
|
| 861 |
|
| 862 |
SetWindowOrgEx(hdcDest,point.x,point.y,NULL);
|
| 863 |
|
| 864 |
//仮想スクリーンでのクライアント領域
|
| 865 |
GetClientRect(HVTWin,&rectClient);
|
| 866 |
OffsetRect(&rectClient,point.x,point.y);
|
| 867 |
|
| 868 |
//モニターを列挙
|
| 869 |
lws.rectClient = &rectClient;
|
| 870 |
lws.src = src;
|
| 871 |
lws.hdcDest = hdcDest;
|
| 872 |
|
| 873 |
if(BGEnumDisplayMonitors)
|
| 874 |
{
|
| 875 |
(*BGEnumDisplayMonitors)(NULL,NULL,BGLoadWallpaperEnumFunc,(LPARAM)&lws);
|
| 876 |
}else{
|
| 877 |
RECT rectMonitor;
|
| 878 |
|
| 879 |
SetRect(&rectMonitor,0,0,CRTWidth,CRTHeight);
|
| 880 |
BGLoadWallpaperEnumFunc(NULL,NULL,&rectMonitor,(LPARAM)&lws);
|
| 881 |
}
|
| 882 |
|
| 883 |
//座標系を戻す
|
| 884 |
SetWindowOrgEx(hdcDest,0,0,NULL);
|
| 885 |
}
|
| 886 |
|
| 887 |
void BGLoadSrc(HDC hdcDest,BGSrc *src)
|
| 888 |
{
|
| 889 |
switch(src->type)
|
| 890 |
{
|
| 891 |
case BG_COLOR :
|
| 892 |
FillBitmapDC(hdcDest,src->color);
|
| 893 |
break;
|
| 894 |
|
| 895 |
case BG_WALLPAPER :
|
| 896 |
BGLoadWallpaper(hdcDest,src);
|
| 897 |
break;
|
| 898 |
|
| 899 |
case BG_PICTURE :
|
| 900 |
BGLoadPicture(hdcDest,src);
|
| 901 |
break;
|
| 902 |
}
|
| 903 |
}
|
| 904 |
|
| 905 |
void BGSetupPrimary(BOOL forceSetup)
|
| 906 |
{
|
| 907 |
POINT point;
|
| 908 |
RECT rect;
|
| 909 |
|
| 910 |
if(!BGEnable)
|
| 911 |
return;
|
| 912 |
|
| 913 |
//窓の位置、大きさが変わったかチェック
|
| 914 |
point.x = 0;
|
| 915 |
point.y = 0;
|
| 916 |
ClientToScreen(HVTWin,&point);
|
| 917 |
|
| 918 |
GetClientRect(HVTWin,&rect);
|
| 919 |
OffsetRect(&rect,point.x,point.y);
|
| 920 |
|
| 921 |
if(!forceSetup && EqualRect(&rect,&BGPrevRect))
|
| 922 |
return;
|
| 923 |
|
| 924 |
CopyRect(&BGPrevRect,&rect);
|
| 925 |
|
| 926 |
#ifdef _DEBUG
|
| 927 |
dprintf("BGSetupPrimary : BGInSizeMove = %d",BGInSizeMove);
|
| 928 |
#endif
|
| 929 |
|
| 930 |
//作業用 DC 作成
|
| 931 |
if(hdcBGWork) DeleteBitmapDC(&hdcBGWork);
|
| 932 |
if(hdcBGBuffer) DeleteBitmapDC(&hdcBGBuffer);
|
| 933 |
|
| 934 |
hdcBGWork = CreateBitmapDC(CreateScreenCompatibleBitmap(ScreenWidth,FontHeight));
|
| 935 |
hdcBGBuffer = CreateBitmapDC(CreateScreenCompatibleBitmap(ScreenWidth,FontHeight));
|
| 936 |
|
| 937 |
//hdcBGBuffer の属性設定
|
| 938 |
SetBkMode(hdcBGBuffer,TRANSPARENT);
|
| 939 |
|
| 940 |
if(!BGInSizeMove)
|
| 941 |
{
|
| 942 |
BGBLENDFUNCTION bf;
|
| 943 |
HDC hdcSrc = NULL;
|
| 944 |
|
| 945 |
//背景 HDC
|
| 946 |
if(hdcBG) DeleteBitmapDC(&hdcBG);
|
| 947 |
hdcBG = CreateBitmapDC(CreateScreenCompatibleBitmap(ScreenWidth,ScreenHeight));
|
| 948 |
|
| 949 |
//作業用DC
|
| 950 |
hdcSrc = CreateBitmapDC(CreateScreenCompatibleBitmap(ScreenWidth,ScreenHeight));
|
| 951 |
|
| 952 |
//背景生成
|
| 953 |
BGLoadSrc(hdcBG,&BGDest);
|
| 954 |
|
| 955 |
ZeroMemory(&bf,sizeof(bf));
|
| 956 |
bf.BlendOp = AC_SRC_OVER;
|
| 957 |
|
| 958 |
if(bf.SourceConstantAlpha = BGSrc1.alpha)
|
| 959 |
{
|
| 960 |
BGLoadSrc(hdcSrc,&BGSrc1);
|
| 961 |
(BGAlphaBlend)(hdcBG,0,0,ScreenWidth,ScreenHeight,hdcSrc,0,0,ScreenWidth,ScreenHeight,bf);
|
| 962 |
}
|
| 963 |
|
| 964 |
if(bf.SourceConstantAlpha = BGSrc2.alpha)
|
| 965 |
{
|
| 966 |
BGLoadSrc(hdcSrc,&BGSrc2);
|
| 967 |
(BGAlphaBlend)(hdcBG,0,0,ScreenWidth,ScreenHeight,hdcSrc,0,0,ScreenWidth,ScreenHeight,bf);
|
| 968 |
}
|
| 969 |
|
| 970 |
DeleteBitmapDC(&hdcSrc);
|
| 971 |
}
|
| 972 |
}
|
| 973 |
|
| 974 |
COLORREF BGGetColor(char *name,COLORREF defcolor,char *file)
|
| 975 |
{
|
| 976 |
unsigned int r,g,b;
|
| 977 |
char colorstr[256],defstr[256];
|
| 978 |
|
| 979 |
_snprintf_s(defstr,sizeof(defstr),_TRUNCATE,"%d,%d,%d",GetRValue(defcolor),GetGValue(defcolor),GetBValue(defcolor));
|
| 980 |
|
| 981 |
GetPrivateProfileString(BG_SECTION,name,defstr,colorstr,255,file);
|
| 982 |
|
| 983 |
r = g = b = 0;
|
| 984 |
|
| 985 |
sscanf(colorstr,"%d , %d , %d",&r,&g,&b);
|
| 986 |
|
| 987 |
return RGB(r,g,b);
|
| 988 |
}
|
| 989 |
|
| 990 |
BG_PATTERN BGGetStrIndex(char *name,BG_PATTERN def,char *file,char **strList,int nList)
|
| 991 |
{
|
| 992 |
char defstr[64],str[64];
|
| 993 |
int i;
|
| 994 |
|
| 995 |
def %= nList;
|
| 996 |
|
| 997 |
strncpy_s(defstr, sizeof(defstr),strList[def], _TRUNCATE);
|
| 998 |
GetPrivateProfileString(BG_SECTION,name,defstr,str,64,file);
|
| 999 |
|
| 1000 |
for(i = 0;i < nList;i++)
|
| 1001 |
if(!_stricmp(str,strList[i]))
|
| 1002 |
return i;
|
| 1003 |
|
| 1004 |
return 0;
|
| 1005 |
}
|
| 1006 |
|
| 1007 |
BOOL BGGetOnOff(char *name,BOOL def,char *file)
|
| 1008 |
{
|
| 1009 |
char *strList[2] = {"Off","On"};
|
| 1010 |
|
| 1011 |
return BGGetStrIndex(name,def,file,strList,2);
|
| 1012 |
}
|
| 1013 |
|
| 1014 |
BG_PATTERN BGGetPattern(char *name,BG_PATTERN def,char *file)
|
| 1015 |
{
|
| 1016 |
char *strList[6]={"stretch","tile","center","fitwidth","fitheight","autofit"};
|
| 1017 |
|
| 1018 |
return BGGetStrIndex(name,def,file,strList,6);
|
| 1019 |
}
|
| 1020 |
|
| 1021 |
BG_PATTERN BGGetType(char *name,BG_TYPE def,char *file)
|
| 1022 |
{
|
| 1023 |
char *strList[3]={"color","picture","wallpaper"};
|
| 1024 |
|
| 1025 |
return BGGetStrIndex(name,def,file,strList,3);
|
| 1026 |
}
|
| 1027 |
|
| 1028 |
void BGReadTextColorConfig(char *file)
|
| 1029 |
{
|
| 1030 |
ANSIColor[IdFore ] = BGGetColor("Fore" ,ANSIColor[IdFore],file);
|
| 1031 |
ANSIColor[IdBack ] = BGGetColor("Back" ,ANSIColor[IdBack],file);
|
| 1032 |
ANSIColor[IdRed ] = BGGetColor("Red" ,ANSIColor[IdRed ],file);
|
| 1033 |
ANSIColor[IdGreen ] = BGGetColor("Green" ,ANSIColor[IdGreen ],file);
|
| 1034 |
ANSIColor[IdYellow ] = BGGetColor("Yellow" ,ANSIColor[IdYellow ],file);
|
| 1035 |
ANSIColor[IdBlue ] = BGGetColor("Blue" ,ANSIColor[IdBlue ],file);
|
| 1036 |
ANSIColor[IdMagenta] = BGGetColor("Magenta",ANSIColor[IdMagenta],file);
|
| 1037 |
ANSIColor[IdCyan ] = BGGetColor("Cyan" ,ANSIColor[IdCyan ],file);
|
| 1038 |
|
| 1039 |
ANSIColor[IdFore + 8] = BGGetColor("DarkFore" ,ANSIColor[IdFore + 8],file);
|
| 1040 |
ANSIColor[IdBack + 8] = BGGetColor("DarkBack" ,ANSIColor[IdBack + 8],file);
|
| 1041 |
ANSIColor[IdRed + 8] = BGGetColor("DarkRed" ,ANSIColor[IdRed + 8],file);
|
| 1042 |
ANSIColor[IdGreen + 8] = BGGetColor("DarkGreen" ,ANSIColor[IdGreen + 8],file);
|
| 1043 |
ANSIColor[IdYellow + 8] = BGGetColor("DarkYellow" ,ANSIColor[IdYellow + 8],file);
|
| 1044 |
ANSIColor[IdBlue + 8] = BGGetColor("DarkBlue" ,ANSIColor[IdBlue + 8],file);
|
| 1045 |
ANSIColor[IdMagenta+ 8] = BGGetColor("DarkMagenta",ANSIColor[IdMagenta+ 8],file);
|
| 1046 |
ANSIColor[IdCyan + 8] = BGGetColor("DarkCyan" ,ANSIColor[IdCyan + 8],file);
|
| 1047 |
|
| 1048 |
BGVTColor[0] = BGGetColor("VTFore",BGVTColor[0],file);
|
| 1049 |
BGVTColor[1] = BGGetColor("VTBack",BGVTColor[1],file);
|
| 1050 |
|
| 1051 |
BGVTBlinkColor[0] = BGGetColor("VTBlinkFore",BGVTBlinkColor[0],file);
|
| 1052 |
BGVTBlinkColor[1] = BGGetColor("VTBlinkBack",BGVTBlinkColor[1],file);
|
| 1053 |
|
| 1054 |
BGVTBoldColor[0] = BGGetColor("VTBoldFore" ,BGVTBoldColor[0],file);
|
| 1055 |
BGVTBoldColor[1] = BGGetColor("VTBoldBack" ,BGVTBoldColor[1],file);
|
| 1056 |
|
| 1057 |
BGVTReverseColor[0] = BGGetColor("VTReverseFore" ,BGVTReverseColor[0],file);
|
| 1058 |
BGVTReverseColor[1] = BGGetColor("VTReverseBack" ,BGVTReverseColor[1],file);
|
| 1059 |
|
| 1060 |
/* begin - ishizaki */
|
| 1061 |
BGURLColor[0] = BGGetColor("URLFore" ,BGURLColor[0],file);
|
| 1062 |
BGURLColor[1] = BGGetColor("URLBack" ,BGURLColor[1],file);
|
| 1063 |
/* end - ishizaki */
|
| 1064 |
}
|
| 1065 |
|
| 1066 |
void BGReadIniFile(char *file)
|
| 1067 |
{
|
| 1068 |
char path[MAX_PATH];
|
| 1069 |
|
| 1070 |
// Easy Setting
|
| 1071 |
BGDest.pattern = BGGetPattern("BGPicturePattern",BGSrc1.pattern,file);
|
| 1072 |
BGDest.color = BGGetColor("BGPictureBaseColor",BGSrc1.color,file);
|
| 1073 |
|
| 1074 |
GetPrivateProfileString(BG_SECTION,"BGPictureFile",BGSrc1.file,path,MAX_PATH,file);
|
| 1075 |
RandomFile(path,BGDest.file,sizeof(BGDest.file));
|
| 1076 |
|
| 1077 |
BGSrc1.alpha = 255 - GetPrivateProfileInt(BG_SECTION,"BGPictureTone",255 - BGSrc1.alpha,file);
|
| 1078 |
|
| 1079 |
if(!strcmp(BGDest.file,""))
|
| 1080 |
BGSrc1.alpha = 255;
|
| 1081 |
|
| 1082 |
BGSrc2.alpha = 255 - GetPrivateProfileInt(BG_SECTION,"BGFadeTone",255 - BGSrc2.alpha,file);
|
| 1083 |
BGSrc2.color = BGGetColor("BGFadeColor",BGSrc2.color,file);
|
| 1084 |
|
| 1085 |
BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION,"BGReverseTextTone",BGReverseTextAlpha,file);
|
| 1086 |
|
| 1087 |
//Src1 の読み出し
|
| 1088 |
BGSrc1.type = BGGetType("BGSrc1Type",BGSrc1.type,file);
|
| 1089 |
BGSrc1.pattern = BGGetPattern("BGSrc1Pattern",BGSrc1.pattern,file);
|
| 1090 |
BGSrc1.antiAlias = BGGetOnOff("BGSrc1AntiAlias",BGSrc1.antiAlias,file);
|
| 1091 |
BGSrc1.alpha = GetPrivateProfileInt(BG_SECTION,"BGSrc1Alpha" ,BGSrc1.alpha ,file);
|
| 1092 |
BGSrc1.color = BGGetColor("BGSrc1Color",BGSrc1.color,file);
|
| 1093 |
|
| 1094 |
GetPrivateProfileString(BG_SECTION,"BGSrc1File",BGSrc1.file,path,MAX_PATH,file);
|
| 1095 |
RandomFile(path,BGSrc1.file,sizeof(BGSrc1.file));
|
| 1096 |
|
| 1097 |
//Src2 の読み出し
|
| 1098 |
BGSrc2.type = BGGetType("BGSrc2Type",BGSrc2.type,file);
|
| 1099 |
BGSrc2.pattern = BGGetPattern("BGSrc2Pattern",BGSrc2.pattern,file);
|
| 1100 |
BGSrc2.antiAlias = BGGetOnOff("BGSrc2AntiAlias",BGSrc2.antiAlias,file);
|
| 1101 |
BGSrc2.alpha = GetPrivateProfileInt(BG_SECTION,"BGSrc2Alpha" ,BGSrc2.alpha ,file);
|
| 1102 |
BGSrc2.color = BGGetColor("BGSrc2Color",BGSrc2.color,file);
|
| 1103 |
|
| 1104 |
GetPrivateProfileString(BG_SECTION,"BGSrc2File",BGSrc2.file,path,MAX_PATH,file);
|
| 1105 |
RandomFile(path,BGSrc2.file,sizeof(BGSrc2.file));
|
| 1106 |
|
| 1107 |
//Dest の読み出し
|
| 1108 |
BGDest.type = BGGetType("BGDestType",BGDest.type,file);
|
| 1109 |
BGDest.pattern = BGGetPattern("BGDestPattern",BGDest.pattern,file);
|
| 1110 |
BGDest.antiAlias = BGGetOnOff("BGDestAntiAlias",BGDest.antiAlias,file);
|
| 1111 |
BGDest.color = BGGetColor("BGDestColor",BGDest.color,file);
|
| 1112 |
|
| 1113 |
GetPrivateProfileString(BG_SECTION,"BGDestFile",BGDest.file,path,MAX_PATH,file);
|
| 1114 |
RandomFile(path,BGDest.file,sizeof(BGDest.file));
|
| 1115 |
|
| 1116 |
//その他読み出し
|
| 1117 |
BGReverseTextAlpha = GetPrivateProfileInt(BG_SECTION,"BGReverseTextAlpha",BGReverseTextAlpha,file);
|
| 1118 |
BGReadTextColorConfig(file);
|
| 1119 |
}
|
| 1120 |
|
| 1121 |
void BGDestruct(void)
|
| 1122 |
{
|
| 1123 |
if(!BGEnable)
|
| 1124 |
return;
|
| 1125 |
|
| 1126 |
DeleteBitmapDC(&hdcBGBuffer);
|
| 1127 |
DeleteBitmapDC(&hdcBGWork);
|
| 1128 |
DeleteBitmapDC(&hdcBG);
|
| 1129 |
DeleteBitmapDC(&(BGDest.hdc));
|
| 1130 |
DeleteBitmapDC(&(BGSrc1.hdc));
|
| 1131 |
DeleteBitmapDC(&(BGSrc2.hdc));
|
| 1132 |
|
| 1133 |
//テンポラリーファイル削除
|
| 1134 |
DeleteFile(BGDest.fileTmp);
|
| 1135 |
DeleteFile(BGSrc1.fileTmp);
|
| 1136 |
DeleteFile(BGSrc2.fileTmp);
|
| 1137 |
}
|
| 1138 |
|
| 1139 |
void BGInitialize(void)
|
| 1140 |
{
|
| 1141 |
char path[MAX_PATH],config_file[MAX_PATH],tempPath[MAX_PATH];
|
| 1142 |
|
| 1143 |
// VTColor を読み込み
|
| 1144 |
BGVTColor[0] = ts.VTColor[0];
|
| 1145 |
BGVTColor[1] = ts.VTColor[1];
|
| 1146 |
|
| 1147 |
BGVTBoldColor[0] = ts.VTBoldColor[0];
|
| 1148 |
BGVTBoldColor[1] = ts.VTBoldColor[1];
|
| 1149 |
|
| 1150 |
BGVTBlinkColor[0] = ts.VTBlinkColor[0];
|
| 1151 |
BGVTBlinkColor[1] = ts.VTBlinkColor[1];
|
| 1152 |
|
| 1153 |
BGVTReverseColor[0] = ts.VTReverseColor[0];
|
| 1154 |
BGVTReverseColor[1] = ts.VTReverseColor[1];
|
| 1155 |
|
| 1156 |
#if 1
|
| 1157 |
// ハイパーリンク描画の復活。(2009.8.26 yutaka)
|
| 1158 |
/* begin - ishizaki */
|
| 1159 |
BGURLColor[0] = ts.URLColor[0];
|
| 1160 |
BGURLColor[1] = ts.URLColor[1];
|
| 1161 |
/* end - ishizaki */
|
| 1162 |
#else
|
| 1163 |
// TODO: ハイパーリンクの描画がリアルタイムに行われないことがあるので、
|
| 1164 |
// 色属性変更はいったん取りやめることにする。将来、対応する。(2005.4.3 yutaka)
|
| 1165 |
BGURLColor[0] = ts.VTColor[0];
|
| 1166 |
BGURLColor[1] = ts.VTColor[1];
|
| 1167 |
#endif
|
| 1168 |
|
| 1169 |
// ANSI color設定のほうを優先させる (2005.2.3 yutaka)
|
| 1170 |
InitColorTable();
|
| 1171 |
|
| 1172 |
//リソース解放
|
| 1173 |
BGDestruct();
|
| 1174 |
|
| 1175 |
//BG が有効かチェック
|
| 1176 |
ts.EtermLookfeel.BGEnable = BGEnable = BGGetOnOff("BGEnable",FALSE,ts.SetupFName);
|
| 1177 |
ts.EtermLookfeel.BGUseAlphaBlendAPI = BGGetOnOff("BGUseAlphaBlendAPI",TRUE ,ts.SetupFName);
|
| 1178 |
ts.EtermLookfeel.BGNoFrame = BGGetOnOff("BGNoFrame" ,FALSE,ts.SetupFName);
|
| 1179 |
ts.EtermLookfeel.BGFastSizeMove = BGGetOnOff("BGFastSizeMove" ,TRUE ,ts.SetupFName);
|
| 1180 |
ts.EtermLookfeel.BGNoCopyBits = BGGetOnOff("BGFlickerlessMove" ,TRUE ,ts.SetupFName);
|
| 1181 |
|
| 1182 |
GetPrivateProfileString(BG_SECTION,"BGSPIPath","plugin",BGSPIPath,MAX_PATH,ts.SetupFName);
|
| 1183 |
strncpy_s(ts.EtermLookfeel.BGSPIPath, sizeof(ts.EtermLookfeel.BGSPIPath), BGSPIPath, _TRUNCATE);
|
| 1184 |
|
| 1185 |
//コンフィグファイルの決定
|
| 1186 |
GetPrivateProfileString(BG_SECTION,"BGThemeFile","",path,MAX_PATH,ts.SetupFName);
|
| 1187 |
strncpy_s(ts.EtermLookfeel.BGThemeFile, sizeof(ts.EtermLookfeel.BGThemeFile), path, _TRUNCATE);
|
| 1188 |
|
| 1189 |
if(!BGEnable)
|
| 1190 |
return;
|
| 1191 |
|
| 1192 |
//乱数初期化
|
| 1193 |
// add cast (2006.2.18 yutaka)
|
| 1194 |
srand((unsigned int)time(NULL));
|
| 1195 |
|
| 1196 |
//BGシステム設定読み出し
|
| 1197 |
BGUseAlphaBlendAPI = ts.EtermLookfeel.BGUseAlphaBlendAPI;
|
| 1198 |
BGNoFrame = ts.EtermLookfeel.BGNoFrame;
|
| 1199 |
BGFastSizeMove = ts.EtermLookfeel.BGFastSizeMove;
|
| 1200 |
BGNoCopyBits = ts.EtermLookfeel.BGNoCopyBits;
|
| 1201 |
|
| 1202 |
#if 0
|
| 1203 |
GetPrivateProfileString(BG_SECTION,"BGSPIPath","plugin",BGSPIPath,MAX_PATH,ts.SetupFName);
|
| 1204 |
strncpy_s(ts.EtermLookfeel.BGSPIPath, sizeof(ts.EtermLookfeel.BGSPIPath), BGSPIPath, _TRUNCATE);
|
| 1205 |
#endif
|
| 1206 |
|
| 1207 |
//テンポラリーファイル名を生成
|
| 1208 |
GetTempPath(MAX_PATH,tempPath);
|
| 1209 |
GetTempFileName(tempPath,"ttAK",0,BGDest.fileTmp);
|
| 1210 |
GetTempFileName(tempPath,"ttAK",0,BGSrc1.fileTmp);
|
| 1211 |
GetTempFileName(tempPath,"ttAK",0,BGSrc2.fileTmp);
|
| 1212 |
|
| 1213 |
//デフォルト値
|
| 1214 |
BGDest.type = BG_PICTURE;
|
| 1215 |
BGDest.pattern = BG_STRETCH;
|
| 1216 |
BGDest.color = RGB(0,0,0);
|
| 1217 |
BGDest.antiAlias = TRUE;
|
| 1218 |
strncpy_s(BGDest.file, sizeof(BGDest.file),"", _TRUNCATE);
|
| 1219 |
|
| 1220 |
BGSrc1.type = BG_WALLPAPER;
|
| 1221 |
BGSrc1.pattern = BG_STRETCH;
|
| 1222 |
BGSrc1.color = RGB(255,255,255);
|
| 1223 |
BGSrc1.antiAlias = TRUE;
|
| 1224 |
BGSrc1.alpha = 255;
|
| 1225 |
strncpy_s(BGSrc1.file, sizeof(BGSrc1.file),"", _TRUNCATE);
|
| 1226 |
|
| 1227 |
BGSrc2.type = BG_COLOR;
|
| 1228 |
BGSrc2.pattern = BG_STRETCH;
|
| 1229 |
BGSrc2.color = RGB(0,0,0);
|
| 1230 |
BGSrc2.antiAlias = TRUE;
|
| 1231 |
BGSrc2.alpha = 128;
|
| 1232 |
strncpy_s(BGSrc2.file, sizeof(BGSrc2.file),"", _TRUNCATE);
|
| 1233 |
|
| 1234 |
BGReverseTextAlpha = 255;
|
| 1235 |
|
| 1236 |
//設定の読み出し
|
| 1237 |
BGReadIniFile(ts.SetupFName);
|
| 1238 |
|
| 1239 |
//コンフィグファイルの決定
|
| 1240 |
GetPrivateProfileString(BG_SECTION,"BGThemeFile","",path,MAX_PATH,ts.SetupFName);
|
| 1241 |
RandomFile(path,config_file,sizeof(config_file));
|
| 1242 |
|
| 1243 |
//設定のオーバーライド
|
| 1244 |
if(strcmp(config_file,""))
|
| 1245 |
{
|
| 1246 |
char dir[MAX_PATH],prevDir[MAX_PATH];
|
| 1247 |
|
| 1248 |
//INIファイルのあるディレクトリに一時的に移動
|
| 1249 |
GetCurrentDirectory(MAX_PATH,prevDir);
|
| 1250 |
|
| 1251 |
ExtractDirName(config_file,dir);
|
| 1252 |
SetCurrentDirectory(dir);
|
| 1253 |
|
| 1254 |
BGReadIniFile(config_file);
|
| 1255 |
|
| 1256 |
SetCurrentDirectory(prevDir);
|
| 1257 |
}
|
| 1258 |
|
| 1259 |
//SPI のパスを整形
|
| 1260 |
AppendSlash(BGSPIPath,sizeof(BGSPIPath));
|
| 1261 |
strncat_s(BGSPIPath,sizeof(BGSPIPath),"*",_TRUNCATE);
|
| 1262 |
|
| 1263 |
//壁紙 or 背景をプリロード
|
| 1264 |
BGPreloadSrc(&BGDest);
|
| 1265 |
BGPreloadSrc(&BGSrc1);
|
| 1266 |
BGPreloadSrc(&BGSrc2);
|
| 1267 |
|
| 1268 |
// AlphaBlend のアドレスを読み込み
|
| 1269 |
if(BGUseAlphaBlendAPI)
|
| 1270 |
(FARPROC)BGAlphaBlend = GetProcAddressWithDllName("msimg32.dll","AlphaBlend");
|
| 1271 |
else
|
| 1272 |
BGAlphaBlend = NULL;
|
| 1273 |
|
| 1274 |
if(!BGAlphaBlend)
|
| 1275 |
BGAlphaBlend = AlphaBlendWithoutAPI;
|
| 1276 |
|
| 1277 |
//EnumDisplayMonitors を探す
|
| 1278 |
(FARPROC)BGEnumDisplayMonitors = GetProcAddressWithDllName("user32.dll","EnumDisplayMonitors");
|
| 1279 |
}
|
| 1280 |
|
| 1281 |
void BGExchangeColor() {
|
| 1282 |
COLORREF ColorRef;
|
| 1283 |
if (ts.ColorFlag & CF_REVERSECOLOR) {
|
| 1284 |
ColorRef = BGVTColor[0];
|
| 1285 |
BGVTColor[0] = BGVTReverseColor[0];
|
| 1286 |
BGVTReverseColor[0] = ColorRef;
|
| 1287 |
ColorRef = BGVTColor[1];
|
| 1288 |
BGVTColor[1] = BGVTReverseColor[1];
|
| 1289 |
BGVTReverseColor[1] = ColorRef;
|
| 1290 |
}
|
| 1291 |
else {
|
| 1292 |
ColorRef = BGVTColor[0];
|
| 1293 |
BGVTColor[0] = BGVTColor[1];
|
| 1294 |
BGVTColor[1] = ColorRef;
|
| 1295 |
}
|
| 1296 |
|
| 1297 |
ColorRef = BGVTBoldColor[0];
|
| 1298 |
BGVTBoldColor[0] = BGVTBoldColor[1];
|
| 1299 |
BGVTBoldColor[1] = ColorRef;
|
| 1300 |
|
| 1301 |
ColorRef = BGVTBlinkColor[0];
|
| 1302 |
BGVTBlinkColor[0] = BGVTBlinkColor[1];
|
| 1303 |
BGVTBlinkColor[1] = ColorRef;
|
| 1304 |
|
| 1305 |
ColorRef = BGURLColor[0];
|
| 1306 |
BGURLColor[0] = BGURLColor[1];
|
| 1307 |
BGURLColor[1] = ColorRef;
|
| 1308 |
|
| 1309 |
// BGReverseText = !BGReverseText;
|
| 1310 |
}
|
| 1311 |
|
| 1312 |
void BGFillRect(HDC hdc,RECT *R,HBRUSH brush)
|
| 1313 |
{
|
| 1314 |
if(!BGEnable)
|
| 1315 |
FillRect(hdc,R,brush);
|
| 1316 |
else
|
| 1317 |
BitBlt(VTDC,R->left,R->top,R->right - R->left,R->bottom - R->top,hdcBG,R->left,R->top,SRCCOPY);
|
| 1318 |
}
|
| 1319 |
|
| 1320 |
void BGScrollWindow(HWND hwnd,int xa,int ya,RECT *Rect,RECT *ClipRect)
|
| 1321 |
{
|
| 1322 |
if (ts.MaximizedBugTweak) {
|
| 1323 |
// Eterm lookfeelが有効、もしくは最大化ウィンドウの場合はスクロールは使わない。
|
| 1324 |
// これにより、最大化ウィンドウで文字欠けとなる現象が改善される。(2008.2.1 doda, yutaka)
|
| 1325 |
if(BGEnable || IsZoomed(hwnd))
|
| 1326 |
InvalidateRect(HVTWin,ClipRect,FALSE);
|
| 1327 |
else
|
| 1328 |
ScrollWindow(hwnd,xa,ya,Rect,ClipRect);
|
| 1329 |
} else {
|
| 1330 |
if(!BGEnable)
|
| 1331 |
ScrollWindow(hwnd,xa,ya,Rect,ClipRect);
|
| 1332 |
else
|
| 1333 |
InvalidateRect(HVTWin,ClipRect,FALSE);
|
| 1334 |
}
|
| 1335 |
}
|
| 1336 |
|
| 1337 |
void BGOnEnterSizeMove(void)
|
| 1338 |
{
|
| 1339 |
int r,g,b;
|
| 1340 |
|
| 1341 |
if(!BGEnable || !BGFastSizeMove)
|
| 1342 |
return;
|
| 1343 |
|
| 1344 |
BGInSizeMove = TRUE;
|
| 1345 |
|
| 1346 |
//背景色生成
|
| 1347 |
r = GetRValue(BGDest.color);
|
| 1348 |
g = GetGValue(BGDest.color);
|
| 1349 |
b = GetBValue(BGDest.color);
|
| 1350 |
|
| 1351 |
r = (r * (255 - BGSrc1.alpha) + GetRValue(BGSrc1.color) * BGSrc1.alpha) >> 8;
|
| 1352 |
g = (g * (255 - BGSrc1.alpha) + GetGValue(BGSrc1.color) * BGSrc1.alpha) >> 8;
|
| 1353 |
b = (b * (255 - BGSrc1.alpha) + GetBValue(BGSrc1.color) * BGSrc1.alpha) >> 8;
|
| 1354 |
|
| 1355 |
r = (r * (255 - BGSrc2.alpha) + GetRValue(BGSrc2.color) * BGSrc2.alpha) >> 8;
|
| 1356 |
g = (g * (255 - BGSrc2.alpha) + GetGValue(BGSrc2.color) * BGSrc2.alpha) >> 8;
|
| 1357 |
b = (b * (255 - BGSrc2.alpha) + GetBValue(BGSrc2.color) * BGSrc2.alpha) >> 8;
|
| 1358 |
|
| 1359 |
BGBrushInSizeMove = CreateSolidBrush(RGB(r,g,b));
|
| 1360 |
}
|
| 1361 |
|
| 1362 |
void BGOnExitSizeMove(void)
|
| 1363 |
{
|
| 1364 |
if(!BGEnable || !BGFastSizeMove)
|
| 1365 |
return;
|
| 1366 |
|
| 1367 |
BGInSizeMove = FALSE;
|
| 1368 |
|
| 1369 |
BGSetupPrimary(TRUE);
|
| 1370 |
InvalidateRect(HVTWin,NULL,FALSE);
|
| 1371 |
|
| 1372 |
//ブラシを削除
|
| 1373 |
if(BGBrushInSizeMove)
|
| 1374 |
{
|
| 1375 |
DeleteObject(BGBrushInSizeMove);
|
| 1376 |
BGBrushInSizeMove = NULL;
|
| 1377 |
}
|
| 1378 |
}
|
| 1379 |
|
| 1380 |
void BGOnSettingChange(void)
|
| 1381 |
{
|
| 1382 |
if(!BGEnable)
|
| 1383 |
return;
|
| 1384 |
|
| 1385 |
CRTWidth = GetSystemMetrics(SM_CXSCREEN);
|
| 1386 |
CRTHeight = GetSystemMetrics(SM_CYSCREEN);
|
| 1387 |
|
| 1388 |
//壁紙 or 背景をプリロード
|
| 1389 |
BGPreloadSrc(&BGDest);
|
| 1390 |
BGPreloadSrc(&BGSrc1);
|
| 1391 |
BGPreloadSrc(&BGSrc2);
|
| 1392 |
|
| 1393 |
BGSetupPrimary(TRUE);
|
| 1394 |
InvalidateRect(HVTWin, NULL, FALSE);
|
| 1395 |
}
|
| 1396 |
|
| 1397 |
//-->
|
| 1398 |
#endif // ALPHABLEND_TYPE2
|
| 1399 |
|
| 1400 |
void DispApplyANSIColor() {
|
| 1401 |
int i;
|
| 1402 |
|
| 1403 |
for (i = IdBack ; i <= IdFore+8 ; i++)
|
| 1404 |
ANSIColor[i] = ts.ANSIColor[i];
|
| 1405 |
|
| 1406 |
if ((ts.ColorFlag & CF_USETEXTCOLOR)!=0) {
|
| 1407 |
#ifdef ALPHABLEND_TYPE2
|
| 1408 |
ANSIColor[IdBack ] = BGVTColor[1]; // use background color for "Black"
|
| 1409 |
ANSIColor[IdFore ] = BGVTColor[0]; // use text color for "white"
|
| 1410 |
#else
|
| 1411 |
ANSIColor[IdBack ] = ts.VTColor[1]; // use background color for "Black"
|
| 1412 |
ANSIColor[IdFore ] = ts.VTColor[0]; // use text color for "white"
|
| 1413 |
#endif
|
| 1414 |
}
|
| 1415 |
}
|
| 1416 |
|
| 1417 |
void InitColorTable()
|
| 1418 |
{
|
| 1419 |
#ifndef NO_ANSI_COLOR_EXTENSION
|
| 1420 |
DispApplyANSIColor();
|
| 1421 |
#else /* NO_ANSI_COLOR_EXTENSION */
|
| 1422 |
ANSIColor[IdBack ] = RGB( 0, 0, 0);
|
| 1423 |
ANSIColor[IdRed ] = RGB(255, 0, 0);
|
| 1424 |
ANSIColor[IdGreen] = RGB( 0,255, 0);
|
| 1425 |
ANSIColor[IdYellow] = RGB(255,255, 0);
|
| 1426 |
ANSIColor[IdBlue] = RGB( 0, 0,255);
|
| 1427 |
ANSIColor[IdMagenta] = RGB(255, 0,255);
|
| 1428 |
ANSIColor[IdCyan] = RGB( 0,255,255);
|
| 1429 |
ANSIColor[IdFore ] = RGB(255,255,255);
|
| 1430 |
ANSIColor[IdBack+8] = RGB(128,128,128);
|
| 1431 |
ANSIColor[IdRed+8] = RGB(128, 0, 0);
|
| 1432 |
ANSIColor[IdGreen+8] = RGB( 0,128, 0);
|
| 1433 |
ANSIColor[IdYellow+8] = RGB(128,128, 0);
|
| 1434 |
ANSIColor[IdBlue+8] = RGB( 0, 0,128);
|
| 1435 |
ANSIColor[IdMagenta+8] = RGB(128, 0,128);
|
| 1436 |
ANSIColor[IdCyan+8] = RGB( 0,128,128);
|
| 1437 |
ANSIColor[IdFore+8] = RGB(192,192,192);
|
| 1438 |
#endif /* NO_ANSI_COLOR_EXTENSION */
|
| 1439 |
ANSIColor[16] = RGB(0,0,0);
|
| 1440 |
ANSIColor[17] = RGB(0,0,95);
|
| 1441 |
ANSIColor[18] = RGB(0,0,135);
|
| 1442 |
ANSIColor[19] = RGB(0,0,175);
|
| 1443 |
ANSIColor[20] = RGB(0,0,215);
|
| 1444 |
ANSIColor[21] = RGB(0,0,255);
|
| 1445 |
ANSIColor[22] = RGB(0,95,0);
|
| 1446 |
ANSIColor[23] = RGB(0,95,95);
|
| 1447 |
ANSIColor[24] = RGB(0,95,135);
|
| 1448 |
ANSIColor[25] = RGB(0,95,175);
|
| 1449 |
ANSIColor[26] = RGB(0,95,215);
|
| 1450 |
ANSIColor[27] = RGB(0,95,255);
|
| 1451 |
ANSIColor[28] = RGB(0,135,0);
|
| 1452 |
ANSIColor[29] = RGB(0,135,95);
|
| 1453 |
ANSIColor[30] = RGB(0,135,135);
|
| 1454 |
ANSIColor[31] = RGB(0,135,175);
|
| 1455 |
ANSIColor[32] = RGB(0,135,215);
|
| 1456 |
ANSIColor[33] = RGB(0,135,255);
|
| 1457 |
ANSIColor[34] = RGB(0,175,0);
|
| 1458 |
ANSIColor[35] = RGB(0,175,95);
|
| 1459 |
ANSIColor[36] = RGB(0,175,135);
|
| 1460 |
ANSIColor[37] = RGB(0,175,175);
|
| 1461 |
ANSIColor[38] = RGB(0,175,215);
|
| 1462 |
ANSIColor[39] = RGB(0,175,255);
|
| 1463 |
ANSIColor[40] = RGB(0,215,0);
|
| 1464 |
ANSIColor[41] = RGB(0,215,95);
|
| 1465 |
ANSIColor[42] = RGB(0,215,135);
|
| 1466 |
ANSIColor[43] = RGB(0,215,175);
|
| 1467 |
ANSIColor[44] = RGB(0,215,215);
|
| 1468 |
ANSIColor[45] = RGB(0,215,255);
|
| 1469 |
ANSIColor[46] = RGB(0,255,0);
|
| 1470 |
ANSIColor[47] = RGB(0,255,95);
|
| 1471 |
ANSIColor[48] = RGB(0,255,135);
|
| 1472 |
ANSIColor[49] = RGB(0,255,175);
|
| 1473 |
ANSIColor[50] = RGB(0,255,215);
|
| 1474 |
ANSIColor[51] = RGB(0,255,255);
|
| 1475 |
ANSIColor[52] = RGB(95,0,0);
|
| 1476 |
ANSIColor[53] = RGB(95,0,95);
|
| 1477 |
ANSIColor[54] = RGB(95,0,135);
|
| 1478 |
ANSIColor[55] = RGB(95,0,175);
|
| 1479 |
ANSIColor[56] = RGB(95,0,215);
|
| 1480 |
ANSIColor[57] = RGB(95,0,255);
|
| 1481 |
ANSIColor[58] = RGB(95,95,0);
|
| 1482 |
ANSIColor[59] = RGB(95,95,95);
|
| 1483 |
ANSIColor[60] = RGB(95,95,135);
|
| 1484 |
ANSIColor[61] = RGB(95,95,175);
|
| 1485 |
ANSIColor[62] = RGB(95,95,215);
|
| 1486 |
ANSIColor[63] = RGB(95,95,255);
|
| 1487 |
ANSIColor[64] = RGB(95,135,0);
|
| 1488 |
ANSIColor[65] = RGB(95,135,95);
|
| 1489 |
ANSIColor[66] = RGB(95,135,135);
|
| 1490 |
ANSIColor[67] = RGB(95,135,175);
|
| 1491 |
ANSIColor[68] = RGB(95,135,215);
|
| 1492 |
ANSIColor[69] = RGB(95,135,255);
|
| 1493 |
ANSIColor[70] = RGB(95,175,0);
|
| 1494 |
ANSIColor[71] = RGB(95,175,95);
|
| 1495 |
ANSIColor[72] = RGB(95,175,135);
|
| 1496 |
ANSIColor[73] = RGB(95,175,175);
|
| 1497 |
ANSIColor[74] = RGB(95,175,215);
|
| 1498 |
ANSIColor[75] = RGB(95,175,255);
|
| 1499 |
ANSIColor[76] = RGB(95,215,0);
|
| 1500 |
ANSIColor[77] = RGB(95,215,95);
|
| 1501 |
ANSIColor[78] = RGB(95,215,135);
|
| 1502 |
ANSIColor[79] = RGB(95,215,175);
|
| 1503 |
ANSIColor[80] = RGB(95,215,215);
|
| 1504 |
ANSIColor[81] = RGB(95,215,255);
|
| 1505 |
ANSIColor[82] = RGB(95,255,0);
|
| 1506 |
ANSIColor[83] = RGB(95,255,95);
|
| 1507 |
ANSIColor[84] = RGB(95,255,135);
|
| 1508 |
ANSIColor[85] = RGB(95,255,175);
|
| 1509 |
ANSIColor[86] = RGB(95,255,215);
|
| 1510 |
ANSIColor[87] = RGB(95,255,255);
|
| 1511 |
ANSIColor[88] = RGB(135,0,0);
|
| 1512 |
ANSIColor[89] = RGB(135,0,95);
|
| 1513 |
ANSIColor[90] = RGB(135,0,135);
|
| 1514 |
ANSIColor[91] = RGB(135,0,175);
|
| 1515 |
ANSIColor[92] = RGB(135,0,215);
|
| 1516 |
ANSIColor[93] = RGB(135,0,255);
|
| 1517 |
ANSIColor[94] = RGB(135,95,0);
|
| 1518 |
ANSIColor[95] = RGB(135,95,95);
|
| 1519 |
ANSIColor[96] = RGB(135,95,135);
|
| 1520 |
ANSIColor[97] = RGB(135,95,175);
|
| 1521 |
ANSIColor[98] = RGB(135,95,215);
|
| 1522 |
ANSIColor[99] = RGB(135,95,255);
|
| 1523 |
ANSIColor[100] = RGB(135,135,0);
|
| 1524 |
ANSIColor[101] = RGB(135,135,95);
|
| 1525 |
ANSIColor[102] = RGB(135,135,135);
|
| 1526 |
ANSIColor[103] = RGB(135,135,175);
|
| 1527 |
ANSIColor[104] = RGB(135,135,215);
|
| 1528 |
ANSIColor[105] = RGB(135,135,255);
|
| 1529 |
ANSIColor[106] = RGB(135,175,0);
|
| 1530 |
ANSIColor[107] = RGB(135,175,95);
|
| 1531 |
ANSIColor[108] = RGB(135,175,135);
|
| 1532 |
ANSIColor[109] = RGB(135,175,175);
|
| 1533 |
ANSIColor[110] = RGB(135,175,215);
|
| 1534 |
ANSIColor[111] = RGB(135,175,255);
|
| 1535 |
ANSIColor[112] = RGB(135,215,0);
|
| 1536 |
ANSIColor[113] = RGB(135,215,95);
|
| 1537 |
ANSIColor[114] = RGB(135,215,135);
|
| 1538 |
ANSIColor[115] = RGB(135,215,175);
|
| 1539 |
ANSIColor[116] = RGB(135,215,215);
|
| 1540 |
ANSIColor[117] = RGB(135,215,255);
|
| 1541 |
ANSIColor[118] = RGB(135,255,0);
|
| 1542 |
ANSIColor[119] = RGB(135,255,95);
|
| 1543 |
ANSIColor[120] = RGB(135,255,135);
|
| 1544 |
ANSIColor[121] = RGB(135,255,175);
|
| 1545 |
ANSIColor[122] = RGB(135,255,215);
|
| 1546 |
ANSIColor[123] = RGB(135,255,255);
|
| 1547 |
ANSIColor[124] = RGB(175,0,0);
|
| 1548 |
ANSIColor[125] = RGB(175,0,95);
|
| 1549 |
ANSIColor[126] = RGB(175,0,135);
|
| 1550 |
ANSIColor[127] = RGB(175,0,175);
|
| 1551 |
ANSIColor[128] = RGB(175,0,215);
|
| 1552 |
ANSIColor[129] = RGB(175,0,255);
|
| 1553 |
ANSIColor[130] = RGB(175,95,0);
|
| 1554 |
ANSIColor[131] = RGB(175,95,95);
|
| 1555 |
ANSIColor[132] = RGB(175,95,135);
|
| 1556 |
ANSIColor[133] = RGB(175,95,175);
|
| 1557 |
ANSIColor[134] = RGB(175,95,215);
|
| 1558 |
ANSIColor[135] = RGB(175,95,255);
|
| 1559 |
ANSIColor[136] = RGB(175,135,0);
|
| 1560 |
ANSIColor[137] = RGB(175,135,95);
|
| 1561 |
ANSIColor[138] = RGB(175,135,135);
|
| 1562 |
ANSIColor[139] = RGB(175,135,175);
|
| 1563 |
ANSIColor[140] = RGB(175,135,215);
|
| 1564 |
ANSIColor[141] = RGB(175,135,255);
|
| 1565 |
ANSIColor[142] = RGB(175,175,0);
|
| 1566 |
ANSIColor[143] = RGB(175,175,95);
|
| 1567 |
ANSIColor[144] = RGB(175,175,135);
|
| 1568 |
ANSIColor[145] = RGB(175,175,175);
|
| 1569 |
ANSIColor[146] = RGB(175,175,215);
|
| 1570 |
ANSIColor[147] = RGB(175,175,255);
|
| 1571 |
ANSIColor[148] = RGB(175,215,0);
|
| 1572 |
ANSIColor[149] = RGB(175,215,95);
|
| 1573 |
ANSIColor[150] = RGB(175,215,135);
|
| 1574 |
ANSIColor[151] = RGB(175,215,175);
|
| 1575 |
ANSIColor[152] = RGB(175,215,215);
|
| 1576 |
ANSIColor[153] = RGB(175,215,255);
|
| 1577 |
ANSIColor[154] = RGB(175,255,0);
|
| 1578 |
ANSIColor[155] = RGB(175,255,95);
|
| 1579 |
ANSIColor[156] = RGB(175,255,135);
|
| 1580 |
ANSIColor[157] = RGB(175,255,175);
|
| 1581 |
ANSIColor[158] = RGB(175,255,215);
|
| 1582 |
ANSIColor[159] = RGB(175,255,255);
|
| 1583 |
ANSIColor[160] = RGB(215,0,0);
|
| 1584 |
ANSIColor[161] = RGB(215,0,95);
|
| 1585 |
ANSIColor[162] = RGB(215,0,135);
|
| 1586 |
ANSIColor[163] = RGB(215,0,175);
|
| 1587 |
ANSIColor[164] = RGB(215,0,215);
|
| 1588 |
ANSIColor[165] = RGB(215,0,255);
|
| 1589 |
ANSIColor[166] = RGB(215,95,0);
|
| 1590 |
ANSIColor[167] = RGB(215,95,95);
|
| 1591 |
ANSIColor[168] = RGB(215,95,135);
|
| 1592 |
ANSIColor[169] = RGB(215,95,175);
|
| 1593 |
ANSIColor[170] = RGB(215,95,215);
|
| 1594 |
ANSIColor[171] = RGB(215,95,255);
|
| 1595 |
ANSIColor[172] = RGB(215,135,0);
|
| 1596 |
ANSIColor[173] = RGB(215,135,95);
|
| 1597 |
ANSIColor[174] = RGB(215,135,135);
|
| 1598 |
ANSIColor[175] = RGB(215,135,175);
|
| 1599 |
ANSIColor[176] = RGB(215,135,215);
|
| 1600 |
ANSIColor[177] = RGB(215,135,255);
|
| 1601 |
ANSIColor[178] = RGB(215,175,0);
|
| 1602 |
ANSIColor[179] = RGB(215,175,95);
|
| 1603 |
ANSIColor[180] = RGB(215,175,135);
|
| 1604 |
ANSIColor[181] = RGB(215,175,175);
|
| 1605 |
ANSIColor[182] = RGB(215,175,215);
|
| 1606 |
ANSIColor[183] = RGB(215,175,255);
|
| 1607 |
ANSIColor[184] = RGB(215,215,0);
|
| 1608 |
ANSIColor[185] = RGB(215,215,95);
|
| 1609 |
ANSIColor[186] = RGB(215,215,135);
|
| 1610 |
ANSIColor[187] = RGB(215,215,175);
|
| 1611 |
ANSIColor[188] = RGB(215,215,215);
|
| 1612 |
ANSIColor[189] = RGB(215,215,255);
|
| 1613 |
ANSIColor[190] = RGB(215,255,0);
|
| 1614 |
ANSIColor[191] = RGB(215,255,95);
|
| 1615 |
ANSIColor[192] = RGB(215,255,135);
|
| 1616 |
ANSIColor[193] = RGB(215,255,175);
|
| 1617 |
ANSIColor[194] = RGB(215,255,215);
|
| 1618 |
ANSIColor[195] = RGB(215,255,255);
|
| 1619 |
ANSIColor[196] = RGB(255,0,0);
|
| 1620 |
ANSIColor[197] = RGB(255,0,95);
|
| 1621 |
ANSIColor[198] = RGB(255,0,135);
|
| 1622 |
ANSIColor[199] = RGB(255,0,175);
|
| 1623 |
ANSIColor[200] = RGB(255,0,215);
|
| 1624 |
ANSIColor[201] = RGB(255,0,255);
|
| 1625 |
ANSIColor[202] = RGB(255,95,0);
|
| 1626 |
ANSIColor[203] = RGB(255,95,95);
|
| 1627 |
ANSIColor[204] = RGB(255,95,135);
|
| 1628 |
ANSIColor[205] = RGB(255,95,175);
|
| 1629 |
ANSIColor[206] = RGB(255,95,215);
|
| 1630 |
ANSIColor[207] = RGB(255,95,255);
|
| 1631 |
ANSIColor[208] = RGB(255,135,0);
|
| 1632 |
ANSIColor[209] = RGB(255,135,95);
|
| 1633 |
ANSIColor[210] = RGB(255,135,135);
|
| 1634 |
ANSIColor[211] = RGB(255,135,175);
|
| 1635 |
ANSIColor[212] = RGB(255,135,215);
|
| 1636 |
ANSIColor[213] = RGB(255,135,255);
|
| 1637 |
ANSIColor[214] = RGB(255,175,0);
|
| 1638 |
ANSIColor[215] = RGB(255,175,95);
|
| 1639 |
ANSIColor[216] = RGB(255,175,135);
|
| 1640 |
ANSIColor[217] = RGB(255,175,175);
|
| 1641 |
ANSIColor[218] = RGB(255,175,215);
|
| 1642 |
ANSIColor[219] = RGB(255,175,255);
|
| 1643 |
ANSIColor[220] = RGB(255,215,0);
|
| 1644 |
ANSIColor[221] = RGB(255,215,95);
|
| 1645 |
ANSIColor[222] = RGB(255,215,135);
|
| 1646 |
ANSIColor[223] = RGB(255,215,175);
|
| 1647 |
ANSIColor[224] = RGB(255,215,215);
|
| 1648 |
ANSIColor[225] = RGB(255,215,255);
|
| 1649 |
ANSIColor[226] = RGB(255,255,0);
|
| 1650 |
ANSIColor[227] = RGB(255,255,95);
|
| 1651 |
ANSIColor[228] = RGB(255,255,135);
|
| 1652 |
ANSIColor[229] = RGB(255,255,175);
|
| 1653 |
ANSIColor[230] = RGB(255,255,215);
|
| 1654 |
ANSIColor[231] = RGB(255,255,255);
|
| 1655 |
ANSIColor[232] = RGB(8,8,8);
|
| 1656 |
ANSIColor[233] = RGB(18,18,18);
|
| 1657 |
ANSIColor[234] = RGB(28,28,28);
|
| 1658 |
ANSIColor[235] = RGB(38,38,38);
|
| 1659 |
ANSIColor[236] = RGB(48,48,48);
|
| 1660 |
ANSIColor[237] = RGB(58,58,58);
|
| 1661 |
ANSIColor[238] = RGB(68,68,68);
|
| 1662 |
ANSIColor[239] = RGB(78,78,78);
|
| 1663 |
ANSIColor[240] = RGB(88,88,88);
|
| 1664 |
ANSIColor[241] = RGB(98,98,98);
|
| 1665 |
ANSIColor[242] = RGB(108,108,108);
|
| 1666 |
ANSIColor[243] = RGB(118,118,118);
|
| 1667 |
ANSIColor[244] = RGB(128,128,128);
|
| 1668 |
ANSIColor[245] = RGB(138,138,138);
|
| 1669 |
ANSIColor[246] = RGB(148,148,148);
|
| 1670 |
ANSIColor[247] = RGB(158,158,158);
|
| 1671 |
ANSIColor[248] = RGB(168,168,168);
|
| 1672 |
ANSIColor[249] = RGB(178,178,178);
|
| 1673 |
ANSIColor[250] = RGB(188,188,188);
|
| 1674 |
ANSIColor[251] = RGB(198,198,198);
|
| 1675 |
ANSIColor[252] = RGB(208,208,208);
|
| 1676 |
ANSIColor[253] = RGB(218,218,218);
|
| 1677 |
ANSIColor[254] = RGB(228,228,228);
|
| 1678 |
ANSIColor[255] = RGB(238,238,238);
|
| 1679 |
|
| 1680 |
if ((ts.ColorFlag & CF_USETEXTCOLOR)!=0) {
|
| 1681 |
#ifdef ALPHABLEND_TYPE2
|
| 1682 |
ANSIColor[IdBack ] = BGVTColor[1]; // use background color for "Black"
|
| 1683 |
ANSIColor[IdFore ] = BGVTColor[0]; // use text color for "white"
|
| 1684 |
#else
|
| 1685 |
ANSIColor[IdBack ] = ts.VTColor[1]; // use background color for "Black"
|
| 1686 |
ANSIColor[IdFore ] = ts.VTColor[0]; // use text color for "white"
|
| 1687 |
#endif
|
| 1688 |
}
|
| 1689 |
}
|
| 1690 |
|
| 1691 |
void DispSetNearestColors(int start, int end, HDC DispCtx) {
|
| 1692 |
HDC TmpDC;
|
| 1693 |
int i;
|
| 1694 |
|
| 1695 |
if (DispCtx) {
|
| 1696 |
TmpDC = DispCtx;
|
| 1697 |
}
|
| 1698 |
else {
|
| 1699 |
TmpDC = GetDC(NULL);
|
| 1700 |
}
|
| 1701 |
|
| 1702 |
for (i = start ; i <= end; i++)
|
| 1703 |
ANSIColor[i] = GetNearestColor(TmpDC, ANSIColor[i]);
|
| 1704 |
|
| 1705 |
if (!DispCtx) {
|
| 1706 |
ReleaseDC(NULL, TmpDC);
|
| 1707 |
}
|
| 1708 |
}
|
| 1709 |
|
| 1710 |
void InitDisp()
|
| 1711 |
{
|
| 1712 |
HDC TmpDC;
|
| 1713 |
BOOL bMultiDisplaySupport = FALSE;
|
| 1714 |
|
| 1715 |
TmpDC = GetDC(NULL);
|
| 1716 |
|
| 1717 |
#ifdef ALPHABLEND_TYPE2
|
| 1718 |
CRTWidth = GetSystemMetrics(SM_CXSCREEN);
|
| 1719 |
CRTHeight = GetSystemMetrics(SM_CYSCREEN);
|
| 1720 |
|
| 1721 |
BGInitialize();
|
| 1722 |
#else
|
| 1723 |
InitColorTable();
|
| 1724 |
#endif // ALPHABLEND_TYPE2
|
| 1725 |
|
| 1726 |
DispSetNearestColors(IdBack, 255, TmpDC);
|
| 1727 |
|
| 1728 |
/* background paintbrush */
|
| 1729 |
Background = CreateSolidBrush(ts.VTColor[1]);
|
| 1730 |
/* CRT width & height */
|
| 1731 |
{
|
| 1732 |
OSVERSIONINFO ver;
|
| 1733 |
ZeroMemory( &ver, sizeof(ver) );
|
| 1734 |
ver.dwOSVersionInfoSize = sizeof(ver);
|
| 1735 |
GetVersionEx( &ver );
|
| 1736 |
switch( ver.dwPlatformId ) {
|
| 1737 |
// Windows 9x か NT かの判定
|
| 1738 |
case VER_PLATFORM_WIN32_WINDOWS:
|
| 1739 |
if( ver.dwMajorVersion > 4 ||
|
| 1740 |
(ver.dwMajorVersion == 4 && ver.dwMinorVersion >= 10) ) // Windows 98 or later
|
| 1741 |
bMultiDisplaySupport = TRUE;
|
| 1742 |
break;
|
| 1743 |
case VER_PLATFORM_WIN32_NT:
|
| 1744 |
if( ver.dwMajorVersion >= 5 ) // Windows 2000 or later
|
| 1745 |
bMultiDisplaySupport = TRUE;
|
| 1746 |
break;
|
| 1747 |
default:
|
| 1748 |
break;
|
| 1749 |
}
|
| 1750 |
}
|
| 1751 |
if( bMultiDisplaySupport ) {
|
| 1752 |
VirtualScreen.left = GetSystemMetrics(SM_XVIRTUALSCREEN);
|
| 1753 |
VirtualScreen.top = GetSystemMetrics(SM_YVIRTUALSCREEN);
|
| 1754 |
VirtualScreen.right = VirtualScreen.left + GetSystemMetrics(SM_CXVIRTUALSCREEN);
|
| 1755 |
VirtualScreen.bottom = VirtualScreen.top + GetSystemMetrics(SM_CYVIRTUALSCREEN);
|
| 1756 |
} else {
|
| 1757 |
VirtualScreen.left = 0;
|
| 1758 |
VirtualScreen.top = 0;
|
| 1759 |
VirtualScreen.right = GetDeviceCaps(TmpDC,HORZRES);
|
| 1760 |
VirtualScreen.bottom = GetDeviceCaps(TmpDC,VERTRES);
|
| 1761 |
}
|
| 1762 |
|
| 1763 |
ReleaseDC(NULL, TmpDC);
|
| 1764 |
|
| 1765 |
if ( (ts.VTPos.x > VirtualScreen.right) || (ts.VTPos.y > VirtualScreen.bottom) )
|
| 1766 |
{
|
| 1767 |
ts.VTPos.x = CW_USEDEFAULT;
|
| 1768 |
ts.VTPos.y = CW_USEDEFAULT;
|
| 1769 |
}
|
| 1770 |
else if ( (ts.VTPos.x < VirtualScreen.left-20) || (ts.VTPos.y < VirtualScreen.top-20) )
|
| 1771 |
{
|
| 1772 |
ts.VTPos.x = CW_USEDEFAULT;
|
| 1773 |
ts.VTPos.y = CW_USEDEFAULT;
|
| 1774 |
}
|
| 1775 |
else {
|
| 1776 |
if ( ts.VTPos.x < VirtualScreen.left ) ts.VTPos.x = VirtualScreen.left;
|
| 1777 |
if ( ts.VTPos.y < VirtualScreen.top ) ts.VTPos.y = VirtualScreen.top;
|
| 1778 |
}
|
| 1779 |
|
| 1780 |
if ( (ts.TEKPos.x > VirtualScreen.right) || (ts.TEKPos.y > VirtualScreen.bottom) )
|
| 1781 |
{
|
| 1782 |
ts.TEKPos.x = CW_USEDEFAULT;
|
| 1783 |
ts.TEKPos.y = CW_USEDEFAULT;
|
| 1784 |
}
|
| 1785 |
else if ( (ts.TEKPos.x < VirtualScreen.left-20) || (ts.TEKPos.y < VirtualScreen.top-20) )
|
| 1786 |
{
|
| 1787 |
ts.TEKPos.x = CW_USEDEFAULT;
|
| 1788 |
ts.TEKPos.y = CW_USEDEFAULT;
|
| 1789 |
}
|
| 1790 |
else {
|
| 1791 |
if ( ts.TEKPos.x < VirtualScreen.left ) ts.TEKPos.x = VirtualScreen.left;
|
| 1792 |
if ( ts.TEKPos.y < VirtualScreen.top ) ts.TEKPos.y = VirtualScreen.top;
|
| 1793 |
}
|
| 1794 |
}
|
| 1795 |
|
| 1796 |
void EndDisp()
|
| 1797 |
{
|
| 1798 |
int i, j;
|
| 1799 |
|
| 1800 |
if (VTDC!=NULL) DispReleaseDC();
|
| 1801 |
|
| 1802 |
/* Delete fonts */
|
| 1803 |
for (i = 0 ; i <= AttrFontMask; i++)
|
| 1804 |
{
|
| 1805 |
for (j = i+1 ; j <= AttrFontMask ; j++)
|
| 1806 |
if (VTFont[j]==VTFont[i])
|
| 1807 |
VTFont[j] = 0;
|
| 1808 |
if (VTFont[i]!=0) DeleteObject(VTFont[i]);
|
| 1809 |
}
|
| 1810 |
|
| 1811 |
if (Background!=0)
|
| 1812 |
{
|
| 1813 |
DeleteObject(Background);
|
| 1814 |
Background = 0;
|
| 1815 |
}
|
| 1816 |
|
| 1817 |
#ifdef ALPHABLEND_TYPE2
|
| 1818 |
//<!--by AKASI
|
| 1819 |
BGDestruct();
|
| 1820 |
//-->
|
| 1821 |
#endif // ALPHABLEND_TYPE2
|
| 1822 |
|
| 1823 |
}
|
| 1824 |
|
| 1825 |
void DispReset()
|
| 1826 |
{
|
| 1827 |
/* Cursor */
|
| 1828 |
CursorX = 0;
|
| 1829 |
CursorY = 0;
|
| 1830 |
|
| 1831 |
/* Scroll status */
|
| 1832 |
ScrollCount = 0;
|
| 1833 |
dScroll = 0;
|
| 1834 |
|
| 1835 |
if (IsCaretOn()) CaretOn();
|
| 1836 |
DispEnableCaret(TRUE); // enable caret
|
| 1837 |
}
|
| 1838 |
|
| 1839 |
void DispConvWinToScreen
|
| 1840 |
(int Xw, int Yw, int *Xs, int *Ys, PBOOL Right)
|
| 1841 |
// Converts window coordinate to screen cordinate
|
| 1842 |
// Xs: horizontal position in window coordinate (pixels)
|
| 1843 |
// Ys: vertical
|
| 1844 |
// Output
|
| 1845 |
// Xs, Ys: screen coordinate
|
| 1846 |
// Right: TRUE if the (Xs,Ys) is on the right half of
|
| 1847 |
// a character cell.
|
| 1848 |
{
|
| 1849 |
if (Xs!=NULL)
|
| 1850 |
*Xs = Xw / FontWidth + WinOrgX;
|
| 1851 |
*Ys = Yw / FontHeight + WinOrgY;
|
| 1852 |
if ((Xs!=NULL) && (Right!=NULL))
|
| 1853 |
*Right = (Xw - (*Xs-WinOrgX)*FontWidth) >= FontWidth/2;
|
| 1854 |
}
|
| 1855 |
|
| 1856 |
void DispConvScreenToWin
|
| 1857 |
(int Xs, int Ys, int *Xw, int *Yw)
|
| 1858 |
// Converts screen coordinate to window cordinate
|
| 1859 |
// Xs: horizontal position in screen coordinate (characters)
|
| 1860 |
// Ys: vertical
|
| 1861 |
// Output
|
| 1862 |
// Xw, Yw: window coordinate
|
| 1863 |
{
|
| 1864 |
if (Xw!=NULL)
|
| 1865 |
*Xw = (Xs - WinOrgX) * FontWidth;
|
| 1866 |
if (Yw!=NULL)
|
| 1867 |
*Yw = (Ys - WinOrgY) * FontHeight;
|
| 1868 |
}
|
| 1869 |
|
| 1870 |
void SetLogFont()
|
| 1871 |
{
|
| 1872 |
memset(&VTlf, 0, sizeof(LOGFONT));
|
| 1873 |
VTlf.lfWeight = FW_NORMAL;
|
| 1874 |
VTlf.lfItalic = 0;
|
| 1875 |
VTlf.lfUnderline = 0;
|
| 1876 |
VTlf.lfStrikeOut = 0;
|
| 1877 |
VTlf.lfWidth = ts.VTFontSize.x;
|
| 1878 |
VTlf.lfHeight = ts.VTFontSize.y;
|
| 1879 |
VTlf.lfCharSet = ts.VTFontCharSet;
|
| 1880 |
VTlf.lfOutPrecision = OUT_CHARACTER_PRECIS;
|
| 1881 |
VTlf.lfClipPrecision = CLIP_CHARACTER_PRECIS;
|
| 1882 |
VTlf.lfQuality = DEFAULT_QUALITY;
|
| 1883 |
VTlf.lfPitchAndFamily = FIXED_PITCH | FF_DONTCARE;
|
| 1884 |
strncpy_s(VTlf.lfFaceName, sizeof(VTlf.lfFaceName),ts.VTFont, _TRUNCATE);
|
| 1885 |
}
|
| 1886 |
|
| 1887 |
void ChangeFont()
|
| 1888 |
{
|
| 1889 |
int i, j;
|
| 1890 |
TEXTMETRIC Metrics;
|
| 1891 |
HDC TmpDC;
|
| 1892 |
|
| 1893 |
/* Delete Old Fonts */
|
| 1894 |
for (i = 0 ; i <= AttrFontMask ; i++)
|
| 1895 |
{
|
| 1896 |
for (j = i+1 ; j <= AttrFontMask ; j++)
|
| 1897 |
if (VTFont[j]==VTFont[i])
|
| 1898 |
VTFont[j] = 0;
|
| 1899 |
if (VTFont[i]!=0)
|
| 1900 |
DeleteObject(VTFont[i]);
|
| 1901 |
}
|
| 1902 |
|
| 1903 |
/* Normal Font */
|
| 1904 |
SetLogFont();
|
| 1905 |
VTFont[0] = CreateFontIndirect(&VTlf);
|
| 1906 |
|
| 1907 |
/* set IME font */
|
| 1908 |
SetConversionLogFont(&VTlf);
|
| 1909 |
|
| 1910 |
TmpDC = GetDC(HVTWin);
|
| 1911 |
|
| 1912 |
SelectObject(TmpDC, VTFont[0]);
|
| 1913 |
GetTextMetrics(TmpDC, &Metrics);
|
| 1914 |
FontWidth = Metrics.tmAveCharWidth + ts.FontDW;
|
| 1915 |
FontHeight = Metrics.tmHeight + ts.FontDH;
|
| 1916 |
|
| 1917 |
ReleaseDC(HVTWin,TmpDC);
|
| 1918 |
|
| 1919 |
/* Underline */
|
| 1920 |
VTlf.lfUnderline = 1;
|
| 1921 |
VTFont[AttrUnder] = CreateFontIndirect(&VTlf);
|
| 1922 |
|
| 1923 |
if (ts.FontFlag & FF_BOLD) {
|
| 1924 |
/* Bold */
|
| 1925 |
VTlf.lfUnderline = 0;
|
| 1926 |
VTlf.lfWeight = FW_BOLD;
|
| 1927 |
VTFont[AttrBold] = CreateFontIndirect(&VTlf);
|
| 1928 |
/* Bold + Underline */
|
| 1929 |
VTlf.lfUnderline = 1;
|
| 1930 |
VTFont[AttrBold | AttrUnder] = CreateFontIndirect(&VTlf);
|
| 1931 |
}
|
| 1932 |
else {
|
| 1933 |
VTFont[AttrBold] = VTFont[AttrDefault];
|
| 1934 |
VTFont[AttrBold | AttrUnder] = VTFont[AttrUnder];
|
| 1935 |
}
|
| 1936 |
|
| 1937 |
/* Special font */
|
| 1938 |
VTlf.lfWeight = FW_NORMAL;
|
| 1939 |
VTlf.lfUnderline = 0;
|
| 1940 |
VTlf.lfWidth = FontWidth + 1; /* adjust width */
|
| 1941 |
VTlf.lfHeight = FontHeight;
|
| 1942 |
VTlf.lfCharSet = SYMBOL_CHARSET;
|
| 1943 |
|
| 1944 |
strncpy_s(VTlf.lfFaceName, sizeof(VTlf.lfFaceName),"Tera Special", _TRUNCATE);
|
| 1945 |
VTFont[AttrSpecial] = CreateFontIndirect(&VTlf);
|
| 1946 |
VTFont[AttrSpecial | AttrBold] = VTFont[AttrSpecial];
|
| 1947 |
VTFont[AttrSpecial | AttrUnder] = VTFont[AttrSpecial];
|
| 1948 |
VTFont[AttrSpecial | AttrBold | AttrUnder] = VTFont[AttrSpecial];
|
| 1949 |
|
| 1950 |
SetLogFont();
|
| 1951 |
|
| 1952 |
for (i = 0 ; i <= 255; i++)
|
| 1953 |
Dx[i] = FontWidth;
|
| 1954 |
}
|
| 1955 |
|
| 1956 |
void ResetIME()
|
| 1957 |
{
|
| 1958 |
/* reset language for communication */
|
| 1959 |
cv.Language = ts.Language;
|
| 1960 |
|
| 1961 |
/* reset IME */
|
| 1962 |
if ((ts.Language==IdJapanese) || (ts.Language==IdKorean) || (ts.Language==IdUtf8)) //HKS
|
| 1963 |
{
|
| 1964 |
if (ts.UseIME==0)
|
| 1965 |
FreeIME();
|
| 1966 |
else if (! LoadIME())
|
| 1967 |
ts.UseIME = 0;
|
| 1968 |
|
| 1969 |
if (ts.UseIME>0)
|
| 1970 |
{
|
| 1971 |
if (ts.IMEInline>0)
|
| 1972 |
SetConversionLogFont(&VTlf);
|
| 1973 |
else
|
| 1974 |
SetConversionWindow(HVTWin,-1,0);
|
| 1975 |
}
|
| 1976 |
}
|
| 1977 |
else
|
| 1978 |
FreeIME();
|
| 1979 |
|
| 1980 |
if (IsCaretOn()) CaretOn();
|
| 1981 |
}
|
| 1982 |
|
| 1983 |
void ChangeCaret()
|
| 1984 |
{
|
| 1985 |
UINT T;
|
| 1986 |
|
| 1987 |
if (! Active) return;
|
| 1988 |
if (CaretEnabled)
|
| 1989 |
{
|
| 1990 |
DestroyCaret();
|
| 1991 |
switch (ts.CursorShape) {
|
| 1992 |
case IdVCur:
|
| 1993 |
CreateCaret(HVTWin, 0, CurWidth, FontHeight);
|
| 1994 |
break;
|
| 1995 |
case IdHCur:
|
| 1996 |
CreateCaret(HVTWin, 0, FontWidth, CurWidth);
|
| 1997 |
break;
|
| 1998 |
}
|
| 1999 |
CaretStatus = 1;
|
| 2000 |
}
|
| 2001 |
CaretOn();
|
| 2002 |
if (CaretEnabled &&
|
| 2003 |
(ts.NonblinkingCursor!=0))
|
| 2004 |
{
|
| 2005 |
T = GetCaretBlinkTime() * 2 / 3;
|
| 2006 |
SetTimer(HVTWin,IdCaretTimer,T,NULL);
|
| 2007 |
}
|
| 2008 |
UpdateCaretPosition(TRUE);
|
| 2009 |
}
|
| 2010 |
|
| 2011 |
// WM_KILLFOCUSされたときのカーソルを自分で描く
|
| 2012 |
void CaretKillFocus(BOOL show)
|
| 2013 |
{
|
| 2014 |
int CaretX, CaretY;
|
| 2015 |
POINT p[5];
|
| 2016 |
HPEN oldpen;
|
| 2017 |
HDC hdc;
|
| 2018 |
|
| 2019 |
if (ts.KillFocusCursor == 0)
|
| 2020 |
return;
|
| 2021 |
|
| 2022 |
// Eterm lookfeelの場合は何もしない
|
| 2023 |
#ifdef ALPHABLEND_TYPE2
|
| 2024 |
if (BGEnable)
|
| 2025 |
return;
|
| 2026 |
#endif // ALPHABLEND_TYPE2
|
| 2027 |
|
| 2028 |
/* Get Device Context */
|
| 2029 |
DispInitDC();
|
| 2030 |
hdc = VTDC;
|
| 2031 |
|
| 2032 |
CaretX = (CursorX-WinOrgX)*FontWidth;
|
| 2033 |
CaretY = (CursorY-WinOrgY)*FontHeight;
|
| 2034 |
|
| 2035 |
p[0].x = CaretX;
|
| 2036 |
p[0].y = CaretY;
|
| 2037 |
p[1].x = CaretX;
|
| 2038 |
p[1].y = CaretY + FontHeight - 1;
|
| 2039 |
if (CursorOnDBCS)
|
| 2040 |
p[2].x = CaretX + FontWidth*2 - 1;
|
| 2041 |
else
|
| 2042 |
p[2].x = CaretX + FontWidth - 1;
|
| 2043 |
p[2].y = CaretY + FontHeight - 1;
|
| 2044 |
if (CursorOnDBCS)
|
| 2045 |
p[3].x = CaretX + FontWidth*2 - 1;
|
| 2046 |
else
|
| 2047 |
p[3].x = CaretX + FontWidth - 1;
|
| 2048 |
p[3].y = CaretY;
|
| 2049 |
p[4].x = CaretX;
|
| 2050 |
p[4].y = CaretY;
|
| 2051 |
|
| 2052 |
if (show) { // ポリゴンカーソルを表示(非フォーカス時)
|
| 2053 |
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, ts.VTColor[0]));
|
| 2054 |
} else {
|
| 2055 |
oldpen = SelectObject(hdc, CreatePen(PS_SOLID, 0, ts.VTColor[1]));
|
| 2056 |
}
|
| 2057 |
Polyline(VTDC, p, 5);
|
| 2058 |
oldpen = SelectObject(hdc, oldpen);
|
| 2059 |
DeleteObject(oldpen);
|
| 2060 |
|
| 2061 |
/* release device context */
|
| 2062 |
DispReleaseDC();
|
| 2063 |
}
|
| 2064 |
|
| 2065 |
// ポリゴンカーソルを消したあとに、その部分の文字を再描画する。
|
| 2066 |
//
|
| 2067 |
// CaretOff()の直後に呼ぶこと。CaretOff()内から呼ぶと、無限再帰呼び出しとなり、
|
| 2068 |
// stack overflowになる。
|
| 2069 |
//
|
| 2070 |
// カーソル形状変更時(ChangeCaret)にも呼ぶことにしたため、関数名変更 -- 2009/04/17 doda.
|
| 2071 |
//
|
| 2072 |
void UpdateCaretPosition(BOOL enforce)
|
| 2073 |
{
|
| 2074 |
int CaretX, CaretY;
|
| 2075 |
RECT rc;
|
| 2076 |
|
| 2077 |
CaretX = (CursorX-WinOrgX)*FontWidth;
|
| 2078 |
CaretY = (CursorY-WinOrgY)*FontHeight;
|
| 2079 |
|
| 2080 |
if (!enforce && !ts.KillFocusCursor)
|
| 2081 |
return;
|
| 2082 |
|
| 2083 |
// Eterm lookfeelの場合は何もしない
|
| 2084 |
#ifdef ALPHABLEND_TYPE2
|
| 2085 |
if (BGEnable)
|
| 2086 |
return;
|
| 2087 |
#endif // ALPHABLEND_TYPE2
|
| 2088 |
|
| 2089 |
if (enforce == TRUE || !Active) {
|
| 2090 |
rc.left = CaretX;
|
| 2091 |
rc.top = CaretY;
|
| 2092 |
if (CursorOnDBCS)
|
| 2093 |
rc.right = CaretX + FontWidth*2;
|
| 2094 |
else
|
| 2095 |
rc.right = CaretX + FontWidth;
|
| 2096 |
rc.bottom = CaretY + FontHeight;
|
| 2097 |
// 指定よりも1ピクセル小さい範囲が再描画されるため
|
| 2098 |
// rc の right, bottom は1ピクセル大きくしている。
|
| 2099 |
InvalidateRect(HVTWin, &rc, FALSE);
|
| 2100 |
}
|
| 2101 |
}
|
| 2102 |
|
| 2103 |
void CaretOn()
|
| 2104 |
// Turn on the cursor
|
| 2105 |
{
|
| 2106 |
int CaretX, CaretY, H;
|
| 2107 |
|
| 2108 |
if (ts.KillFocusCursor == 0 && !Active)
|
| 2109 |
return;
|
| 2110 |
|
| 2111 |
CaretX = (CursorX-WinOrgX)*FontWidth;
|
| 2112 |
CaretY = (CursorY-WinOrgY)*FontHeight;
|
| 2113 |
|
| 2114 |
if ((ts.Language==IdJapanese || ts.Language==IdKorean || ts.Language==IdUtf8) &&
|
| 2115 |
CanUseIME() && (ts.IMEInline>0))
|
| 2116 |
{
|
| 2117 |
/* set IME conversion window pos. & font */
|
| 2118 |
SetConversionWindow(HVTWin,CaretX,CaretY);
|
| 2119 |
}
|
| 2120 |
|
| 2121 |
if (! CaretEnabled) return;
|
| 2122 |
|
| 2123 |
if (Active) {
|
| 2124 |
if (ts.CursorShape!=IdVCur) {
|
| 2125 |
if (ts.CursorShape==IdHCur) {
|
| 2126 |
CaretY = CaretY+FontHeight-CurWidth;
|
| 2127 |
H = CurWidth;
|
| 2128 |
}
|
| 2129 |
else {
|
| 2130 |
H = FontHeight;
|
| 2131 |
}
|
| 2132 |
|
| 2133 |
DestroyCaret();
|
| 2134 |
if (CursorOnDBCS) {
|
| 2135 |
/* double width caret */
|
| 2136 |
CreateCaret(HVTWin, 0, FontWidth*2, H);
|
| 2137 |
}
|
| 2138 |
else {
|
| 2139 |
/* single width caret */
|
| 2140 |
CreateCaret(HVTWin, 0, FontWidth, H);
|
| 2141 |
}
|
| 2142 |
CaretStatus = 1;
|
| 2143 |
}
|
| 2144 |
SetCaretPos(CaretX,CaretY);
|
| 2145 |
}
|
| 2146 |
|
| 2147 |
while (CaretStatus > 0) {
|
| 2148 |
if (! Active) {
|
| 2149 |
CaretKillFocus(TRUE);
|
| 2150 |
} else {
|
| 2151 |
ShowCaret(HVTWin);
|
| 2152 |
}
|
| 2153 |
CaretStatus--;
|
| 2154 |
}
|
| 2155 |
}
|
| 2156 |
|
| 2157 |
void CaretOff()
|
| 2158 |
{
|
| 2159 |
if (ts.KillFocusCursor == 0 && !Active)
|
| 2160 |
return;
|
| 2161 |
|
| 2162 |
if (CaretStatus == 0) {
|
| 2163 |
if (! Active) {
|
| 2164 |
CaretKillFocus(FALSE);
|
| 2165 |
} else {
|
| 2166 |
HideCaret(HVTWin);
|
| 2167 |
}
|
| 2168 |
CaretStatus++;
|
| 2169 |
}
|
| 2170 |
}
|
| 2171 |
|
| 2172 |
void DispDestroyCaret()
|
| 2173 |
{
|
| 2174 |
DestroyCaret();
|
| 2175 |
if (ts.NonblinkingCursor!=0)
|
| 2176 |
KillTimer(HVTWin,IdCaretTimer);
|
| 2177 |
}
|
| 2178 |
|
| 2179 |
BOOL IsCaretOn()
|
| 2180 |
// check if caret is on
|
| 2181 |
{
|
| 2182 |
// 非アクティブ(フォーカス無効)の場合においても、カーソル描画を行いたいため、
|
| 2183 |
// 2つめの条件を追加する。(2008.1.24 yutaka)
|
| 2184 |
if (ts.KillFocusCursor == 0)
|
| 2185 |
return (( Active && (CaretStatus==0)) );
|
| 2186 |
else
|
| 2187 |
return ((Active && (CaretStatus==0)) || (!Active && (CaretStatus==0)));
|
| 2188 |
}
|
| 2189 |
|
| 2190 |
void DispEnableCaret(BOOL On)
|
| 2191 |
{
|
| 2192 |
if (! On) CaretOff();
|
| 2193 |
CaretEnabled = On;
|
| 2194 |
}
|
| 2195 |
|
| 2196 |
BOOL IsCaretEnabled()
|
| 2197 |
{
|
| 2198 |
return CaretEnabled;
|
| 2199 |
}
|
| 2200 |
|
| 2201 |
void DispSetCaretWidth(BOOL DW)
|
| 2202 |
{
|
| 2203 |
/* TRUE if cursor is on a DBCS character */
|
| 2204 |
CursorOnDBCS = DW;
|
| 2205 |
}
|
| 2206 |
|
| 2207 |
void DispChangeWinSize(int Nx, int Ny)
|
| 2208 |
{
|
| 2209 |
LONG W,H,dW,dH;
|
| 2210 |
RECT R;
|
| 2211 |
|
| 2212 |
if (SaveWinSize)
|
| 2213 |
{
|
| 2214 |
WinWidthOld = WinWidth;
|
| 2215 |
WinHeightOld = WinHeight;
|
| 2216 |
SaveWinSize = FALSE;
|
| 2217 |
}
|
| 2218 |
else {
|
| 2219 |
WinWidthOld = NumOfColumns;
|
| 2220 |
WinHeightOld = NumOfLines;
|
| 2221 |
}
|
| 2222 |
|
| 2223 |
WinWidth = Nx;
|
| 2224 |
WinHeight = Ny;
|
| 2225 |
|
| 2226 |
ScreenWidth = WinWidth*FontWidth;
|
| 2227 |
ScreenHeight = WinHeight*FontHeight;
|
| 2228 |
|
| 2229 |
AdjustScrollBar();
|
| 2230 |
|
| 2231 |
GetWindowRect(HVTWin,&R);
|
| 2232 |
W = R.right-R.left;
|
| 2233 |
H = R.bottom-R.top;
|
| 2234 |
GetClientRect(HVTWin,&R);
|
| 2235 |
dW = ScreenWidth - R.right + R.left;
|
| 2236 |
dH = ScreenHeight - R.bottom + R.top;
|
| 2237 |
|
| 2238 |
if ((dW!=0) || (dH!=0))
|
| 2239 |
{
|
| 2240 |
AdjustSize = TRUE;
|
| 2241 |
|
| 2242 |
// SWP_NOMOVE を指定しているのになぜか 0,0 が反映され、
|
| 2243 |
// マルチディスプレイ環境ではプライマリモニタに
|
| 2244 |
// 移動してしまうのを修正 (2008.5.29 maya)
|
| 2245 |
//SetWindowPos(HVTWin,HWND_TOP,0,0,W+dW,H+dH,SWP_NOMOVE);
|
| 2246 |
|
| 2247 |
// マルチディスプレイ環境で最大化したときに、
|
| 2248 |
// 隣のディスプレイにウィンドウの端がはみ出す問題を修正 (2008.5.30 maya)
|
| 2249 |
// また、上記の状態では最大化状態でもウィンドウを移動させることが出来る。
|
| 2250 |
if (!IsZoomed(HVTWin)) {
|
| 2251 |
SetWindowPos(HVTWin,HWND_TOP,R.left,R.top,W+dW,H+dH,SWP_NOMOVE);
|
| 2252 |
}
|
| 2253 |
}
|
| 2254 |
else
|
| 2255 |
InvalidateRect(HVTWin,NULL,FALSE);
|
| 2256 |
}
|
| 2257 |
|
| 2258 |
void ResizeWindow(int x, int y, int w, int h, int cw, int ch)
|
| 2259 |
{
|
| 2260 |
int dw,dh, NewX, NewY;
|
| 2261 |
POINT Point;
|
| 2262 |
|
| 2263 |
if (! AdjustSize) return;
|
| 2264 |
dw = ScreenWidth - cw;
|
| 2265 |
dh = ScreenHeight - ch;
|
| 2266 |
if ((dw!=0) || (dh!=0)) {
|
| 2267 |
SetWindowPos(HVTWin,HWND_TOP,x,y,w+dw,h+dh,SWP_NOMOVE);
|
| 2268 |
AdjustSize = FALSE;
|
| 2269 |
}
|
| 2270 |
else {
|
| 2271 |
AdjustSize = FALSE;
|
| 2272 |
|
| 2273 |
NewX = x;
|
| 2274 |
NewY = y;
|
| 2275 |
if (x+w > VirtualScreen.right)
|
| 2276 |
{
|
| 2277 |
NewX = VirtualScreen.right-w;
|
| 2278 |
if (NewX < 0) NewX = 0;
|
| 2279 |
}
|
| 2280 |
if (y+h > VirtualScreen.bottom)
|
| 2281 |
{
|
| 2282 |
NewY = VirtualScreen.bottom-h;
|
| 2283 |
if (NewY < 0) NewY = 0;
|
| 2284 |
}
|
| 2285 |
if ((NewX!=x) || (NewY!=y))
|
| 2286 |
SetWindowPos(HVTWin,HWND_TOP,NewX,NewY,w,h,SWP_NOSIZE);
|
| 2287 |
|
| 2288 |
Point.x = 0;
|
| 2289 |
Point.y = ScreenHeight;
|
| 2290 |
ClientToScreen(HVTWin,&Point);
|
| 2291 |
CompletelyVisible = (Point.y <= VirtualScreen.bottom);
|
| 2292 |
if (IsCaretOn()) CaretOn();
|
| 2293 |
}
|
| 2294 |
}
|
| 2295 |
|
| 2296 |
void PaintWindow(HDC PaintDC, RECT PaintRect, BOOL fBkGnd,
|
| 2297 |
int* Xs, int* Ys, int* Xe, int* Ye)
|
| 2298 |
// Paint window with background color &
|
| 2299 |
// convert paint region from window coord. to screen coord.
|
| 2300 |
// Called from WM_PAINT handler
|
| 2301 |
// PaintRect: Paint region in window coordinate
|
| 2302 |
// Return:
|
| 2303 |
// *Xs, *Ys: upper left corner of the region
|
| 2304 |
// in screen coord.
|
| 2305 |
// *Xe, *Ye: lower right
|
| 2306 |
{
|
| 2307 |
if (VTDC!=NULL)
|
| 2308 |
DispReleaseDC();
|
| 2309 |
VTDC = PaintDC;
|
| 2310 |
DCPrevFont = SelectObject(VTDC, VTFont[0]);
|
| 2311 |
DispInitDC();
|
| 2312 |
|
| 2313 |
#ifdef ALPHABLEND_TYPE2
|
| 2314 |
//<!--by AKASI
|
| 2315 |
//if (fBkGnd)
|
| 2316 |
if(!BGEnable && fBkGnd)
|
| 2317 |
//-->
|
| 2318 |
#else
|
| 2319 |
if (fBkGnd)
|
| 2320 |
#endif // ALPHABLEND_TYPE2
|
| 2321 |
|
| 2322 |
FillRect(VTDC, &PaintRect,Background);
|
| 2323 |
|
| 2324 |
*Xs = PaintRect.left / FontWidth + WinOrgX;
|
| 2325 |
*Ys = PaintRect.top / FontHeight + WinOrgY;
|
| 2326 |
*Xe = (PaintRect.right-1) / FontWidth + WinOrgX;
|
| 2327 |
*Ye = (PaintRect.bottom-1) / FontHeight + WinOrgY;
|
| 2328 |
}
|
| 2329 |
|
| 2330 |
void DispEndPaint()
|
| 2331 |
{
|
| 2332 |
if (VTDC==NULL) return;
|
| 2333 |
SelectObject(VTDC,DCPrevFont);
|
| 2334 |
VTDC = NULL;
|
| 2335 |
}
|
| 2336 |
|
| 2337 |
void DispClearWin()
|
| 2338 |
{
|
| 2339 |
InvalidateRect(HVTWin,NULL,FALSE);
|
| 2340 |
|
| 2341 |
ScrollCount = 0;
|
| 2342 |
dScroll = 0;
|
| 2343 |
if (WinHeight > NumOfLines)
|
| 2344 |
DispChangeWinSize(NumOfColumns,NumOfLines);
|
| 2345 |
else {
|
| 2346 |
if ((NumOfLines==WinHeight) && (ts.EnableScrollBuff>0))
|
| 2347 |
{
|
| 2348 |
SetScrollRange(HVTWin,SB_VERT,0,1,FALSE);
|
| 2349 |
}
|
| 2350 |
else
|
| 2351 |
SetScrollRange(HVTWin,SB_VERT,0,NumOfLines-WinHeight,FALSE);
|
| 2352 |
|
| 2353 |
SetScrollPos(HVTWin,SB_HORZ,0,TRUE);
|
| 2354 |
SetScrollPos(HVTWin,SB_VERT,0,TRUE);
|
| 2355 |
}
|
| 2356 |
if (IsCaretOn()) CaretOn();
|
| 2357 |
}
|
| 2358 |
|
| 2359 |
void DispChangeBackground()
|
| 2360 |
{
|
| 2361 |
DispReleaseDC();
|
| 2362 |
if (Background != NULL) DeleteObject(Background);
|
| 2363 |
|
| 2364 |
if ((CurCharAttr.Attr2 & Attr2Back) != 0) {
|
| 2365 |
if ((CurCharAttr.Back<16) && (CurCharAttr.Back&7)!=0)
|
| 2366 |
Background = CreateSolidBrush(ANSIColor[CurCharAttr.Back ^ 8]);
|
| 2367 |
else
|
| 2368 |
Background = CreateSolidBrush(ANSIColor[CurCharAttr.Back]);
|
| 2369 |
}
|
| 2370 |
else {
|
| 2371 |
#ifdef ALPHABLEND_TYPE2
|
| 2372 |
Background = CreateSolidBrush(BGVTColor[1]);
|
| 2373 |
#else
|
| 2374 |
Background = CreateSolidBrush(ts.VTColor[1]);
|
| 2375 |
#endif // ALPHABLEND_TYPE2
|
| 2376 |
}
|
| 2377 |
|
| 2378 |
InvalidateRect(HVTWin,NULL,TRUE);
|
| 2379 |
}
|
| 2380 |
|
| 2381 |
void DispChangeWin()
|
| 2382 |
{
|
| 2383 |
/* Change window caption */
|
| 2384 |
ChangeTitle();
|
| 2385 |
|
| 2386 |
/* Menu bar / Popup menu */
|
| 2387 |
SwitchMenu();
|
| 2388 |
|
| 2389 |
SwitchTitleBar();
|
| 2390 |
|
| 2391 |
/* Change caret shape */
|
| 2392 |
ChangeCaret();
|
| 2393 |
|
| 2394 |
if ((ts.ColorFlag & CF_USETEXTCOLOR)==0)
|
| 2395 |
{
|
| 2396 |
#ifndef NO_ANSI_COLOR_EXTENSION
|
| 2397 |
ANSIColor[IdFore ] = ts.ANSIColor[IdFore ];
|
| 2398 |
ANSIColor[IdBack ] = ts.ANSIColor[IdBack ];
|
| 2399 |
#else /* NO_ANSI_COLOR_EXTENSION */
|
| 2400 |
ANSIColor[IdFore ] = RGB(255,255,255);
|
| 2401 |
ANSIColor[IdBack ] = RGB( 0, 0, 0);
|
| 2402 |
#endif /* NO_ANSI_COLOR_EXTENSION */
|
| 2403 |
}
|
| 2404 |
else { // use text (background) color for "white (black)"
|
| 2405 |
ANSIColor[IdFore ] = ts.VTColor[0];
|
| 2406 |
ANSIColor[IdBack ] = ts.VTColor[1];
|
| 2407 |
|
| 2408 |
#ifdef ALPHABLEND_TYPE2
|
| 2409 |
ANSIColor[IdFore ] = BGVTColor[0];
|
| 2410 |
ANSIColor[IdBack ] = BGVTColor[1];
|
| 2411 |
#endif // ALPHABLEND_TYPE2
|
| 2412 |
|
| 2413 |
}
|
| 2414 |
|
| 2415 |
/* change background color */
|
| 2416 |
DispChangeBackground();
|
| 2417 |
}
|
| 2418 |
|
| 2419 |
void DispInitDC()
|
| 2420 |
{
|
| 2421 |
|
| 2422 |
if (VTDC==NULL)
|
| 2423 |
{
|
| 2424 |
VTDC = GetDC(HVTWin);
|
| 2425 |
DCPrevFont = SelectObject(VTDC, VTFont[0]);
|
| 2426 |
}
|
| 2427 |
else
|
| 2428 |
SelectObject(VTDC, VTFont[0]);
|
| 2429 |
|
| 2430 |
#ifdef ALPHABLEND_TYPE2
|
| 2431 |
SetTextColor(VTDC, BGVTColor[0]);
|
| 2432 |
SetBkColor(VTDC, BGVTColor[1]);
|
| 2433 |
#else
|
| 2434 |
SetTextColor(VTDC, ts.VTColor[0]);
|
| 2435 |
SetBkColor(VTDC, ts.VTColor[1]);
|
| 2436 |
#endif // ALPHABLEND_TYPE2
|
| 2437 |
|
| 2438 |
SetBkMode(VTDC,OPAQUE);
|
| 2439 |
DCAttr = DefCharAttr;
|
| 2440 |
DCReverse = FALSE;
|
| 2441 |
|
| 2442 |
#ifdef ALPHABLEND_TYPE2
|
| 2443 |
//<!--by AKASI
|
| 2444 |
BGReverseText = FALSE;
|
| 2445 |
//-->
|
| 2446 |
#endif // ALPHABLEND_TYPE2
|
| 2447 |
}
|
| 2448 |
|
| 2449 |
void DispReleaseDC()
|
| 2450 |
{
|
| 2451 |
if (VTDC==NULL) return;
|
| 2452 |
SelectObject(VTDC, DCPrevFont);
|
| 2453 |
ReleaseDC(HVTWin,VTDC);
|
| 2454 |
VTDC = NULL;
|
| 2455 |
}
|
| 2456 |
|
| 2457 |
#define isURLColored(x) ((ts.ColorFlag & CF_URLCOLOR) && ((x).Attr & AttrURL))
|
| 2458 |
#define isURLUnderlined(x) ((ts.FontFlag & FF_URLUNDERLINE) && ((x).Attr & AttrURL))
|
| 2459 |
#define isBoldColored(x) ((ts.ColorFlag & CF_BOLDCOLOR) && ((x).Attr & AttrBold))
|
| 2460 |
#define isBlinkColored(x) ((ts.ColorFlag & CF_BLINKCOLOR) && ((x).Attr & AttrBlink))
|
| 2461 |
#define isReverseColored(x) ((ts.ColorFlag & CF_REVERSECOLOR) && ((x).Attr & AttrReverse))
|
| 2462 |
#define isForeColored(x) ((ts.ColorFlag & CF_ANSICOLOR) && ((x).Attr2 & Attr2Fore))
|
| 2463 |
#define isBackColored(x) ((ts.ColorFlag & CF_ANSICOLOR) && ((x).Attr2 & Attr2Back))
|
| 2464 |
|
| 2465 |
void DispSetupDC(TCharAttr Attr, BOOL Reverse)
|
| 2466 |
// Setup device context
|
| 2467 |
// Attr: character attributes
|
| 2468 |
// Reverse: true if text is selected (reversed) by mouse
|
| 2469 |
{
|
| 2470 |
COLORREF TextColor, BackColor;
|
| 2471 |
int NoReverseColor = 2;
|
| 2472 |
|
| 2473 |
if (VTDC==NULL) DispInitDC();
|
| 2474 |
|
| 2475 |
if (TCharAttrCmp(DCAttr, Attr) == 0 && DCReverse == Reverse) {
|
| 2476 |
return;
|
| 2477 |
}
|
| 2478 |
DCAttr = Attr;
|
| 2479 |
DCReverse = Reverse;
|
| 2480 |
|
| 2481 |
SelectObject(VTDC, VTFont[(Attr.Attr & AttrFontMask) | (isURLUnderlined(Attr)?AttrUnder:0)]);
|
| 2482 |
|
| 2483 |
if ((ts.ColorFlag & CF_FULLCOLOR) == 0) {
|
| 2484 |
if (isBlinkColored(Attr)) {
|
| 2485 |
#ifdef ALPHABLEND_TYPE2 // AKASI
|
| 2486 |
TextColor = BGVTBlinkColor[0];
|
| 2487 |
BackColor = BGVTBlinkColor[1];
|
| 2488 |
#else
|
| 2489 |
TextColor = ts.VTBlinkColor[0];
|
| 2490 |
BackColor = ts.VTBlinkColor[1];
|
| 2491 |
#endif
|
| 2492 |
}
|
| 2493 |
else if (isBoldColored(Attr)) {
|
| 2494 |
#ifdef ALPHABLEND_TYPE2 // AKASI
|
| 2495 |
TextColor = BGVTBoldColor[0];
|
| 2496 |
BackColor = BGVTBoldColor[1];
|
| 2497 |
#else
|
| 2498 |
TextColor = ts.VTBoldColor[0];
|
| 2499 |
BackColor = ts.VTBoldColor[1];
|
| 2500 |
#endif
|
| 2501 |
}
|
| 2502 |
/* begin - ishizaki */
|
| 2503 |
else if (isURLColored(Attr)) {
|
| 2504 |
#ifdef ALPHABLEND_TYPE2 // AKASI
|
| 2505 |
TextColor = BGURLColor[0];
|
| 2506 |
BackColor = BGURLColor[1];
|
| 2507 |
#else
|
| 2508 |
TextColor = ts.URLColor[0];
|
| 2509 |
BackColor = ts.URLColor[1];
|
| 2510 |
#endif
|
| 2511 |
}
|
| 2512 |
/* end - ishizaki */
|
| 2513 |
else {
|
| 2514 |
if (isForeColored(Attr)) {
|
| 2515 |
TextColor = ANSIColor[Attr.Fore];
|
| 2516 |
}
|
| 2517 |
else {
|
| 2518 |