void GraphicalSummaryWnd::DoLayout() { GG::Pt ul(GG::X0, SIDE_BOX_MARGIN); if(!m_options_bar) { m_options_bar = new OptionsBar(m_sizer); AttachChild(m_options_bar); GG::Connect( m_options_bar->ChangedSignal, &GraphicalSummaryWnd::DoLayout, this ); } m_options_bar->Resize( GG::Pt( ClientWidth(), OPTION_BAR_HEIGHT ) ); GG::Pt space_for_bars = ClientSize(); space_for_bars.y -= m_options_bar->Height(); m_sizer->SetAvailableSize(space_for_bars); m_options_bar->DoLayout(); for(std::vector<SideBar*>::iterator it = m_side_boxes.begin(); it != m_side_boxes.end(); ++it ) { SideBar* box = *it; box->MoveTo(ul); box->DoLayout(); ul.y += box->Height() + SIDE_BOX_MARGIN; } m_options_bar->MoveTo(GG::Pt(GG::X(10), ClientSize().y - m_options_bar->Height() )); }
////////////////////////////////////////////////// // ResearchWnd // ////////////////////////////////////////////////// ResearchWnd::ResearchWnd(GG::X w, GG::Y h) : GG::Wnd(GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::ONTOP), m_research_info_panel(0), m_queue_lb(0), m_tech_tree_wnd(0), m_enabled(false) { m_research_info_panel = new ProductionInfoPanel(RESEARCH_INFO_AND_QUEUE_WIDTH, GG::Y(200), UserString("RESEARCH_INFO_PANEL_TITLE"), UserString("RESEARCH_INFO_RP"), OUTER_LINE_THICKNESS, ClientUI::KnownTechFillColor(), ClientUI::KnownTechTextAndBorderColor()); m_queue_lb = new QueueListBox(GG::X(2), m_research_info_panel->LowerRight().y, m_research_info_panel->Width() - 4, ClientSize().y - 4 - m_research_info_panel->Height(), "RESEARCH_QUEUE_ROW"); GG::Connect(m_queue_lb->QueueItemMoved, &ResearchWnd::QueueItemMoved, this); m_queue_lb->SetStyle(GG::LIST_NOSORT | GG::LIST_NOSEL | GG::LIST_USERDELETE); GG::Pt tech_tree_wnd_size = ClientSize() - GG::Pt(m_research_info_panel->Width(), GG::Y0); m_tech_tree_wnd = new TechTreeWnd(tech_tree_wnd_size.x, tech_tree_wnd_size.y); m_tech_tree_wnd->MoveTo(GG::Pt(m_research_info_panel->Width(), GG::Y0)); GG::Connect(m_tech_tree_wnd->AddTechToQueueSignal, &ResearchWnd::AddTechToQueueSlot, this); GG::Connect(m_tech_tree_wnd->AddMultipleTechsToQueueSignal, &ResearchWnd::AddMultipleTechsToQueueSlot, this); GG::Connect(m_queue_lb->ErasedSignal, &ResearchWnd::QueueItemDeletedSlot, this); GG::Connect(m_queue_lb->LeftClickedSignal, &ResearchWnd::QueueItemClickedSlot, this); GG::Connect(m_queue_lb->DoubleClickedSignal, &ResearchWnd::QueueItemDoubleClickedSlot, this); AttachChild(m_research_info_panel); AttachChild(m_queue_lb); AttachChild(m_tech_tree_wnd); SetChildClippingMode(ClipToClient); }
void ProductionWnd::DoLayout() { GG::Pt queue_ul = GG::Pt(GG::X(2), m_production_info_panel->Height()); GG::Pt queue_size = GG::Pt(m_production_info_panel->Width() - 4, ClientSize().y - 4 - m_production_info_panel->Height()); m_queue_lb->SizeMove(queue_ul, queue_ul + queue_size); GG::Pt build_wnd_size = ClientSize() - GG::Pt(m_production_info_panel->Width(), GG::Y0); GG::Pt build_wnd_ul = GG::Pt(m_production_info_panel->Width(), GG::Y0); m_build_designator_wnd->SizeMove(build_wnd_ul, build_wnd_ul + build_wnd_size); }
void ResearchWnd::DoLayout() { GG::Pt queue_ul = GG::Pt(GG::X(2), m_research_info_panel->Height()); GG::Pt queue_size = GG::Pt(m_research_info_panel->Width() - 4, ClientSize().y - 4 - m_research_info_panel->Height()); m_queue_lb->SizeMove(queue_ul, queue_ul + queue_size); GG::Pt tech_tree_wnd_size = ClientSize() - GG::Pt(m_research_info_panel->Width(), GG::Y0); GG::Pt tech_tree_wnd_ul = GG::Pt(m_research_info_panel->Width(), GG::Y0); m_tech_tree_wnd->SizeMove(tech_tree_wnd_ul, tech_tree_wnd_ul + tech_tree_wnd_size); }
void ResearchWnd::DoLayout() { m_research_info_panel->Resize(GG::Pt(GG::X(GetOptionsDB().Get<int>("UI.queue-width")), m_research_info_panel->MinUsableSize().y)); GG::Pt queue_ul = GG::Pt(GG::X(2), m_research_info_panel->Height()); GG::Pt queue_size = GG::Pt(m_research_info_panel->Width() - 4, ClientSize().y - 4 - m_research_info_panel->Height()); m_queue_lb->SizeMove(queue_ul, queue_ul + queue_size); GG::Pt tech_tree_wnd_size = ClientSize() - GG::Pt(m_research_info_panel->Width(), GG::Y0); GG::Pt tech_tree_wnd_ul = GG::Pt(m_research_info_panel->Width(), GG::Y0); m_tech_tree_wnd->SizeMove(tech_tree_wnd_ul, tech_tree_wnd_ul + tech_tree_wnd_size); }
void ProductionWnd::DoLayout() { GG::X queue_width(GetOptionsDB().Get<int>("UI.queue-width")); GG::Y info_height(ClientUI::Pts()*6 + 34); m_production_info_panel->MoveTo(GG::Pt(GG::X0, GG::Y0)); m_production_info_panel->Resize(GG::Pt(queue_width, info_height)); m_queue_wnd->MoveTo(GG::Pt(GG::X0, info_height)); m_queue_wnd->Resize(GG::Pt(queue_width, ClientSize().y - info_height)); m_build_designator_wnd->Resize(ClientSize()); }
////////////////////////////////////////////////// // ResearchWnd // ////////////////////////////////////////////////// ResearchWnd::ResearchWnd(GG::X w, GG::Y h) : GG::Wnd(GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::ONTOP), m_research_info_panel(0), m_queue_lb(0), m_tech_tree_wnd(0), m_enabled(false) { GG::X queue_width(GetOptionsDB().Get<int>("UI.queue-width")); m_research_info_panel = new ProductionInfoPanel(UserString("RESEARCH_INFO_PANEL_TITLE"), UserString("RESEARCH_INFO_RP"), GG::X0, GG::Y0, GG::X(queue_width), GG::Y(100), "research.InfoPanel"); m_queue_lb = new QueueListBox("RESEARCH_QUEUE_ROW", UserString("RESEARCH_QUEUE_PROMPT")); m_queue_lb->SetStyle(GG::LIST_NOSORT | GG::LIST_NOSEL | GG::LIST_USERDELETE); GG::Connect(m_queue_lb->QueueItemMovedSignal, &ResearchWnd::QueueItemMoved, this); GG::Connect(m_queue_lb->QueueItemDeletedSignal, &ResearchWnd::DeleteQueueItem, this); GG::Connect(m_queue_lb->LeftClickedSignal, &ResearchWnd::QueueItemClickedSlot, this); GG::Connect(m_queue_lb->DoubleClickedSignal, &ResearchWnd::QueueItemDoubleClickedSlot, this); GG::Pt tech_tree_wnd_size = ClientSize() - GG::Pt(GG::X(GetOptionsDB().Get<int>("UI.queue-width")), GG::Y0); m_tech_tree_wnd = new TechTreeWnd(tech_tree_wnd_size.x, tech_tree_wnd_size.y); GG::Connect(m_tech_tree_wnd->AddTechsToQueueSignal, &ResearchWnd::AddTechsToQueueSlot, this); AttachChild(m_research_info_panel); AttachChild(m_queue_lb); AttachChild(m_tech_tree_wnd); SetChildClippingMode(ClipToClient); DoLayout(); }
void DoLayout() { GG::Pt bar_size = m_sizer.GetSideBarSize(m_side_summary.empire); if( bar_size != Size() ) { Resize(bar_size); } GG::Pt alive_ll = GG::Pt(GG::X0, GG::Y0); alive_ll.y += ClientHeight(); GG::Pt dead_lr = ClientSize(); for(std::vector<ParticipantBar*>::const_iterator it = m_participant_bars.begin(); it != m_participant_bars.end(); ++it) { ParticipantBar* bar = *it; bar->DoLayout(); if(bar->Alive()) { bar->MoveBottomTo(alive_ll); alive_ll.x += bar->Width(); } else { dead_lr.x -= bar->Width(); bar->MoveBottomTo(dead_lr); } } m_x_axis_label->MoveTo(GG::Pt(GG::X0, Height() - m_x_axis_label->Height())); m_y_axis_label->MoveTo(GG::Pt(-m_y_axis_label->MinUsableSize().x / 2 - AXIS_WIDTH, Height()/2 - m_y_axis_label->Height()/2)); m_dead_label->MoveTo(GG::Pt(ClientWidth() - m_dead_label->Width(), Height() - m_dead_label->Height())); }
void GraphicalSummaryWnd::GenerateGraph() { DeleteSideBars(); m_sizer.reset(new BarSizer(m_summaries, ClientSize())); for (std::map<int, CombatSummary>::iterator it = m_summaries.begin(); it != m_summaries.end(); ++it) { if (it->second.total_max_health > EPSILON) { it->second.Sort(); SideBar* box = new SideBar(it->second, *m_sizer); m_side_boxes.push_back(box); AttachChild(box); } } if (m_options_bar) { DebugLogger() << "GraphicalSummaryWnd::GenerateGraph(): m_options_bar " "already exists, calling DeleteChild(m_options_bar) " "before creating a new one."; DeleteChild(m_options_bar); } m_options_bar = new OptionsBar(m_sizer); AttachChild(m_options_bar); GG::Connect(m_options_bar->ChangedSignal, &GraphicalSummaryWnd::HandleButtonChanged, this); MinSizeChangedSignal(); DoLayout(); }
////////////////////////////////////////////////// // ProductionWnd // ////////////////////////////////////////////////// ProductionWnd::ProductionWnd(GG::X w, GG::Y h) : GG::Wnd(GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::ONTOP), m_production_info_panel(0), m_queue_lb(0), m_build_designator_wnd(0), m_order_issuing_enabled(false) { Logger().debugStream() << "ProductionWindow: app-width: "<< GetOptionsDB().Get<int>("app-width") << " ; windowed width: " << GetOptionsDB().Get<int>("app-width-windowed"); m_production_info_panel = new ProductionInfoPanel(GG::X(GetOptionsDB().Get<int>("UI.queue-width")), GG::Y(200), UserString("PRODUCTION_INFO_PANEL_TITLE"), UserString("PRODUCTION_INFO_PP"), static_cast<GLfloat>(OUTER_LINE_THICKNESS), ClientUI::KnownTechFillColor(), ClientUI::KnownTechTextAndBorderColor()); m_queue_lb = new QueueListBox(GG::X(2), m_production_info_panel->Bottom(), m_production_info_panel->Width() - 4, ClientSize().y - 4 - m_production_info_panel->Height(), "PRODUCTION_QUEUE_ROW", UserString("PRODUCTION_QUEUE_PROMPT")); m_queue_lb->SetStyle(GG::LIST_NOSORT | GG::LIST_NOSEL | GG::LIST_USERDELETE); m_queue_lb->SetName("ProductionQueue ListBox"); GG::Pt buid_designator_wnd_size = ClientSize() - GG::Pt(m_production_info_panel->Width(), GG::Y0); m_build_designator_wnd = new BuildDesignatorWnd(buid_designator_wnd_size.x, buid_designator_wnd_size.y); m_build_designator_wnd->MoveTo(GG::Pt(m_production_info_panel->Width(), GG::Y0)); SetChildClippingMode(ClipToClient); GG::Connect(m_build_designator_wnd->AddNamedBuildToQueueSignal, static_cast<void (ProductionWnd::*)(BuildType, const std::string&, int, int)>(&ProductionWnd::AddBuildToQueueSlot), this); GG::Connect(m_build_designator_wnd->AddIDedBuildToQueueSignal, static_cast<void (ProductionWnd::*)(BuildType, int, int, int)>(&ProductionWnd::AddBuildToQueueSlot), this); GG::Connect(m_build_designator_wnd->BuildQuantityChangedSignal, &ProductionWnd::ChangeBuildQuantitySlot, this); GG::Connect(m_build_designator_wnd->SystemSelectedSignal, SystemSelectedSignal); GG::Connect(m_queue_lb->QueueItemMovedSignal, &ProductionWnd::QueueItemMoved, this); GG::Connect(m_queue_lb->LeftClickedSignal, &ProductionWnd::QueueItemClickedSlot, this); GG::Connect(m_queue_lb->DoubleClickedSignal, &ProductionWnd::QueueItemDoubleClickedSlot, this); AttachChild(m_production_info_panel); AttachChild(m_queue_lb); AttachChild(m_build_designator_wnd); }
void CProgressWnd::SetWindowSize(int nNumTextLines, int nWindowWidth /*=390*/) { int nMargin = 10; CSize EdgeSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE)); CRect TextRect, CancelRect, ProgressRect; CSize CancelSize; // Set up a default size for the text area in case things go wrong TextRect.SetRect(nMargin,nMargin, nWindowWidth-2*nMargin, 100+2*nMargin); // Get DrawText to tell us how tall the text area will be (while we're at // it, we'll see how big the word "Cancel" is) CDC* pDC = GetDC(); if (pDC) { CFont* pOldFont = pDC->SelectObject(&m_font); CString str = _T("M"); for (int i = 0; i < nNumTextLines-1; i++) str += _T("\nM"); pDC->DrawText(str, TextRect, DT_CALCRECT|DT_NOCLIP|DT_NOPREFIX); TextRect.right = TextRect.left + nWindowWidth; CancelSize = pDC->GetTextExtent(m_strCancelLabel + _T(" ")) + CSize(EdgeSize.cx*4, EdgeSize.cy*3); pDC->SelectObject(pOldFont); ReleaseDC(pDC); } // Work out how big (and where) the cancel button should be CancelRect.SetRect(TextRect.right-CancelSize.cx, TextRect.bottom+nMargin, TextRect.right, TextRect.bottom+nMargin + CancelSize.cy); // Work out how big (and where) the progress control should be ProgressRect.SetRect(TextRect.left, CancelRect.top + EdgeSize.cy, CancelRect.left-nMargin, CancelRect.bottom - EdgeSize.cy); // Resize the main window to fit the controls CSize ClientSize(nMargin + TextRect.Width() + nMargin, nMargin + TextRect.Height() + nMargin + CancelRect.Height() + nMargin); CRect WndRect, ClientRect; GetWindowRect(WndRect); GetClientRect(ClientRect); WndRect.right = WndRect.left + WndRect.Width()-ClientRect.Width()+ClientSize.cx; WndRect.bottom = WndRect.top + WndRect.Height()-ClientRect.Height()+ClientSize.cy; MoveWindow(WndRect); // Now reposition the controls... m_wndProgress.MoveWindow(ProgressRect); m_CancelButton.MoveWindow(CancelRect); m_Text.MoveWindow(TextRect); }
void GraphicalSummaryWnd::DoLayout() { if (!m_sizer || !m_options_bar) return; GG::Pt ul(GG::X0, SIDE_BOX_MARGIN); m_options_bar->Resize( GG::Pt( ClientWidth(), OPTION_BAR_HEIGHT ) ); GG::Pt space_for_bars = ClientSize(); space_for_bars.y -= m_options_bar->Height(); m_sizer->SetAvailableSize(space_for_bars); m_options_bar->DoLayout(); for (std::vector<SideBar*>::iterator it = m_side_boxes.begin(); it != m_side_boxes.end(); ++it ) { SideBar* box = *it; box->MoveTo(ul); box->DoLayout(); ul.y += box->Height() + SIDE_BOX_MARGIN; } m_options_bar->MoveTo(GG::Pt(GG::X(4), ClientSize().y - m_options_bar->Height())); }
////////////////////////////////////////////////// // ProductionWnd // ////////////////////////////////////////////////// ProductionWnd::ProductionWnd(GG::X w, GG::Y h) : GG::Wnd(GG::X0, GG::Y0, w, h, GG::INTERACTIVE | GG::ONTOP), m_production_info_panel(0), m_queue_wnd(0), m_build_designator_wnd(0), m_order_issuing_enabled(false), m_empire_shown_id(ALL_EMPIRES) { //DebugLogger() << "ProductionWindow: app-width: "<< GetOptionsDB().Get<int>("app-width") // << " ; windowed width: " << GetOptionsDB().Get<int>("app-width-windowed"); GG::X queue_width(GetOptionsDB().Get<int>("UI.queue-width")); GG::Y info_height(ClientUI::Pts()*8); m_production_info_panel = new ProductionInfoPanel(UserString("PRODUCTION_WND_TITLE"), UserString("PRODUCTION_INFO_PP"), GG::X0, GG::Y0, queue_width, info_height, "production.InfoPanel"); m_queue_wnd = new ProductionQueueWnd(GG::X0, info_height, queue_width, ClientSize().y - info_height); m_build_designator_wnd = new BuildDesignatorWnd(ClientSize().x, ClientSize().y); SetChildClippingMode(ClipToClient); GG::Connect(m_build_designator_wnd->AddBuildToQueueSignal, &ProductionWnd::AddBuildToQueueSlot, this); GG::Connect(m_build_designator_wnd->BuildQuantityChangedSignal, &ProductionWnd::ChangeBuildQuantitySlot, this); GG::Connect(m_build_designator_wnd->SystemSelectedSignal, SystemSelectedSignal); GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemMovedSignal, &ProductionWnd::QueueItemMoved, this); GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemDeletedSignal, &ProductionWnd::DeleteQueueItem, this); GG::Connect(m_queue_wnd->GetQueueListBox()->LeftClickedSignal, &ProductionWnd::QueueItemClickedSlot, this); GG::Connect(m_queue_wnd->GetQueueListBox()->DoubleClickedSignal, &ProductionWnd::QueueItemDoubleClickedSlot, this); GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemRalliedToSignal, &ProductionWnd::QueueItemRallied, this); GG::Connect(m_queue_wnd->GetQueueListBox()->ShowPediaSignal, &ProductionWnd::ShowPedia, this); GG::Connect(m_queue_wnd->GetQueueListBox()->QueueItemPausedSignal, &ProductionWnd::QueueItemPaused, this); AttachChild(m_production_info_panel); AttachChild(m_queue_wnd); AttachChild(m_build_designator_wnd); }
void GraphicalSummaryWnd::GenerateGraph() { DeleteSideBars(); m_sizer.reset(new BarSizer(m_summaries, ClientSize())); for(std::map<int, CombatSummary>::iterator it = m_summaries.begin(); it != m_summaries.end(); ++it ) { if ( it->second.total_max_health > EPSILON ) { it->second.Sort(); SideBar* box = new SideBar(it->second, *m_sizer); m_side_boxes.push_back(box); AttachChild(box); } } DoLayout(); }
//============================================================================= CXProgressWnd& CXProgressWnd::SetWindowSize(int nNumTextLines, int nWindowWidth /*=390*/) //============================================================================= { int nWidth = nWindowWidth; int nMargin = 10; CSize EdgeSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE)); CSize CancelSize; CRect CancelRect, ProgressRect, AviRect; AviRect.SetRectEmpty(); if (IsWindow(m_avi.m_hWnd)) { // we'll adjust the width later AviRect.SetRect(nMargin, nMargin, nMargin + m_nAviHeight, nMargin + m_nAviHeight); } // set up a default size for the text area in case things go wrong m_TextRect.SetRect(nMargin, AviRect.bottom+nMargin, nWindowWidth-2*nMargin, AviRect.bottom+100+2*nMargin); m_TimeLeftRect.SetRectEmpty(); // get DrawText to tell us how tall the text area will be (while we're at // it, we'll see how big the word "Cancel" is) CDC* pDC = GetDC(); if (pDC) { CFont *pOldFont = pDC->SelectObject(&m_font); CString str = _T("M"); for (int i = 0; i < nNumTextLines-1; i++) str += _T("\nM"); pDC->DrawText(str, m_TextRect, DT_CALCRECT|DT_NOCLIP|DT_NOPREFIX); if (m_bTimeLeft) pDC->DrawText(_T("M"), 1, m_TimeLeftRect, DT_CALCRECT|DT_NOCLIP|DT_NOPREFIX); nWidth = max(nWindowWidth, m_TextRect.Width()+2*nMargin); m_TextRect.right = nWidth - nMargin; CancelSize = pDC->GetTextExtent(m_strCancelLabel + _T(" ")); CancelSize += CSize(EdgeSize.cx*11, EdgeSize.cy*5); pDC->SelectObject(pOldFont); ReleaseDC(pDC); } AviRect.right = m_TextRect.right; // Work out how big (and where) the progress control should be ProgressRect.SetRect(m_TextRect.left, m_TextRect.bottom + nMargin, m_TextRect.right, m_TextRect.bottom + nMargin + CancelSize.cy); if (m_bTimeLeft) { // Work out how big (and where) the time left text should be int h = m_TimeLeftRect.Height(); m_TimeLeftRect.SetRect(m_TextRect.left, ProgressRect.bottom + nMargin, m_TextRect.right, ProgressRect.bottom + nMargin + h); } else { m_TimeLeftRect = ProgressRect; } // work out how big (and where) the cancel button should be CancelRect.SetRect(ProgressRect.right - CancelSize.cx, m_TimeLeftRect.bottom + nMargin, ProgressRect.right, m_TimeLeftRect.bottom + nMargin + CancelSize.cy); // resize the main window to fit the controls CSize ClientSize(nWidth, nMargin + CancelRect.bottom); CRect WndRect, ClientRect; GetWindowRect(WndRect); GetClientRect(ClientRect); WndRect.right = WndRect.left + WndRect.Width() - ClientRect.Width() + ClientSize.cx; WndRect.bottom = WndRect.top + WndRect.Height() - ClientRect.Height() + ClientSize.cy; MoveWindow(WndRect); // now reposition the controls... if (IsWindow(m_avi.m_hWnd)) m_avi.MoveWindow(AviRect); // start modified code: added to allow dialog with only a message if (m_bEnableProgressBar) // end modified code m_wndProgress.MoveWindow(ProgressRect); // start modified code: added to allow dialog with only a message if (m_bEnableCancel) // end modified code m_CancelButton.MoveWindow(CancelRect); return *this; }