/* * selectColor - select the color */ static void selectColor( WPI_POINT *pt, HWND hwnd ) { int i; WPI_PRES pres; HWND currentwnd; int top; int bottom; WPI_RECT wrect; currentwnd = _wpi_getdlgitem( hwnd, BK_CURRENT ); pres = _wpi_getpres( currentwnd ); _wpi_mapwindowpoints( hwnd, currentwnd, pt, 1 ); _wpi_torgbmode( pres ); for( i = 0; i < 16; i++ ) { top = availColor[i].box.top; bottom = availColor[i].box.bottom; top = _wpi_cvth_y( top, 2 * SQR_SIZE ); bottom = _wpi_cvth_y( bottom, 2 * SQR_SIZE ); _wpi_setintwrectvalues( &wrect, availColor[i].box.left, top, availColor[i].box.right, bottom ); if( _wpi_ptinrect( &wrect, *pt ) ) { screenColor.color = availColor[i].color; DisplayColorBox( pres, &screenColor ); inverseColor.color = GetInverseColor( screenColor.color ); DisplayColorBox( pres, &inverseColor ); break; } } _wpi_releasepres( currentwnd, pres ); } /* selectColor */
/* * paintCurrent - paint the current window (process WM_PAINT) */ static void paintCurrent( HWND hwnd ) { WPI_PRES pres; WPI_PRES mempres; HDC hdc; PAINTSTRUCT ps; WPI_RECT rect; HBITMAP oldbitmap; int top; int bottom; pres = _wpi_beginpaint( hwnd, NULL, &ps ); #ifdef __OS2_PM__ WinFillRect( pres, &ps, CLR_PALEGRAY ); #endif mempres = _wpi_createcompatiblepres( pres, Instance, &hdc ); _wpi_torgbmode( pres ); _wpi_torgbmode( mempres ); oldbitmap = _wpi_selectobject( mempres, lButton.bitmap ); _wpi_bitblt( pres, 0, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1, mempres, 0, 0, SRCCOPY ); _wpi_selectobject( mempres, oldbitmap ); oldbitmap = _wpi_selectobject( mempres, rButton.bitmap ); _wpi_bitblt( pres, CUR_RCOL_X - 1, 0, CUR_SQR_SIZE + 1, 2 * CUR_SQR_SIZE + 1, mempres, 0, 0, SRCCOPY ); _wpi_selectobject( mempres, oldbitmap ); _wpi_deletecompatiblepres( mempres, hdc ); _wpi_setbackmode( pres, TRANSPARENT ); _wpi_settextcolor( pres, GetInverseColor( lButton.solid ) ); top = _wpi_cvth_y( CUR_COL_Y, currentHeight ); bottom = _wpi_cvth_y( CUR_COL_Y + CUR_SQR_SIZE, currentHeight ); _wpi_setintwrectvalues( &rect, CUR_LCOL_X, top, CUR_LCOL_X + CUR_SQR_SIZE, bottom ); _wpi_drawtext( pres, "L", 1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER ); _wpi_settextcolor( pres, GetInverseColor( rButton.solid ) ); _wpi_setintwrectvalues( &rect, CUR_RCOL_X, top, CUR_RCOL_X + CUR_SQR_SIZE, bottom ); _wpi_drawtext( pres, "R", 1, &rect, DT_CENTER | DT_SINGLELINE | DT_VCENTER ); _wpi_endpaint( hwnd, pres, &ps ); } /* paintCurrent */
/* * ReplacePaletteEntry - replace the current entry with the given RGB value */ void ReplacePaletteEntry( COLORREF newcolor ) { COLORREF cur_color; COLORREF nearestcolor; COLORREF screencolor; COLORREF rightcolor; wie_clrtype lefttype; wie_clrtype righttype; int index; int rightindex; WPI_PRES pres; if( currentPalIndex != COLOR_16 && currentPalIndex != COLOR_256 ) { return; } cur_color = GetSelectedColor( LMOUSEBUTTON, NULL, &lefttype ); if( lefttype == NORMAL_CLR ) { index = getColorIndex( cur_color ); rightcolor = GetSelectedColor( RMOUSEBUTTON, NULL, &righttype ); rightindex = getColorIndex( rightcolor ); palette[currentPalIndex][index].rgbRed = GetRValue( newcolor ); palette[currentPalIndex][index].rgbGreen = GetGValue( newcolor ); palette[currentPalIndex][index].rgbBlue = GetBValue( newcolor ); palette[currentPalIndex][index].rgbReserved = 0; ShowNewColor( index, newcolor, TRUE ); pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); SetColor( LMOUSEBUTTON, newcolor, _wpi_getnearestcolor( pres, newcolor ), NORMAL_CLR ); if( index == rightindex ) { SetColor( RMOUSEBUTTON, newcolor, _wpi_getnearestcolor( pres, newcolor ), NORMAL_CLR ); } _wpi_releasepres( HWND_DESKTOP, pres ); } else if( lefttype == SCREEN_CLR ) { pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); nearestcolor = _wpi_getnearestcolor( pres, newcolor ); _wpi_releasepres( HWND_DESKTOP, pres ); SetScreenClr( nearestcolor ); } else { pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); nearestcolor = _wpi_getnearestcolor( pres, newcolor ); _wpi_releasepres( HWND_DESKTOP, pres ); screencolor = GetInverseColor( nearestcolor ); SetScreenClr( screencolor ); } } /* ReplacePaletteEntry */
/* * SetScreenClr - set the color to represent the screen */ void SetScreenClr( COLORREF screen_color ) { WPI_PRES pres; pres = _wpi_getpres( HWND_DESKTOP ); _wpi_torgbmode( pres ); screenColor.color = _wpi_getnearestcolor( pres, screen_color ); screenColor.solid_color = screenColor.color; _wpi_releasepres( HWND_DESKTOP, pres ); inverseColor.color = GetInverseColor( screenColor.color ); inverseColor.solid_color = inverseColor.color; VerifyCurrentClr( screenColor.color, inverseColor.color ); _wpi_invalidaterect( hScreenWnd, NULL, FALSE ); } /* SetScreenClr */
/* * initPaletteBoxes - assign the values of the colors in the palette and * initialize the palette boxes */ static void initPaletteBoxes( BOOL firsttime ) { SetBoxColors( &screenColor, &inverseColor, numberOfColors, paletteBox ); if( firsttime ) { SetColor( LMOUSEBUTTON, BLACK, BLACK, NORMAL_CLR ); SetColor( RMOUSEBUTTON, WHITE, WHITE, NORMAL_CLR ); /* * screenColor has been set by profile information */ inverseColor.color = GetInverseColor( screenColor.color ); inverseColor.solid_color = inverseColor.color; } else { SetCurrentColors( fShowScreenClr ); } #ifdef __OS2_PM__ convertToPMCoords(); #endif } /* initPaletteBoxes */
/* * displayColors - display the colors */ static void displayColors( HWND hwnd ) { short i; WPI_PRES pres; HWND currentwnd; inverseColor.color = GetInverseColor( screenColor.color ); currentwnd = _wpi_getdlgitem( hwnd, BK_CURRENT ); pres = _wpi_getpres( currentwnd ); _wpi_torgbmode( pres ); DisplayColorBox( pres, &screenColor ); DisplayColorBox( pres, &inverseColor ); for( i = 0; i < 16; i++ ) { DisplayColorBox( pres, &availColor[i] ); } _wpi_releasepres( currentwnd, pres ); } /* displayColors */