int TE_Init(void) { const char *data[] = { "16 16 3 1", " c None", ". c #FFFFFF", "+ c #000000", " ", " .. .. ", " .+++. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+. ", " .+++. ", " .. .. ", " ", "7,7" }; SDL_EnableUNICODE(1); TE_EditionCursor = CreateCursor(data); TE_NormalCursor = SDL_GetCursor(); TE_initialized = 1; return 1; }
static RD_HCURSOR l_ui_create_cursor(struct rdp_inst * inst, uint32 x, uint32 y, int width, int height, uint8 * andmask, uint8 * xormask, int bpp) { wfInfo * wfi; HCURSOR cursor; ICONINFO iconinfo; uint8 * cdata; wfi = GET_WFI(inst); if (bpp == 1) { cursor = CreateCursor(g_hInstance, x, y, width, height, andmask, xormask); } else { iconinfo.fIcon = FALSE; iconinfo.xHotspot = x; iconinfo.yHotspot = y; cdata = wf_cursor_mask_convert(wfi, width, height, andmask); iconinfo.hbmMask = CreateBitmap(width, height, 1, 1, cdata); iconinfo.hbmColor = wf_create_dib(wfi, width, height, bpp, 0, xormask); cursor = CreateIconIndirect(&iconinfo); DeleteObject(iconinfo.hbmMask); DeleteObject(iconinfo.hbmColor); free(cdata); } return (RD_HCURSOR)cursor; }
static HCURSOR getZoomOutCursor() { if (0 == hZoomOutCursor) { hZoomOutCursor = CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, zoomOutCursorA, zoomOutCursorB); } return hZoomOutCursor; }
static HCURSOR getNoMoveVertCursor() { if (0 == hNoMoveVertCursor) { hNoMoveVertCursor = CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, noMoveVertCursorA, noMoveVertCursorB); } return hNoMoveVertCursor; }
HCURSOR make_transparent_cursor () { int x = GetSystemMetrics ( SM_CXICON ); int y = GetSystemMetrics ( SM_CYICON ); BYTE * aAnd = new BYTE [ x * y ]; BYTE * aXor = new BYTE [ x * y ]; memset ( aAnd, 0xFF, x*y ); memset ( aXor, 0x00, x*y ); HCURSOR hCursor = CreateCursor ( g_hInstance, 0, 0, x, y, aAnd, aXor ); return hCursor; }
static void DDCreateClass(directx_priv *priv) { WNDCLASS wc; wc.style = 0; wc.lpfnWndProc = WindowProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = priv->hInstance; wc.hIcon = LoadIcon(priv->hInstance, MAKEINTRESOURCE("DirectX.ico")); switch (priv->cursortype) { case 0: wc.hCursor = CreateCursor(priv->hInstance, 15, 16, /* hot spot x, y */ 32, 32, /* size x, y */ ANDmaskInvCursor, /* masks */ XORmaskInvCursor); priv->hCursor = wc.hCursor; break; case 1: wc.hCursor = CreateCursor(priv->hInstance, 15, 16, /* hot spot x, y */ 32, 32, /* size x, y */ ANDmaskDotCursor, /* masks */ XORmaskDotCursor); priv->hCursor = wc.hCursor; break; default: wc.hCursor = LoadCursor(NULL, IDC_ARROW); priv->hCursor = NULL; break; } wc.hbrBackground = (HBRUSH) GetStockObject(BLACK_BRUSH); wc.lpszMenuName = NAME; wc.lpszClassName = NAME; priv->wndclass = RegisterClass(&wc); }
void INTERNAL_init_cursor(void) { unsigned int hot_x, hot_y; int i; if (hcursorHand) return; hMouseHook = NULL; init_store_cursor(); for (i = 0; i < G_MAXWINDOW; i++) { mswin_draw_cursor_func[i] = mswin_default_cursor_func; WI[i].pixcopymode = FALSE; } hot_x = 8; hot_y = 12; hcursorHand = CreateCursor(_hInst, hot_x, hot_y, hand32_width, hand32_height, hand32_bits, handm32_bits); hot_x = 16; hot_y = 16; hcursorUpdown = CreateCursor(_hInst, hot_x, hot_y, updown32_width, updown32_height, updown32_bits, updownmask32_bits); }
/* Creates a new Cursor Object. */ HCURSOR CreateDefaultCursor(HDEVICE handle) { HCURSOR cursor; if (!(cursor = CreateCursor(handle))) { return NULL; } void *data = NULL; if ((data = MapSurface((HSURFACE)cursor)) != NULL) { memcpy(data, DEFAULTCURSOR, (64*64*4)); } return cursor; }
void plMouseDevice::SetCursorY(float y) { /// Set the cursor position if( fCursor == nil && !plMouseDevice::bCursorHidden) CreateCursor( fCursorID ); if (fCursor) fCursor->SetPosition( ( fXPos * 2.0f ) - 1.0f, ( y * 2.0f ) - 1.0f ); // plDebugText &txt = plDebugText::Instance(); // txt.DrawString(fWXPos + 20,fWYPos - 10,"test"); }
static inline ATOM win_register_class (HINSTANCE hmod) { BYTE and_mask[1] = { 0xff }; BYTE xor_mask[1] = { 0x00 }; WNDCLASSEX wc = { sizeof(WNDCLASSEX), 0, }; wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hInstance = hmod; wc.lpfnWndProc = win_handle_event; wc.lpszClassName = "_ZBar Class"; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.hCursor = CreateCursor(hmod, 0, 0, 1, 1, and_mask, xor_mask); return(RegisterClassEx(&wc)); }
/** Startup cursor support. */ void StartupCursors() { Window win1; int winx, winy; unsigned int mask; int x; for(x = 0; x < CURSOR_COUNT; x++) { cursors[x] = CreateCursor(cursor_shapes[x]); } JXQueryPointer(display, rootWindow, &win1, &mousew, &mousex, &mousey, &winx, &winy, &mask); }
static VALUE swincursor_new(VALUE klass,VALUE hotspot,VALUE size,VALUE aplane,VALUE xplane){ int hx,hy; int sx,sy,ssx,ssy; int psize; struct SwinCursor* sc; VALUE tmp,robj; if(TYPE(aplane)!=T_STRING || TYPE(xplane)!=T_STRING) { rb_raise(rb_eArgError,"and-plane and xor-plane must be String"); return Qfalse; } ssx=GetSystemMetrics(SM_CXCURSOR); ssy=GetSystemMetrics(SM_CYCURSOR); tmp = rb_ary_entry(size,0); sx = NUM2INT(tmp); tmp = rb_ary_entry(size,1); sy = NUM2INT(tmp); if(sx!=ssx || sy!=ssy){ rb_raise(rb_eRuntimeError,"cursor size mismatch [%d,%d] for [%d,%d]", sx,sy,ssx,ssy); return Qfalse; } tmp = rb_ary_entry(hotspot,0); hx = NUM2INT(tmp); tmp = rb_ary_entry(hotspot,1); hy = NUM2INT(tmp); psize = sx*sy/8; if( (psize>RSTRING_LEN(aplane)) || (psize>RSTRING_LEN(xplane)) ){ rb_raise(rb_eRuntimeError,"short plane size for %d",psize); return Qfalse; } robj = Data_Make_Struct(cSwinCursor,struct SwinCursor,0,release_cursor,sc); sc->sysflag = FALSE; sc->hotspot = (hx<<16) + hy; sc->hcursor = CreateCursor(hInstance,hx,hy,sx,sy, RSTRING_PTR(aplane),RSTRING_PTR(xplane) ); sc->shared = FALSE; if(sc->hcursor==NULL){ rb_raise(rb_eRuntimeError,"fail to create cursor"); return Qfalse; } return robj; }
static HCURSOR EmptyCursor( HINSTANCE instance ) { const int cw = GetSystemMetrics(SM_CXCURSOR); const int ch = GetSystemMetrics(SM_CYCURSOR); HCURSOR cursor = NULL; uint8_t *and = malloc(cw * ch); uint8_t *xor = malloc(cw * ch); if( and && xor ) { memset(and, 0xff, cw * ch ); memset(xor, 0x00, cw * ch ); cursor = CreateCursor( instance, 0, 0, cw, ch, and, xor); } free( and ); free( xor ); return cursor; }
void MakeHyperlink(HWND hwnd, UINT staticid, COLORREF crLink) { URLCtrl *url; HWND hwndCtrl = GetDlgItem(hwnd, staticid); // If already a hyperlink if((UINT_PTR)GetWindowLongPtr(hwndCtrl, GWLP_WNDPROC) == (UINT_PTR)URLCtrlProc) return; url = (URLCtrl *)HeapAlloc(GetProcessHeap(), 0, sizeof(URLCtrl)); // Create font and cursor resources if this is // the first control being created if(InterlockedIncrement(&lRefCount) == 1) { LOGFONT lf; HFONT hf = (HFONT)GetStockObject(DEFAULT_GUI_FONT); GetObject(hf, sizeof lf, &lf); lf.lfUnderline = TRUE; hfUnderlined = CreateFontIndirect(&lf); hCursor = CreateCursor(GetModuleHandle(0), 5, 2, 32, 32, XORMask, ANDMask); } //turn on notify style SetWindowLong(hwndCtrl, GWL_STYLE, GetWindowLong(hwndCtrl, GWL_STYLE) | SS_NOTIFY); SetWindowLong(hwndCtrl, GWL_EXSTYLE, GetWindowLong(hwndCtrl, GWL_EXSTYLE) | WS_EX_TRANSPARENT); // setup colours if(crLink != -1) url->crLink = crLink; else url->crLink = RGB(0,0,255); url->crVisited = RGB(128,0,128); SendMessage(hwndCtrl, WM_SETFONT, (WPARAM)hfUnderlined, 0); // subclass url->oldproc = (WNDPROC)SetWindowLongPtr(hwndCtrl, GWLP_WNDPROC, (LONG_PTR)URLCtrlProc); SetWindowLongPtr(hwndCtrl, GWLP_USERDATA, (LONG_PTR)url); return; }
static int create_cursor (int cli, int clifd, void* buff, size_t len) { HCURSOR hcsr; int* tmp; BYTE* and_bits, *xor_bits; tmp = (int*)buff; and_bits = (BYTE*)(tmp + 6); xor_bits = and_bits + tmp [5]; hcsr = CreateCursor (tmp [0], tmp [1], tmp [2], tmp [3], and_bits, xor_bits, tmp [4]); #ifdef _MGHAVE_CURSOR if (hcsr) { add_global_res (cli, (void*) hcsr, (void*)hcsr, (ReleaseProc)DestroyCursor); } #endif return ServerSendReply (clifd, &hcsr, sizeof (HCURSOR)); }
void setcursor(void) { HCURSOR nh; int x, y, h, w; uchar *sp, *cp; uchar *and, *xor; h = GetSystemMetrics(SM_CYCURSOR); w = (GetSystemMetrics(SM_CXCURSOR)+7)/8; and = mallocz(h*w, 1); memset(and, 0xff, h*w); xor = mallocz(h*w, 1); lock(&cursor.lk); for(y=0,sp=cursor.set,cp=cursor.clr; y<16; y++) { for(x=0; x<2; x++) { and[y*w+x] = ~(*sp|*cp); xor[y*w+x] = ~*sp & *cp; cp++; sp++; } } nh = CreateCursor(inst, -cursor.offset.x, -cursor.offset.y, GetSystemMetrics(SM_CXCURSOR), h, and, xor); if(nh != NULL) { SetCursor(nh); if(hcursor != NULL) DestroyCursor(hcursor); hcursor = nh; } unlock(&cursor.lk); free(and); free(xor); PostMessage(window, WM_SETCURSOR, (int)window, 0); }
BOOL urlctrl_set(HWND hwnd,TCHAR *szURL,COLORREF *unvisited,COLORREF *visited,DWORD dwFlags, COLORREF clr) { BOOL fResult=FALSE; if (IsWindow(hwnd)) { URLCTRL *url; if (GetWindowLong(hwnd,GWL_WNDPROC)==(LONG)urlctrl_proc) { //update old url=(URLCTRL*)GetWindowLong(hwnd,GWL_USERDATA); } else { //create new url=(URLCTRL*)this_malloc(sizeof(URLCTRL)); if (url) { //init once HFONT hfont=(HFONT)SendMessage(hwnd,WM_GETFONT,0,0); url->oldproc=(WNDPROC)SetWindowLong(hwnd,GWL_WNDPROC,(LONG)urlctrl_proc); SetWindowLong(hwnd,GWL_USERDATA,(LONG)url);//store in control url->fClicking=FALSE; url->hcur=CreateCursor(GetModuleHandle(NULL),5,0,32,32,curAND,curXOR); SendMessage(hwnd,WM_SETFONT,(WPARAM)hfont,0);//modify current font url->bkg = clr; } } if (url) { //init always LONG style=GetWindowLong(hwnd,GWL_STYLE); if (szURL) lstrcpyn(url->szURL,szURL,MAX_PATH); else url->szURL[0]=0; url->crUnvisited=(unvisited)?(*unvisited):(RGB(0,0,255)); url->crVisited=(visited)?(*visited):(RGB(128,0,128)); //if(dwFlags&UCF_TXT_RIGHT) dwFlags&=~UCF_TXT_HCENTER;//patch //if(dwFlags&UCF_TXT_BOTTOM) dwFlags&=~UCF_TXT_VCENTER;//patch url->dwFlags=dwFlags; style&=~(WS_BORDER|WS_TABSTOP);//remove style|=SS_NOTIFY;//add if (url->dwFlags&UCF_KBD) style|=WS_TABSTOP;//add? SetWindowLong(hwnd,GWL_STYLE,style); if (url->dwFlags&UCF_FIT) util_url_fit(hwnd,FALSE); InvalidateRect(hwnd,NULL,TRUE); UpdateWindow(hwnd); fResult=TRUE; } } return fResult; }
plMouseDevice::plMouseDevice() { fXPos = 0; fYPos = 0; fCursorID = CURSOR_UP; fButtonState = 0; fOpacity = 1.f; fCursor = nil; CreateCursor( fCursorID ); plMouseDevice::fInstance = this; fXMsg = nil; fYMsg = nil; fB2Msg = nil; fLeftBMsg[0] = nil; fLeftBMsg[1] = nil; fRightBMsg[0] = nil; fRightBMsg[1] = nil; fMiddleBMsg[0] = nil; fMiddleBMsg[1] = nil; }
int WIN32Window::internalLoadMouseCursor(const ImagePtr& image, const Point& hotSpot) { int width = image->getWidth(); int height = image->getHeight(); int numbits = width * height; int numbytes = (width * height)/8; std::vector<uchar> andMask(numbytes, 0); std::vector<uchar> xorMask(numbytes, 0); for(int i=0;i<numbits;++i) { uint32 rgba = stdext::readULE32(image->getPixelData() + i*4); if(rgba == 0xffffffff) { //white HSB_BIT_SET(xorMask, i); } else if(rgba == 0x00000000) { //alpha HSB_BIT_SET(andMask, i); } // otherwise 0xff000000 => black } HCURSOR cursor = CreateCursor(m_instance, hotSpot.x, hotSpot.y, width, height, &andMask[0], &xorMask[0]); m_cursors.push_back(cursor); return m_cursors.size()-1; }
Word BURGER_API Burger::OSCursorImage::CreateMonoChromeImage(const Word8 *pXor,const Word8 *pAnd,Word uWidth,Word uHeight,Int iHotX,Int iHotY) { Shutdown(); // Ask windows as to the maximum size allowed for a hardware cursor Word uAllowedX = static_cast<Word>(GetSystemMetrics(SM_CXCURSOR)); Word uAllowedY = static_cast<Word>(GetSystemMetrics(SM_CYCURSOR)); // Round up to the 8s Word uFinalWidth = (uWidth+7)&(~7); Word uFinalHeight = uHeight; Word uResult = 10; if ((uFinalWidth<=uAllowedX) && (uFinalHeight<=uAllowedY)) { m_uWidth = uFinalWidth; m_uHeight = uFinalHeight; m_iHotX = iHotX; m_iHotY = iHotY; HCURSOR hCursor = CreateCursor(Globals::GetInstance(),iHotX,iHotY,static_cast<int>(uFinalWidth),static_cast<int>(uFinalHeight),pAnd,pXor); if (hCursor) { m_pCursorImage = hCursor; } } return uResult; }
/** Startup cursor support. */ void StartupCursors() { Window win1, win2; int winx, winy; unsigned int mask; defaultCursor = CreateCursor(XC_left_ptr); moveCursor = CreateCursor(XC_fleur); northCursor = CreateCursor(XC_top_side); southCursor = CreateCursor(XC_bottom_side); eastCursor = CreateCursor(XC_right_side); westCursor = CreateCursor(XC_left_side); northEastCursor = CreateCursor(XC_ur_angle); northWestCursor = CreateCursor(XC_ul_angle); southEastCursor = CreateCursor(XC_lr_angle); southWestCursor = CreateCursor(XC_ll_angle); chooseCursor = CreateCursor(XC_tcross); JXQueryPointer(display, rootWindow, &win1, &win2, &mousex, &mousey, &winx, &winy, &mask); }
void GameStateMain::OnStart() { CreatePawn(); CreateCursor(); CreateBattleWindow(); }
WMcursor *WIN_CreateWMCursor(_THIS, Uint8 *data, Uint8 *mask, int w, int h, int hot_x, int hot_y) { #ifdef USE_STATIC_CURSOR WMcursor *cursor; /* Allocate the cursor */ cursor = (WMcursor *)SDL_malloc(sizeof(*cursor)); if ( cursor ) { cursor->curs = LoadCursor(NULL, IDC_ARROW); } return(cursor); #else WMcursor *cursor; int allowed_x; int allowed_y; int run, pad, i; Uint8 *aptr, *xptr; /* Check to make sure the cursor size is okay */ allowed_x = GetSystemMetrics(SM_CXCURSOR); allowed_y = GetSystemMetrics(SM_CYCURSOR); if ( (w > allowed_x) || (h > allowed_y) ) { SDL_SetError("Only cursors of dimension (%dx%d) are allowed", allowed_x, allowed_y); return(NULL); } /* Allocate the cursor */ cursor = (WMcursor *)SDL_malloc(sizeof(*cursor)); if ( cursor == NULL ) { SDL_SetError("Out of memory"); return(NULL); } cursor->curs = NULL; cursor->ands = NULL; cursor->xors = NULL; /* Pad out to the normal cursor size */ run = PAD_BITS(w); pad = PAD_BITS(allowed_x)-run; aptr = cursor->ands = (Uint8 *)SDL_malloc((run+pad)*allowed_y); xptr = cursor->xors = (Uint8 *)SDL_malloc((run+pad)*allowed_y); if ( (aptr == NULL) || (xptr == NULL) ) { WIN_FreeWMCursor(NULL, cursor); SDL_OutOfMemory(); return(NULL); } for ( i=0; i<h; ++i ) { memxor(xptr, data, mask, run); xptr += run; data += run; memnot(aptr, mask, run); mask += run; aptr += run; SDL_memset(xptr, 0, pad); xptr += pad; SDL_memset(aptr, ~0, pad); aptr += pad; } pad += run; for ( ; i<allowed_y; ++i ) { SDL_memset(xptr, 0, pad); xptr += pad; SDL_memset(aptr, ~0, pad); aptr += pad; } /* Create the cursor */ cursor->curs = CreateCursor( (HINSTANCE)GetWindowLongPtr(SDL_Window, GWLP_HINSTANCE), hot_x, hot_y, allowed_x, allowed_y, cursor->ands, cursor->xors); if ( cursor->curs == NULL ) { WIN_FreeWMCursor(NULL, cursor); SDL_SetError("Windows couldn't create the requested cursor"); return(NULL); } return(cursor); #endif /* USE_STATIC_CURSOR */ }
MRESULT EXPENTRY ClientWndProc ( HWND hwndWnd, ULONG ulMsg, MPARAM mpParm1, MPARAM mpParm2 ) { switch ( ulMsg ) { // For HELP debugging #if 0 case HM_ERROR: { CHAR szTempBuffer[256]; sprintf( szTempBuffer, "Received HM_ERROR message, mp1=0X%8.8X", (ULONG)mpParm1 ); WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, szTempBuffer, "HM_ERROR", 0, MB_OK ); } break; case HM_EXT_HELP_UNDEFINED: WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_EXT_HELP_UNDEFINED message", "HM_EXT_HELP_UNDEFINED", 0, MB_OK ); break; case HM_HELPSUBITEM_NOT_FOUND: WinMessageBox ( HWND_DESKTOP, HWND_DESKTOP, "Received HM_HELPSUBITEM_NOT_FOUND message", "HM_HELPSUBITEM_NOT_FOUND", 0, MB_OK ); break; #endif case HM_QUERY_KEYS_HELP: return (MRESULT)IDP_KEYS_INFO; break; case WM_BUTTON1CLICK: MoveCursorToPointer( hwndWnd, (*(POINTS *)&mpParm1).x, (*(POINTS *)&mpParm1).y ); break; #if 0 case WM_BUTTON2CLICK: { HPS hpsClient; POINTL ptl; INT xC, yC; xC = ( ( (*(POINTS *)&mpParm1).x - cxChar) / cxChar ); yC = ( ( cyClient - (*(POINTS *)&mpParm1).y ) / cyChar ); hpsClient = WinGetPS( hwndWnd ); GpiSetColor( hpsClient, CLR_PALEGRAY ); if ( xC < 10 ) GpiSetMix( hpsClient, FM_XOR ); else if ( xC < 20 ) GpiSetMix( hpsClient, FM_INVERT ); else if ( xC < 30 ) GpiSetMix( hpsClient, FM_NOTXORSRC ); else if ( xC < 40 ) GpiSetMix( hpsClient, FM_NOTMASKSRC ); else if ( xC < 50 ) GpiSetMix( hpsClient, FM_SUBTRACT ); /// GpiSetBackColor( hpsClient, CLR_PALEGRAY ); /// GpiSetBackMix( hpsClient, BM_OVERPAINT ); /// ptl.x = ( ( (*(POINTS *)&mpParm1).x - cxChar ) / cxChar ) * cxChar + cxChar; /// ptl.y = ( ( (*(POINTS *)&mpParm1).y - cyClient ) / cyChar - 1 ) * cyChar + cyClient; ptl.x = cxChar + ( xC * cxChar ); ptl.y = cyClient - ( ( yC + 1) * cyChar ); GpiMove( hpsClient, &ptl ); ptl.x += cxChar; ptl.y += cyChar; if ( yC < 5 ) GpiBox( hpsClient, DRO_FILL, &ptl, 0, 0 ); else GpiBox( hpsClient, DRO_OUTLINE, &ptl, 0, 0 ); /// GpiSetBackColor( hpsClient, CLR_BACKGROUND ); /// GpiSetMix( hpsClient, FM_DEFAULT ); WinReleasePS( hpsClient ); } break; #endif case WM_CHAR: if ( !( CHARMSG(&ulMsg)->fs & KC_KEYUP ) ) { if ( CHARMSG(&ulMsg)->fs & KC_CHAR ) { ProcessCharMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ); } else if ( CHARMSG(&ulMsg)->fs & KC_VIRTUALKEY ) { if ( !ProcessCursorMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) ) { return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 ); } } } break; case WM_CLOSE: if ( QueryAbandonChanges( hwndWnd ) ) return WinDefWindowProc ( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; case WM_COMMAND: return ProcessCommandMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; case WM_CREATE: hwndMenu = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_MENU ); hwndHScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_HORZSCROLL ); hwndVScroll = WinWindowFromID( WinQueryWindow( hwndWnd, QW_PARENT ), FID_VERTSCROLL ); SetWindowTitle( hwndWnd ); break; case WM_DESTROY: ClearFile( hwndWnd ); break; case WM_ERASEBACKGROUND: return MRFROMSHORT ( TRUE ) ; case WM_HELP: ProcessHelpMessage( hwndWnd, mpParm1, mpParm2 ); break; case WM_HSCROLL: if ( !ProcessHScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) ) return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; case WM_PAINT: PaintScreen( hwndWnd ); break; case WM_SAVEAPPLICATION: SaveSettings( hwndWnd, habAnchor ); return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; case WM_SETFOCUS: if ( SHORT1FROMMP( mpParm2 ) ) CreateCursor( hwndWnd ); else DestroyCursor( hwndWnd ); break; case WM_SIZE: UpdateWindowSize( hwndWnd, SHORT1FROMMP( mpParm2), SHORT2FROMMP( mpParm2 ) ); if ( hwndWnd == WinQueryFocus( HWND_DESKTOP ) ) { DestroyCursor( hwndWnd ); CreateCursor( hwndWnd ); } break; case WM_VSCROLL: if ( !ProcessVScrollMsg( hwndWnd, ulMsg, mpParm1, mpParm2 ) ) return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; default: return WinDefWindowProc( hwndWnd, ulMsg, mpParm1, mpParm2 ); break; } return MRFROMSHORT ( FALSE ) ; }
HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c) { int hx = c.hotSpot().x(); int hy = c.hotSpot().y(); const Qt::CursorShape cshape = c.shape(); if (cshape == Qt::BitmapCursor) { const QPixmap pixmap = c.pixmap(); if (!pixmap.isNull()) if (const HCURSOR hc = createPixmapCursor(pixmap, hx, hy)) return hc; } // Non-standard Windows cursors are created from bitmaps static const uchar vsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar vsplitm_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar hsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar hsplitm_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar openhand_bits[] = { 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; static const uchar openhandm_bits[] = { 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; static const uchar closedhand_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; static const uchar closedhandm_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; wchar_t *sh = 0; switch (c.shape()) { // map to windows cursor case Qt::ArrowCursor: sh = IDC_ARROW; break; case Qt::UpArrowCursor: sh = IDC_UPARROW; break; case Qt::CrossCursor: sh = IDC_CROSS; break; case Qt::WaitCursor: sh = IDC_WAIT; break; case Qt::IBeamCursor: sh = IDC_IBEAM; break; case Qt::SizeVerCursor: sh = IDC_SIZENS; break; case Qt::SizeHorCursor: sh = IDC_SIZEWE; break; case Qt::SizeBDiagCursor: sh = IDC_SIZENESW; break; case Qt::SizeFDiagCursor: sh = IDC_SIZENWSE; break; case Qt::SizeAllCursor: sh = IDC_SIZEALL; break; case Qt::ForbiddenCursor: sh = IDC_NO; break; case Qt::WhatsThisCursor: sh = IDC_HELP; break; case Qt::BusyCursor: sh = IDC_APPSTARTING; break; case Qt::PointingHandCursor: sh = IDC_HAND; break; case Qt::BlankCursor: case Qt::SplitVCursor: case Qt::SplitHCursor: case Qt::OpenHandCursor: case Qt::ClosedHandCursor: case Qt::BitmapCursor: { QImage bbits, mbits; bool invb, invm; if (cshape == Qt::BlankCursor) { bbits = QImage(32, 32, QImage::Format_Mono); bbits.fill(0); // ignore color table mbits = bbits.copy(); hx = hy = 16; invb = invm = false; } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { bool open = cshape == Qt::OpenHandCursor; QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits); QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits); bbits = cb.toImage().convertToFormat(QImage::Format_Mono); mbits = cm.toImage().convertToFormat(QImage::Format_Mono); hx = hy = 8; invb = invm = false; } else if (cshape == Qt::BitmapCursor) { bbits = c.bitmap()->toImage().convertToFormat(QImage::Format_Mono); mbits = c.mask()->toImage().convertToFormat(QImage::Format_Mono); invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); } else { // Qt::SplitVCursor, Qt::SplitHCursor const QBitmap cb = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplit_bits : hsplit_bits); const QBitmap cm = QBitmap::fromData(QSize(32, 32), cshape == Qt::SplitVCursor ? vsplitm_bits : hsplitm_bits); bbits = cb.toImage().convertToFormat(QImage::Format_Mono); mbits = cm.toImage().convertToFormat(QImage::Format_Mono); hx = hy = 16; invb = invm = false; } const int n = qMax(1, bbits.width() / 8); const int h = bbits.height(); #if !defined(Q_OS_WINCE) QScopedArrayPointer<uchar> xBits(new uchar[h * n]); QScopedArrayPointer<uchar> xMask(new uchar[h * n]); int x = 0; for (int i = 0; i < h; ++i) { uchar *bits = bbits.scanLine(i); uchar *mask = mbits.scanLine(i); for (int j = 0; j < n; ++j) { uchar b = bits[j]; uchar m = mask[j]; if (invb) b ^= 0xff; if (invm) m ^= 0xff; xBits[x] = ~m; xMask[x] = b ^ m; ++x; } } return CreateCursor(GetModuleHandle(0), hx, hy, bbits.width(), bbits.height(), xBits.data(), xMask.data()); #elif defined(GWES_ICONCURS) // Q_WS_WINCE // Windows CE only supports fixed cursor size. int sysW = GetSystemMetrics(SM_CXCURSOR); int sysH = GetSystemMetrics(SM_CYCURSOR); int sysN = qMax(1, sysW / 8); uchar* xBits = new uchar[sysH * sysN]; uchar* xMask = new uchar[sysH * sysN]; int x = 0; for (int i = 0; i < sysH; ++i) { if (i >= h) { memset(&xBits[x] , 255, sysN); memset(&xMask[x] , 0, sysN); x += sysN; } else { int fillWidth = n > sysN ? sysN : n; uchar *bits = bbits.scanLine(i); uchar *mask = mbits.scanLine(i); for (int j = 0; j < fillWidth; ++j) { uchar b = bits[j]; uchar m = mask[j]; if (invb) b ^= 0xFF; if (invm) m ^= 0xFF; xBits[x] = ~m; xMask[x] = b ^ m; ++x; } for (int j = fillWidth; j < sysN; ++j ) { xBits[x] = 255; xMask[x] = 0; ++x; } } } HCURSOR hcurs = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH, xBits, xMask); delete [] xBits; delete [] xMask; return hcurs; #else Q_UNUSED(n); Q_UNUSED(h); return 0; #endif } case Qt::DragCopyCursor: case Qt::DragMoveCursor: case Qt::DragLinkCursor: { const QPixmap pixmap = QGuiApplicationPrivate::instance()->getPixmapCursor(cshape); return createPixmapCursor(pixmap, hx, hy); } default: qWarning("%s: Invalid cursor shape %d", __FUNCTION__, cshape); return 0; } #ifdef Q_OS_WINCE return LoadCursor(0, sh); #else return (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED); #endif }
void QCursorData::update() { if (!QCursorData::initialized) QCursorData::initialize(); if (hcurs) return; if (cshape == Qt::BitmapCursor && !pixmap.isNull()) { hcurs = create32BitCursor(pixmap, hx, hy); if (hcurs) return; } // Non-standard Windows cursors are created from bitmaps static const uchar vsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar vsplitm_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar hsplit_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03, 0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar hsplitm_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00, 0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07, 0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar phand_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x04, 0x00, 0x00, 0x80, 0x1c, 0x00, 0x00, 0x80, 0xe4, 0x00, 0x00, 0x80, 0x24, 0x03, 0x00, 0x80, 0x24, 0x05, 0x00, 0xb8, 0x24, 0x09, 0x00, 0xc8, 0x00, 0x09, 0x00, 0x88, 0x00, 0x08, 0x00, 0x90, 0x00, 0x08, 0x00, 0xa0, 0x00, 0x08, 0x00, 0x20, 0x00, 0x08, 0x00, 0x40, 0x00, 0x08, 0x00, 0x40, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x80, 0x00, 0x04, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar phandm_bits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x07, 0x00, 0x00, 0x80, 0x1f, 0x00, 0x00, 0x80, 0xff, 0x00, 0x00, 0x80, 0xff, 0x03, 0x00, 0x80, 0xff, 0x07, 0x00, 0xb8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0xf8, 0xff, 0x0f, 0x00, 0xf0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xe0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x0f, 0x00, 0xc0, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x80, 0xff, 0x07, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0xff, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; static const uchar openhand_bits[] = { 0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92, 0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20, 0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00}; static const uchar openhandm_bits[] = { 0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff, 0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f, 0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00}; static const uchar closedhand_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50, 0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10, 0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00}; static const uchar closedhandm_bits[] = { 0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f, 0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f, 0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00}; static const uchar * const cursor_bits32[] = { vsplit_bits, vsplitm_bits, hsplit_bits, hsplitm_bits, phand_bits, phandm_bits }; wchar_t *sh = 0; switch (cshape) { // map to windows cursor case Qt::ArrowCursor: sh = IDC_ARROW; break; case Qt::UpArrowCursor: sh = IDC_UPARROW; break; case Qt::CrossCursor: sh = IDC_CROSS; break; case Qt::WaitCursor: sh = IDC_WAIT; break; case Qt::IBeamCursor: sh = IDC_IBEAM; break; case Qt::SizeVerCursor: sh = IDC_SIZENS; break; case Qt::SizeHorCursor: sh = IDC_SIZEWE; break; case Qt::SizeBDiagCursor: sh = IDC_SIZENESW; break; case Qt::SizeFDiagCursor: sh = IDC_SIZENWSE; break; case Qt::SizeAllCursor: sh = IDC_SIZEALL; break; case Qt::ForbiddenCursor: sh = IDC_NO; break; case Qt::WhatsThisCursor: sh = IDC_HELP; break; case Qt::BusyCursor: sh = IDC_APPSTARTING; break; case Qt::PointingHandCursor: sh = IDC_HAND; break; case Qt::BlankCursor: case Qt::SplitVCursor: case Qt::SplitHCursor: case Qt::OpenHandCursor: case Qt::ClosedHandCursor: case Qt::BitmapCursor: { QImage bbits, mbits; bool invb, invm; if (cshape == Qt::BlankCursor) { bbits = QImage(32, 32, QImage::Format_Mono); bbits.fill(0); // ignore color table mbits = bbits.copy(); hx = hy = 16; invb = invm = false; } else if (cshape == Qt::OpenHandCursor || cshape == Qt::ClosedHandCursor) { bool open = cshape == Qt::OpenHandCursor; QBitmap cb = QBitmap::fromData(QSize(16, 16), open ? openhand_bits : closedhand_bits); QBitmap cm = QBitmap::fromData(QSize(16, 16), open ? openhandm_bits : closedhandm_bits); bbits = cb.toImage().convertToFormat(QImage::Format_Mono); mbits = cm.toImage().convertToFormat(QImage::Format_Mono); hx = hy = 8; invb = invm = false; } else if (cshape != Qt::BitmapCursor) { int i = cshape - Qt::SplitVCursor; QBitmap cb = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2]); QBitmap cm = QBitmap::fromData(QSize(32, 32), cursor_bits32[i * 2 + 1]); bbits = cb.toImage().convertToFormat(QImage::Format_Mono); mbits = cm.toImage().convertToFormat(QImage::Format_Mono); if (cshape == Qt::PointingHandCursor) { hx = 7; hy = 0; } else hx = hy = 16; invb = invm = false; } else { bbits = bm->toImage().convertToFormat(QImage::Format_Mono); mbits = bmm->toImage().convertToFormat(QImage::Format_Mono); invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); } int n = qMax(1, bbits.width() / 8); int h = bbits.height(); #if !defined(Q_WS_WINCE) uchar* xBits = new uchar[h * n]; uchar* xMask = new uchar[h * n]; int x = 0; for (int i = 0; i < h; ++i) { uchar *bits = bbits.scanLine(i); uchar *mask = mbits.scanLine(i); for (int j = 0; j < n; ++j) { uchar b = bits[j]; uchar m = mask[j]; if (invb) b ^= 0xff; if (invm) m ^= 0xff; xBits[x] = ~m; xMask[x] = b ^ m; ++x; } } hcurs = CreateCursor(qWinAppInst(), hx, hy, bbits.width(), bbits.height(), xBits, xMask); delete [] xBits; delete [] xMask; #elif defined(GWES_ICONCURS) // Q_WS_WINCE // Windows CE only supports fixed cursor size. int sysW = GetSystemMetrics(SM_CXCURSOR); int sysH = GetSystemMetrics(SM_CYCURSOR); int sysN = qMax(1, sysW / 8); uchar* xBits = new uchar[sysH * sysN]; uchar* xMask = new uchar[sysH * sysN]; int x = 0; for (int i = 0; i < sysH; ++i) { if (i >= h) { memset(&xBits[x] , 255, sysN); memset(&xMask[x] , 0, sysN); x += sysN; } else { int fillWidth = n > sysN ? sysN : n; uchar *bits = bbits.scanLine(i); uchar *mask = mbits.scanLine(i); for (int j = 0; j < fillWidth; ++j) { uchar b = bits[j]; uchar m = mask[j]; if (invb) b ^= 0xFF; if (invm) m ^= 0xFF; xBits[x] = ~m; xMask[x] = b ^ m; ++x; } for (int j = fillWidth; j < sysN; ++j ) { xBits[x] = 255; xMask[x] = 0; ++x; } } } hcurs = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH, xBits, xMask); delete [] xBits; delete [] xMask; #else Q_UNUSED(n); Q_UNUSED(h); #endif return; } default: qWarning("QCursor::update: Invalid cursor shape %d", cshape); return; } #ifdef Q_WS_WINCE hcurs = LoadCursor(0, sh); #else hcurs = (HCURSOR)LoadImage(0, sh, IMAGE_CURSOR, 0, 0, LR_DEFAULTSIZE | LR_SHARED); #endif }
static HCURSOR create32BitCursor(const QPixmap &pixmap, int hx, int hy) { HCURSOR cur = 0; #if !defined(Q_WS_WINCE) QBitmap mask = pixmap.mask(); if (mask.isNull()) { mask = QBitmap(pixmap.size()); mask.fill(Qt::color1); } HBITMAP ic = pixmap.toWinHBITMAP(QPixmap::Alpha); HBITMAP im = qt_createIconMask(mask); ICONINFO ii; ii.fIcon = 0; ii.xHotspot = hx; ii.yHotspot = hy; ii.hbmMask = im; ii.hbmColor = ic; cur = CreateIconIndirect(&ii); DeleteObject(ic); DeleteObject(im); #elif defined(GWES_ICONCURS) QImage bbits, mbits; bool invb, invm; bbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); mbits = pixmap.toImage().convertToFormat(QImage::Format_Mono); invb = bbits.colorCount() > 1 && qGray(bbits.color(0)) < qGray(bbits.color(1)); invm = mbits.colorCount() > 1 && qGray(mbits.color(0)) < qGray(mbits.color(1)); int sysW = GetSystemMetrics(SM_CXCURSOR); int sysH = GetSystemMetrics(SM_CYCURSOR); int sysN = qMax(1, sysW / 8); int n = qMax(1, bbits.width() / 8); int h = bbits.height(); uchar* xBits = new uchar[sysH * sysN]; uchar* xMask = new uchar[sysH * sysN]; int x = 0; for (int i = 0; i < sysH; ++i) { if (i >= h) { memset(&xBits[x] , 255, sysN); memset(&xMask[x] , 0, sysN); x += sysN; } else { int fillWidth = n > sysN ? sysN : n; uchar *bits = bbits.scanLine(i); uchar *mask = mbits.scanLine(i); for (int j = 0; j < fillWidth; ++j) { uchar b = bits[j]; uchar m = mask[j]; if (invb) b ^= 0xFF; if (invm) m ^= 0xFF; xBits[x] = ~m; xMask[x] = b ^ m; ++x; } for (int j = fillWidth; j < sysN; ++j ) { xBits[x] = 255; xMask[x] = 0; ++x; } } } cur = CreateCursor(qWinAppInst(), hx, hy, sysW, sysH, xBits, xMask); #else Q_UNUSED(pixmap); Q_UNUSED(hx); Q_UNUSED(hy); #endif return cur; }
//------------------------------------------------------------------------------------ // инициализация меню //------------------------------------------------------------------------------------ void InitMenu() { CreateCursor(); // установка курсора на центр // получаем размер клиентской области int W, H; vw_GetViewport(0, 0, &W, &H); float AWw = W*1.0f; float AHw = H*1.0f; float ARWidth; float ARHeight; vw_GetAspectWH(&ARWidth, &ARHeight); // установка мышки, чтобы не учитывать перемещения в меню #ifndef USE_GLES SDL_WarpMouse((int)((512.0f+256.0f)/(ARWidth/AWw)), (int)(384.0f/(ARHeight/AHw))); #endif Button1Transp = 1.0f; LastButton1UpdateTime = 0.0f; Button2Transp = 1.0f; LastButton2UpdateTime = 0.0f; Button3Transp = 1.0f; LastButton3UpdateTime = 0.0f; Button4Transp = 1.0f; LastButton4UpdateTime = 0.0f; Button5Transp = 1.0f; LastButton5UpdateTime = 0.0f; Button6Transp = 1.0f; LastButton6UpdateTime = 0.0f; Button7Transp = 1.0f; LastButton7UpdateTime = 0.0f; Button8Transp = 1.0f; LastButton8UpdateTime = 0.0f; Button9Transp = 1.0f; LastButton9UpdateTime = 0.0f; Button10Transp = 1.0f; LastButton10UpdateTime = 0.0f; Button11Transp = 1.0f; LastButton11UpdateTime = 0.0f; Button12Transp = 1.0f; LastButton12UpdateTime = 0.0f; Button13Transp = 1.0f; LastButton13UpdateTime = 0.0f; Button14Transp = 1.0f; LastButton14UpdateTime = 0.0f; LastMenuUpdateTime = 0.0f; MenuContentTransp = 0.0f; //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ // иним камеру, всегда до работы со скриптом (!!!) //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ vw_ResizeScene(45.0f, Setup.fAspectRatioWidth/Setup.fAspectRatioHeight, 1.0f, 2000.0f); InitGameCamera(); vw_SetCameraLocation(VECTOR3D(-50,30,-50)); vw_SetCameraMoveAroundPoint(VECTOR3D(0,0,0), 0.0f, VECTOR3D(0.0f, 0.0f, 0.0f)); if (Script != 0){delete Script; Script = 0;} Script = new ScriptEngine; if (Setup.MenuScript > 2) Setup.MenuScript = 0; switch (Setup.MenuScript) { case 0: Script->RunScript("DATA/SCRIPT/menu1.xml", vw_GetTime()); break; case 1: Script->RunScript("DATA/SCRIPT/menu2.xml", vw_GetTime()); break; case 2: Script->RunScript("DATA/SCRIPT/menu3.xml", vw_GetTime()); break; // на всякий случай default: Script->RunScript("DATA/SCRIPT/menu1.xml", vw_GetTime()); break; } Setup.MenuScript ++; // немного прокручиваем скрипт float Time1 = vw_GetTime(); Script->StartTime = Time1-30; Script->TimeLastOp = Time1-30; for (float i=Time1-30; i<Time1;i+=1.0f) { UpdateAllObject3D(i); Script->Update(i); } Script->StartTime = Time1; Script->TimeLastOp = Time1; // активные частицы космоса psSpace = 0; if (psSpace==0) psSpace = new eParticleSystem; psSpace->ColorStart.r = 0.80f; psSpace->ColorStart.g = 0.80f; psSpace->ColorStart.b = 1.00f; psSpace->ColorEnd.r = 0.70f; psSpace->ColorEnd.g = 0.70f; psSpace->ColorEnd.b = 1.00f; psSpace->AlphaStart = 1.00f; psSpace->AlphaEnd = 0.00f; psSpace->SizeStart = 0.10f; psSpace->SizeVar = 0.05f; psSpace->SizeEnd = 0.30f; psSpace->Speed = 4.00f; psSpace->SpeedVar = 8.00f; psSpace->Theta = 0.00f; psSpace->Life = 10.00f; psSpace->LifeVar = 0.00f; psSpace->CreationType = 1; psSpace->CreationSize = VECTOR3D(2.0f,50.0f,30.0f); psSpace->ParticlesPerSec = 140; psSpace->Texture[0] = vw_FindTextureByName("DATA/GFX/flare3.tga"); psSpace->Direction = VECTOR3D(1.0f, 0.0f, 0.0f); psSpace->Resize = 0.1f; psSpace->SetStartLocation(VECTOR3D(-50,10,-20)); // немного "прокручиваем", чтобы сразу по появлению было заполнено float Time = psSpace->TimeLastUpdate; for (float i=Time; i<Time+20;i+=1.0f) { psSpace->Update(i); } psSpace->TimeLastUpdate = Time; LastMenuUpdateTime = vw_GetTime(); NeedShowMenu = true; NeedHideMenu = false; LastMenuOnOffUpdateTime = vw_GetTime(); MenuBlackTransp = 1.0f; NeedOnMenu = true; // подстраховка, если не укажем меню, перейдем в основное GameStatus = MAIN_MENU; DrawGameCursor = true; StarsTileUpdateTime = vw_GetTime(); StarsTileUpdateTime2 = vw_GetTime(); }