void URLView::MouseUp( BPoint point ) { // If the link isn't enabled, don't do anything. if( !IsEnabled() ) return; // Do we want to show the right-click menu? if( inPopup && GetTextRect().Contains( point ) ) { BPopUpMenu *popup = CreatePopupMenu(); // Work around a current bug in Be's popup menus. point.y = point.y - 6; // Display the popup menu. BMenuItem *selected = popup->Go( ConvertToScreen( point ) , false, true ); // Did the user select an item? if( selected ) { BString label( selected->Label() ); // Did the user select the first item? If so, launch the URL. if( label.FindFirst( "Open" ) != B_ERROR || label.FindFirst( "Send" ) != B_ERROR || label.FindFirst( "Connect" ) != B_ERROR ) { LaunchURL(); } // Did the user select the second item? else if( label.FindFirst( "Copy" ) != B_ERROR ) { CopyToClipboard(); } } // If not, restore the normal link color. else { SetHighColor( color ); Redraw(); } } // If the link was clicked on (and not dragged), run the program // that should handle the URL. if( selected && GetTextRect().Contains( point ) && !draggedOut && !inPopup ) { LaunchURL(); } selected = false; draggedOut = false; inPopup = false; // Should we restore the hovering-highlighted color or the original // link color? if( GetTextRect().Contains( point ) && !draggedOut && !inPopup && hoverEnabled ) { SetHighColor( hoverColor ); } else if( !hovering ) SetHighColor( color ); Redraw(); }
UINT_PTR CBkSafeMsgBox2::ShowMutlLineMsg(LPCWSTR pszMsg, LPCWSTR lpszCaption /* = NULL */, UINT uType /* = NULL */, BOOL *pbNoNotifyLater /* = NULL */, HWND hWndParent /* = ::GetActiveWindow */) { CString strMsg = pszMsg, strXml(L""), strXmlPanel(L""); CAtlArray<CString> arrMsgLine; if ( 0 == ParseMsgLine(strMsg, arrMsgLine)) return -1; int nWidth = 0, nLineCount = arrMsgLine.GetCount(), nHeight = nLineCount* 18, nTop = 0; CRect rcText; for (int i = 0; i < nLineCount; i++) { if (1 == nLineCount) nTop = 10; else nTop = i*18; strXml.Format(L"<text pos=\"0,%d\">%s</text>", nTop, arrMsgLine[i]); strXmlPanel += strXml; rcText = GetTextRect(arrMsgLine[i]); if (nWidth < rcText.Width()) nWidth = rcText.Width(); } CRect rc(0, 0, nWidth+10, nHeight); return ShowPanelMsg(strXmlPanel, &rc, NULL, uType, pbNoNotifyLater, hWndParent); }
const QRectF QtRoundedEditRectItem::GetPaddedTextRect(const std::string& s) const { return GetTextRect(s).adjusted( -m_text_padding.left, -m_text_padding.top, m_text_padding.right, m_text_padding.bottom); }
void RichEdit::SetObjectPos(int pos) { Rect r = GetObjectRect(cursor); Rect rr = r.Offseted(GetTextRect().left, -sb); objectrect = GetObjectRect(pos); objectpos = cursor; PlaceCaret(); Refresh(rr); ReadFormat(); }
HRESULT ID3DApplication::SetTextFont(LOGFONT* pFont) { LOGFONT lf; if (pFont) { // copy the parameter to our local fontspec ::memcpy(&lf, pFont, sizeof(LOGFONT)); } else { // parameter is NULL, init fontspec with // default font ::memset(&lf, 0, sizeof(LOGFONT)); lf.lfHeight = -12; lf.lfWeight = 400; lf.lfOutPrecision = 1; lf.lfClipPrecision = 2; lf.lfQuality = 1; lf.lfPitchAndFamily = 49; ::_tcscpy_s(lf.lfFaceName, _T("Lucida Console")); } // release the previous font if (m_pFont) { m_pFont->Release(); m_pFont = NULL; } // create new font HRESULT hres; hres = D3DXCreateFont( m_pDevice, lf.lfHeight, lf.lfWidth, lf.lfWeight, 0, lf.lfItalic, lf.lfCharSet, lf.lfOutPrecision, lf.lfQuality, lf.lfPitchAndFamily, lf.lfFaceName, &m_pFont ); if (FAILED(hres)) { return hres; } RECT rcArea = GetTextRect(0, 0, _T("W")); m_iTextHeight = rcArea.bottom; return S_OK; }
void CAbstractTextEdit::Render() { CAbstractLabel::Render(); if(m_Composing) { int FontSize = GetFontSize(); vec4 FontColor = 1.0f; CRect ComposingRect = CRect( GetTextRect().x + GetTextRect().w, GetTextRect().y, TextRenderer()->GetTextWidth(&m_ComposingTextCache), GetTextRect().h ); const CAsset_GuiLabelStyle* pLabelStyle = AssetsManager()->GetAsset<CAsset_GuiLabelStyle>(CAssetPath::GuiLabelStyleSystem(GUILABELSTYLE_COMPOSING)); if(pLabelStyle) { FontSize = Context()->ApplyGuiScale(pLabelStyle->GetFontSize()); FontColor = pLabelStyle->m_TextColor; CRect Rect = ComposingRect; int Padding = Context()->ApplyGuiScale(pLabelStyle->GetPadding()); Rect.AddMargin(Padding); ComposingRect.x += Padding; AssetsRenderer()->DrawGuiRect(&ComposingRect, pLabelStyle->GetRectPath()); } m_ComposingTextCache.SetFontSize(GetFontSize()); m_ComposingTextCache.SetBoxSize(ivec2(-1, ComposingRect.h)); TextRenderer()->DrawText(&m_ComposingTextCache, ivec2(ComposingRect.x, ComposingRect.y), FontColor); } // render the cursor // cursor position if(m_TextCursor.m_TextIter >= 0) { if((2*time_get()/time_freq()) % 2) { Graphics()->TextureClear(); Graphics()->LinesBegin(); Graphics()->SetColor(1.0f, 1.0f, 1.0f, 1.0f); float x = m_TextCursor.m_Position.x + 0.5f; float y0 = GetTextRect().y; float y1 = GetTextRect().y + GetTextRect().h; IGraphics::CLineItem Line(x, y0, x, y1); Graphics()->LinesDraw(&Line, 1); Graphics()->LinesEnd(); } } }
void WebEditBox::EnsureCursorVisible (void) { WebGraphics *gc = GetGraphics(); WebFont font = mFont.GetFont(); if (gc && font && mpText) { DISPLAY_INT cursorX = gc->TextWidthLen(mpText + GetLineOffset(miCurrentLine), font, miCursorPos - GetLineOffset(miCurrentLine)) - miXOffset; DISPLAY_INT cursorY = WEB_FONT_HEIGHT(font)*miCurrentLine - miYOffset; WebRect box; GetTextRect(&box); cursorX += box.left; cursorY += box.top; if (cursorY < box.top) { miYOffset -= (box.top - cursorY); } else if ((cursorY + WEB_FONT_HEIGHT(font)) > box.bottom) { miYOffset += (cursorY + WEB_FONT_HEIGHT(font)) - box.bottom; } if (cursorX > box.right) { // overshoot by a bit miXOffset += cursorX - box.right + 10; } else if (cursorX < box.left) { miXOffset -= (box.left - cursorX); } if (mpVScroll) { mpVScroll->SetPosition(miYOffset); } if (mpHScroll) { mpHScroll->SetPosition(miXOffset); } mEditFlags &= ~EDIT_FLAG_ENSURE_CURSOR_VISIBLE; } }
void CTabItem_Normal::Paint(CDC* pDC) { CRect rect; rect = GetRect(); rect.right -= m_iItemGap; if (m_bActive) CFaceManager::GetInstance()->DrawImageBar(IBI_PAGETAB_A, pDC->m_hDC, rect); else { if (IsHover()) CFaceManager::GetInstance()->DrawImageBar(IBI_PAGETAB_H, pDC->m_hDC, rect); else CFaceManager::GetInstance()->DrawImageBar(IBI_PAGETAB_N, pDC->m_hDC, rect); } if(m_bHasIcon) { if (GetIconRect(rect)) { m_imgIcon.Draw(pDC->GetSafeHdc(), rect.left, rect.top); } } // DrawText <begin> if (GetTextRect(rect)) { CFontDC font(pDC->GetSafeHdc(), _T("宋体")); font = 12; int iOldMode = pDC->SetBkMode(TRANSPARENT); COLORREF clrOldText; if (m_bActive) { clrOldText = pDC->SetTextColor(RGB(154, 2, 1)); } else { clrOldText = pDC->SetTextColor(RGB(255, 255, 255)); } pDC->DrawText(m_strCaption, rect, DT_VCENTER | DT_SINGLELINE | DT_CENTER | DT_WORD_ELLIPSIS); pDC->SetTextColor(clrOldText); pDC->SetBkMode(iOldMode); } // DrawText <end> }
void ID3DApplication::DrawText(int iX, int iY, LPCTSTR strText, DWORD dwColor) { if (m_pFont == NULL || m_pSprite == NULL) { // invalid user error... return; } RECT rcArea = GetTextRect(iX, iY, strText); m_pFont->DrawText( m_pSprite, strText, -1, &rcArea, 0, dwColor); }
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ void ContextItem::Paint(HDC hDC) { if (m_ItemID == MENUITEM_ID_FOLDER) FolderItem::Paint(hDC); else MenuItem::Paint(hDC); if (0==(m_type & MFT_OWNERDRAW)) return; RECT r; GetTextRect(&r); int w = r.right - r.left; int h = r.bottom - r.top; // the remaining margin int m = (int)imax(0, w - (m_bmp_width - m_icon_offset)); // text width int tw = w - m; HDC buf = CreateCompatibleDC(NULL); HGDIOBJ other_bmp = SelectObject(buf, m_bmp); #if 0 BitBlt(hDC, r.left, r.top, tw, h, buf, m_icon_offset, 0, SRCCOPY); #else // adjust offset according to justifications if (mStyle.MenuFrame.Justify == DT_CENTER) m /= 2; else if (mStyle.MenuFrame.Justify != DT_RIGHT) m = 0; // then plot points when they seem to have the textcolor // icons on the left are cut off COLORREF CRTXT_BB = m_bActive ? mStyle.MenuHilite.TextColor : mStyle.MenuFrame.TextColor; int x, y; for (y = 0; y < h; y++) for (x = 0; x < tw; x++) if (CRTXT_WIN == GetPixel(buf, x+m_icon_offset, y)) SetPixel (hDC, r.left+m+x, r.top+y, CRTXT_BB); #endif SelectObject(buf, other_bmp); // this let's the handler know which command to invoke eventually if (m_bActive) DrawItem(buf, m_bmp_width, h, true); DeleteDC(buf); }
void STextButton::OnPaint( IRenderTarget *pRT ) { SPainter painter; BeforePaint(pRT, painter); CRect rcText; GetTextRect(rcText); DrawText(pRT,m_strText, m_strText.GetLength(), rcText, GetTextAlign()); //draw focus rect if(IsFocused()) { DrawFocus(pRT); } AfterPaint(pRT, painter); }
/***************************************************************************** If no text in the cell, add up all the button text together and use that as the title tip text *****************************************************************************/ BOOL CGridBtnCellBase::GetTipTextRect( LPRECT pRect) // i/o: i=dims of cell rect; o=dims of text rect { if( HasCellText() ) return GetTextRect( pRect); // if any text, just use default // no string text... maybe there's btns with text const int iCtlNbr = GetDrawCtlNbr(); if( iCtlNbr <= 0) { pRect->left = 0; pRect->top = 0; pRect->right = 0; pRect->bottom = 0; } // else, don't modify rect -- rect is full cell size return TRUE; }
//------------------------------------------------------------------------ //! Checks if the mouse click should start the cell editor (OnEditBegin) //! Validates that the click was on the text-link within the label-part //! //! @param owner The list control being clicked //! @param nRow The index of the row //! @param nCol The index of the column //! @param pt The position clicked, in client coordinates. //! @param bDblClick Whether the position was double clicked //! @return How should the cell editor be started (0 = No editor, 1 = Start Editor, 2 = Start Editor and block click-event) //------------------------------------------------------------------------ int CGridColumnTraitHyperLink::OnClickEditStart(CGridListCtrlEx& owner, int nRow, int nCol, CPoint pt, bool bDblClick) { int startEdit = CGridColumnTraitImage::OnClickEditStart(owner, nRow, nCol, pt, bDblClick); if (startEdit) { // Check if mouse click was inside the label-part of the cell CRect labelRect; if (owner.GetCellRect(nRow, nCol, LVIR_LABEL, labelRect) && labelRect.PtInRect(pt)) { // Check if mouse click was inside the text-link of the cell CString cellText = owner.GetItemText(nRow, nCol); if (GetTextRect(owner, nRow, nCol, cellText).PtInRect(pt)) return startEdit; else return 0; } } return startEdit; }
void QtRoundedEditRectItem::SetText(const std::vector<std::string>& text) { if (text != m_text) { m_text = text; const QRectF text_rect = GetTextRect(m_text); this->SetRoundedRect( text_rect.adjusted( -m_padding.left, -m_padding.top, m_padding.right, m_padding.bottom), this->GetRadiusX(), this->GetRadiusY() ); this->update(); m_signal_request_scene_update(); } }
WEBC_BOOL WebEditBox::GetFocusRect (WebRect* rect) { WebGraphics *gc = GetGraphics(); WebFont font = mFont.GetFont(); if (gc && font && mpText && (mEditFlags & EDIT_FLAG_ENSURE_CURSOR_VISIBLE)) { EnsureCursorVisible(); DISPLAY_INT cursorX = gc->TextWidthLen(mpText + GetLineOffset(miCurrentLine), font, miCursorPos - GetLineOffset(miCurrentLine)) - miXOffset; DISPLAY_INT cursorY = WEB_FONT_HEIGHT(font)*miCurrentLine - miYOffset; GetTextRect(rect); rect->Shift(cursorX, cursorY); rect->SizeTo(5, WEB_FONT_HEIGHT(font)); return WEBC_TRUE; } return WEBC_FALSE; }
void SComboBase::OnPaint(IRenderTarget * pRT ) { SPainter painter; BeforePaint(pRT, painter); if(GetCurSel() != -1 && m_pEdit==NULL) { CRect rcText; GetTextRect(rcText); SStringT strText=GetWindowText(); DrawText(pRT,strText, strText.GetLength(), rcText, GetTextAlign()); } //draw focus rect if(IsFocused()) { DrawFocus(pRT); } AfterPaint(pRT, painter); CRect rcBtn; GetDropBtnRect(&rcBtn); m_pSkinBtn->Draw(pRT,rcBtn,IIF_STATE3(m_dwBtnState,WndState_Normal,WndState_Hover,WndState_PushDown)); }
VOID CDUIIconTextItem::PaintText(HDC dc) { if(m_pParentControl == NULL) { DUI_ASSERT(FALSE); return; } CRefPtr<CTextStyle> pTextStyle = m_pParentControl->GetTextStyle(); if(pTextStyle.IsNull()) return; CRefPtr<CFontObject> pFont = pTextStyle->GetFont(); if(pFont.IsNull() || pFont->IsNull()) return; HFONT hFont = pFont->GetFont(); if(m_strText.size() > 0) { RECT rtText = GetTextRect(); SelectObject(dc, hFont); SetBkMode(dc, TRANSPARENT); if(GetSelect()) { SetTextColor(dc, pTextStyle->GetSelectColor().GetColor()); } else if(GetStatus() & CONTROL_STATUS_HOVER) { SetTextColor(dc, pTextStyle->GetHoverColor().GetColor()); } else { SetTextColor(dc, pTextStyle->GetNormalColor().GetColor()); } CDUIRenderEngine::DrawText(dc, m_strText.c_str() , m_strText.size(), &rtText, pTextStyle->GetTextFormat()); } }
BOOL CGridBtnCellBase::HasCellText() // returns: F=auto-size buttons, only { CGridCtrl* pGrid = GetGrid(); ASSERT( pGrid); CRect RectCell; if( !pGrid->GetCellRect(m_iRow, m_iCol, &RectCell) ) return FALSE; // rather than see if there is text assigned, check if any // space allocated for text CRect RectText( RectCell); if( !GetTextRect( &RectText) ) // i/o: i=dims of cell rect; o=dims of text rect return FALSE; if( RectText.Width() > 0 ) return TRUE; return FALSE; }
void QtRoundedEditRectItem::SetPadding(const Padding& padding) { if ( padding.bottom != m_padding.bottom || padding.left != m_padding.left || padding.right != m_padding.right || padding.top != m_padding.top ) { m_padding = padding; const QRectF text_rect = GetTextRect(m_text); this->SetRoundedRect( text_rect.adjusted( -m_padding.left, -m_padding.top, m_padding.right, m_padding.bottom), this->GetRadiusX(), this->GetRadiusY() ); this->update(); m_signal_request_scene_update(); } }
void URLView::MouseDown( BPoint point ) { // If the link isn't enabled, don't do anything. if( !IsEnabled() ) return; // See which mouse buttons were clicked. int32 buttons = Window()->CurrentMessage()->FindInt32( "buttons" ); // We want to highlight the text if the user clicks on // the URL. We want to be sure to only register a click // if the user clicks on the link text itself and not just // anywhere in the view. if( GetTextRect().Contains( point ) ) { SetHighColor( clickColor ); Redraw(); // Set the link as selected and track the mouse. selected = true; SetMouseEventMask( B_POINTER_EVENTS ); // Remember where the user clicked so we can correctly // offset the transparent URL if the user drags. BRect frame = Frame(); frame.OffsetTo( B_ORIGIN ); dragOffset = point; if( Alignment() == B_ALIGN_RIGHT ) { dragOffset.x -= frame.Width() - StringWidth( Text() ); } else if( Alignment() == B_ALIGN_CENTER ) { dragOffset.x -= (frame.Width() / 2) - (StringWidth( Text() ) / 2); } // Pop up the context menu? if( buttons == B_SECONDARY_MOUSE_BUTTON ) inPopup = true; } }
void StringItem::Paint(HDC hDC) { RECT r; HFONT hFont; int x, y, w, h, padd; if (Settings_menu.showBroams) { if (hText) DestroyWindow(hText), hText = NULL; m_Justify = MENUITEM_STANDARD_JUSTIFY; MenuItem::Paint(hDC); return; } m_Justify = MENUITEM_CUSTOMTEXT; MenuItem::Paint(hDC); GetTextRect(&r); if (EqualRect(&m_textrect, &r)) return; m_textrect = r; if (NULL == hText) { hText = CreateWindow( TEXT("EDIT"), m_pszTitle, WS_CHILD | WS_VISIBLE | ES_AUTOHSCROLL | ES_MULTILINE, 0, 0, 0, 0, m_pMenu->m_hwnd, (HMENU)1234, hMainInstance, NULL ); SetWindowLongPtr(hText, GWLP_USERDATA, (LONG_PTR)this); wpEditProc = (WNDPROC)SetWindowLongPtr(hText, GWLP_WNDPROC, (LONG_PTR)EditProc); #if 0 int n = GetWindowTextLength(hText); SendMessage(hText, EM_SETSEL, 0, n); SendMessage(hText, EM_SCROLLCARET, 0, 0); #endif m_pMenu->m_hwndChild = hText; if (GetFocus() == m_pMenu->m_hwnd) SetFocus(hText); } hFont = MenuInfo.hFrameFont; SendMessage(hText, WM_SETFONT, (WPARAM)hFont, 0); x = r.left-1; y = r.top+2; h = r.bottom - r.top - 4; w = r.right - r.left + 2; SetWindowPos(hText, NULL, x, y, w, h, SWP_NOZORDER); padd = imax(0, (h - get_fontheight(hFont)) / 2); r.left = padd+2; r.right = w - (padd+2); r.top = padd; r.bottom = h - padd; SendMessage(hText, EM_SETRECT, 0, (LPARAM)&r); }
void CFont::PrintString(float arg_x, float arg_y, CharType *arg_text) { CRect textBoxRect; float xBound; float yBound = arg_y; float strWidth, widthLimit; float var_38 = 0.0f; float print_x; float justifyWrap; CharType *ptext = arg_text; CharType *strHead = arg_text; bool emptyLine = true; short numSpaces = 0; Details->UselessFlag1 = false; if (*arg_text == '*') { return; } ++Details->TextCount; if (Details->Background) { GetTextRect(&textBoxRect, arg_x, arg_y, arg_text); CSprite2d::fpDrawRect.fun(textBoxRect, Details->BackgroundColor); } if (Details->Centre || Details->RightJustify) { xBound = 0.0f; } else { xBound = arg_x; } while (*ptext != 0) { strWidth = GetStringWidth(ptext, false); if (Details->Centre) { widthLimit = Details->CentreSize; } else if (Details->RightJustify) { widthLimit = arg_x - Details->RightJustifyWrap; } else { widthLimit = Details->WrapX; } if (((xBound + strWidth) <= widthLimit) || emptyLine) { ptext = GetNextSpace(ptext); xBound += strWidth; if (*ptext != 0) { if (*ptext == ' ') { if (*(ptext + 1) == 0) { *ptext = 0; } else { if (!emptyLine) { ++numSpaces; } xBound += GetCharacterSizeNormal(' '); ++ptext; } } emptyLine = false; var_38 = xBound; } else { if (Details->Centre) { print_x = arg_x - xBound * 0.5f; } else if (Details->RightJustify) { print_x = arg_x - xBound; } else { print_x = arg_x; } fpPrintStringPart.fun(print_x, yBound, 0, strHead, ptext, 0.0f); } } else { if (Details->Justify && !(Details->Centre)) { justifyWrap = (Details->WrapX - var_38) / numSpaces; } else { justifyWrap = 0.0f; } if (Details->Centre) { print_x = arg_x - xBound * 0.5f; } else if (Details->RightJustify) { print_x = arg_x - xBound; } else { print_x = arg_x; } fpPrintStringPart.fun(print_x, yBound, 0, strHead, ptext, justifyWrap); strHead = ptext; if (Details->Centre || Details->RightJustify) { xBound = 0.0f; } else { xBound = arg_x; } yBound += Details->Scale.y * 18.0f; var_38 = 0.0f; numSpaces = 0; emptyLine = true; } } }
void URLView::MouseMoved( BPoint point, uint32 transit, const BMessage *message ) { // If the link isn't enabled, don't do anything. if( !IsEnabled() ) return; // Make sure the window is the active one. if( !Window()->IsActive() ) return; // See which mouse buttons were clicked. int32 buttons = Window()->CurrentMessage()->FindInt32( "buttons" ); // Is the user currently dragging the link? (i.e. is a mouse button // currently down?) bool alreadyDragging = (buttons != 0); switch( transit ) { case( B_ENTERED_VIEW ): // Should we set the cursor to the link cursor? if( GetTextRect().Contains( point ) && !draggedOut ) { if( !alreadyDragging ) be_app->SetCursor( linkCursor ); // Did the user leave and re-enter the view while // holding down the mouse button? If so, highlight // the link. if( selected ) { SetHighColor( clickColor ); Redraw(); } // Should we hover-highlight the link? else if( hoverEnabled && !alreadyDragging ) { if( buttons == 0 ) { SetHighColor( hoverColor ); Redraw(); hovering = true; } } } break; case( B_EXITED_VIEW ): // We want to restore the link to it normal color and the // mouse cursor to the normal hand. However, we should only // set the color and re-draw if it is needed. if( selected && !draggedOut ) { be_app->SetCursor( B_HAND_CURSOR ); SetHighColor( color ); Redraw(); // Is the user drag-and-dropping a bookmark or person? if( draggable ) { draggedOut = true; if( IsEmailLink() ) DoPersonDrag(); else DoBookmarkDrag(); } } // Is the link currently hover-highlighted? If so, restore // the normal color now. else if( hovering && !alreadyDragging ) { be_app->SetCursor( B_HAND_CURSOR ); SetHighColor( color ); Redraw(); hovering = false; } // Change the cursor back to the hand. else { be_app->SetCursor( B_HAND_CURSOR ); } break; case( B_INSIDE_VIEW ): // The user could either be moving out of the view or // back into it here, so we must handle both cases. // In the first case, the cursor is now over the link. if( GetTextRect().Contains( point ) && !draggedOut ) { // We only want to change the cursor if not dragging. if( !alreadyDragging ) be_app->SetCursor( linkCursor ); if( selected ) { if( draggable ) { // If the user moves the mouse more than ten // pixels, begin the drag. if( (point.x - dragOffset.x) > 10 || (dragOffset.x - point.x) > 10 || (point.y - dragOffset.y) > 10 || (dragOffset.y - point.y) > 10 ) { draggedOut = true; // Draw the appropriate drag object, etc. if( IsEmailLink() ) DoPersonDrag(); else DoBookmarkDrag(); SetHighColor( color ); Redraw(); } } else { // Since the link is not draggable, highlight it // as long as the user holds the button down and // has the mouse cursor over it (like a standard // button). SetHighColor( clickColor ); Redraw(); } } // The link isn't currently selected? If hover-highlighting // is enabled, highlight the link. else if( hoverEnabled && !alreadyDragging ) { SetHighColor( hoverColor ); Redraw(); hovering = true; } } // In this case, the mouse cursor is not over the link, so we // need to restore the original link color, etc. else if( !draggedOut ) { be_app->SetCursor( B_HAND_CURSOR ); if( selected ) { SetHighColor( color ); Redraw(); // Is the user dragging the link? if( draggable ) { draggedOut = true; if( IsEmailLink() ) DoPersonDrag(); else DoBookmarkDrag(); } } // Is the mouse cursor hovering over the link? else if( hovering ) { SetHighColor( color ); Redraw(); hovering = false; } } break; } }
void WebEditBox::Format (void) { WebGraphics *gc = GetGraphics(); WebFont font = mFont.GetFont(); if (!gc || !mpText || !font) { return; } int i = 0; do { long iIndex = 0; long iNextWord; DISPLAY_INT iWidthUsed = 0; WebRect box; DISPLAY_INT iWordWidth; GetTextRect(&box); DISPLAY_INT iWidthAvailable = box.Width(); //printf("Box w == %d\n",iWidthAvailable); miMaxLineWidth = 0; miNumLines = 1; while (mpText[iIndex]) { switch (mpText[iIndex]) { case (WebChar) '\r': case (WebChar) '\n': // break the line at CR/LF AddLine(++iIndex); iWidthUsed = 0; break; default: if (!(mEditFlags & EDIT_FLAG_WRAP)) { iWordWidth = gc->TextWidthLen(&mpText[iIndex], font, 1); iWidthUsed += iWordWidth; miMaxLineWidth = EBSMAX(miMaxLineWidth, iWidthUsed); iIndex++; } else { #if (TEXT_BOX_SCROLL_DISABLED) WebChar mpText1='m'; DISPLAY_INT charWidth = gc->TextWidthLen(&mpText[iIndex], font, 1); if (iWidthUsed + charWidth > (iWidthAvailable) && iWidthUsed > 0) { AddLine(iIndex); iWidthUsed = charWidth; miMaxLineWidth = EBSMAX(miMaxLineWidth, charWidth); iIndex++; } else { iIndex++; iWidthUsed += charWidth; } }//switch statement #else if (IS_WHITESPACE(mpText[iIndex])) { iWidthUsed += gc->TextWidthLen(&mpText[iIndex++], font, 1); } else { iNextWord = iIndex; while (!IS_WHITESPACE(mpText[iNextWord]) && mpText[iNextWord]) { iNextWord++; } iWordWidth = gc->TextWidthLen(&mpText[iIndex], font, iNextWord-iIndex); // only do a line break if there is something already on the line if (iWidthUsed + iWordWidth > iWidthAvailable && iWidthUsed > 0) { // the next word_ will not fit; break the line. AddLine(iIndex); iWidthUsed = iWordWidth; miMaxLineWidth = EBSMAX(miMaxLineWidth, iWordWidth); iIndex = iNextWord; } else { // the next word_ will fit on this line iWidthUsed += iWordWidth; miMaxLineWidth = EBSMAX(miMaxLineWidth, iWordWidth); iIndex = iNextWord; } } } #endif break; } } i++; }
void URLView::DoPersonDrag() { // Handle all of the bookmark dragging. This includes setting up // the drag message and drawing the dragged bitmap. // Set up the drag message to support both BTextView dragging (using // the e-mail address) and file dropping (to Tracker). BMessage *dragMessage = new BMessage( B_MIME_DATA ); dragMessage->AddInt32( "be:actions", B_COPY_TARGET ); dragMessage->AddString( "be:types", "application/octet-stream" ); dragMessage->AddString( "be:filetypes", "application/x-person" ); dragMessage->AddString( "be:type_descriptions", "person" ); dragMessage->AddString( "be:clip_name", Text() ); // This allows the user to drag the e-mail address into a // standard BTextView. BString email = GetImportantURL(); dragMessage->AddData( "text/plain", B_MIME_DATA, email.String(), email.Length() + 1 ); // Query for the system's icon for bookmarks. BBitmap *personIcon = new BBitmap( BRect( 0, 0, iconSize - 1, iconSize - 1 ), B_CMAP8 ); #ifdef ZETA BMimeType mime( "application/x-vnd.Be-PEPL" ); #else BMimeType mime( "application/x-person" ); #endif if( iconSize == 16 ) mime.GetIcon( personIcon, B_MINI_ICON ); else mime.GetIcon( personIcon, B_LARGE_ICON ); // Find the size of the bitmap to drag. If the text is bigger than the // icon, use that size. Otherwise, use the icon's. Center the icon // vertically in the bitmap. BRect rect = GetTextRect(); rect.right += iconSize + 4; if( (rect.bottom - rect.top) < iconSize ) { int adjustment = (int) ((iconSize - (rect.bottom - rect.top)) / 2) + 1; rect.top -= adjustment; rect.bottom += adjustment; } // Make sure the rectangle starts at 0,0. rect.bottom += 0 - rect.top; rect.top = 0; // Create the bitmap to draw the dragged image in. BBitmap *dragBitmap = new BBitmap( rect, B_RGBA32, true ); BView *dragView = new BView( rect, "Drag View", 0, 0 ); dragBitmap->Lock(); dragBitmap->AddChild( dragView ); BRect frameRect = dragView->Frame(); // Make the background of the dragged image transparent. dragView->SetHighColor( B_TRANSPARENT_COLOR ); dragView->FillRect( frameRect ); // We want 'g's, etc. to go below the underline. When the BeOS can // do underlining of any font, this code can be removed. font_height height; GetFontHeight( &height ); float descent = height.descent; // Find the vertical center of the view so we can vertically // center everything. int centerPixel = (int) ((frameRect.bottom - frameRect.top) / 2); int textCenter = (int) (descent + underlineThickness) + centerPixel; // We want to draw everything only half opaque. dragView->SetDrawingMode( B_OP_ALPHA ); dragView->SetHighColor( 0.0, 0.0, 0.0, 128.0 ); dragView->SetBlendingMode( B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE ); // Center the icon in the view. dragView->MovePenTo( BPoint( frameRect.left, centerPixel - (iconSize / 2) ) ); dragView->DrawBitmap( personIcon ); // Draw the text in the same font (size, etc.) as the link view. // Note: DrawString() draws the text at one pixel above the pen's // current y coordinate. BFont font; GetFont( &font ); dragView->SetFont( &font ); dragView->MovePenTo( BPoint( frameRect.left + iconSize + 4, textCenter ) ); dragView->DrawString( Text() ); // Be sure to flush the view buffer so everything is drawn. dragView->Flush(); dragBitmap->Unlock(); // The Person icon adds some width to the bitmap that we are // going to draw. So horizontally offset the bitmap proportionally // to where the user clicked on the link. float horiz = dragOffset.x / GetTextRect().Width(); dragOffset.x = horiz * frameRect.right; DragMessage( dragMessage, dragBitmap, B_OP_ALPHA, BPoint( dragOffset.x, (rect.Height() + underlineThickness) / 2 + 2), this ); delete dragMessage; draggedOut = true; }
void WebEditBox::DrawThisOnly (DISPLAY_INT x, DISPLAY_INT y, WebGraphics *gc) { WebChar c; long line; WebRect box; GetFrameRect(&box); box.Shift(x,y); // gc->StartBuffer(); // begin buffering graphics commands gc->Rectangle(&box, GetBgColor(gc), GetBgColor(gc), 1); // draw background DrawFrame(&box, gc); // save the current graphics context clip rectangle and set clipping to the // text display region of the widget GetTextRect(&box); box.Shift(x,y); WebRect clipSave; gc->GetClip(&clipSave); if (clipSave.Overlaps(&box)) { WebRect clip(box); clip.And(&clipSave); gc->SetClip(&clip); miXOffset = (mpHScroll)? mpHScroll->GetPosition() : 0; miYOffset = (mpVScroll)? mpVScroll->GetPosition() : 0; // render our text WebFont font = mFont.GetFont(); if (mpText && font) { // this loop draws up to the last line for (line=0; line<(miNumLines-1); line++) { c = mpText[GetLineOffset(line+1)]; mpText[GetLineOffset(line+1)] = 0; DrawText(gc, box.left - miXOffset, box.top - miYOffset + (line * WEB_FONT_HEIGHT(font)), mpText + GetLineOffset(line), GetTextColor(gc), 0, 0, font); mpText[GetLineOffset(line+1)] = c; } // now draw the last line of text. DrawText(gc, box.left - miXOffset, box.top - miYOffset + (line*WEB_FONT_HEIGHT(font)), mpText + GetLineOffset(line), GetTextColor(gc), 0, 0, font); // if we have the focus, draw the cursor if ((mFlags & DISPLAY_FLAG_FOCUS) && !(mFlags & DISPLAY_FLAG_DISABLED)) { // now render the selected portion in reverse video (if we have one) if (mEditFlags & EDIT_FLAG_HAS_SELECTION) { long begin = EBSMIN(miCursorPos, miSelectBegin); long end = EBSMAX(miCursorPos, miSelectBegin); long beginLine = FindLine(begin), endLine = FindLine(end); DISPLAY_INT textLeft; long currentBegin, currentEnd; for (line=beginLine; line<=endLine; line++) { currentBegin = EBSMAX(begin, GetLineOffset(line)); if (line == endLine) { currentEnd = end; } else { currentEnd = EBSMIN(end, GetLineOffset(line+1)); } textLeft = gc->TextWidthLen(mpText + GetLineOffset(line), font, EBSMAX(0, begin - GetLineOffset(line))); c = mpText[currentEnd]; mpText[currentEnd] = 0; DrawText(gc, box.left - miXOffset + textLeft, box.top - miYOffset + (line*WEB_FONT_HEIGHT(font)), mpText + currentBegin, GetBgColor(gc), GetSelectColor(gc), 1, font); mpText[currentEnd] = c; } } DISPLAY_INT cursorX = box.left - miXOffset + gc->TextWidthLen(mpText + GetLineOffset(miCurrentLine), font, miCursorPos - GetLineOffset(miCurrentLine)) ; box.Set(cursorX, box.top - miYOffset + WEB_FONT_HEIGHT(font)*miCurrentLine, cursorX, box.top - miYOffset + WEB_FONT_HEIGHT(font)*(miCurrentLine+1)); gc->Rectangle(&box, GetSelectColor(gc), GetSelectColor(gc), 1); } } gc->SetClip(&clipSave); // restore the clip rectangle } // if clip overlaps /* if (mpVScroll && mpHScroll) { GetCornerRect(&box); box.Shift(x,y); gc->Rectangle(&box, LIGHTGRAY, LIGHTGRAY, 1); }*/ // gc->EndBuffer(); // send all buffered commands to the display }
bool nGraphics::InitGraphics() { // Create our base direct3d object m_pDirect3D = Direct3DCreate9(D3D_SDK_VERSION); if(!m_pDirect3D) { nMainFrame::LastError("Failed to create direct3d 9, directx 9 not installed?"); return TraceRet(__FUNCTION__" Failed to create direct3d 9, directx 9 not installed?\n",false); } // Check if the device support's the caps we will use if(!ValidateDevice()) return false; // Get the desktop's display mode D3DDISPLAYMODE displayMode; if(FAILED(m_pDirect3D->GetAdapterDisplayMode(D3DADAPTER_DEFAULT, &displayMode))) { nMainFrame::LastError("Failed to get current display adapter mode."); return TraceRet(__FUNCTION__" Failed to get current display adapter mode.\n",false); } // The struct that describes our direct3d device ZeroMemory(&m_PresentParameters,sizeof(m_PresentParameters)); m_Fullscreen = !nGetInstance()->GetCommandLineVar("-windowed",SETTINGS_WINDOWED).asBool(); m_PresentParameters.Windowed = !m_Fullscreen; m_PresentParameters.SwapEffect = D3DSWAPEFFECT_DISCARD; m_PresentParameters.BackBufferFormat = D3DFMT_X8R8G8B8; m_PresentParameters.EnableAutoDepthStencil = TRUE; m_PresentParameters.AutoDepthStencilFormat = D3DFMT_D24S8; // Check if we should use fsaa if(nGetInstance()->GetCommandLineVar("-fsaa",SETTINGS_FSAA).asBool()) { unsigned long samples = 0; // Check if multisampling is supported and enable it if it is if(SUCCEEDED(m_pDirect3D->CheckDeviceMultiSampleType(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,m_PresentParameters.BackBufferFormat,!m_Fullscreen,D3DMULTISAMPLE_NONMASKABLE,&samples))) { m_PresentParameters.MultiSampleQuality = samples-1; m_PresentParameters.MultiSampleType = D3DMULTISAMPLE_NONMASKABLE; Trace(__FUNCTION__" Using %dx multisampling.\n",samples-1); } } // Check if we should display in fullscreen if(m_Fullscreen) { m_PresentParameters.BackBufferWidth = displayMode.Width; m_PresentParameters.BackBufferHeight = displayMode.Height; } else { nRect rect; GetClientRect(nGetInstance()->GetWindowHandle(),(LPRECT)&rect); m_PresentParameters.BackBufferWidth = rect.GetWidth(); m_PresentParameters.BackBufferHeight = rect.GetHeight(); } // Check if we shouldn't use vsync if(!nGetInstance()->GetCommandLineVar("-vsync",SETTINGS_VSYNC).asBool()) m_PresentParameters.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE; Trace(__FUNCTION__" Display mode %dx%d.\n",m_PresentParameters.BackBufferWidth,m_PresentParameters.BackBufferHeight); // Now create our direct3d device from the base direct3d object HRESULT hr = m_pDirect3D->CreateDevice(D3DADAPTER_DEFAULT,D3DDEVTYPE_HAL,nGetInstance()->GetWindowHandle(),D3DCREATE_SOFTWARE_VERTEXPROCESSING,&m_PresentParameters,&m_pDevice); if(FAILED(hr)) return TraceRet(__FUNCTION__" Failed to create the device.\n",false); // Turn on color dithering hr = m_pDevice->SetRenderState(D3DRS_DITHERENABLE,TRUE); if(FAILED(hr)) Trace(__FUNCTION__" Display adapter doesn't support color dithering, using default.\n"); // Turn off culling m_pDevice->SetRenderState(D3DRS_CULLMODE,D3DCULL_NONE); // Enable anisotropic filtering if fsaa is enabled //if(flags & RECFLAG_FSAA) // EnableAnisotropic(m_p3DDevice); // Create our line drawing object hr = D3DXCreateLine(m_pDevice, &m_pLine); if(FAILED(hr)) { nMainFrame::LastError("Failed to create line drawing object."); return TraceRet(__FUNCTION__" Failed to create line drawing object.\n",false); } // Don't use gl lines m_pLine->SetGLLines(false); // Init our font hr = D3DXCreateFont(m_pDevice,SETTINGS_FONTHEIGHT,0,FW_BOLD,0,FALSE,DEFAULT_CHARSET,OUT_TT_PRECIS,6/*CLEARTYPE_QUALITY*/,DEFAULT_PITCH,SETTINGS_FONTNAME,&m_pFontBold); if(FAILED(hr)) { nMainFrame::LastError("Failed to create font. Font not found?"); return TraceRet(__FUNCTION__" Failed to create font. Font not found?",false); } // Init our thin font hr = D3DXCreateFont(m_pDevice,SETTINGS_FONTHEIGHT,0,FW_NORMAL,0,FALSE,DEFAULT_CHARSET,OUT_TT_PRECIS,6/*CLEARTYPE_QUALITY*/,DEFAULT_PITCH,SETTINGS_FONTNAME,&m_pFontNormal); if(FAILED(hr)) { nMainFrame::LastError("Failed to create bold font. Font not found?"); return TraceRet(__FUNCTION__" Failed to create bold font. Font not found?",false); } // Get the font sizes nRect fontSize; GetTextRect(GetBoldFont(),"str",&fontSize,NULL); m_BoldFontHeight = fontSize.GetHeight(); GetTextRect(GetNormalFont(),"str",&fontSize,NULL); m_NormalFontHeight = fontSize.GetHeight(); // Create our sprite drawing object hr = D3DXCreateSprite(m_pDevice, &m_pSprite); if(FAILED(hr)) { nMainFrame::LastError("Failed to create sprite."); return TraceRet(__FUNCTION__" Failed to create sprite.\n",false); } // Turn on texture filtering m_pDevice->SetSamplerState(0,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); m_pDevice->SetSamplerState(0,D3DSAMP_MINFILTER, D3DTEXF_LINEAR); m_pDevice->SetSamplerState(1,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); m_pDevice->SetSamplerState(1,D3DSAMP_MINFILTER, D3DTEXF_LINEAR); m_pDevice->SetSamplerState(2,D3DSAMP_MAGFILTER, D3DTEXF_LINEAR); m_pDevice->SetSamplerState(2,D3DSAMP_MINFILTER, D3DTEXF_LINEAR); return true; }
void MenuItem::Paint(HDC hDC) { RECT rc, rhi; StyleItem *pSI; COLORREF TC, BC; int j; GetTextRect(&rc); pSI = &mStyle.MenuFrame; if (m_bActive && false == m_bNOP) { // draw hilite bar GetItemRect(&rhi); pSI = &mStyle.MenuHilite; MakeStyleGradient(hDC, &rhi, pSI, pSI->bordered); TC = pSI->TextColor; BC = pSI->foregroundColor; } else if (m_bDisabled) { BC = TC = pSI->disabledColor; } else { TC = pSI->TextColor; BC = pSI->foregroundColor; } j = m_Justify; if (MENUITEM_CUSTOMTEXT != j) { if (MENUITEM_STANDARD_JUSTIFY == j) j = mStyle.MenuFrame.Justify; // draw menu item text //bbDrawText(hDC, GetDisplayString(), &rc, j | DT_MENU_STANDARD, TC); /* BlackboxZero 1.5.2012 */ BBDrawText(hDC, GetDisplayString(), -1, &rc, j | DT_MENU_STANDARD, pSI); } //#ifdef BBOPT_MENUICONS if ( Settings_menu.iconSize ) /* BlackboxZero 1.3.2012 */ this->DrawIcon(hDC); //#endif if (m_bChecked) // draw check-mark { int d, atright; //#ifdef BBOPT_MENUICONS if ( Settings_menu.iconSize ) { /* BlackboxZero 1.3.2012 */ if (m_ItemID & MENUITEM_ID_FOLDER) atright = MenuInfo.nBulletPosition == FOLDER_LEFT; else atright = true; } else { //#else if (MenuInfo.nItemLeftIndent != MenuInfo.nItemRightIndent) atright = MenuInfo.nBulletPosition != FOLDER_LEFT; else if (m_ItemID & MENUITEM_ID_FOLDER) atright = MenuInfo.nBulletPosition == FOLDER_LEFT; else atright = j != DT_LEFT; } //#endif rc.bottom = (rc.top = m_nTop) + m_nHeight + 1; if (atright) { d = MenuInfo.nItemRightIndent + mStyle.MenuHilite.borderWidth; rc.left = (rc.right = m_nLeft + m_nWidth) - d + 1; } else { d = MenuInfo.nItemLeftIndent + mStyle.MenuHilite.borderWidth; rc.right = (rc.left = m_nLeft) + d; } #if 1 bbDrawPix(hDC, &rc, BC, BS_CHECK); #else { bool pr, lit; const int w = 6; pSI = &mStyle.MenuHilite; pr = pSI->parentRelative; lit = m_bActive && false == m_bNOP; if (lit != pr) pSI = &mStyle.MenuFrame; rc.left = (rc.left + rc.right - w)/2; rc.right = rc.left + w; rc.top = (rc.top + rc.bottom - w)/2; rc.bottom = rc.top + w; if (pr) MakeGradient(hDC, rc, B_SOLID, pSI->TextColor, 0, false, BEVEL_FLAT, 0, 0, 0, 0); else MakeStyleGradient(hDC, &rc, pSI, false); } #endif } }
void MenuItem::Paint(HDC hDC) { RECT rect; COLORREF cr0 = (COLORREF)-1; bool lit = false; StyleItem *pSI = &mStyle.MenuFrame; if (m_bActive && 0 == (m_isNOP & (MI_NOP_TEXT | MI_NOP_SEP)) && (0 == (m_isNOP & MI_NOP_DISABLED) || m_pSubMenu)) { // draw hilite bar GetItemRect(&rect); pSI = &mStyle.MenuHilite; MakeStyleGradient(hDC, &rect, pSI, pSI->bordered); cr0 = SetTextColor(hDC, pSI->TextColor); lit = true; } else if (m_isNOP & MI_NOP_DISABLED) { cr0 = SetTextColor(hDC, mStyle.MenuFrame.disabledColor); } //dbg_printf("Menu separator style is: %s",Settings_menuSeparatorStyle); // draw separator if (m_isNOP & MI_NOP_LINE) { int x, y = m_nTop + m_nHeight / 2; // Noccy: Looks like we have to remove some pixels here to prevent it from overwriting the right border. int left = m_nLeft + ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin) - 1; int right = m_nLeft + m_nWidth - ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin); // int dist = (m_nWidth + 1) / 2 - ((Settings_menuFullSeparatorWidth==true)?mStyle.MenuFrame.borderWidth:mStyle.MenuSepMargin); int dist = (m_nWidth+1) / 2 - ((Settings_menuFullSeparatorWidth)?1:mStyle.MenuSepMargin); COLORREF c = mStyle.MenuSepColor; COLORREF cs = pSI->ShadowColor; if (pSI->ShadowXY) { int yS = y + pSI->ShadowY; int leftS = left + pSI->ShadowX; int rightS = right + pSI->ShadowX; if (0 == stricmp(Settings_menuSeparatorStyle,"gradient")) { // Gradient shadow for (x = 0; x <= dist; ++x) { int pos, hue = x * 255 / dist; pos = leftS + x; SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue)); pos = rightS - x; SetPixel(hDC, pos, yS, mixcolors(cs, GetPixel(hDC, pos, y), hue)); } } else if (0 == stricmp(Settings_menuSeparatorStyle,"flat")) { // Flat shadow for (x = 0; x <= dist; ++x) { int pos; pos = leftS + x; SetPixel(hDC, pos, yS, cs); pos = rightS - x; SetPixel(hDC, pos, yS, cs); } } else if (0 == stricmp(Settings_menuSeparatorStyle,"bevel")) { // Bevel shadow is simply none... } } if (0 == stricmp(Settings_menuSeparatorStyle,"gradient")) { for (x = 0; x <= dist; ++x) { int pos, hue = x * 255 / dist; pos = left + x; SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue)); pos = right - x; SetPixel(hDC, pos, y, mixcolors(c, GetPixel(hDC, pos, y), hue)); } } else if (0 == stricmp(Settings_menuSeparatorStyle,"flat")) { for (x = 0; x <= dist; ++x) { int pos; //, hue = x * 255 / dist; pos = left + x; SetPixel(hDC, pos, y, c); pos = right - x; SetPixel(hDC, pos, y, c); } } else if (0 == stricmp(Settings_menuSeparatorStyle,"bevel")) { for (x = 0; x <= dist; ++x) { int pos; pos = left + x; SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160)); pos = right - x; SetPixel(hDC, pos, y, mixcolors(0x00000000, GetPixel(hDC, pos, y), 160)); pos = left + x; SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160)); pos = right - x; SetPixel(hDC, pos, y+1, mixcolors(0x00FFFFFF, GetPixel(hDC, pos, y+1), 160)); } } } int iconSize = m_pMenu->m_iconSize; if (-2 == iconSize) iconSize = MenuInfo.nIconSize; GetTextRect(&rect, iconSize); // [load and ]draw menu item icon if (iconSize) { bool bSmallIcon = (16 >= iconSize); // load menu item icon if (NULL == m_hIcon || bSmallIcon != m_bSmallIcon) { DestroyIcon(m_hIcon), m_hIcon = NULL; m_bSmallIcon = bSmallIcon; switch (m_iconMode) { case IM_PIDL: { const _ITEMIDLIST *pidl = (MENUITEM_ID_SF == m_ItemID) ? ((SpecialFolderItem*)this)->check_pidl() : m_pidl; if (pidl) { SHFILEINFO sfi; HIMAGELIST sysimgl = (HIMAGELIST)SHGetFileInfo((LPCSTR)pidl, 0, &sfi, sizeof(SHFILEINFO), SHGFI_PIDL | SHGFI_SYSICONINDEX | (bSmallIcon ? SHGFI_SMALLICON : SHGFI_LARGEICON)); if (sysimgl) m_hIcon = ImageList_GetIcon(sysimgl, sfi.iIcon, ILD_NORMAL); } } break; case IM_TASK: { const struct tasklist *tl = (struct tasklist *)m_im_stuff; m_hIcon = CopyIcon(bSmallIcon ? tl->icon : tl->icon_big); } break; case IM_PATH: char *icon = (char *)m_im_stuff; char *path = strrchr(icon, ','); int idx; if (path) idx = atoi(path + 1), *path = 0; else idx = 0; if (bSmallIcon) ExtractIconEx(icon, idx, NULL, &m_hIcon, 1); else ExtractIconEx(icon, idx, &m_hIcon, NULL, 1); if (path) *path = ','; break; } } // draw menu item icon if (m_hIcon) { int top = rect.top + (m_nHeight - iconSize) / 2; int adjust = (MenuInfo.nItemIndent[iconSize] - iconSize) / 2; int left = ((DT_LEFT == FolderItem::m_nBulletPosition) ? rect.right : m_nLeft) + adjust; drawIco(left, top, iconSize, m_hIcon, hDC, !m_bActive, Settings_menuIconSaturation, Settings_menuIconHue); } } /* Noccy: Added DT_NOPREFIX to BBDrawText to prevent ampersand (&) to be interpreted as a hotkey. Note: Reverted. */ // draw menu item text const char *title = GetDisplayString(); if (0 == (m_ItemID & (~MENUITEM_ID_CI & (MENUITEM_ID_CIInt|MENUITEM_ID_CIStr))) || Settings_menusBroamMode) BBDrawText(hDC, title, -1, &rect, mStyle.MenuFrame.Justify | DT_MENU_STANDARD, pSI); else if (m_ItemID != MENUITEM_ID_CIStr) BBDrawText(hDC, title, -1, &rect, DT_CENTER | DT_MENU_STANDARD, pSI); // set back previous textColor if ((COLORREF)-1 != cr0) SetTextColor(hDC, cr0); if (m_isChecked) // draw check-mark { pSI = &mStyle.MenuHilite; bool pr = pSI->parentRelative; if (lit != pr) pSI = &mStyle.MenuFrame; int x, y = m_nTop + m_nHeight / 2; if ((FolderItem::m_nBulletPosition == DT_RIGHT) == (0 == (MENUITEM_ID_FOLDER & m_ItemID))) x = m_nLeft + m_nWidth - MenuInfo.nItemIndent[iconSize] / 2 - 1; else x = m_nLeft + MenuInfo.nItemIndent[iconSize] / 2; const int r = 3; rect.left = x - r; rect.right = x + r; rect.top = y - r; rect.bottom = y + r; if (pr) MakeGradient(hDC, rect, B_SOLID, pSI->TextColor, 0, false, BEVEL_FLAT, 0, 0, 0, 0); else MakeStyleGradient(hDC, &rect, pSI, false); } }
void RichEdit::LeftDown(Point p, dword flags) { useraction = true; NextUndo(); SetFocus(); selclick = false; tabmove = GetHotPos(p); if(tabmove.table && tabmove.column >= -2) { SaveTableFormat(tabmove.table); SetCapture(); Move(text.GetCellPos(tabmove.table, 0, max(tabmove.column, 0)).pos); return; } int c = GetHotSpot(p); if(c >= 0 && objectpos >= 0) { int pos = objectpos; RectTracker tracker(*this); RichObject obj = text.GetRichPos(pos).object; tracker.MinSize(Size(16, 16)) .MaxSize(GetZoom() * pagesz) .Animation() .Dashed() .KeepRatio(obj.IsKeepRatio()); int tx, ty; switch(c) { case 1: tracker.SetCursorImage(Image::SizeVert()); tx = ALIGN_CENTER; ty = ALIGN_BOTTOM; break; case 2: tracker.SetCursorImage(Image::SizeHorz()); tx = ALIGN_RIGHT; ty = ALIGN_CENTER; break; default: tracker.SetCursorImage(Image::SizeBottomRight()); tx = ALIGN_RIGHT; ty = ALIGN_RIGHT; break; } double zoom = GetZoom().AsDouble(); Size sz = obj.GetSize(); sz.cx = int(zoom * sz.cx + 0.5); sz.cy = int(zoom * sz.cy + 0.5); sz = tracker.Track(Rect(objectrect.Offseted(GetTextRect().left, -sb).TopLeft(), sz), tx, ty).Size(); sz.cx = int(sz.cx / zoom + 0.5); sz.cy = int(sz.cy / zoom + 0.5); obj.SetSize(sz); ReplaceObject(obj); } else { c = GetMousePos(p); if(c >= 0) { if(InSelection(c)) { selclick = true; return; } Move(c, flags & K_SHIFT); mpos = c; SetCapture(); if(cursorp.object && GetObjectRect(cursor).Offseted(GetTextRect().left, -sb).Contains(p)) SetObjectPos(cursor); } } }