mmAssetsListCtrl::mmAssetsListCtrl(mmAssetsPanel* cp, wxWindow *parent, wxWindowID winid) : mmListCtrl(parent, winid) , m_panel(cp) { ToggleWindowStyle(wxLC_EDIT_LABELS); // load the global variables m_selected_col = Model_Setting::instance().GetIntSetting("ASSETS_SORT_COL", m_default_sort_column); m_asc = Model_Setting::instance().GetBoolSetting("ASSETS_ASC", true); m_columns.push_back(PANEL_COLUMN(" ", 25, wxLIST_FORMAT_LEFT)); m_columns.push_back(PANEL_COLUMN(_("ID"), wxLIST_AUTOSIZE, wxLIST_FORMAT_RIGHT)); m_columns.push_back(PANEL_COLUMN(_("Name"), 150, wxLIST_FORMAT_LEFT)); m_columns.push_back(PANEL_COLUMN(_("Date"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT)); m_columns.push_back(PANEL_COLUMN(_("Type"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT)); m_columns.push_back(PANEL_COLUMN(_("Initial Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT)); m_columns.push_back(PANEL_COLUMN(_("Current Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT)); m_columns.push_back(PANEL_COLUMN(_("Notes"), 450, wxLIST_FORMAT_LEFT)); m_col_width = "ASSETS_COL%d_WIDTH"; m_default_sort_column = m_panel->col_sort(); for (const auto& entry : m_columns) { long count = GetColumnCount(); InsertColumn(count , entry.HEADER , entry.FORMAT , Model_Setting::instance().GetIntSetting(wxString::Format(m_col_width, count), entry.WIDTH)); } }
void LoadTocTree(WindowInfo *win) { TabInfo *tab = win->currentTab; CrashIf(!tab); if (win->tocLoaded) return; win->tocLoaded = true; if (!tab->tocRoot) { tab->tocRoot = tab->ctrl->GetTocTree(); if (!tab->tocRoot) return; } // consider a ToC tree right-to-left if a more than half of the // alphabetic characters are in a right-to-left script int l2r = 0, r2l = 0; GetLeftRightCounts(tab->tocRoot, l2r, r2l); bool isRTL = r2l > l2r; SendMessage(win->hwndTocTree, WM_SETREDRAW, FALSE, 0); ToggleWindowStyle(win->hwndTocTree, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, isRTL, GWL_EXSTYLE); PopulateTocTreeView(win->hwndTocTree, tab->tocRoot, tab->tocState); UpdateTocColors(win); SendMessage(win->hwndTocTree, WM_SETREDRAW, TRUE, 0); UINT fl = RDW_ERASE | RDW_FRAME | RDW_INVALIDATE | RDW_ALLCHILDREN; RedrawWindow(win->hwndTocTree, nullptr, nullptr, fl); }
mmAssetsListCtrl::mmAssetsListCtrl(mmAssetsPanel* cp, wxWindow *parent, wxWindowID winid) : mmListCtrl(parent, winid) , m_panel(cp) { ToggleWindowStyle(wxLC_EDIT_LABELS); // load the global variables m_selected_col = Model_Setting::instance().GetIntSetting("ASSETS_SORT_COL", 0); m_asc = Model_Setting::instance().GetBoolSetting("ASSETS_ASC", true); }
void NotificationWnd::UpdateMessage(const WCHAR *message, int timeoutInMS, bool highlight) { win::SetText(self, message); this->highlight = highlight; if (timeoutInMS) hasCancel = false; ToggleWindowStyle(self, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE); UpdateWindowPosition(message); InvalidateRect(self, NULL, TRUE); if (timeoutInMS) SetTimer(self, TIMEOUT_TIMER_ID, timeoutInMS, NULL); }
void NotificationWnd::CreatePopup(HWND parent, const WCHAR *message) { NONCLIENTMETRICS ncm = { 0 }; ncm.cbSize = sizeof(ncm); SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0); font = CreateFontIndirect(&ncm.lfMessageFont); HDC hdc = GetDC(parent); progressWidth = MulDiv(PROGRESS_WIDTH, GetDeviceCaps(hdc, LOGPIXELSX), USER_DEFAULT_SCREEN_DPI); ReleaseDC(parent, hdc); self = CreateWindowEx(WS_EX_TOPMOST, NOTIFICATION_WND_CLASS_NAME, message, WS_CHILD | SS_CENTER, TL_MARGIN, TL_MARGIN, 0, 0, parent, (HMENU)0, ghinst, NULL); SetWindowLongPtr(self, GWLP_USERDATA, (LONG_PTR)this); ToggleWindowStyle(self, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE); UpdateWindowPosition(message, true); ShowWindow(self, SW_SHOW); }
mmAssetsListCtrl::mmAssetsListCtrl(mmAssetsPanel* cp, wxWindow *parent, wxWindowID winid) : mmListCtrl(parent, winid) , m_panel(cp) { ToggleWindowStyle(wxLC_EDIT_LABELS); // load the global variables m_selected_col = Model_Setting::instance().GetIntSetting("ASSETS_SORT_COL", m_default_sort_column); m_asc = Model_Setting::instance().GetBoolSetting("ASSETS_ASC", true); m_columns.push_back(std::make_tuple(" ", 25, wxLIST_FORMAT_LEFT)); m_columns.push_back(std::make_tuple(_("ID"), 0, wxLIST_FORMAT_RIGHT)); m_columns.push_back(std::make_tuple(_("Name"), 150, wxLIST_FORMAT_LEFT)); m_columns.push_back(std::make_tuple(_("Date"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT)); m_columns.push_back(std::make_tuple(_("Type"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_LEFT)); m_columns.push_back(std::make_tuple(_("Initial Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT)); m_columns.push_back(std::make_tuple(_("Current Value"), wxLIST_AUTOSIZE_USEHEADER, wxLIST_FORMAT_RIGHT)); m_columns.push_back(std::make_tuple(_("Notes"), 450, wxLIST_FORMAT_LEFT)); m_col_width = "ASSETS_COL%d_WIDTH"; m_default_sort_column = m_panel->col_sort(); }
static bool CreatePropertiesWindow(HWND hParent, PropertiesLayout* layoutData) { CrashIf(layoutData->hwnd); HWND hwnd = CreateWindow( PROPERTIES_CLASS_NAME, PROPERTIES_WIN_TITLE, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, ghinst, NULL); if (!hwnd) return false; layoutData->hwnd = hwnd; layoutData->hwndParent = hParent; ToggleWindowStyle(hwnd, WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT, IsUIRightToLeft(), GWL_EXSTYLE); // get the dimensions required for the about box's content RectI rc; PAINTSTRUCT ps; HDC hdc = BeginPaint(hwnd, &ps); UpdatePropertiesLayout(layoutData, hdc, &rc); EndPaint(hwnd, &ps); // resize the new window to just match these dimensions // (as long as they fit into the current monitor's work area) WindowRect wRc(hwnd); ClientRect cRc(hwnd); RectI work = GetWorkAreaRect(WindowRect(hParent)); wRc.dx = min(rc.dx + wRc.dx - cRc.dx, work.dx); wRc.dy = min(rc.dy + wRc.dy - cRc.dy, work.dy); MoveWindow(hwnd, wRc.x, wRc.y, wRc.dx, wRc.dy, FALSE); CenterDialog(hwnd, hParent); ShowWindow(hwnd, SW_SHOW); return true; }
void UpdateTocColors(WindowInfo *win) { COLORREF labelBgCol = GetSysColor(COLOR_BTNFACE); COLORREF labelTxtCol = GetSysColor(COLOR_BTNTEXT); COLORREF treeBgCol = (DWORD)-1; COLORREF splitterCol = GetSysColor(COLOR_BTNFACE); bool flatTreeWnd = false; if (win->AsEbook() && !gGlobalPrefs->useSysColors) { labelBgCol = gGlobalPrefs->ebookUI.backgroundColor; labelTxtCol = gGlobalPrefs->ebookUI.textColor; treeBgCol = labelBgCol; float factor = 14.f; int sign = GetLightness(labelBgCol) + factor > 255 ? 1 : -1; splitterCol = AdjustLightness2(labelBgCol, sign * factor); flatTreeWnd = true; } TreeView_SetBkColor(win->hwndTocTree, treeBgCol); SetBgCol(win->tocLabelWithClose, labelBgCol); SetTextCol(win->tocLabelWithClose, labelTxtCol); SetBgCol(win->sidebarSplitter, splitterCol); ToggleWindowStyle(win->hwndTocTree, WS_EX_STATICEDGE, !flatTreeWnd, GWL_EXSTYLE); SetWindowPos(win->hwndTocTree, nullptr, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED); // TODO: if we have favorites in ebook view, we'll need this //SetBgCol(win->favLabelWithClose, labelBgCol); //SetTextCol(win->favLabelWithClose, labelTxtCol); //SetBgCol(win->favSplitter, labelTxtCol); // TODO: more work needed to to ensure consistent look of the ebook window: // - tab bar should match the color // - change the tree item text color // - change the tree item background color when selected (for both focused and non-focused cases) // - ultimately implement owner-drawn scrollbars in a simpler style (like Chrome or VS 2013) // and match their colors as well }
void wxSplitterWindow::SetSashInvisible(bool invisible) { if ( IsSashInvisible() != invisible ) ToggleWindowStyle(wxSP_NOSASH); }
static INT_PTR CALLBACK Dialog_ChangeLanguage_Proc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) { Dialog_ChangeLanguage_Data * data; HWND langList; if (WM_INITDIALOG == msg) { DIALOG_SIZER_START(sz) DIALOG_SIZER_ENTRY(IDOK, DS_MoveX | DS_MoveY) DIALOG_SIZER_ENTRY(IDCANCEL, DS_MoveX | DS_MoveY) DIALOG_SIZER_ENTRY(IDC_CHANGE_LANG_LANG_LIST, DS_SizeY | DS_SizeX) DIALOG_SIZER_END() DialogSizer_Set(hDlg, sz, TRUE); data = (Dialog_ChangeLanguage_Data*)lParam; assert(data); SetWindowLongPtr(hDlg, GWLP_USERDATA, (LONG_PTR)data); // for non-latin languages this depends on the correct fonts being installed, // otherwise all the user will see are squares win::SetText(hDlg, _TR("Change Language")); langList = GetDlgItem(hDlg, IDC_CHANGE_LANG_LANG_LIST); int itemToSelect = 0; for (int i = 0; i < trans::GetLangsCount(); i++) { const char *name = trans::GetLangNameByIdx(i); const char *langCode = trans::GetLangCodeByIdx(i); ScopedMem<WCHAR> langName(str::conv::FromUtf8(name)); ListBox_AppendString_NoSort(langList, langName); if (str::Eq(langCode, data->langCode)) itemToSelect = i; } ListBox_SetCurSel(langList, itemToSelect); // the language list is meant to be laid out left-to-right ToggleWindowStyle(langList, WS_EX_LAYOUTRTL, false, GWL_EXSTYLE); SetDlgItemText(hDlg, IDOK, _TR("OK")); SetDlgItemText(hDlg, IDCANCEL, _TR("Cancel")); CenterDialog(hDlg); SetFocus(langList); return FALSE; } switch (msg) { case WM_COMMAND: data = (Dialog_ChangeLanguage_Data*)GetWindowLongPtr(hDlg, GWLP_USERDATA); assert(data); if (HIWORD(wParam) == LBN_DBLCLK) { assert(IDC_CHANGE_LANG_LANG_LIST == LOWORD(wParam)); langList = GetDlgItem(hDlg, IDC_CHANGE_LANG_LANG_LIST); assert(langList == (HWND)lParam); int langIdx = (int)ListBox_GetCurSel(langList); data->langCode = trans::GetLangCodeByIdx(langIdx); EndDialog(hDlg, IDOK); return FALSE; } switch (LOWORD(wParam)) { case IDOK: { langList = GetDlgItem(hDlg, IDC_CHANGE_LANG_LANG_LIST); int langIdx = ListBox_GetCurSel(langList); data->langCode = trans::GetLangCodeByIdx(langIdx); EndDialog(hDlg, IDOK); } return TRUE; case IDCANCEL: EndDialog(hDlg, IDCANCEL); return TRUE; } break; } return FALSE; }
static LRESULT CALLBACK WndProcSplitter(HWND hwnd, UINT msg, WPARAM wp, LPARAM lp) { if (WM_ERASEBKGND == msg) { return TRUE; // tells Windows we handle background erasing so it doesn't do it } SplitterWnd *w = nullptr; if (WM_NCCREATE == msg) { LPCREATESTRUCT lpcs = reinterpret_cast<LPCREATESTRUCT>(lp); w = reinterpret_cast<SplitterWnd *>(lpcs->lpCreateParams); w->hwnd = hwnd; SetWindowLongPtr(hwnd, GWLP_USERDATA, reinterpret_cast<LPARAM>(w)); goto Exit; } else { w = reinterpret_cast<SplitterWnd *>(GetWindowLongPtr(hwnd, GWLP_USERDATA)); } if (!w) { goto Exit; } if (WM_LBUTTONDOWN == msg) { SetCapture(hwnd); if (!w->isLive) { if (w->parentClipsChildren) { ToggleWindowStyle(GetParent(hwnd), WS_CLIPCHILDREN, false); } DrawResizeLine(w, false, true); } return 0; } if (WM_LBUTTONUP == msg) { if (!w->isLive) { DrawResizeLine(w, true, false); if (w->parentClipsChildren) { ToggleWindowStyle(GetParent(hwnd), WS_CLIPCHILDREN, true); } } ReleaseCapture(); w->cb(w->ctx, true); ScheduleRepaint(w->hwnd); return 0; } if (WM_MOUSEMOVE == msg) { LPWSTR curId = IDC_SIZENS; if (SplitterVert == w->type) { curId = IDC_SIZEWE; } if (hwnd == GetCapture()) { bool resizingAllowed = w->cb(w->ctx, false); if (!resizingAllowed) { curId = IDC_NO; } else if (!w->isLive) { DrawResizeLine(w, true, true); } } SetCursor(curId); return 0; } if (WM_PAINT == msg) { OnPaint(w); return 0; } Exit: return DefWindowProc(hwnd, msg, wp, lp); }