void duZorderList::DispatchOnCreate() { duCtrlManager *pCtrlManager = GetCtrlManager(m_pRoot->GetHwnd()); if (pCtrlManager == NULL) return; duPlugin *pPlugin = NULL; int i, j; int nLevelCount = GetLayerCount(); for (i = 0;i < nLevelCount; i++) { int nCtrlCount = GetLayerChildCount(i); for (j = nCtrlCount - 1;j >= 0; j--) { pPlugin = GetPlugin(i, j); if (pPlugin == NULL || !Plugin_IsValid(pPlugin)) continue; pCtrlManager->AddName(pPlugin); } } for (i = 0;i < nLevelCount; i++) { int nCtrlCount = GetLayerChildCount(i); for (j = nCtrlCount - 1;j >= 0; j--) { pPlugin = GetPlugin(i, j); if (pPlugin == NULL || !Plugin_IsValid(pPlugin)) continue; pPlugin->OnCreate(); } } }
void duSplitter::OnMouseLUp(POINT pt) { duPlugin *pFPlugin = GetPluginByName(m_szFName); duPlugin *pSPlugin = GetPluginByName(m_szSName); if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin)) return; if (m_fTracking) { Plugin_ReleaseCapture(this); m_fTracking = FALSE; duRect rectFirst; Plugin_GetRect(pFPlugin, &rectFirst); duRect rectSplitter; Plugin_GetRect(this, &rectSplitter); duRect rectSecond; Plugin_GetRect(pSPlugin, &rectSecond); int nDistance = 0; if (m_fVert) { int nFirstMinY = rectFirst.top + m_nFMinPixel + (m_ptStart.y - rectSplitter.top); int nSecondMinY = rectSecond.bottom - m_nSMinPixel - (rectSplitter.bottom - m_ptStart.y); if (pt.y < nFirstMinY) nDistance = m_ptStart.y - nFirstMinY; else if (pt.y >= nFirstMinY && pt.y <= m_ptStart.y) nDistance = m_ptStart.y - pt.y; else if (pt.y >= m_ptStart.y && pt.y <= nSecondMinY) nDistance = m_ptStart.y - pt.y; else if (pt.y > nSecondMinY) nDistance = m_ptStart.y - nSecondMinY; MoveVert(nDistance); } else { int nFirstMinX = rectFirst.left + m_nFMinPixel + (m_ptStart.x - rectSplitter.left); int nSecondMinX = rectSecond.right - m_nSMinPixel - (rectSplitter.right - m_ptStart.x); if (pt.x < nFirstMinX) nDistance = m_ptStart.x - nFirstMinX; else if (pt.x >= nFirstMinX && pt.x <= m_ptStart.x) nDistance = m_ptStart.x - pt.x; else if (pt.x >= m_ptStart.x && pt.x <= nSecondMinX) nDistance = m_ptStart.x - pt.x; else if (pt.x > nSecondMinX) nDistance = m_ptStart.x - nSecondMinX; MoveHorz(nDistance); } } Plugin_SetState(this, DU_STATE_NORMAL); ::InvalidateRect(m_hWnd, NULL, TRUE); }
void duSplitter::OnMouseLDown(POINT pt) { duPlugin *pFPlugin = GetPluginByName(m_szFName); duPlugin *pSPlugin = GetPluginByName(m_szSName); if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin)) return; duRect rectSplitter; Plugin_GetRect(this, &rectSplitter); if (rectSplitter.PtInRect(pt)) { m_ptStart = pt; m_rectLast.SetRectEmpty(); m_fTracking = TRUE; Plugin_SetState(this, DU_STATE_PRESS); Plugin_SetCapture(this); Plugin_Redraw(this, TRUE); } }
void WINAPI duListCtrl::ResetLine() { m_nYOffset = 0; m_nFirstLine = 0; m_nFLTotalHeight = 0; m_nHotLine = 0; if (Plugin_IsValid(m_pHot)) { m_pHot->SetState(DU_STATE_NORMAL); Plugin_Redraw(m_pHot, TRUE); } UpdateScroll(); AdjustVisibleLine(0); }
void duSplitter::MoveVert(int nDistance) { duPlugin *pFPlugin = GetPluginByName(m_szFName); duPlugin *pSPlugin = GetPluginByName(m_szSName); duPlugin *pParent = GetParent(); if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin) || !Plugin_IsValid(pParent)) return; duRect rectFirst, rectSplitter, rectSecond, rectParent; Plugin_GetRect(pFPlugin, &rectFirst); Plugin_GetRect(pSPlugin, &rectSecond); Plugin_GetRect(this, &rectSplitter); Plugin_GetRect(pParent, &rectParent); // Move first int nFirstHeight = rectFirst.Height() - nDistance; int nFirstBottom = rectParent.bottom - (rectFirst.top + nFirstHeight); int nFirstRatio = 0; if (rectParent.Height() > 0) nFirstRatio = (int) nFirstHeight / (float)rectParent.Height(); int first_VertType = pFPlugin->GetPosVertAnchor(); if (first_VertType == 0) pFPlugin->SetPosHeight(nFirstHeight); else if (first_VertType == 1) pFPlugin->SetPosHeight(nFirstRatio); else if (first_VertType == 2) pFPlugin->SetPosBottom(nFirstBottom); Plugin_Resize(pFPlugin, NULL); // Move splitter Plugin_GetRect(pFPlugin, &rectFirst); int splitter_VertType = GetPosVertAnchor(); if (splitter_VertType != 0) { SetPosVertAnchor(0); SetPosHeight(rectSplitter.Height()); } int nSplitterTop = rectFirst.bottom - rectParent.top; SetPosTop(nSplitterTop); Plugin_Resize(this, NULL); // Move second Plugin_GetRect(this, &rectSplitter); int nSecondTop_positive = max(0, rectSplitter.bottom - rectParent.top); int nSecondTop_negative = min(0, nSecondTop_positive - rectParent.Height()); int nSecondHeight = rectSecond.bottom - rectSplitter.bottom; int nSecondBottom = rectParent.bottom - (rectSplitter.bottom + nSecondHeight); int nSecondRatio = 0; if (rectSecond.Height()) nSecondRatio = (int)nSecondHeight / (float)rectSecond.Height(); if (pSPlugin->GetPosTop() < 0) pSPlugin->SetPosTop( nSecondTop_negative ); else pSPlugin->SetPosTop( nSecondTop_positive ); int second_VertType = pSPlugin->GetPosVertAnchor(); if (second_VertType == 0) pSPlugin->SetPosHeight(nSecondHeight); else if (second_VertType == 1) pSPlugin->SetPosHeight(nSecondRatio); else if (second_VertType == 2) pSPlugin->SetPosBottom(nSecondBottom); Plugin_Resize(pSPlugin, NULL); NotifyUser(DUM_SPLITTERMOVED, NULL, NULL); }
void duSplitter::MoveHorz(int nDistance) { duPlugin *pFPlugin = GetPluginByName(m_szFName); duPlugin *pSPlugin = GetPluginByName(m_szSName); duPlugin *pParent = GetParent(); if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin) || !Plugin_IsValid(pParent)) return; duRect rectFirst, rectSplitter, rectSecond, rectParent; Plugin_GetRect(pFPlugin, &rectFirst); Plugin_GetRect(pSPlugin, &rectSecond); Plugin_GetRect(this, &rectSplitter); Plugin_GetRect(pParent, &rectParent); // Move first int nFirstWidth = rectFirst.Width() - nDistance; int nFirstRight = rectParent.right - (rectFirst.left + nFirstWidth); int nFirstRatio = 0; if (rectParent.Width() > 0) nFirstRatio = (int)nFirstWidth / (float)rectParent.Width(); int first_HorzType = pFPlugin->GetPosHorzAnchor(); if (first_HorzType == 0) pFPlugin->SetPosWidth(nFirstWidth); else if (first_HorzType == 1) pFPlugin->SetPosWidth(nFirstRatio); else if (first_HorzType == 2) pFPlugin->SetPosRight(nFirstRight); Plugin_Resize(pFPlugin, NULL); // Move splitter Plugin_GetRect(pFPlugin, &rectFirst); int splitter_HorzType = GetPosHorzAnchor(); if (splitter_HorzType != 0) { SetPosHorzAnchor(0); SetPosWidth(rectSplitter.Width()); } int nSplitterLeft = rectFirst.right - rectParent.left; SetPosLeft(nSplitterLeft); Plugin_Resize(this, NULL); // Move second Plugin_GetRect(this, &rectSplitter); int nSecondLeft_positive = max(0, rectSplitter.right - rectParent.left); int nSecondLeft_negative = min(0, nSecondLeft_positive - rectParent.Width()); int nSecondWidth = rectSecond.right - rectSplitter.right; int nSecondRight = rectParent.right - (rectSplitter.right + nSecondWidth); int nSecondRatio = 0; if (rectSecond.Width()) nSecondRatio = (int)nSecondWidth / (float)rectSecond.Width(); if (pSPlugin->GetPosLeft() < 0) pSPlugin->SetPosLeft(nSecondLeft_negative); else pSPlugin->SetPosLeft(nSecondLeft_positive); int second_HorzType = pSPlugin->GetPosHorzAnchor(); if (second_HorzType == 0) pSPlugin->SetPosWidth(nSecondWidth); else if (second_HorzType == 1) pSPlugin->SetPosWidth(nSecondRatio); else if (second_HorzType == 2) pSPlugin->SetPosRight(nSecondRight); Plugin_Resize(pSPlugin, NULL); NotifyUser(DUM_SPLITTERMOVED, NULL, NULL); }
void duSplitter::OnMouseMove(POINT pt) { duPlugin *pFPlugin = GetPluginByName(m_szFName); duPlugin *pSPlugin = GetPluginByName(m_szSName); if (!Plugin_IsValid(pFPlugin) || !Plugin_IsValid(pSPlugin)) return; if (GetState() == DU_STATE_NORMAL) { Plugin_SetState(this, DU_STATE_OVER); Plugin_Redraw(this, TRUE); } if (m_fTracking) { duRect rectFirst; Plugin_GetRect(pFPlugin, &rectFirst); duRect rectSplitter; Plugin_GetRect(this, &rectSplitter); duRect rectSecond; Plugin_GetRect(pSPlugin, &rectSecond); duRect rectTracking = rectSplitter; if (m_fVert) { int yOffset = pt.y - m_ptStart.y; rectTracking.OffsetRect(0, yOffset); int nFirstMinY = rectFirst.top + m_nFMinPixel + (m_ptStart.y - rectSplitter.top); int nSecondMinY = rectSecond.bottom - m_nSMinPixel - (rectSplitter.bottom - m_ptStart.y); if (pt.y >= nFirstMinY && pt.y <= nSecondMinY) { OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } else { if (pt.y < nFirstMinY && m_rectLast.top != (rectFirst.top + m_nFMinPixel)) { int nSplitterHeight = m_rectLast.Height(); rectTracking.top = rectFirst.top + m_nFMinPixel; rectTracking.bottom = rectTracking.top + nSplitterHeight; OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } if (pt.y > nSecondMinY && m_rectLast.bottom != (rectSecond.bottom - m_nSMinPixel)) { int nSplitterHeight = m_rectLast.Height(); rectTracking.bottom = rectSecond.bottom - m_nSMinPixel; rectTracking.top = rectTracking.bottom - nSplitterHeight; OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } } } else { int xOffset = pt.x - m_ptStart.x; rectTracking.OffsetRect(xOffset, 0); int nFirstMinX = rectFirst.left + m_nFMinPixel + (m_ptStart.x - rectSplitter.left); int nSecondMinX = rectSecond.right - m_nSMinPixel - (rectSplitter.right - m_ptStart.x); if (pt.x >= nFirstMinX && pt.x <= nSecondMinX) { OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } else { if (pt.x < nFirstMinX && m_rectLast.left != (rectFirst.left + m_nFMinPixel)) { int nSplitterWidth = m_rectLast.Width(); rectTracking.left = rectFirst.left + m_nFMinPixel; rectTracking.right = rectTracking.left + nSplitterWidth; OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } if (pt.x > nSecondMinX && m_rectLast.right != (rectSecond.right - m_nSMinPixel)) { int nSplitterWidth = m_rectLast.Width(); rectTracking.right = rectSecond.right - m_nSMinPixel; rectTracking.left = rectTracking.right - nSplitterWidth; OnInvertTracker(m_rectLast); OnInvertTracker(rectTracking); m_rectLast = rectTracking; } } } //static int count = 0; //if (rectTracking.Height() != 10) //{ // __asm int 3; //_TRACE("[%d] pointClient (%d, %d)\r\n", count, pointClient.x, pointClient.y); //_TRACE("[%d] m_ptStart (%d, %d)\r\n", count, m_ptStart.x, m_ptStart.y); //_TRACE("[%d] rectFirst (%d, %d, %d, %d)\r\n", count, rectFirst.left, rectFirst.top, rectFirst.right, rectFirst.bottom); //_TRACE("[%d] rectSecond (%d, %d, %d, %d)\r\n", count, rectSecond.left, rectSecond.top, rectSecond.right, rectSecond.bottom); //_TRACE("[%d] rectTracking(%d, %d, %d, %d,) Width : %d, Height : %d\r\n", // count, rectTracking.left, rectTracking.top, rectTracking.right, rectTracking.bottom, rectTracking.Width(), rectTracking.Height()); // count++; //} } }
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; }
LRESULT WINAPI duListCtrl::OnWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (!Plugin_IsVisible(this)) { m_fDispMouseWheel = FALSE; return 0; } if (uMsg == WM_LBUTTONDOWN) { POINT pointClient; pointClient.x = GET_X_LPARAM(lParam); pointClient.y = GET_Y_LPARAM(lParam); duRect rcListCtrl; GetRect(&rcListCtrl); if (!rcListCtrl.PtInRect(pointClient)) { m_fDispMouseWheel = FALSE; return 0; } m_fDispMouseWheel = TRUE; //pointClient.Offset(-rcListCtrl.left, -rcListCtrl.top); duScroll *pVertScroll = (duScroll *)GetPluginByName(m_szVertScroll); if (pVertScroll && pVertScroll->IsVisible()) { duRect rcVertScroll; pVertScroll->GetRect(&rcVertScroll); if (rcVertScroll.PtInRect(pointClient)) { m_fDispMouseWheel = FALSE; return 0; } } duScroll *pHorzScroll = (duScroll *)GetPluginByName(m_szHorzScroll); if (pHorzScroll && pHorzScroll->IsVisible()) { duRect rcHorzScroll; pHorzScroll->GetRect(&rcHorzScroll); if (rcHorzScroll.PtInRect(pointClient)) { m_fDispMouseWheel = FALSE; return 0; } } int nHeight = rcListCtrl.Height(); int i; int nLineCount = GetLineCount(); for (i = m_nFirstLine;i < nLineCount; i++) { duPlugin *pTemp = m_vtLines[i]; if (pTemp) { duRect rc; pTemp->GetRect(&rc); if (rc.PtInRect(pointClient)) { if (m_pSel != pTemp) { if (Plugin_IsValid(m_pSel)) { m_pSel->SetState(DU_STATE_NORMAL); Plugin_Redraw(m_pSel, TRUE); } pTemp->SetState(DU_STATE_PRESS); m_pSel = pTemp; Plugin_Redraw(pTemp, TRUE); } break; } if (rc.top >= rcListCtrl.bottom) break; } } } else if (uMsg == WM_MOUSEWHEEL) { POINT pt; pt.x = GET_X_LPARAM(lParam); pt.y = GET_Y_LPARAM(lParam); UINT fwKeys = (UINT)(short)LOWORD(wParam); int zDelta = (int)(short)HIWORD(wParam); duScroll *pVertScrollBar = (duScroll *)GetPluginByName(m_szVertScroll); if (Plugin_IsValid(pVertScrollBar) && pVertScrollBar->IsVisible() && m_fDispMouseWheel) pVertScrollBar->OnMouseWheel(fwKeys, zDelta, pt); } else if (uMsg == WM_MOUSEMOVE) { POINT pointClient; pointClient.x = GET_X_LPARAM(lParam); pointClient.y = GET_Y_LPARAM(lParam); duRect rcListCtrl; GetRect(&rcListCtrl); if (!rcListCtrl.PtInRect(pointClient)) { if (Plugin_IsValid(m_pHot)) { if (m_pHot != m_pSel) { m_pHot->SetState(DU_STATE_NORMAL); Plugin_Redraw(m_pHot, TRUE); m_pHot = NULL; } } return 0; } duScroll *pVertScroll = (duScroll *)GetPluginByName(m_szVertScroll); if (pVertScroll && pVertScroll->IsVisible()) { duRect rcVertScroll; pVertScroll->GetRect(&rcVertScroll); if (rcVertScroll.PtInRect(pointClient)) { if (Plugin_IsValid(m_pHot)) { if (m_pHot != m_pSel) { m_pHot->SetState(DU_STATE_NORMAL); Plugin_Redraw(m_pHot, TRUE); m_pHot = NULL; } } return 0; } } duScroll *pHorzScroll = (duScroll *)GetPluginByName(m_szHorzScroll); if (pHorzScroll && pHorzScroll->IsVisible()) { duRect rcHorzScroll; pHorzScroll->GetRect(&rcHorzScroll); if (rcHorzScroll.PtInRect(pointClient)) { if (Plugin_IsValid(m_pHot)) { if (m_pHot != m_pSel) { m_pHot->SetState(DU_STATE_NORMAL); Plugin_Redraw(m_pHot, TRUE); m_pHot = NULL; } } return 0; } } BOOL fNeedRedraw = FALSE; BOOL fMouseIn = FALSE; int nHeight = rcListCtrl.Height(); int i; int nLineCount = GetLineCount(); for (i = m_nFirstLine;i < nLineCount; i++) { duPlugin *pTemp = m_vtLines[i]; if (pTemp) { duRect rc; pTemp->GetRect(&rc); if (rc.PtInRect(pointClient)) { fMouseIn = TRUE; if (pTemp == m_pSel) { if (Plugin_IsValid(m_pHot)) { if (m_pHot == m_pSel) break; m_pHot->SetState(DU_STATE_NORMAL); m_pHot = NULL; fNeedRedraw = TRUE; } m_pHot = NULL; } else { if (m_pHot != pTemp) { if (Plugin_IsValid(m_pHot)) { if (m_pHot != m_pSel) { m_pHot->SetState(DU_STATE_NORMAL); m_pHot = NULL; fNeedRedraw = TRUE; } } pTemp->SetState(DU_STATE_OVER); m_pHot = pTemp; fNeedRedraw = TRUE; } } break; } if (rc.top >= rcListCtrl.bottom) break; } } if (!fMouseIn) { if (Plugin_IsValid(m_pHot)) { if (m_pHot != m_pSel) { m_pHot->SetState(DU_STATE_NORMAL); m_pHot = NULL; fNeedRedraw = TRUE; } } } if (fNeedRedraw) Plugin_Redraw(this, TRUE); } return 0; }