void application::handle_size(int w, int h, int) { m_width = w; m_height = h; on_size_changed(); perform_idle(); }
void splitter_window_impl::start_autohide_dehide(unsigned p_panel, bool b_next_too) { bool b_have_next = b_next_too && is_index_valid(p_panel + 1); if ((m_panels[p_panel]->m_hidden) || (b_have_next && m_panels[p_panel + 1]->m_hidden)) { bool a1 = false, a2 = false; if (m_panels[p_panel]->m_autohide) { m_panels[p_panel]->m_hidden = false; a1 = true; } if (b_have_next && m_panels[p_panel + 1]->m_autohide) { m_panels[p_panel + 1]->m_hidden = false; a2 = true; } if (a1 || a2) { get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); if (a1) m_panels[p_panel]->m_container.enter_autohide_hook(); if (a2) m_panels[p_panel + 1]->m_container.enter_autohide_hook(); } } }
void splitter_window_impl::start_autohide_dehide(unsigned p_panel, bool b_next_too) { bool b_have_next = b_next_too && is_index_valid(p_panel + 1); auto & panel_before = m_panels[p_panel]; auto & panel_after = b_have_next ? m_panels[p_panel + 1] : panel::null_ptr; if ((panel_before->m_autohide && !panel_before->m_container.m_hook_active) || (b_have_next && panel_after->m_autohide && !panel_after->m_container.m_hook_active)) { bool a1 = false, a2 = false; if (panel_before->m_autohide && !panel_before->m_container.m_hook_active) { panel_before->m_hidden = false; a1 = true; } if (b_have_next && panel_after->m_autohide && !panel_after->m_container.m_hook_active) { panel_after->m_hidden = false; a2 = true; } if (a1 || a2) { get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); if (a1) panel_before->m_container.enter_autohide_hook(); if (a2) panel_after->m_container.enter_autohide_hook(); } } }
LRESULT splitter_window_impl::on_message(HWND wnd, UINT msg, WPARAM wp, LPARAM lp) { switch (msg) { case WM_NCCREATE: m_wnd = wnd; g_instances.add_item(this); break; case WM_CREATE: if (!g_count++) { g_font_menu_horizontal = uCreateMenuFont(); g_font_menu_vertical = uCreateMenuFont(true); } refresh_children(); break; case WM_DESTROY: destroy_children(); if (!--g_count) { g_font_menu_horizontal.release(); g_font_menu_vertical.release(); } break; case WM_NCDESTROY: g_instances.remove_item(this); m_wnd = NULL; break; case WM_SHOWWINDOW: if (wp == TRUE && lp == 0) { unsigned n, count = m_panels.get_count(); for (n = 0; n<count; n++) { ShowWindow(m_panels[n]->m_wnd_child, SW_SHOWNORMAL); ShowWindow(m_panels[n]->m_wnd, SW_SHOWNORMAL); } RedrawWindow(wnd, 0, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); } break; case WM_WINDOWPOSCHANGED: { LPWINDOWPOS lpwp = (LPWINDOWPOS)lp; if (!(lpwp->flags & SWP_NOSIZE)) { on_size_changed(lpwp->cx, lpwp->cy); } } break; /*case WM_SIZE: on_size_changed(LOWORD(lp), HIWORD(lp)); break;*/ case WM_GETMINMAXINFO: { LPMINMAXINFO lpmmi = (LPMINMAXINFO)lp; lpmmi->ptMinTrackSize.y = 0; lpmmi->ptMinTrackSize.x = 0; lpmmi->ptMaxTrackSize.y = get_orientation() == vertical ? 0 : MAXLONG; lpmmi->ptMaxTrackSize.x = get_orientation() == horizontal ? 0 : MAXLONG; unsigned n, count = m_panels.get_count(); bool b_found = false; for (n = 0; n<count; n++) { MINMAXINFO mmi; memset(&mmi, 0, sizeof(MINMAXINFO)); mmi.ptMaxTrackSize.x = MAXLONG; mmi.ptMaxTrackSize.y = MAXLONG; if (m_panels[n]->m_wnd_child) { b_found = true; unsigned divider_size = get_panel_divider_size(n); unsigned caption_height = m_panels[n]->m_show_caption ? g_get_caption_size() : 0; if (m_panels[n]->m_hidden) { if (get_orientation() == horizontal) { if (m_panels[n]->m_caption_orientation == vertical) { mmi.ptMinTrackSize.x = caption_height; mmi.ptMaxTrackSize.x = caption_height; } } else { if (m_panels[n]->m_caption_orientation == horizontal) { mmi.ptMinTrackSize.y = caption_height; mmi.ptMaxTrackSize.y = caption_height; } } } else { SendMessage(m_panels[n]->m_wnd_child, WM_GETMINMAXINFO, 0, (LPARAM)&mmi); if (caption_height) { if (m_panels[n]->m_caption_orientation == horizontal) { mmi.ptMinTrackSize.y += caption_height; if (mmi.ptMaxTrackSize.y < MAXLONG - (long)caption_height) mmi.ptMaxTrackSize.y += caption_height; else mmi.ptMaxTrackSize.y = MAXLONG; } else { mmi.ptMinTrackSize.x += caption_height; if (mmi.ptMaxTrackSize.x < MAXLONG - (long)caption_height) mmi.ptMaxTrackSize.x += caption_height; else mmi.ptMaxTrackSize.x = MAXLONG; } } } if (m_panels[n]->m_show_toggle_area && !m_panels[n]->m_autohide) { mmi.ptMinTrackSize.x++; if (mmi.ptMaxTrackSize.x < MAXLONG) mmi.ptMaxTrackSize.x++; } if (get_orientation() == vertical) { lpmmi->ptMinTrackSize.y += mmi.ptMinTrackSize.y + divider_size; lpmmi->ptMinTrackSize.x = max(mmi.ptMinTrackSize.x, lpmmi->ptMinTrackSize.x); if (lpmmi->ptMaxTrackSize.y <= MAXLONG - mmi.ptMaxTrackSize.y && lpmmi->ptMaxTrackSize.y + mmi.ptMaxTrackSize.y <= MAXLONG - (long)divider_size) { lpmmi->ptMaxTrackSize.y += mmi.ptMaxTrackSize.y + divider_size; } else { lpmmi->ptMaxTrackSize.y = MAXLONG; } lpmmi->ptMaxTrackSize.x = min(mmi.ptMaxTrackSize.x, lpmmi->ptMaxTrackSize.x); } else { lpmmi->ptMinTrackSize.x += mmi.ptMinTrackSize.x + divider_size; lpmmi->ptMinTrackSize.y = max(mmi.ptMinTrackSize.y, lpmmi->ptMinTrackSize.y); if (lpmmi->ptMaxTrackSize.x <= MAXLONG - mmi.ptMaxTrackSize.x && lpmmi->ptMaxTrackSize.x + mmi.ptMaxTrackSize.x <= MAXLONG - (long)divider_size) { lpmmi->ptMaxTrackSize.x += mmi.ptMaxTrackSize.x + divider_size; } else { lpmmi->ptMaxTrackSize.x = MAXLONG; } lpmmi->ptMaxTrackSize.y = min(mmi.ptMaxTrackSize.y, lpmmi->ptMaxTrackSize.y); } } } if (b_found) { if (get_orientation() == vertical) lpmmi->ptMaxTrackSize.x = max(lpmmi->ptMaxTrackSize.x, lpmmi->ptMinTrackSize.x); else lpmmi->ptMaxTrackSize.y = max(lpmmi->ptMaxTrackSize.y, lpmmi->ptMinTrackSize.y); } else { if (get_orientation() == vertical) lpmmi->ptMaxTrackSize.y = MAXLONG; else lpmmi->ptMaxTrackSize.x = MAXLONG; } if (0) { lpmmi->ptMinTrackSize.y = 0; if (get_orientation() == horizontal) lpmmi->ptMaxTrackSize.x = 0; lpmmi->ptMinTrackSize.x = 0; if (get_orientation() == vertical) lpmmi->ptMaxTrackSize.y = 0; } } return 0; case WM_MOUSEHOVER: { POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; HWND child = RealChildWindowFromPoint(wnd, pt); if (child == wnd) { unsigned p_panel = -1; bool b_have_next = false; bool b_on_divider = false; b_on_divider = find_by_divider_pt(pt, p_panel); if (b_on_divider) { if (p_panel < m_panels.get_count()) { b_have_next = (p_panel + 1 < m_panels.get_count()); } if (is_index_valid(p_panel)) start_autohide_dehide(p_panel); } } } break; case WM_LBUTTONDOWN: case WM_MOUSEMOVE: { if (m_panels.get_count()) { POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; HWND child = RealChildWindowFromPoint(wnd, pt); if (child == wnd) { unsigned p_panel = -1; bool b_have_next = false; bool b_on_divider = false; if (m_panel_dragging_valid) { b_on_divider = true; p_panel = m_panel_dragging; } else b_on_divider = find_by_divider_pt(pt, p_panel); if (b_on_divider) { if (p_panel < m_panels.get_count()) { b_have_next = (p_panel + 1 < m_panels.get_count()); } if (msg == WM_MOUSEMOVE && ((is_index_valid(p_panel) && m_panels[p_panel]->m_autohide) || (b_have_next && m_panels[p_panel + 1]->m_autohide))) { if (cfg_sidebar_use_custom_show_delay && !cfg_sidebar_show_delay) { if ((is_index_valid(p_panel))) { start_autohide_dehide(p_panel); } } else { TRACKMOUSEEVENT tme; memset(&tme, 0, sizeof(TRACKMOUSEEVENT)); tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.dwFlags = TME_QUERY; tme.hwndTrack = wnd; _TrackMouseEvent(&tme); if (!(tme.dwFlags & TME_HOVER)) { memset(&tme, 0, sizeof(TRACKMOUSEEVENT)); tme.cbSize = sizeof(TRACKMOUSEEVENT); tme.hwndTrack = wnd; tme.dwHoverTime = cfg_sidebar_use_custom_show_delay ? cfg_sidebar_show_delay : HOVER_DEFAULT; tme.dwFlags = TME_HOVER; _TrackMouseEvent(&tme); } } } } if (b_on_divider && is_index_valid(p_panel) && can_resize_divider(p_panel)) { SetCursor(LoadCursor(0, get_orientation() == horizontal ? IDC_SIZEWE : IDC_SIZENS)); if (msg == WM_LBUTTONDOWN) { save_sizes(); m_panel_dragging = p_panel; SetCapture(wnd); m_last_position = (get_orientation() == vertical ? pt.y : pt.x); m_panel_dragging_valid = true; } } else { if (!(wp & MK_LBUTTON)) SetCursor(LoadCursor(0, IDC_ARROW)); m_panel_dragging_valid = false; } } if (m_panel_dragging_valid && wp & MK_LBUTTON && is_index_valid(m_panel_dragging)) { int new_height = m_last_position - (get_orientation() == vertical ? pt.y : pt.x); int delta = (get_orientation() == vertical ? pt.y : pt.x) - m_last_position; //console::formatter() << "before or: pt = " << pt.y << "," << pt.x << " lastpos: " << m_last_position << " enddelta: " << delta; auto & p_panel = m_panels[m_panel_dragging]; if (p_panel->m_hidden && delta) { p_panel->m_hidden = false; p_panel->m_size = 0; get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); } int delta_changed = override_size(m_panel_dragging, delta); m_last_position = (get_orientation() == vertical ? pt.y : pt.x) + delta_changed; on_size_changed(); if (delta + delta_changed) start_autohide_dehide(m_panel_dragging); } } //msg_last = msg; //lp_last = lp; //wp_last = wp; } break; case WM_LBUTTONDBLCLK: { POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; HWND child = ChildWindowFromPoint(wnd, pt); if (child == wnd) { unsigned p_panel = -1; if (find_by_divider_pt(pt, p_panel) && is_index_valid(p_panel)) { bool b_have_next = is_index_valid(p_panel + 1); if (m_panels[p_panel]->m_locked && !m_panels[p_panel]->m_autohide && (!b_have_next || !m_panels[p_panel + 1]->m_locked)) { m_panels[p_panel]->m_hidden = !m_panels[p_panel]->m_hidden; get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); } else if (!m_panels[p_panel]->m_locked && b_have_next && m_panels[p_panel]->m_locked && !m_panels[p_panel]->m_autohide) { m_panels[p_panel + 1]->m_hidden = !m_panels[p_panel]->m_hidden; get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); } } } } break; case WM_LBUTTONUP: if (m_panel_dragging_valid) { m_panel_dragging_valid = false; if (GetCapture() == wnd) ReleaseCapture(); //SetCursor(LoadCursor(0, IDC_ARROW)); } break; #if 0 case WM_PAINT: { PAINTSTRUCT ps; BeginPaint(wnd, &ps); COLORREF cr = GetSysColor(COLOR_3DFACE); gdi_object_t<HBRUSH>::ptr_t br_line = CreateSolidBrush(/*RGB(226, 226, 226)*/cr); t_size n, count = m_panels.get_count(); for (n = 0; n + 1<count; n++) { pfc::refcounted_object_ptr_t<panel> p_item = m_panels.get_item(n); if (p_item->m_wnd_child) { RECT rc_area; GetRelativeRect(p_item->m_wnd_child, m_wnd, &rc_area); if (get_orientation() == vertical) { rc_area.top = rc_area.bottom; rc_area.bottom += 2; //FillRect(ps.hdc, &rc_area, GetSysColorBrush(COLOR_WINDOW)); //rc_area.top++; } else { rc_area.left = rc_area.right; rc_area.right += 2; //FillRect(ps.hdc, &rc_area, GetSysColorBrush(COLOR_WINDOW)); //rc_area.right--; } FillRect(ps.hdc, &rc_area, br_line); } } EndPaint(wnd, &ps); } ; #endif #if 0 case WM_CONTEXTMENU: if ((HWND)wp == wnd) { window_transparent_fill m_trans_fill; if (m_layout_editing_active) { RECT rc; GetRelativeRect(wnd, HWND_DESKTOP, &rc); ShowWindow(m_trans_fill.create(get_wnd(), 0, ui_helpers::window_position_t(rc)), SW_SHOWNORMAL); POINT pt = { GET_X_LPARAM(lp), GET_Y_LPARAM(lp) }; HMENU menu = CreatePopupMenu(); HMENU menu_add = CreatePopupMenu(); uie::window_info_list_simple panels; g_get_panel_list(panels); enum { ID_CLOSE = 1, ID_ADD_BASE = 2 }; g_append_menu_panels(menu_add, panels, ID_ADD_BASE); pfc::string8 temp; get_name(temp); uAppendMenu(menu, MF_STRING | MF_GRAYED, (UINT_PTR)0, temp); uAppendMenu(menu, MF_MENUBREAK, (UINT_PTR)0, NULL); AppendMenu(menu, MF_STRING | MF_POPUP, (UINT_PTR)menu_add, L"Add panel"); int cmd = TrackPopupMenu(menu, TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, pt.x, pt.y, 0, m_trans_fill.get_wnd(), 0); DestroyMenu(menu); m_trans_fill.destroy(); if (cmd) { if (cmd >= ID_ADD_BASE && cmd < panels.get_count() + ID_ADD_BASE) { pfc::refcounted_object_ptr_t<panel> ptr = new panel; ptr->m_guid = panels[cmd - ID_ADD_BASE].guid; m_panels.add_item(ptr); refresh_children(); get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); uie::splitter_window_v2_ptr sw2; if (ptr->m_child.is_valid() && ptr->m_child->service_query_t(sw2)) { sw2->enter_layout_editing_mode(); } } } } return 0; } break; #endif } return DefWindowProc(wnd, msg, wp, lp); }
bool splitter_window_impl::set_config_item(unsigned index, const GUID & p_type, stream_reader * p_source, abort_callback & p_abort) { if (is_index_valid(index)) { if (p_type == uie::splitter_window::bool_show_caption) { p_source->read_object_t(m_panels[index]->m_show_caption, p_abort); if (get_wnd()) { get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); on_size_changed(); m_panels[index]->on_size(); } return true; } else if (p_type == uie::splitter_window::bool_hidden) { if (!m_panels[index]->m_autohide) p_source->read_object_t(m_panels[index]->m_hidden, p_abort); return true; } else if (p_type == uie::splitter_window::bool_autohide) { p_source->read_object_t(m_panels[index]->m_autohide, p_abort); m_panels[index]->m_hidden = m_panels[index]->m_autohide; return true; } else if (p_type == uie::splitter_window::bool_locked) { if (get_wnd()) save_sizes(); p_source->read_object_t(m_panels[index]->m_locked, p_abort); return true; } else if (p_type == uie::splitter_window::uint32_orientation) { p_source->read_object_t(m_panels[index]->m_caption_orientation, p_abort); return true; } else if (p_type == uie::splitter_window::uint32_size) { p_source->read_object_t(m_panels[index]->m_size, p_abort); return true; } else if (p_type == uie::splitter_window::bool_show_toggle_area && get_orientation() == horizontal) { p_source->read_object_t(m_panels[index]->m_show_toggle_area, p_abort); return true; } else if (p_type == uie::splitter_window::bool_use_custom_title) { p_source->read_object_t(m_panels[index]->m_use_custom_title, p_abort); return true; } else if (p_type == uie::splitter_window::string_custom_title) { p_source->read_string(m_panels[index]->m_custom_title, p_abort); return true; } return false; } return false; }
void splitter_window_impl::refresh_children() { unsigned n, count = m_panels.get_count(), size_cumulative = 0; pfc::array_t<bool> new_items; new_items.set_count(count); new_items.fill_null(); for (n = 0; n<count; n++) { if (!m_panels[n]->m_wnd) { uie::window_ptr p_ext; p_ext = m_panels[n]->m_child; bool b_new = false; if (!p_ext.is_valid()) { ui_extension::window::create_by_guid(m_panels[n]->m_guid, p_ext); b_new = true; } if (!m_panels[n]->m_interface.is_valid()) { service_ptr_t<service_base> temp; g_splitter_host_vert.instance_create(temp); uie::window_host_ptr ptr; if (temp->service_query_t(ptr)) { m_panels[n]->m_interface = static_cast<splitter_host_impl*>(ptr.get_ptr()); m_panels[n]->m_interface->set_window_ptr(this); } } if (p_ext.is_valid() && p_ext->is_available(uie::window_host_ptr(static_cast<uie::window_host*>(m_panels[n]->m_interface.get_ptr())))) { pfc::string8 name; if (m_panels[n]->m_use_custom_title) { name = m_panels[n]->m_custom_title; } else { if (!p_ext->get_short_name(name)) p_ext->get_name(name); } HWND wnd_host = m_panels[n]->m_container.create(m_wnd); m_panels[n]->m_container.set_window_ptr(this); uSetWindowText(wnd_host, name); if (wnd_host) { if (b_new) { try { p_ext->set_config(&stream_reader_memblock_ref(m_panels[n]->m_child_data.get_ptr(), m_panels[n]->m_child_data.get_size()), m_panels[n]->m_child_data.get_size(), abort_callback_impl()); } catch (const exception_io & e) { console::formatter() << "Error setting panel config: " << e.what(); } } HWND wnd_panel = p_ext->create_or_transfer_window(wnd_host, uie::window_host_ptr(m_panels[n]->m_interface.get_ptr())); //FIXX if (wnd_panel) { SetWindowLongPtr(wnd_panel, GWL_STYLE, GetWindowLongPtr(wnd_panel, GWL_STYLE) | WS_CLIPSIBLINGS); MINMAXINFO mmi; memset(&mmi, 0, sizeof(MINMAXINFO)); mmi.ptMaxTrackSize.x = MAXLONG; mmi.ptMaxTrackSize.y = MAXLONG; uSendMessage(wnd_panel, WM_GETMINMAXINFO, 0, (LPARAM)&mmi); clip_minmaxinfo(mmi); m_panels[n]->m_wnd = wnd_host; m_panels[n]->m_wnd_child = wnd_panel; m_panels[n]->m_child = p_ext; m_panels[n]->m_size_limits.min_height = mmi.ptMinTrackSize.y; m_panels[n]->m_size_limits.min_width = mmi.ptMinTrackSize.x; m_panels[n]->m_size_limits.max_width = mmi.ptMaxTrackSize.x; m_panels[n]->m_size_limits.max_height = mmi.ptMaxTrackSize.y; /*console::formatter() << "name: " << name << " min width: " << (t_int32)mmi.ptMinTrackSize.x << " min height: " << (t_int32)mmi.ptMinTrackSize.y << " max width: " << (t_int32)mmi.ptMaxTrackSize.y << " max height: " << (t_int32)mmi.ptMaxTrackSize.y;*/ } else { m_panels[n]->m_container.destroy(); } } } new_items[n] = true;//b_new; } } on_size_changed(); if (IsWindowVisible(get_wnd())) { for (n = 0; n<count; n++) { if (new_items[n]) { ShowWindow(m_panels[n]->m_wnd_child, SW_SHOWNORMAL); ShowWindow(m_panels[n]->m_wnd, SW_SHOWNORMAL); } } get_host()->on_size_limit_change(get_wnd(), uie::size_limit_all); RedrawWindow(get_wnd(), 0, 0, RDW_UPDATENOW | RDW_ALLCHILDREN); } }
void splitter_window_impl::on_size_changed() { RECT rc; GetClientRect(m_wnd, &rc); on_size_changed(rc.right, rc.bottom); }