void Button::MouseReleased(const MouseEvent& lEvent) { if(IsDisabled()) { return; } SetSelected(false); OnMouseReleased(); if(m_offsetApplied) { for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++) { if(m_bChangeLabelText) { if(m_vpAddedComponentList[i]->GetComponentType() == EComponentType_Label) { if(IsHover()) { ((Label*)m_vpAddedComponentList[i])->SetColour(m_hoverLabelColour); } else { ((Label*)m_vpAddedComponentList[i])->SetColour(m_normalLabelColour); } } } m_vpAddedComponentList[i]->SetLocation(m_vpAddedComponentList[i]->GetLocation().m_x - m_pressedOffsetX, m_vpAddedComponentList[i]->GetLocation().m_y - m_pressedOffsetY); } m_label.SetLocation(m_label.GetLocation().m_x - m_pressedOffsetX, m_label.GetLocation().m_y - m_pressedOffsetY); if(m_bChangeLabelText) { if(IsHover()) { m_label.SetColour(m_hoverLabelColour); } else { m_label.SetColour(m_normalLabelColour); } } m_offsetApplied = false; } if(m_Callback_Released) { m_Callback_Released(m_pCallbackData_Released); } }
void MenuItem::DrawSelf() { // Reset visibility m_pSelectedIcon->SetVisible(false); m_pHoverIcon->SetVisible(false); m_pDisabledIcon->SetVisible(false); m_pDefaultIcon->SetVisible(false); if(!IsParentMenuOpen()) { m_label.SetVisible(false); return; } if(m_bOnlyShowSelectedItems) { if(IsSelected()) { m_pSelectedIcon->SetVisible(true); } else if(IsHover()) { m_pHoverIcon->SetVisible(true); } } else { if(IsSelected()) { m_pSelectedIcon->SetVisible(true); } else if(IsHover()) { m_pHoverIcon->SetVisible(true); } else if(IsDisabled()) { m_pDisabledIcon->SetVisible(true); } else { m_pDefaultIcon->SetVisible(true); } } // Set the label visibility m_label.SetVisible(true); }
void Button::DrawSelf() { // Reset visibility m_pSelectedIcon->SetVisible(false); m_pHoverIcon->SetVisible(false); m_pDisabledIcon->SetVisible(false); m_pDefaultIcon->SetVisible(false); if(IsSelected()) { m_pSelectedIcon->SetVisible(true); } else if(IsHover()) { m_pHoverIcon->SetVisible(true); } else if(IsDisabled()) { m_pDisabledIcon->SetVisible(true); } else { m_pDefaultIcon->SetVisible(true); } // Set the label visibility m_label.SetVisible(m_bDisplayLabel); }
void GameTable::ProcessInputOnBlocks(SDL_Point& mousePos, SDL_Event& event) { bool found = false; bool remove = false; Uint32 linkNR = 0; for (auto& p1 : *table) { auto col = p1.first; auto colRow = p1.second; // For each block in the current column for (auto& p2 : *colRow) { auto row = p2.first; auto block = p2.second; found = block != nullptr && block->IsHover(mousePos); if (found) { if (event.button.state == SDL_PRESSED) { MarkBlocks(block, true, true); linkNR = block->link; remove = true; } else { MarkBlocks(block, true, false); } break; } } if (found) { break; } } if (!found) { ClearBlocks(false); } if (remove && linkNR > 0) { GatherPoints(linkNR); RemoveBlocksAndUpdateTable(linkNR); } }
void CHoverEdit::OnNcPaint() { CWindowDC DC(this); CRect Rect; GetWindowRect(&Rect); if (IsHover()) { DC.Rectangle(0,0,Rect.Width(),Rect.Height()); } else { DC.DrawEdge(CRect(0,0,Rect.Width(),Rect.Height()),EDGE_SUNKEN,BF_FLAT|BF_RECT); } }
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 Button::MouseClicked(const MouseEvent& lEvent) { if(IsDisabled()) { return; } // Call the function if this class has a derived sub-class OnMouseClicked(); if(m_bChangeLabelText) { if(IsHover()) { for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++) { if(m_vpAddedComponentList[i]->GetComponentType() == EComponentType_Label) { ((Label*)m_vpAddedComponentList[i])->SetColour(m_hoverLabelColour); } } m_label.SetColour(m_hoverLabelColour); } else { for(unsigned int i = 0; i < m_vpAddedComponentList.size(); i++) { if(m_vpAddedComponentList[i]->GetComponentType() == EComponentType_Label) { ((Label*)m_vpAddedComponentList[i])->SetColour(m_normalLabelColour); } } m_label.SetColour(m_normalLabelColour); } } // Call the callback function callback if this class is just a simple button if(m_Callback) { m_Callback(m_pCallbackData); } }
void CTabItem_MainTabBn::Paint(CDC* pDC) { //CRect rtDraw(GetRectInbar()); //CBufferDC bufDC(pDC->GetSafeHdc(), rtDraw); //CBrush brush(RGB(200, 200, 200)); //bufDC.FillRect(&rtDraw, &brush); //int iOldMode = pDC->GetBkMode(); //bufDC.SetBkMode(TRANSPARENT); //bufDC.DrawText(m_strCaption, rtDraw, DT_VCENTER | DT_SINGLELINE | DT_CENTER); //bufDC.SetBkMode(iOldMode); //DrawRound(pDC->GetSafeHdc(), rtDraw, 3); /*CFontDC font(pDC->GetSafeHdc(), _T("Wingdings 3")); font = 12;*/ CRect rect; rect = GetRect(); rect.right -= m_iItemGap; //if (m_bActive) //{ // DrawActiveBk(pDC, rect); //} //else //{ // if(IsHover()) // { // DrawHover(pDC, rect); // } // else // { // DrawInactiveBk(pDC, rect); // } //} CSize sizeIcon; CRect rtIcon; CFaceManager::GetInstance()->GetImageSize(II_MAINTABMORE_N, sizeIcon); CenterRect(&rtIcon, rect, sizeIcon); rtIcon.OffsetRect(0, 3); if (IsHover()) { CFaceManager::GetInstance()->DrawImageBar(IBI_MAINBTN_H, pDC->m_hDC, rect); CFaceManager::GetInstance()->DrawImage(II_MAINTABMORE_H, pDC->m_hDC, rtIcon); } else { CFaceManager::GetInstance()->DrawImageBar(IBI_MAINBTN_N, pDC->m_hDC, rect); CFaceManager::GetInstance()->DrawImage(II_MAINTABMORE_N, pDC->m_hDC, rtIcon); } //{ // CPenDC penDC(pDC->GetSafeHdc(), RGB(255, 255, 255)); // DrawTriangle(pDC, rect); //} }