1 #ifndef _WIN32_H_ 2 #define _WIN32_H_ 3 #include <windows.h> 4 #include <winspool.h> 5 #include <wtypes.h> 6 #define Rect xxRect 7 #define Color xxColor 8 #define Point xxPoint 9 #include <gdiplus/gdiplus.h> 10 #undef Rect 11 #undef Color 12 #undef Point 13 #include "apricot.h" 14 15 #ifdef __cplusplus 16 extern "C" { 17 #endif 18 19 20 #define SEVERE_DEBUG 21 typedef HANDLE WINHANDLE; 22 23 #ifdef __CYGWIN__ 24 typedef int SOCKETHANDLE; 25 #else 26 typedef HANDLE SOCKETHANDLE; 27 #endif 28 29 #undef HWND_DESKTOP 30 #define HWND_DESKTOP guts. desktopWindow 31 32 33 #ifdef UNICODE 34 #error This version of apc_Win32 does not support Unicode 35 #endif 36 37 #define DEFAULT_SYSTEM_FONT "System" 38 #define DEFAULT_WIDGET_FONT (((DWORD)(LOBYTE(LOWORD(guts.version)))>5)?"Segoe UI":"MS Shell Dlg") 39 #define DEFAULT_WIDGET_FONT_SIZE (((DWORD)(LOBYTE(LOWORD(guts.version)))>5)?9:8) 40 #define COLOR_TOLERANCE 4 41 #define HASMATE_MAGIC 0xDEAF0CE1 42 #define MENU_ID_AUTOSTART 100 43 #define TID_USERMAX 32767 44 #define REG_STORAGE "SOFTWARE\\Perl\\Prima" 45 #define MAXREGLEN 1024 46 47 #define WM_WRITE_TO_LOG ( WM_USER + 0) 48 #define WM_PRIMA_CREATE ( WM_USER + 1) 49 #define WM_POSTAL ( WM_USER + 2) 50 #define WM_DLGENTERMODAL ( WM_USER + 3) 51 #define WM_ZORDERSYNC ( WM_USER + 4) 52 #define WM_MOUSEENTER ( WM_USER + 6) 53 #define WM_MOUSEEXIT ( WM_USER + 7) 54 #define WM_SETVISIBLE ( WM_USER + 8) 55 #define WM_KEYPACKET ( WM_USER + 9) 56 #define WM_LMOUSECLICK ( WM_USER + 10) 57 #define WM_MMOUSECLICK ( WM_USER + 11) 58 #define WM_RMOUSECLICK ( WM_USER + 12) 59 #define WM_FORCEFOCUS ( WM_USER + 13) 60 #define WM_SYNCMOVE ( WM_USER + 14) 61 #define WM_SOCKET ( WM_USER + 15) 62 #define WM_SOCKET_REHASH ( WM_USER + 16) 63 #define WM_EXTERNAL ( WM_USER + 17) 64 #define WM_HASMATE ( WM_USER + 18) 65 #define WM_FILE ( WM_USER + 19) 66 #define WM_CROAK ( WM_USER + 20) 67 #define WM_REPAINT_LAYERED ( WM_USER + 21) 68 #define WM_DRAG_RESPONSE ( WM_USER + 22) 69 #define WM_XMOUSECLICK ( WM_USER + 23) 70 #define WM_TERMINATE ( WM_USER + 99) 71 #define WM_FIRST_USER_MESSAGE ( WM_USER +100) 72 #define WM_LAST_USER_MESSAGE ( WM_USER +900) 73 74 #ifndef WM_DPICHANGED 75 #define WM_DPICHANGED 0x02E0 76 #endif 77 78 #define WC_CUSTOM 0 79 #define WC_DLG 1 80 #define WC_APPLICATION 2 81 #define WC_FRAME 3 82 #define WC_MENU 4 83 #define WC_POPUP 5 84 85 #define exsLinePattern 1 86 #define exsLineEnd 2 87 #define exsLineJoin 4 88 89 #define stbPen 0x01 90 #define stbBrush 0x02 91 #define stbText 0x04 92 #define stbBacking 0x08 93 #define stbGDIMask 0x0F 94 #define stbGPBrush 0x10 95 96 #define SOCKETS_NONE ( guts. socket_version == -1) 97 #define SOCKETS_AS_HANDLES ( guts. socket_version == 1) 98 #define SOCKETS_NATIVE ( guts. socket_version == 2) 99 100 #define FHT_SOCKET 1 101 #define FHT_PIPE 2 102 #define FHT_OTHER 3 103 104 #define apcWarn \ 105 if (debug) \ 106 warn( "win32 error 0x%x: '%s' at line %d in %s\n", (unsigned int)rc, \ 107 err_msg( rc, NULL), __LINE__, __FILE__); \ 108 else \ 109 err_msg( rc, NULL) 110 111 #define apcErr( err) apcError = err 112 #define apiErr { \ 113 rc = GetLastError(); \ 114 apcError = errApcError; \ 115 apcWarn; \ 116 } 117 #define apiAltErr( err) { \ 118 apcError = errApcError; \ 119 rc = err; \ 120 apcWarn; \ 121 } 122 #define apiErrRet { apiErr; return false; } 123 #define apcErrRet(err) { apcErr(err); return false; } 124 #define apcErrClear { apcError = errOk; } 125 126 #define GPCALL rc = (DWORD) 127 #define apiGPErr { \ 128 apcError = errApcError; \ 129 if ( debug ) \ 130 warn( "win32 error 0x%x: '%s' at line %d in %s\n", (unsigned int)rc, \ 131 err_msg_gplus( rc, NULL), __LINE__, __FILE__); \ 132 rc |= 0x40000; \ 133 } 134 #define apiGPErrCheck if (rc) apiGPErr; 135 #define apiGPErrCheckRet(f) if (rc) { apiGPErr; return f; } 136 #define apiHErr(hr) { \ 137 apcError = errApcError; \ 138 rc = hr; \ 139 apcWarn; \ 140 } 141 142 #define apiHErrRet(hr) { apiHErr(hr); return false; } 143 144 #define objCheck if ( var stage == csDead) return 145 #define dobjCheck(handle) if ((( PObject)handle)-> stage == csDead) return 146 147 #define SHIFT_X(X) X + sys gp_transform.x 148 #define SHIFT_Y(Y) sys lastSize.y - (Y) - 1 + sys gp_transform.y 149 #define SHIFT_XY(X,Y) X += sys gp_transform.x,Y = sys lastSize.y - (Y) - 1 + sys gp_transform.y 150 151 typedef struct _HandleOptions_ { 152 unsigned aptWM_PAINT : 1; // true if inside WM_PAINT 153 unsigned aptWinPS : 1; // window PS was passed to paint 154 unsigned aptCompatiblePS : 1; // PS is screen-compatible 155 unsigned aptFontExists : 1; // font is selected on HPS 156 unsigned aptCursorVis : 1; // cursor visible flag 157 unsigned aptFocused : 1; // set if control if focused 158 unsigned aptFirstClick : 1; // set if control can process WM_BUTTONXDOWN without pre-activation 159 unsigned aptClipOwner : 1; // if set, parent of this window is HWND_DESKTOP 160 unsigned aptLockVisState : 1; // visible/locked flag 161 unsigned aptTransparent : 1; // transparency flag 162 unsigned aptSyncPaint : 1; // WS_SYNCPAINT analog 163 unsigned aptVisible : 1; // visibility flag 164 unsigned aptTaskList : 1; // Window flag - set if in task list 165 unsigned aptDeviceBitmap : 1; // == kind_of( CDeviceBitmap) 166 unsigned aptBitmap : 1; // buffered widget 167 unsigned aptImage : 1; // == kind_of( CImage) 168 unsigned aptIcon : 1; // == kind_of( CIcon) 169 unsigned aptPrinter : 1; // == kind_of( CPrinter) 170 unsigned aptExtraFont : 1; // extra font styles ( angle, shear) has been applied 171 unsigned aptDCChangeLock : 1; // locks SelectObject() calls 172 unsigned aptEnabled : 1; // enabled flag 173 unsigned aptTextOpaque : 1; // gp text drawing flag 174 unsigned aptTextOutBaseline : 1; // gp text drawing flag 175 unsigned aptWinPosDetermined : 1; // 0 when size is set, but position is not 176 unsigned aptOnTop : 1; // HWND_TOPMOST is set 177 unsigned aptLayered : 1; // WS_EX_LAYERED 178 unsigned aptRepaintPending : 1; // for optLayered 179 unsigned aptMovePending : 1; // for optLayered 180 unsigned aptLayeredPaint : 1; // painting children of layered window 181 unsigned aptLayeredRequested : 1; // Prima wants layered 182 unsigned aptClipByChildren : 1; // cached clipping by children 183 unsigned aptIgnoreSizeMessages : 1; // during window recreation 184 unsigned aptGDIPlus : 1; // uses GDI+ 185 } HandleOptions; 186 187 #define CLIPBOARD_MAIN 0 188 #define CLIPBOARD_DND 1 189 190 typedef struct _WinGuts 191 { 192 HINSTANCE instance; // application instance 193 int cmdShow; // run command state 194 int appLock; // application lock count 195 int pointerLock; // pointer lock count 196 DWORD mainThreadId; // Id of main thread 197 Point displayResolution; // screen resolution in ppi 198 char defaultFixedFont [ 256]; 199 char defaultVariableFont [ 256]; 200 char defaultSystemFont [ 256]; 201 Font windowFont; // window default font 202 Font menuFont; // menu default font 203 Font msgFont; // message default font 204 Font capFont; // caption default font 205 BITMAPINFO displayBMInfo; // display bpp & size 206 HWND desktopWindow; // GetDesktopWindow() result 207 Bool insertMode; // fake insert mode 208 Point iconSizeLarge; 209 Point iconSizeSmall; 210 Point pointerSize; 211 BYTE keyState[ 256]; // application key buffer state 212 BYTE emptyKeyState[ 256];// just zeros 213 BYTE *currentKeyState; // current virtual key buffer state 214 HKL keyLayout; // key layout, most likely latin for Ctrl+Key mapping 215 NONCLIENTMETRICSW ncmData; // windows system data 216 List transp; // transparent controls list 217 int topWindows; // count of top-level windows in app 218 Bool focSysDisabled; // focus system disabled 219 Bool focSysGranted; // SetFocus() was called inside apc_widget_set_focused 220 Bool focSysDialog; // system dialog is in action 221 UINT errorMode; // SetErrorMode() result 222 DWORD version; // GetVersion() cached result 223 Point smDblClk; // cached SM_CxDOUBLECLK values 224 int socket_version; // socket behavior type 225 List files; // List of active File objects 226 int mouseTimer; // is mouse timer started 227 Bool popupActive; // flag to avoid double popup activation 228 Bool pointerInvisible; 229 HWND console; // win32-bound console window 230 Byte msgMask[100]; // 800 user-defined messages allowed 231 // socket variables 232 List sockets; // List of watchable sockets 233 HANDLE socketMutex; // thread semaphore 234 HANDLE socketThread; // thread id 235 Bool socketPostSync; // semaphore 236 Bool dont_xlate_message; // one-time stopper to TranslateMessage() call 237 int utf8_prepend_0x202D;// newer windows do automatic bidi conversion, this is to cancel it 238 WCHAR * (*alloc_utf8_to_wchar_visual)(const char*,int,int*); 239 ULONG_PTR gdiplusToken; // GDI+ handle 240 Handle clipboards[2]; 241 Bool ole_initialized; 242 void* dndDataSender; // IDropTarget.DragEnter.DataObject dnd storage object 243 void* dndDataReceiver; // CLIPBOARD_DND storage object 244 Bool dndInsideEvent; // to distinguish whether the clipboard is read-only or not 245 Bool dndDefaultCursors; 246 void* dragSource; // not null if dragging 247 Handle dragSourceWidget; // 248 Handle dragTarget; // last successful drop 249 WORD language_id; // default shaping language 250 char language_descr[32]; 251 Bool application_stop_signal; 252 } WinGuts, *PWinGuts; 253 254 typedef struct _WindowData 255 { 256 int borderIcons; 257 int borderStyle; 258 Point hiddenPos; 259 Point hiddenSize; 260 int state; 261 Handle oldFoc; 262 HWND oldActive; 263 PHash effects; 264 } WindowData; 265 266 typedef struct _TimerData 267 { 268 int timeout; 269 } TimerData; 270 271 typedef struct _MenuItemData 272 { 273 int saved_dc; 274 } MenuItemData; 275 276 typedef struct _FileData 277 { 278 SOCKETHANDLE object; 279 int type; 280 } FileData; 281 282 typedef struct 283 { 284 HRGN region; 285 int aperture; 286 } RegionData; 287 288 289 typedef struct _XLOGPALETTE { 290 WORD palVersion; 291 WORD palNumEntries; 292 PALETTEENTRY palPalEntry[ 256]; 293 } XLOGPALETTE, *PXLOGPALETTE; 294 295 typedef struct _XBITMAPINFO { 296 BITMAPINFOHEADER bmiHeader; 297 RGBQUAD bmiColors[ 256]; 298 } XBITMAPINFO, *PXBITMAPINFO; 299 300 #define BM_NONE 0 301 #define BM_BITMAP 1 302 #define BM_PIXMAP 2 303 #define BM_LAYERED 3 304 #define BM_AUTO 4 305 306 typedef struct _ImageCache 307 { 308 int cacheType; 309 XBITMAPINFO rawHeader; 310 Byte* rawBits; 311 Bool freeBits; 312 HBITMAP bitmap; /* copy of sys bm, if any */ 313 } ImageCache; 314 315 typedef struct _ImageData 316 { 317 HRGN imgCachedRegion; 318 uint32_t* argbBits; 319 ImageCache cache; 320 } ImageData; 321 322 typedef struct _PrinterData 323 { 324 PRINTER_INFO_2 ppi; 325 char defPrnBuf[ 256]; 326 char *device; 327 char *driver; 328 char *port; 329 } PrinterData; 330 331 typedef struct _PaintSaveData 332 { 333 Bool antialias; 334 int alpha; 335 Color lbs[2]; 336 Bool fillMode; 337 float lineWidth; 338 int lineEnd; 339 int lineJoin; 340 unsigned char * linePattern; 341 int linePatternLen; 342 float miterLimit; 343 FillPattern fillPattern; 344 Point fillPatternOffset; 345 int rop; 346 int rop2; 347 Point transform; 348 Font font; 349 Bool textOpaque; 350 Bool textOutB; 351 } PaintSaveData, *PPaintSaveData; 352 353 typedef struct _PatResource 354 { 355 DWORD dotsCount; 356 DWORD* dotsPtr; 357 DWORD dots[ 1]; 358 } PatResource, *PPatResource; 359 360 typedef struct _EXTPEN 361 { 362 Bool actual; 363 DWORD style; 364 DWORD lineEnd; 365 DWORD lineJoin; 366 float lineWidth; 367 PatResource * patResource; 368 } EXTPEN, *PEXTPEN; 369 370 typedef struct _EXTLOGBRUSH 371 { 372 LOGBRUSH lb; 373 COLORREF backColor; 374 FillPattern pattern; 375 } EXTLOGBRUSH, *PEXTLOGBRUSH; 376 377 typedef struct _DIBMONOBRUSH 378 { 379 BITMAPINFOHEADER bmiHeader; 380 RGBQUAD bmiColors[2]; 381 unsigned char bmiData[32]; 382 } DIBMONOBRUSH, *PDIBMONOBRUSH; 383 384 typedef struct _Stylus 385 { 386 LOGPEN pen; 387 EXTLOGBRUSH brush; 388 EXTPEN extPen; 389 } Stylus, *PStylus; 390 391 typedef struct _DCStylus 392 { 393 Stylus s; 394 int refcnt; 395 HPEN hpen; 396 HBRUSH hbrush; 397 } DCStylus, *PDCStylus; 398 399 typedef struct _DCFont 400 { 401 Font font; 402 int refcnt; 403 HFONT hfont; 404 } DCFont, *PDCFont; 405 406 #define GP_BRUSH_SOLID 0 407 #define GP_BRUSH_FILLPATTERN 1 408 #define GP_SOLID_PEN 2 409 410 typedef struct _GPStylus 411 { 412 int type, opaque; 413 uint32_t fg, bg; 414 FillPattern fill; 415 } GPStylus, *PGPStylus; 416 417 typedef struct _DCGPStylus 418 { 419 GPStylus s; 420 int refcnt; 421 GpBrush * brush; 422 GpPen * pen; 423 } DCGPStylus, *PDCGPStylus; 424 425 typedef struct _DrawableData 426 { 427 /* Drawable basic data*/ 428 HDC ps; // general HDC 429 GpGraphics *graphics; // GDI+ context 430 PAINTSTRUCT paintStruc; // HDC counterpart 431 HBITMAP bm; // cached bitmap 432 HPALETTE pal; // cached palette 433 434 /* stylus and font hash management fields */ 435 PDCStylus stylusResource; // current stylus pointer 436 int stylusFlags; // stylus resource cache( stbXXXX) 437 Stylus stylus; // widgets stylus record 438 PDCFont fontResource; // font resource pointer 439 PDCGPStylus stylusGPResource; // GDI+ resource pointer 440 441 /* Stock objects of HDC - to be restored after paint mode */ 442 HPEN stockPen; 443 HBRUSH stockBrush; 444 HFONT stockFont; 445 HBITMAP stockBM; 446 HPALETTE stockPalette; 447 448 /* HDC info fields */ 449 int bpp; // bits per pixel 450 Point res; // resolution 451 452 /* for opaque stroke emulation */ 453 int currentROP; 454 int currentROP2; 455 int alpha; 456 HPEN opaquePen; 457 458 /* cached GetTextMetrics */ 459 BYTE tmPitchAndFamily; 460 LONG tmOverhang; 461 int otmsStrikeoutSize, otmsStrikeoutPosition, otmsUnderscoreSize, otmsUnderscorePosition; 462 float font_sin, font_cos; 463 464 /* HDC attributes storage outside paint mode */ 465 Color lbs[2]; 466 int fillMode, psFillMode; 467 float lineWidth; 468 int lineEnd; 469 int lineJoin; 470 unsigned char *linePattern; 471 int linePatternLen; 472 FillPattern fillPattern; 473 FillPattern fillPattern2; 474 Point fillPatternOffset; 475 int rop; 476 int rop2; 477 float miterLimit; 478 Point transform; 479 Point gp_transform; 480 PPaintSaveData psd; // Their values during paint saved in sys psd 481 482 /* Basic widget fields */ 483 HWND handle; // Windows handle of a widget 484 HWND owner; // Windows owner of a widget 485 HWND parent; // Windows parent of a widget 486 HWND parentHandle; 487 int className; // class name ( WC_XXX) 488 489 /* Widget properties */ 490 HandleOptions options; // apt_XXX settings 491 ColorSet viewColors; // widget color palette 492 PXLOGPALETTE p256; // cached squeezed palette 493 void * recreateData; // ViewProfile custom area 494 495 /* Custom data for widget paint in optBuffered state */ 496 HDC ps2; // original HDC 497 HPALETTE pal2; // original palette 498 Point transform2; // necessary additional transposition 499 500 /* Positioning support fields */ 501 Point lastSize; // last actual size 502 int sizeLockLevel; // size locking flag 503 int yOverride; // special cached height value. Used in WM_SIZE<->WM_MOVE interactions 504 505 /* Widget attributes - timers, cursor, pointers, menu, shape */ 506 Point cursorPos; // cursor position 507 Point cursorSize; // cursor size 508 HCURSOR pointer; // pointer handle 509 HCURSOR pointer2; // user pointer data 510 int pointerId; // pointer id 511 Handle lastMenu; // last menu activated by WM_INITMENU or WM_INITMENUPOPUP 512 Point extraBounds; // used in region calculations 513 Point extraPos; // used in region calculations 514 Point layeredPos; // delayed layered window positioning 515 516 /* Widget DND stuff */ 517 void* dropTarget; 518 519 /* Layered subpaint */ 520 Point layeredPaintOffset; 521 HDC layeredPaintSurface; 522 HRGN layeredParentRegion; 523 524 /* alpha text amulation */ 525 HDC alphaArenaDC; 526 HBITMAP alphaArenaBitmap; 527 uint32_t* alphaArenaPtr; 528 Point alphaArenaSize; 529 Bool alphaArenaFontChanged; 530 HFONT alphaArenaStockFont; 531 HBITMAP alphaArenaStockBitmap; 532 uint32_t* alphaArenaPalette; 533 534 /* Other class-specific data */ 535 union { 536 TimerData timer; 537 WindowData window; 538 PrinterData prn; 539 FileData file; 540 ImageData image; 541 RegionData region; 542 MenuItemData menuitem; 543 } s; 544 } DrawableData, *PDrawableData; 545 546 typedef struct _MenuWndData 547 { 548 Handle menu; 549 int id; 550 } MenuWndData, *PMenuWndData; 551 552 typedef struct _KeyPacket 553 { 554 HWND wnd; 555 UINT msg; 556 WPARAM mp1; 557 LPARAM mp2; 558 int mod; 559 } KeyPacket, *PKeyPacket; 560 561 typedef struct _MusClkRec { 562 Bool pending; 563 UINT emsg; 564 MSG msg; 565 } MusClkRec; 566 567 #define STYLUS_USE_PEN( __ps) \ 568 if ( !( sys stylusFlags & stbPen)) { \ 569 if ( __ps) \ 570 SelectObject( __ps, sys stylusResource-> hpen); \ 571 sys stylusFlags |= stbPen; \ 572 } 573 574 #define STYLUS_USE_BRUSH( __ps) \ 575 if ( !( sys stylusFlags & stbBrush)) { \ 576 if ( __ps) \ 577 SelectObject( __ps, sys stylusResource-> hbrush); \ 578 sys stylusFlags |= stbBrush; \ 579 } 580 581 #define STYLUS_USE_TEXT( __ps) \ 582 if ( !( sys stylusFlags & stbText)) { \ 583 if ( __ps) \ 584 SetTextColor( __ps, sys stylus. pen. lopnColor); \ 585 sys stylusFlags |= stbText; \ 586 } 587 588 #define STYLUS_USE_BACKING( __ps) \ 589 if ( !( sys stylusFlags & stbBacking)) { \ 590 if ( __ps) \ 591 SetBkColor( __ps, sys stylus. brush. backColor); \ 592 sys stylusFlags |= stbBacking; \ 593 } 594 595 596 #define STYLUS_USE_GP_BRUSH \ 597 if ( !( sys stylusFlags & stbGPBrush)) { \ 598 if ( stylus_gp_alloc(self) == NULL ) return false; \ 599 sys stylusFlags |= stbGPBrush; \ 600 } 601 602 #define STYLUS_FREE_GP_BRUSH sys stylusFlags &= ~stbGPBrush 603 604 #define psDot "\3\3" 605 #define psDash "\x16\6" 606 #define psDashDot "\x9\6\3\6" 607 #define psDashDotDot "\x9\3\3\3\3\3" 608 609 #define csAxEvents csFrozen 610 611 #define apt_set( option) ( sys options. option = 1) 612 #define apt_clear( option) ( sys options. option = 0) 613 #define is_apt( option) ( sys options. option) 614 #define apt_assign( option, value) ( sys options. option = (value)?1:0) 615 616 #define is_declipped( handle) ( \ 617 handle && ( dsys(handle) className != WC_FRAME ) && \ 618 ( !dsys(handle)options.aptClipOwner || ((( PWidget)handle)-> owner == application)) \ 619 ) 620 621 #define is_declipped_child( handle) ( \ 622 handle && ( dsys(handle) className != WC_FRAME ) && \ 623 !dsys(handle)options.aptClipOwner \ 624 ) 625 626 #define palette_create image_create_palette 627 628 typedef struct _ItemRegRec { 629 int cmd; 630 void *item; 631 } ItemRegRec, *PItemRegRec; 632 633 extern Bool appDead; 634 extern Bool debug; 635 extern DIBMONOBRUSH bmiHatch; 636 extern PHash fontMan; 637 extern PHash myfontMan; 638 extern int FONTSTRUCSIZE; 639 extern WinGuts guts; 640 extern PHash imageMan; 641 extern PHash menuMan; 642 extern MusClkRec musClk; 643 extern PHash patMan; 644 extern DWORD rc; 645 extern PHash stylusMan; 646 extern PHash stylusGpMan; 647 extern HBRUSH hBrushHollow; 648 extern PatResource hPatHollow; 649 extern HPEN hPenHollow; 650 extern PHash regnodeMan; 651 extern Handle lastMouseOver; 652 extern int timeDefsCount; 653 extern PItemRegRec timeDefs; 654 extern PHash menuBitmapMan; 655 extern HBITMAP uncheckedBitmap; 656 extern PHash scriptCacheMan; 657 extern HCURSOR arrowCursor; 658 659 LRESULT CALLBACK generic_app_handler ( HWND win, UINT msg, WPARAM mp1, LPARAM mp2); 660 LRESULT CALLBACK generic_frame_handler ( HWND win, UINT msg, WPARAM mp1, LPARAM mp2); 661 LRESULT CALLBACK layered_frame_handler ( HWND win, UINT msg, WPARAM mp1, LPARAM mp2); 662 LRESULT CALLBACK generic_view_handler ( HWND win, UINT msg, WPARAM mp1, LPARAM mp2); 663 664 extern int arc_completion( double * angleStart, double * angleEnd, int * needFigure); 665 extern Bool add_font_to_hash( const PFont key, const PFont font, Bool addSizeEntry); 666 extern void cm_squeeze_palette( PRGBColor source, int srcColors, PRGBColor dest, int destColors); 667 extern Bool create_font_hash( void); 668 extern Bool cursor_update( Handle self); 669 extern HDC dc_alloc( void); 670 extern void dc_free( void); 671 extern HDC dc_compat_alloc( HDC compatDC); 672 extern void dc_compat_free( void); 673 extern void dbm_recreate( Handle self); 674 extern Bool destroy_font_hash( void); 675 extern char * err_msg( DWORD errId, char * buffer); 676 extern char * err_msg_gplus( GpStatus errId, char * buffer); 677 extern PDCFont font_alloc( Font * data); 678 extern void font_change( Handle self, Font * font); 679 extern void font_clean( void); 680 extern void font_font2logfont( Font * font, LOGFONTW * lf); 681 extern void font_free( PDCFont res, Bool permanent); 682 extern void font_logfont2font( LOGFONTW * lf, Font * font, Point * resolution); 683 extern void font_pp2font( char * presParam, Font * font); 684 extern void font_textmetric2font( TEXTMETRICW * tm, Font * fm, Bool readOnly); 685 extern Bool get_font_from_hash( PFont font, Bool bySize); 686 extern Point get_window_borders( int borderStyle); 687 extern Bool hwnd_check_limits( int x, int y, Bool uint); 688 extern void hwnd_enter_paint( Handle self); 689 extern Handle hwnd_frame_top_level( Handle self); 690 extern void hwnd_leave_paint( Handle self); 691 extern Handle hwnd_to_view( HWND win); 692 extern Handle hwnd_top_level( Handle self); 693 extern Handle hwnd_layered_top_level( Handle self); 694 extern Bool hwnd_repaint_layered( Handle self, Bool now); 695 extern HICON image_make_icon_handle( Handle img, Point size, Point * hotSpot); 696 extern void image_query_bits( Handle self, Bool forceNewImage); 697 extern void image_argb_query_bits( Handle self); 698 extern HBITMAP image_create_bitmap_by_type( Handle self, HPALETTE pal, XBITMAPINFO * bitmapinfo, int bm_type); 699 extern HBITMAP image_create_bitmap( Handle self ); 700 extern HBITMAP image_create_argb_dib_section( HDC dc, int w, int h, uint32_t ** ptr); 701 extern HPALETTE image_create_palette( Handle self); 702 extern void image_destroy_cache( Handle self); 703 extern BITMAPINFO* image_fill_bitmap_info( Handle self, XBITMAPINFO * bi, int bm_type); 704 extern void mod_free( BYTE * modState); 705 extern BYTE * mod_select( int mod); 706 extern Bool palette_change( Handle self); 707 extern long palette_match( Handle self, long color); 708 extern int palette_match_color( XLOGPALETTE * lp, long clr, int * diffFactor); 709 extern PPatResource patres_fetch( unsigned char * pattern, int len); 710 extern UINT patres_user( unsigned char * pattern, int len); 711 extern void process_transparents( Handle self); 712 extern long remap_color( long clr, Bool toSystem); 713 extern void socket_rehash( void); 714 extern PDCStylus stylus_alloc( PStylus data); 715 extern void stylus_change( Handle self); 716 extern void stylus_clean( void); 717 extern Bool stylus_complex( PStylus stylus, HDC dc); 718 extern Bool stylus_extpenned( PStylus stylus); 719 extern void stylus_free( PDCStylus res, Bool permanent); 720 extern DWORD stylus_get_extpen_style( PStylus s); 721 extern GpBrush* stylus_gp_alloc(Handle self); 722 extern void stylus_gp_clean( void); 723 extern void stylus_gp_free( PDCGPStylus res, Bool permanent); 724 extern GpPen* stylus_gp_get_pen(int lineWidth, uint32_t color); 725 extern HRGN region_create( Handle mask); 726 extern WCHAR * alloc_utf8_to_wchar( const char * utf8, int length, int * mb_len); 727 extern WCHAR * alloc_utf8_to_wchar_visual( const char * utf8, int length, int * mb_len); 728 extern WCHAR * alloc_ascii_to_wchar( const char * text, int length); 729 extern char * alloc_wchar_to_utf8( WCHAR * src, int * len ); 730 extern void wchar2char( char * dest, WCHAR * src, int lim); 731 extern void char2wchar( WCHAR * dest, char * src, int lim); 732 extern int apcUpdateWindow( HWND wnd ); 733 extern void reset_system_fonts(void); 734 extern void register_mapper_fonts(void); 735 extern void dpi_change(void); 736 extern Bool is_dwm_enabled(void); 737 extern Bool dnd_clipboard_create(void); 738 extern void dnd_clipboard_destroy(void); 739 extern Bool dnd_clipboard_open(void); 740 extern Bool dnd_clipboard_close(void); 741 extern Bool dnd_clipboard_clear(void); 742 extern PList dnd_clipboard_get_formats(void); 743 extern Bool dnd_clipboard_get_data( Handle id, PClipboardDataRec c); 744 extern Bool dnd_clipboard_has_format( Handle id); 745 extern Bool dnd_clipboard_set_data( Handle id, PClipboardDataRec c); 746 extern PList dnd_clipboard_get_formats(); 747 extern char * cf2name( UINT cf ); 748 extern Bool clipboard_get_data(int cfid, PClipboardDataRec c, void * p1, void * p2); 749 extern void * image_create_dib(Handle image, Bool global_alloc); 750 extern Bool HWND_lock( Bool lock); 751 extern Bool process_msg( MSG * msg); 752 extern Bool aa_text_out( Handle self, int x, int y, void * text, int len, Bool wide); 753 extern Bool aa_glyphs_out( Handle self, PGlyphsOutRec t, int x, int y, int * text_advance, HFONT font); 754 extern void aa_free_arena(Handle self, Bool for_reuse); 755 extern void gp_get_text_widths( Handle self, const char* text, int len, int flags, ABC * extents); 756 extern void gp_get_text_box( Handle self, ABC * abc, Point * pt); 757 758 /* compatibility to MSVC 6 */ 759 #ifndef GWLP_USERDATA 760 # define GWLP_USERDATA GWL_USERDATA 761 # define GWLP_WNDPROC GWL_WNDPROC 762 # define LONG_PTR LONG 763 # define GetWindowLongPtr GetWindowLong 764 # define SetWindowLongPtr SetWindowLong 765 #endif 766 767 #ifndef WS_EX_LAYERED 768 #define ULW_ALPHA 0x00000002 769 #define WS_EX_LAYERED 0x00080000 770 WINUSERAPI 771 BOOL 772 WINAPI 773 UpdateLayeredWindow( 774 __in HWND hWnd, 775 __in_opt HDC hdcDst, 776 __in_opt POINT* pptDst, 777 __in_opt SIZE* psize, 778 __in_opt HDC hdcSrc, 779 __in_opt POINT* pptSrc, 780 __in COLORREF crKey, 781 __in_opt BLENDFUNCTION* pblend, 782 __in DWORD dwFlags); 783 #endif 784 785 #ifndef MUI_LANGUAGE_NAME 786 #define MUI_LANGUAGE_NAME 0x8 787 #define MUI_COMPLEX_SCRIPT_FILTER 0x200 788 #endif 789 790 BOOL 791 my_GetUserPreferredUILanguages( 792 DWORD dwFlags, PULONG pulNumLanguages, 793 PZZWSTR pwszLanguagesBuffer, PULONG pcchLanguagesBuffer 794 ); 795 796 797 #ifdef __cplusplus 798 } 799 #endif 800 801 802 #endif 803 804