void duTreeCtrl::OnMouseMove(POINT pt) { duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); duRect rcTreeCtrl; Plugin_GetRect(this, &rcTreeCtrl); duRect rcItem; rcItem.SetRectEmpty(); TreeCtrlItem *pItem = yHitTest(rcTreeCtrl, pt, rcItem); if (m_pHot != pItem) { m_pHot = pItem; Plugin_Redraw(this, TRUE); if(m_fShowTooltip) { pCtrlManager->DelToolTip(); m_fShowTooltip = FALSE; } } if (pItem == NULL) { m_hitCode = tc_hit_empty; if(m_fShowTooltip) { pCtrlManager->DelToolTip(); m_fShowTooltip = FALSE; } } else { POINT ptClient(pt); ptClient.x -= rcTreeCtrl.left; ptClient.y -= rcTreeCtrl.top; int nLeft = (pItem->nLevel - 1) * m_nIndentWidth; duRect rcIndent = CalcVCenterRect(rcItem, nLeft, m_nIndentWidth, m_nIndentHeight); if (ItemHasChildren(pItem) && (rcIndent.PtInRect(ptClient))) m_hitCode = tc_hit_indent; nLeft += (m_nIndentWidth + m_nIndentIconSpace); duRect rcIcon = CalcVCenterRect(rcItem, nLeft, m_nIconWidth, m_nIconHeight); if (rcIcon.PtInRect(ptClient)) m_hitCode = tc_hit_icon; duRect rcText; nLeft += (m_nIconWidth + m_nIconTextSpace); rcText = rcItem; rcText.left = rcItem.left + nLeft; if (rcText.PtInRect(ptClient)) m_hitCode = tc_hit_text; } }
void duTreeCtrl::SetAutoShowTooltip(BOOL fAutoShowTooltip) { m_fAutoShowToolTip = fAutoShowTooltip; if(m_fAutoShowToolTip) { if(m_fShowTooltip) { duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); pCtrlManager->DelToolTip(); m_fShowTooltip = FALSE; } } }
//void CFlatComboBox::OnMouseMove(UINT nFlags, CPoint point) //{ // SetTimer(1, 10, NULL); // SECComboBtn::OnMouseMove(nFlags, point); //} BOOL CFlatComboBox::OnSetCursor (CWnd* pWnd, UINT nHitTest, UINT message) { if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) { if (message == WM_MOUSEMOVE) { CRect rcWindow; GetWindowRect (&rcWindow); if (rcWindow.PtInRect(GetCurrentMessage()->pt)) { SetTimer(1, 10, NULL); } } } return SECComboBtn::OnSetCursor(pWnd, nHitTest, message); }
void duTreeCtrl::OnMouseHover(POINT pt) { if(m_pHot) { NotifyUser(DUM_TREEITEMHOVER, (WPARAM)m_pHot, (LPARAM)m_hitCode); if(m_fAutoShowToolTip) { if(!m_fShowTooltip) { LPTSTR strText = new TCHAR[m_pHot->strText.size() + 1]; _tcscpy(strText, m_pHot->strText.c_str()); duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); pCtrlManager->AddToolTip(strText); m_fShowTooltip = TRUE; } } } }
void CFlatComboBox::OnTimer(UINT nIDEvent) { if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) { POINT pt; CRect rcItem; GetCursorPos(&pt); GetWindowRect(&rcItem); // OnLButtonDown, show pressed. if (m_bLBtnDown) { KillTimer (1); if (m_bPainted) { DrawCombo(FC_DRAWPRESSD, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); m_bPainted = false; } return; } // If mouse leaves, show flat. if (!rcItem.PtInRect(pt)) { KillTimer (1); if (m_bPainted) { DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE), ::GetSysColor(COLOR_BTNFACE)); m_bPainted = false; } return; } else { // On mouse over, show raised. if (m_bPainted) return; else { m_bPainted = true; DrawCombo (FC_DRAWRAISED, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); } } } SECComboBtn::OnTimer(nIDEvent); }
void CFlatComboBox::OnPaint() { // SECComboBtn::OnPaint(); // if (m_pToolBar->CoolLookEnabled()) // DrawCombo (FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE), ::GetSysColor(COLOR_BTNFACE)); if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) { ModifyStyleEx (WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE | WS_EX_STATICEDGE, 0, SWP_FRAMECHANGED); SECComboBtn::OnPaint(); CPoint pt; CRect rcItem; GetCursorPos(&pt); GetWindowRect(&rcItem); if ((rcItem.PtInRect(pt)) || (::GetFocus() == m_edit.m_hWnd)) DrawCombo(FC_DRAWRAISED, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); else DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE), ::GetSysColor(COLOR_BTNFACE)); } else SECComboBtn::OnPaint(); }
void CFlatComboBox::OnEnable(BOOL bEnable) { SECComboBtn::OnEnable(bEnable); if (!bEnable && m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE), ::GetSysColor(COLOR_BTNFACE)); }
void CFlatComboBox::OnKillFocus(CWnd* pNewWnd) { SECComboBtn::OnKillFocus(pNewWnd); if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) DrawCombo(FC_DRAWNORMAL, ::GetSysColor(COLOR_BTNFACE), ::GetSysColor(COLOR_BTNFACE)); }
void CFlatComboBox::OnSetFocus(CWnd* pOldWnd) { SECComboBtn::OnSetFocus(pOldWnd); if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) DrawCombo(FC_DRAWRAISED, ::GetSysColor(COLOR_BTNSHADOW), ::GetSysColor(COLOR_BTNHIGHLIGHT)); }
void CFlatComboBox::OnLButtonDown(UINT nFlags, CPoint point) { if (m_pToolBar->CoolLookEnabled() && !GetCtrlManager().IsEnabled()) m_bLBtnDown = true; SECComboBtn::OnLButtonDown(nFlags, point); }
static LRESULT WINAPI ComboListBox_WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { duComboBox *pComboBox = NULL; if (uMsg == WM_NCCREATE) { LPCREATESTRUCT lpCS = (LPCREATESTRUCT)lParam; pComboBox = (duComboBox *)lpCS->lpCreateParams; if (!Plugin_IsValid(pComboBox)) return ::DefWindowProc(hWnd, uMsg, wParam, lParam); ::SetWindowLongPtr(hWnd, GWLP_USERDATA, (LONG_PTR)pComboBox); } pComboBox = (duComboBox *)::GetWindowLongPtr(hWnd, GWLP_USERDATA); if (!pComboBox || !Plugin_IsValid(pComboBox)) return ::DefWindowProc(hWnd, uMsg, wParam, lParam); switch (uMsg) { case WM_CREATE: { duCtrlManager *pCtrlManager = GetCtrlManager(pComboBox->GetHwnd()); if (pCtrlManager == NULL) break; duWindowManager *pWinManager = pCtrlManager->GetWindowManager(); if (pWinManager == NULL) break; WindowManager_Attach(pWinManager, hWnd, pComboBox->m_szWindow); duCtrlManager *pNewCtrlManager = GetCtrlManager(hWnd); if (pNewCtrlManager == NULL) return -1; duWindow *pWindow = (duWindow *)pNewCtrlManager->GetPluginByName(pComboBox->m_szWindow); if (pWindow == NULL) return -1; duRect rcWindow; ::GetWindowRect(hWnd, &rcWindow); pWindow->SetPosWidth(rcWindow.Width()); pWindow->SetPosHeight(rcWindow.Height()); pWindow->Resize(NULL); duListBox *pListBox = (duListBox *)pNewCtrlManager->GetPluginByName(pComboBox->m_szListBox); if (!Plugin_IsValid(pListBox)) return -1; pListBox->SetComboBoxListBox(TRUE); vector<ListBoxItem *> &vtListBoxItem = pListBox->GetItemVector(); int nItemCount = (int)pComboBox->GetItemCount(); int i; ListBoxItem *pItem = NULL; for (i = 0; i < nItemCount; i++) { pItem = pComboBox->GetItem(i); ListBoxItem *pNewItem = new ListBoxItem; if (pItem->uIconX == LISTBOX_DEFAULT_VALUE) pNewItem->uIconX = pListBox->m_nItemIconX; else pNewItem->uIconX = pItem->uIconX; if (pItem->uIconY == LISTBOX_DEFAULT_VALUE) pNewItem->uIconY = pListBox->m_nItemIconY; else pNewItem->uIconY = pItem->uIconY; if (pItem->uIconWidth == LISTBOX_DEFAULT_VALUE) pNewItem->uIconWidth = pListBox->m_nItemIconWidth; else pNewItem->uIconWidth = pItem->uIconWidth; if (pItem->uIconHeight == LISTBOX_DEFAULT_VALUE) pNewItem->uIconHeight = pListBox->m_nItemIconHeight; else pNewItem->uIconHeight = pItem->uIconHeight; pNewItem->szIcon = pItem->szIcon; pNewItem->szText = pItem->szText; pNewItem->fDisable = pItem->fDisable; vtListBoxItem.push_back(pNewItem); } Plugin_SetFocus(pListBox, TRUE); } break; case WM_DIRECTUI_NOTIFY: { duPlugin *pPlugin = (duPlugin *)wParam; duNotify *pNotify = (duNotify *)lParam; if ((lstrcmpi(pPlugin->GetName(), pComboBox->m_szListBox) == 0) && (pNotify->uMsg == DUM_LBSELCHANGED)) { duCtrlManager *pCtrlManager = GetCtrlManager(hWnd); if (pCtrlManager == NULL) return 0; duListBox *pListBox = (duListBox *)pCtrlManager->GetPluginByName(pComboBox->m_szListBox); if (pListBox == NULL) return 0; LPCTSTR lpszText = pListBox->GetItemText(pNotify->lParam); pComboBox->m_nCurSel = (int)pNotify->lParam; pComboBox->SetText(lpszText); pComboBox->SetEnd(TRUE); pComboBox->NotifyUser(DUM_COMBOSELCHANGE, pNotify->lParam, NULL); } } break; case WM_LBUTTONDOWN: { POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); duCtrlManager *pCtrlManager = GetCtrlManager(hWnd); if (pCtrlManager == NULL) return 0; duListBox *pListBox = (duListBox *)pCtrlManager->GetPluginByName(pComboBox->m_szListBox); if (pListBox == NULL) return 0; duScroll *pScroll = pListBox->GetVertScrollBar(); if (pScroll == NULL) { pComboBox->SetEnd(TRUE); return 0; } duRect rcScroll; Plugin_GetRect(pScroll, &rcScroll); if (!rcScroll.PtInRect(pt)) pComboBox->SetEnd(TRUE); } break; default: return ::DefWindowProc(hWnd, uMsg, wParam, lParam); } return 0; }
duPlugin *WINAPI duListCtrl::InsertLine(int nIndex, LPCTSTR lpszTemplate) { int nLineCount = m_vtLines.size(); if (nIndex == -1) nIndex = nLineCount; if (nIndex < 0 || nIndex > nLineCount || lpszTemplate == NULL) return NULL; duPlugin *pTemplate = GetPluginByName(lpszTemplate); if (pTemplate == NULL) return NULL; duCtrlManager *pCtrlManager = GetCtrlManager(m_hWnd); duPlugin *pNewPlugin = pCtrlManager->Clone(pTemplate, this, NULL, m_nCloneIndex); if (pNewPlugin == NULL) return NULL; m_nCloneIndex++; pNewPlugin->SetVisible(FALSE); // 初始化隐藏 m_vtLines.insert(m_vtLines.begin() + nIndex, pNewPlugin); duRect rcNewPlugin; pNewPlugin->GetRect(&rcNewPlugin); m_nViewCy += rcNewPlugin.Height(); nLineCount = m_vtLines.size(); duRect rcListCtrl; GetRect(&rcListCtrl); if (nIndex < m_nFirstLine) { int nInsertHeight = rcNewPlugin.Height(); int nNewFirstLine = m_nFirstLine + 1; int nFLTotalHeight = m_nFLTotalHeight; duPlugin *pOldFirstLine = m_vtLines[nNewFirstLine]; duRect rcOld; pOldFirstLine->GetRect(&rcOld); int i; for (i = nNewFirstLine; i >= 0; i--) { duPlugin *pTemp = m_vtLines[i]; wstring strText = pTemp->GetText(); if (pTemp) { duRect rcTemp; pTemp->GetRect(&rcTemp); nNewFirstLine--; nInsertHeight -= rcTemp.Height(); if (nInsertHeight <= rcOld.Height()) { nFLTotalHeight += nInsertHeight; break; } } } m_nFLTotalHeight = nFLTotalHeight; m_nFirstLine = nNewFirstLine; } UpdateScroll(); int nTop = m_nFLTotalHeight - m_nYOffset; AdjustVisibleLine(nTop); return pNewPlugin; }