void DockCont::Serialize(Stream& s) { int ctrl = 'D'; int cont = 'C'; const Vector<DockableCtrl *> &dcs = base->GetDockableCtrls(); if (s.IsStoring()) { if (GetCount() == 1 && IsDockCont(tabbar.Get(0))) return ContCast(tabbar.Get(0))->Serialize(s); int cnt = GetCount(); s / cont / cnt; for (int i = GetCount() - 1; i >= 0; i--) { if (IsDockCont(tabbar.Get(i))) ContCast(tabbar.Get(i))->Serialize(s); else { DockableCtrl *dc = DockCast(tabbar.Get(i)); int ix = base->FindDocker(dc); s / ctrl / ix; } } int cursor = tabbar.GetCursor(); int groupix = tabbar.GetGroup(); s / cursor / groupix; } else { int cnt; int type; s / type / cnt; ASSERT(type == cont); for (int i = 0; i < cnt; i++) { int64 pos = s.GetPos(); s / type; if (type == cont) { s.Seek(pos); DockCont *dc = base->CreateContainer(); dc->Serialize(s); base->DockContainerAsTab(*this, *dc, true); } else if (type == ctrl) { int ix; s / ix; if (ix >= 0 && ix <= dcs.GetCount()) Add(*dcs[ix]); } else ASSERT(false); } int cursor, groupix; s / cursor / groupix; tabbar.SetGroup(groupix); tabbar.SetCursor(min(tabbar.GetCount()-1, cursor)); TabSelected(); } }
void DockCont::ChildAdded(Ctrl *child) { if (child->GetParent() != this) return; else if (DockableCtrl *dc = dynamic_cast<DockableCtrl *>(child)) { Value v = ValueCast(dc); tabbar.Insert(0, v, dc->GetGroup(), true); } else if (DockCont *dc = dynamic_cast<DockCont *>(child)) { Value v = ValueCast(dc); tabbar.Insert(0, v, Null, true); } else return; child->SizePos(); TabSelected(); if (GetCount() >= 2) RefreshLayout(); }
void DockCont::Layout() { if (waitsync) { waitsync = false; if (GetCount() == 1) { Value v = tabbar.Get(0); if (IsDockCont(v)) { DockCont *dc = ContCast(v); AddFrom(*dc); base->CloseContainer(*dc); RefreshLayout(); } } if (!tabbar.GetCount()) base->CloseContainer(*this); TabSelected(); } }
void ConEmuAbout::searchProc(HWND hDlg, HWND hSearch, bool bReentr) { HWND hEdit = GetDlgItem(hDlg, tAboutText); wchar_t* pszPart = GetDlgItemTextPtr(hSearch, 0); wchar_t* pszText = GetDlgItemTextPtr(hEdit, 0); bool bRetry = false; if (pszPart && *pszPart && pszText && *pszText) { LPCWSTR pszFrom = pszText; DWORD nStart = 0, nEnd = 0; SendMessage(hEdit, EM_GETSEL, (WPARAM)&nStart, (LPARAM)&nEnd); size_t cchMax = wcslen(pszText); size_t cchFrom = max(nStart,nEnd); if (cchMax > cchFrom) pszFrom += cchFrom; LPCWSTR pszFind = StrStrI(pszFrom, pszPart); if (!pszFind && bReentr && (pszFrom != pszText)) pszFind = StrStrI(pszText, pszPart); if (pszFind) { const wchar_t szBrkChars[] = L"()[]<>{}:;,.-=\\/ \t\r\n"; LPCWSTR pszEnd = wcspbrk(pszFind, szBrkChars); INT_PTR nPartLen = wcslen(pszPart); if (!pszEnd || ((pszEnd - pszFind) > max(nPartLen,60))) pszEnd = pszFind + nPartLen; while ((pszFind > pszFrom) && !wcschr(szBrkChars, *(pszFind-1))) pszFind--; //SetFocus(hEdit); nTextSelStart = (DWORD)(pszEnd-pszText); nTextSelEnd = (DWORD)(pszFind-pszText); SendMessage(hEdit, EM_SETSEL, nTextSelStart, nTextSelEnd); SendMessage(hEdit, EM_SCROLLCARET, 0, 0); } else if (!bReentr) { HWND hTab = GetDlgItem(hDlg, tbAboutTabs); int iPage = TabCtrl_GetCurSel(hTab); int iFound = -1; for (int s = 0; (iFound == -1) && (s <= 1); s++) { int iFrom = (s == 0) ? (iPage+1) : 0; int iTo = (s == 0) ? (int)countof(Pages) : (iPage-1); for (int i = iFrom; i < iTo; i++) { if (StrStrI(Pages[i].Title, pszPart) || StrStrI(Pages[i].Text, pszPart)) { iFound = i; break; } } } if (iFound >= 0) { TabSelected(hDlg, iFound); TabCtrl_SetCurSel(hTab, iFound); //SetFocus(hEdit); bRetry = true; } } } SafeFree(pszPart); SafeFree(pszText); if (bRetry) { searchProc(hDlg, hSearch, true); } }
INT_PTR WINAPI ConEmuAbout::aboutProc(HWND hDlg, UINT messg, WPARAM wParam, LPARAM lParam) { INT_PTR lRc = 0; if (DonateBtns_Process(hDlg, messg, wParam, lParam, lRc) || EditIconHint_Process(hDlg, messg, wParam, lParam, lRc)) { SetWindowLongPtr(hDlg, DWLP_MSGRESULT, lRc); return TRUE; } PatchMsgBoxIcon(hDlg, messg, wParam, lParam); switch (messg) { case WM_INITDIALOG: { gpConEmu->OnOurDialogOpened(); mh_AboutDlg = hDlg; DonateBtns_Add(hDlg, pIconCtrl, IDOK); if (mp_DpiAware) { mp_DpiAware->Attach(hDlg, ghWnd, CDynDialog::GetDlgClass(hDlg)); } RECT rect = {}; if (GetWindowRect(hDlg, &rect)) { CDpiAware::GetCenteredRect(ghWnd, rect); MoveWindowRect(hDlg, rect); } if ((ghOpWnd && IsWindow(ghOpWnd)) || (WS_EX_TOPMOST & GetWindowLongPtr(ghWnd, GWL_EXSTYLE))) { SetWindowPos(hDlg, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE|SWP_NOSIZE); } LPCWSTR pszActivePage = (LPCWSTR)lParam; wchar_t* pszTitle = lstrmerge(gpConEmu->GetDefaultTitle(), L" About"); if (pszTitle) { SetWindowText(hDlg, pszTitle); SafeFree(pszTitle); } if (hClassIcon) { SendMessage(hDlg, WM_SETICON, ICON_BIG, (LPARAM)hClassIcon); SendMessage(hDlg, WM_SETICON, ICON_SMALL, (LPARAM)CreateNullIcon()); SetClassLongPtr(hDlg, GCLP_HICON, (LONG_PTR)hClassIcon); } SetDlgItemText(hDlg, stConEmuAbout, pAboutTitle); SetDlgItemText(hDlg, stConEmuUrl, gsHomePage); EditIconHint_Set(hDlg, GetDlgItem(hDlg, tAboutSearch), true, L"Search", false, UM_SEARCH, IDOK); EditIconHint_Subclass(hDlg); wchar_t* pszLabel = GetDlgItemTextPtr(hDlg, stConEmuVersion); if (pszLabel) { wchar_t* pszSet = NULL; if (gpUpd) { wchar_t* pszVerInfo = gpUpd->GetCurVerInfo(); if (pszVerInfo) { pszSet = lstrmerge(pszLabel, L" ", pszVerInfo); free(pszVerInfo); } } if (!pszSet) { pszSet = lstrmerge(pszLabel, L" ", L"Please check for updates manually"); } if (pszSet) { SetDlgItemText(hDlg, stConEmuVersion, pszSet); free(pszSet); } free(pszLabel); } HWND hTab = GetDlgItem(hDlg, tbAboutTabs); INT_PTR nPage = -1; for (size_t i = 0; i < countof(Pages); i++) { TCITEM tie = {}; tie.mask = TCIF_TEXT; tie.pszText = (LPWSTR)Pages[i].Title; TabCtrl_InsertItem(hTab, i, &tie); if (pszActivePage && (lstrcmpi(pszActivePage, Pages[i].Title) == 0)) nPage = i; } if (nPage >= 0) { TabSelected(hDlg, nPage); TabCtrl_SetCurSel(hTab, (int)nPage); } else if (!pszActivePage) { TabSelected(hDlg, 0); } else { _ASSERTE(pszActivePage==NULL && "Unknown page name?"); } SetFocus(hTab); return FALSE; } case WM_CTLCOLORSTATIC: if (GetWindowLongPtr((HWND)lParam, GWLP_ID) == stConEmuUrl) { SetTextColor((HDC)wParam, GetSysColor(COLOR_HOTLIGHT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } else { SetTextColor((HDC)wParam, GetSysColor(COLOR_WINDOWTEXT)); HBRUSH hBrush = GetSysColorBrush(COLOR_3DFACE); SetBkMode((HDC)wParam, TRANSPARENT); return (INT_PTR)hBrush; } break; case WM_SETCURSOR: { if (GetWindowLongPtr((HWND)wParam, GWLP_ID) == stConEmuUrl) { SetCursor(LoadCursor(NULL, IDC_HAND)); SetWindowLongPtr(hDlg, DWLP_MSGRESULT, TRUE); return TRUE; } return FALSE; } break; case WM_COMMAND: switch (HIWORD(wParam)) { case BN_CLICKED: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: case IDCLOSE: aboutProc(hDlg, WM_CLOSE, 0, 0); return 1; case stConEmuUrl: ConEmuAbout::OnInfo_HomePage(); return 1; } // BN_CLICKED break; case EN_SETFOCUS: switch (LOWORD(wParam)) { case tAboutText: { // Do not autosel all text HWND hEdit = (HWND)lParam; DWORD nStart = 0, nEnd = 0; SendMessage(hEdit, EM_GETSEL, (WPARAM)&nStart, (LPARAM)&nEnd); if (nStart != nEnd) { SendMessage(hEdit, EM_SETSEL, nTextSelStart, nTextSelEnd); } } break; } } // switch (HIWORD(wParam)) break; case WM_NOTIFY: { LPNMHDR nmhdr = (LPNMHDR)lParam; if ((nmhdr->code == TCN_SELCHANGE) && (nmhdr->idFrom == tbAboutTabs)) { int iPage = TabCtrl_GetCurSel(nmhdr->hwndFrom); if ((iPage >= 0) && (iPage < (int)countof(Pages))) TabSelected(hDlg, iPage); } break; } case UM_SEARCH: searchProc(hDlg, (HWND)lParam, false); break; case UM_EDIT_KILL_FOCUS: SendMessage((HWND)lParam, EM_GETSEL, (WPARAM)&nTextSelStart, (LPARAM)&nTextSelEnd); break; case WM_CLOSE: //if (ghWnd == NULL) gpConEmu->OnOurDialogClosed(); if (mp_DpiAware) mp_DpiAware->Detach(); EndDialog(hDlg, IDOK); //else // DestroyWindow(hDlg); break; case WM_DESTROY: mh_AboutDlg = NULL; break; default: if (mp_DpiAware && mp_DpiAware->ProcessDpiMessages(hDlg, messg, wParam, lParam)) { return TRUE; } } return FALSE; }