void MAS::Progress::MsgInitSkin() { Widget::MsgInitSkin(); if (orientation == 1) { if (GetBitmapIndex() == -1) SetBitmap(Skin::PROGRESSH); } else { if (GetBitmapIndex() == -1) SetBitmap(Skin::PROGRESSV); } UpdateSize(); }
void DrawBitmapButton (HWND hWnd, LPRECT r) { HDC hDC, hMemoryDC ; HBITMAP hBitmap, hTempBitmap ; int OldStretchMode ; BITMAP Bitmap ; WORD State; State = (WORD) GetWindowWord(hWnd, CBWNDEXTRA_STATE); hBitmap = (HBITMAP) GetWindowHandle(hWnd, GetBitmapIndex(State)); hDC = GetDC (hWnd) ; Dbg(hMemoryDC = CreateCompatibleDC (hDC)); Dbg(GetObject (hBitmap, sizeof(BITMAP), (LPSTR) &Bitmap)); // save the current bitmap handle. Dbg(hTempBitmap = (HBITMAP) SelectObject (hMemoryDC, hBitmap)); OldStretchMode = SetStretchBltMode (hDC, COLORONCOLOR); StretchBlt (hDC, r->left, r->top, r->right, r->bottom, hMemoryDC, 0, 0, Bitmap.bmWidth, Bitmap.bmHeight, SRCCOPY); SetStretchBltMode(hDC, OldStretchMode); // restore the old bitmap back into DC SelectObject(hMemoryDC, hTempBitmap); Dbg(DeleteDC(hMemoryDC)); Dbg(ReleaseDC(hWnd, hDC)); return; } /* DrawBitmapButton() */
void MAS::RadioButton::MsgInitSkin() { Button::MsgInitSkin(); for (int i=0; i<4; i++) { if (GetFontColor(i) == Color::transparent) SetFontColor(skin->fcol[Skin::INFO_RADIO][i], skin->scol[Skin::INFO_RADIO][i], i); if (GetFontIndex(i) == -1) SetFont(skin->fnt[Skin::INFO_RADIO][i], i); } if (GetTextMode() == Color::transparent) SetTextMode(skin->c_face); if (GetBitmapIndex() == Skin::BUTTON) SetBitmap(Skin::RADIO); SetFlag(D_TOGGLE); ClearFlag(D_SPINNER | D_AUTOSIZE); }
void NEAR FreeBitmaps(HWND hwndToolbar, int CtrlId) { HWND hwndCtrl; WORD State; HBITMAP hBitmap; hwndCtrl = GetDlgItem(hwndToolbar, CtrlId); for (State = STATE_NORMAL; State <= STATE_GRAYED; State++) { hBitmap = (HBITMAP)GetWindowHandle(hwndCtrl, GetBitmapIndex(State)); Dbg(DeleteObject(hBitmap)); } } /* FreeBitmaps() */
/** * Returns the width of the string 'str' in pixels (at subpixel accuracy) * had the string been rendered in this face. this is the same logic as in * DrawString() without issuing the GL commands to actually draw to the screen */ float STFont::ComputeWidth(const std::string& str) { if (str.length() == 0 || mImpl->ftFace == NULL) return 0.0f; float totalAdvance = 0.0f; unsigned int useKerning = FT_HAS_KERNING(mImpl->ftFace); int strLength = (int)str.length(); for (int i=0; i<strLength; i++) { unsigned int ch = str[i]; int bitmapIndex = GetBitmapIndex( ch ); if (bitmapIndex == -1) { if (ch == ' ') { totalAdvance += (float)mImpl->size / 4.0f; continue; } else { bitmapIndex = GenerateBitmap( ch ); } } // Get the kerning offset for the next character. FT_Vector kerning = {0,0}; if( useKerning && (i < strLength-1) ) { FT_Get_Kerning(mImpl->ftFace, FT_Get_Char_Index(mImpl->ftFace, str[i] ), FT_Get_Char_Index(mImpl->ftFace, str[i+1] ), 0, &kerning); } totalAdvance += mImpl->glyphBitmaps[bitmapIndex].advanceX + kerning.x/64.0f; } return totalAdvance; }
HWND CreateQCQPWindow(LPSTR lpWindowName, DWORD dwStyle, int x, int y, int dx, int dy, HWND hParent, HMENU hMenu, HINSTANCE hInstance, WPARAM wMessage) { HWND hTemp ; char szClass[MAX_MSG_TXT] ; WORD BaseId = 0; WORD State; HBITMAP hBitmap; Dbg(LoadString(hInstance, SYS_QCQPCtrl_wClass, szClass, MAX_MSG_TXT)) ; hTemp = CreateWindow( (LPSTR)szClass, // Window szClass name lpWindowName, // Window's title WS_CHILD | WS_VISIBLE, // window created visible x, y, // X, Y dx, dy, // Width, Height of window hParent, // Parent window's handle hMenu, // child's id hInstance, // Instance of window NULL); // Create struct for WM_CREATE if (hTemp != NULL) { SetWindowWord (hTemp, CBWNDEXTRA_STYLE, LOWORD(dwStyle)) ; SetWindowWord (hTemp, CBWNDEXTRA_BITMAP, HIWORD(dwStyle)) ; SetWindowWord (hTemp, CBWNDEXTRA_STATE, STATE_NORMAL) ; SetWindowHandle (hTemp, CBWNDEXTRA_MESSAGE, wMessage) ; if (LOWORD(dwStyle) == QCQP_CS_PUSHBUTTON) { // Load the bitmaps and store the handles switch (HIWORD(dwStyle)) { case IDS_CTRL_TRACENORMAL: case IDS_CTRL_TRACEPUSHED: case IDS_CTRL_TRACEGRAYED: BaseId = VGA_TRACE_NORMAL; break; case IDS_CTRL_STEPNORMAL: case IDS_CTRL_STEPPUSHED: case IDS_CTRL_STEPGRAYED: BaseId = VGA_STEP_NORMAL; break; case IDS_CTRL_BREAKNORMAL: case IDS_CTRL_BREAKPUSHED: case IDS_CTRL_BREAKGRAYED: BaseId = VGA_BREAK_NORMAL; break; case IDS_CTRL_GONORMAL: case IDS_CTRL_GOPUSHED: case IDS_CTRL_GOGRAYED: BaseId = VGA_GO_NORMAL; break; case IDS_CTRL_HALTNORMAL: case IDS_CTRL_HALTPUSHED: case IDS_CTRL_HALTGRAYED: BaseId = VGA_HALT_NORMAL; break; case IDS_CTRL_QWATCHNORMAL: case IDS_CTRL_QWATCHPUSHED: case IDS_CTRL_QWATCHGRAYED: BaseId = VGA_QWATCH_NORMAL; break; case IDS_CTRL_SMODENORMAL: case IDS_CTRL_SMODEPUSHED: case IDS_CTRL_SMODEGRAYED: BaseId = VGA_SMODE_NORMAL; break; case IDS_CTRL_AMODENORMAL: case IDS_CTRL_AMODEPUSHED: case IDS_CTRL_AMODEGRAYED: BaseId = VGA_AMODE_NORMAL; break; case IDS_CTRL_FORMATNORMAL: case IDS_CTRL_FORMATPUSHED: case IDS_CTRL_FORMATGRAYED: BaseId = VGA_FORMAT_NORMAL; break; default: Assert(FALSE); } // Load the bitmaps for each state for the button for (State = STATE_NORMAL; State <= STATE_GRAYED; State++) { Dbg(hBitmap = LoadBitmap(hInstance, MAKEINTRESOURCE( BaseId + State ))); SetWindowHandle(hTemp, GetBitmapIndex(State), (WPARAM)hBitmap); } } } return hTemp ; } /* CreateQCQPWindow() */
/** * Renders a string of text using this face * Returns the width of the rendered text in pixels (at subpixel accuracy) */ float STFont::DrawString(const std::string& str, const STColor4f& color) { if (str.length() == 0 || mImpl->ftFace == NULL) return 0.0f; // // Set up OpenGL state for rendering text, and push // attributes so that we can restore when done. // glPushAttrib( GL_ENABLE_BIT | GL_PIXEL_MODE_BIT | GL_COLOR_BUFFER_BIT); glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glDisable(GL_TEXTURE_2D); glPixelTransferf(GL_RED_SCALE, color.r); glPixelTransferf(GL_GREEN_SCALE, color.g); glPixelTransferf(GL_BLUE_SCALE, color.b); glPixelTransferf(GL_ALPHA_SCALE, color.a); glRasterPos2f(0.0f, 0.0f); // // Draw each character in order. // float totalAdvance = 0.0f; unsigned int useKerning = FT_HAS_KERNING(mImpl->ftFace); // Render glyph for each character in the string int strLength = (int)str.length(); for (int i=0; i<strLength; i++) { unsigned int ch = str[i]; int bitmapIndex = GetBitmapIndex( ch ); // Pixmap for this character hasn't been generated. Do that now. if (bitmapIndex == -1) { if (ch == ' ') { glBitmap( 0, 0, 0.0f, 0.0f, (float) mImpl->size / 4.0f, 0.0f, (const GLubyte*)0 ); totalAdvance += (float) mImpl->size / 4.0f; continue; } else { bitmapIndex = GenerateBitmap( ch ); } } STBitmapGlyph& bitmapGlyph = mImpl->glyphBitmaps[bitmapIndex]; // Move the raster position by (offsetX, offsetY) glBitmap(0, 0, 0.0f, 0.0f, (float) bitmapGlyph.offsetX, (float) bitmapGlyph.offsetY, NULL); // Render the glyph to the framebuffer glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); glPixelStorei(GL_UNPACK_ALIGNMENT, 2); glDrawPixels(bitmapGlyph.width, bitmapGlyph.height, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, (const GLvoid*) bitmapGlyph.data); // Restore raster position glBitmap(0, 0, 0.0f, 0.0f, (float) -bitmapGlyph.offsetX, (float) -bitmapGlyph.offsetY, NULL); // Get the kerning offset for the next character. FT_Vector kerning = {0,0}; if( useKerning && (i < strLength-1) ) { FT_Get_Kerning(mImpl->ftFace, FT_Get_Char_Index(mImpl->ftFace, str[i] ), FT_Get_Char_Index(mImpl->ftFace, str[i+1] ), 0, &kerning ); } // Move the raster position to where it should be for the next character. glBitmap(0, 0, 0.0f, 0.0f, (float) (bitmapGlyph.advanceX + kerning.x/64.0f), 0.0f, NULL); totalAdvance += bitmapGlyph.advanceX + kerning.x/64.0f; } // // Restore OpenGL state. // glPopClientAttrib(); glPopAttrib(); return totalAdvance; }